From ac7f9f195fcb894c4b09110d7020d01847cd7040 Mon Sep 17 00:00:00 2001 From: kn Date: Tue, 17 Jan 2023 16:22:56 +0000 Subject: [PATCH] Add debug FUNCS_ONLY knob Hacking on the installer while running it is a lot easier when you can inspect or run functions directly without paging the whole script or poking around in it with ed. install.sub is already structured so that all functions come first, then MD code, then actual commands. Copy FUNCS_ONLY from rc.subr(8) so you can drop out any time and hack around more conveniently: Available disks are: sd0 sd1. Which disk is the root disk? ('?' for details) [sd0] ! Type 'exit' to return to install. test# FUNCS_ONLY=1 . /install.sub test# typeset -f get_dkdevs get_dkdevs() { echo $(scan_disknames "${MDDKDEVS:-/^[sw]d[0-9][0-9]* /s/ .*//p}") } test# get_dkdevs sd0 sd1 test# This requires the sourcing shell to be ksh(1) or sh(1) with 'strict Bourne shell mode' disabled. '!' is ksh now, but the initial (S)hell answer still lands in a strict (default) sh(1) -- that can/should be fixed separately. OK deraadt --- distrib/miniroot/install.sub | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub index 4592f371f1a..92b3569c118 100644 --- a/distrib/miniroot/install.sub +++ b/distrib/miniroot/install.sub @@ -1,5 +1,5 @@ #!/bin/ksh -# $OpenBSD: install.sub,v 1.1220 2023/01/17 16:14:23 kn Exp $ +# $OpenBSD: install.sub,v 1.1221 2023/01/17 16:22:56 kn Exp $ # # Copyright (c) 1997-2015 Todd Miller, Theo de Raadt, Ken Westerback # Copyright (c) 2015, Robert Peichaer @@ -3430,6 +3430,9 @@ start_watchdog() { set +m } +# return if we only want internal functions +[[ -n $FUNCS_ONLY ]] && return + # ------------------------------------------------------------------------------ # Initial actions common to both installs and upgrades. # -- 2.20.1