This patch fixes scripted installation on systems with mounted ESPs, which were causing difficulties with tar. Tar tries to set the modification time of the ESP root directory, which FAT doesn't support, resulting in an error and the installation failing. For more backstory, see https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=254395
The patch here fixes this using a combination of options 3 and 4 from https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=254395. If the controlling console is a TTY, it uses distextract, like interactive installs, which works around the issue intelligently. Otherwise, it uses tar(1) but has it not extract the EFI mountpoint and instead makes it (unconditionally) by hand. This makes scripted installs with a console work across the board (presumably, almost all of them), and isolates remaining brokenness to powerpc64 and ARM systems installed with non-standard scripted installers where the controlling console is not a TTY (presumably, a vanishingly small number). A solution will come for those later, potentially involving this PR against tar: https://github.com/libarchive/libarchive/issues/1516.
With the tar issue fixed, a second issue involving umount(8) became apparent. While mount -a is smart enough to track dependencies in fstab and mount things in the right order, umount -a is not and will try to unmount root before the ESP on error, resulting in scripted installs still failing. This patch addresses that problem too by sorting fstab.