From: Klemens Nanni Subject: installer: sets: do not offer http/nfs without network To: OpenBSD tech Date: Thu, 1 May 2025 18:48:09 +0000 Offline installs/upgrades, i.e. when there are no interfaces, still default to fetching sets over HTTP, which makes no sense (minimal reproducer): # vmctl create -1g disk; vmctl start -c -b /bsd.rd -d disk offline ... Let's install the sets! Location of sets? (disk http nfs or 'done') [http] At this point, interfaces are configured already and state is basically known, yet NFS and HTTP are offered unconditionally. Skip these two methodos unless there is a physical interface around: Let's install the sets! Location of sets? (disk or 'done') [disk] Shorten and clarify the comments while here. NB: The shell idiom ${var:=val} means "set $var to 'val' unless already non-empty". This diff reads much better with `sdiff -w165 old new' than in unified form. Feedback? OK? Index: install.sub =================================================================== RCS file: /cvs/src/distrib/miniroot/install.sub,v diff -u -p -r1.1269 install.sub --- install.sub 6 Apr 2025 11:54:36 -0000 1.1269 +++ install.sub 1 May 2025 18:12:45 -0000 @@ -2796,27 +2796,30 @@ feed_random() { # selects from that location. Repeat as many times as the user needs to get all # desired sets. install_sets() { - local _cddevs=$(get_cddevs) _d _im _locs="disk http" _src + # Default to method recorded last time, if any. + local _cddevs=$(get_cddevs) _d=$CGI_METHOD _im _locs=disk _src - echo + [[ -n $_cddevs ]] && : ${_d:=cd0} - # Set default location to method recorded last time. - _d=$CGI_METHOD + # Offer network methods if there are physical interfaces. + if [[ -n $(get_ifs) ]]; then + _locs="$_locs http" - # Set default location to HTTP in case we netbooted. - ifconfig netboot >/dev/null 2>&1 && : ${_d:=http} + # Default to HTTP if netbooted. + [[ -n $(get_ifs netboot) ]] && : ${_d:=http} - # Set default location to HTTP if installurl(5) exists. - [[ -s /mnt/etc/installurl ]] && _d=http + # Prefer HTTP to any existing default if installurl(5) exists. + [[ -s /mnt/etc/installurl ]] && _d=http - # Set default location to the first cdrom device if any are found. - [[ -n $_cddevs ]] && : ${_d:=cd0} + # Offer NFS if the ramdisk supports it. + [[ -x /sbin/mount_nfs ]] && _locs="$_locs nfs" - # Add NFS to set locations if the boot kernel supports it. - [[ -x /sbin/mount_nfs ]] && _locs="$_locs nfs" + # Default to HTTP. + : ${_d:=http} + fi - # In case none of the above applied, set HTTP as default location. - : ${_d:=http} + # Without CD and network, disk is the only option. + : ${_d:=disk} # If the default location set so far is not one of the cdrom devices or # is not in the list of valid locations, set a sane default. @@ -2826,7 +2829,7 @@ install_sets() { done fi - echo "Let's $MODE the sets!" + echo "\nLet's $MODE the sets!" while :; do # Get list of cdroms again in case one just got plugged in. _cddevs=$(get_cddevs)