diff options
| author | Alan Somers <asomers@FreeBSD.org> | 2026-04-28 17:27:17 +0000 |
|---|---|---|
| committer | Colin Percival <cperciva@FreeBSD.org> | 2026-05-14 19:04:21 +0000 |
| commit | cb7880bb09009c977d3fb70a66b0f57f9fbe83ed (patch) | |
| tree | 5fb4a559153b8d729811a6f664eafde6c5a0b3cc /usr.sbin/bsdinstall/scripts | |
| parent | 628c42a28e76e281045c7b3225fbe6b9bb4f1e3b (diff) | |
bsdinstall: do pkgbase installations with the "script" command
"bsdinstall script" will now do a pkgbase installation by default. The
system components to install can be specified in the COMPONENTS
variable, and have the same names as those used in the interactive
installer. bsdinstall will still do a legacy distset installation if
DISTRIBUTIONS is defined in the installerconfig file.
Approved by: re (cperciva)
PR: 290375
Sponsored by: ConnectWise
Reviewed by: ziaee, ivy, jduran
Differential Revision: https://reviews.freebsd.org/D56717
(cherry picked from commit dc14ae4217a0babb1240f813b642edc2d7b955a6)
(cherry picked from commit 1f5869130f6ebd299e65a627eff23a8c3d360afb)
Diffstat (limited to 'usr.sbin/bsdinstall/scripts')
| -rwxr-xr-x | usr.sbin/bsdinstall/scripts/pkgbase.in | 15 | ||||
| -rwxr-xr-x | usr.sbin/bsdinstall/scripts/script | 71 |
2 files changed, 55 insertions, 31 deletions
diff --git a/usr.sbin/bsdinstall/scripts/pkgbase.in b/usr.sbin/bsdinstall/scripts/pkgbase.in index 89ddc244171e..2c7d6bcae904 100755 --- a/usr.sbin/bsdinstall/scripts/pkgbase.in +++ b/usr.sbin/bsdinstall/scripts/pkgbase.in @@ -180,7 +180,18 @@ local function select_components(components, options) } append_list(bsddialog_args, checklist_items) - local exit_code, output = bsddialog(bsddialog_args) + local exit_code = 0 + local output = "" + if options.non_interactive then + local env_components = os.getenv("COMPONENTS") + if env_components then + output = env_components:gsub(" ", "\n") + else + output = "base\nkernel-dbg" + end + else + exit_code, output = bsddialog(bsddialog_args) + end -- This should only be possible if bsddialog is killed by a signal -- or buggy, we disable the cancel option and esc key. -- If this does happen, there's not much we can do except exit with a @@ -300,6 +311,8 @@ local function parse_options() for _, a in ipairs(arg) do if a == "--jail" then options.jail = true + elseif a == "--non-interactive" then + options.non_interactive = true else io.stderr:write("Error: unknown option " .. a .. "\n") os.exit(1) diff --git a/usr.sbin/bsdinstall/scripts/script b/usr.sbin/bsdinstall/scripts/script index 21da2ea7c366..93d07c7899c3 100755 --- a/usr.sbin/bsdinstall/scripts/script +++ b/usr.sbin/bsdinstall/scripts/script @@ -40,6 +40,7 @@ f_include $BSDCFG_SHARE/variable.subr # PARTITIONS # DISTRIBUTIONS # BSDINSTALL_DISTDIR +# COMPONENTS # # Default name of the ZFS boot-pool @@ -97,7 +98,6 @@ awk 'BEGIN {pathb=ARGV[2]; ARGV[2]=""} /^#!/{b=1} { >$TMPDIR/bsdinstall-installscript-preamble . $TMPDIR/bsdinstall-installscript-preamble -: ${DISTRIBUTIONS="kernel.txz base.txz"}; export DISTRIBUTIONS export BSDINSTALL_DISTDIR # Re-initialize a new log if preamble changed BSDINSTALL_LOG @@ -118,37 +118,48 @@ else fi bsdinstall mount -# Fetch missing distribution files, if any -exec 5>&1 -export BSDINSTALL_DISTDIR=$(`dirname $0`/fetchmissingdists 2>&1 1>&5) -FETCH_RESULT=$? -exec 5>&- +if [ -n "$COMPONENTS" -a -n "$DISTRIBUTIONS" ]; then + error "Cannot set both COMPONENTS and DISTRIBUTIONS" +elif [ -z "$DISTRIBUTIONS" ]; then + # If COMPONENTS is set, or neither is, install with pkgbase + bsdinstall pkgbase --non-interactive +else + # Otherwise, unpack distsets -[ $FETCH_RESULT -ne 0 ] && error "Could not fetch remote distributions" + # Fetch missing distribution files, if any + exec 5>&1 + export BSDINSTALL_DISTDIR=$(`dirname $0`/fetchmissingdists 2>&1 1>&5) + FETCH_RESULT=$? + exec 5>&- -# Unpack distributions -bsdinstall checksum -if [ -t 0 ]; then - # If install is a tty, use distextract as normal - bsdinstall distextract -else - # Otherwise, we need to use tar (see https://reviews.freebsd.org/D10736) - for set in $DISTRIBUTIONS; do - f_dprintf "Extracting $BSDINSTALL_DISTDIR/$set" - # XXX: The below fails if any mountpoints are FAT, due to - # inability to set ctime/mtime on the root of FAT partitions, - # which is needed to support e.g. EFI system partitions. tar has - # no option to ignore this (distextract ignores them internally - # through a hack), and returns 1 on any warning or error, - # effectively turning all warnings into fatal errors. - # - # Work around this in an extremely lame way for the specific - # case of EFI system partitions only. This *ONLY WORKS* if - # /boot/efi is empty and does not handle analogous problems on - # other systems (ARM, PPC64). - tar -xf "$BSDINSTALL_DISTDIR/$set" -C $BSDINSTALL_CHROOT --exclude boot/efi - mkdir -p $BSDINSTALL_CHROOT/boot/efi - done + [ $FETCH_RESULT -ne 0 ] && error "Could not fetch remote distributions" + + bsdinstall checksum + if [ -t 0 ]; then + # If install is a tty, use distextract as normal + bsdinstall distextract + else + # Otherwise, we need to use tar (see + # https://reviews.freebsd.org/D10736) + for set in $DISTRIBUTIONS; do + f_dprintf "Extracting $BSDINSTALL_DISTDIR/$set" + # XXX: The below fails if any mountpoints are FAT, due + # to inability to set ctime/mtime on the root of FAT + # partitions, which is needed to support e.g. EFI + # system partitions. tar has no option to ignore this + # (distextract ignores them internally through a hack), + # and returns 1 on any warning or error, effectively + # turning all warnings into fatal errors. + # + # Work around this in an extremely lame way for the + # specific case of EFI system partitions only. This + # *ONLY WORKS* if /boot/efi is empty and does not + # handle analogous problems on other systems (ARM, + # PPC64). + tar -xf "$BSDINSTALL_DISTDIR/$set" -C $BSDINSTALL_CHROOT --exclude boot/efi + mkdir -p $BSDINSTALL_CHROOT/boot/efi + done + fi fi # Configure bootloader if needed |
