On Tue, Sep 06, 2022 at 05:12:33PM +0000, Lucas wrote:
> Klemens Nanni <[email protected]> wrote:
> > On rare occasions, I need 'disable xxx' in /etc/bsd.re-config to be able to
> > boot a system, e.g. to ignore quirky devices crashing drivers during attach.
> >
> > bsd.re-config(5) currently applies to GENERIC(.MP) /bsd alone, but /bsd.rd
> > and /bsd.upgrade RAMDISK kernels will require the same quirks to avoid
> > crashes.
> >
> > I currently hit this with arc(4) and one specific RAID card on sparc64 where
> > manually editing /bsd.upgrade each time I sysupgrade(8) until arc(4) is
> > fixed annoys me.
> >
> > So copy over the bits from libexec/reorder_kernel/reorder_kernel.sh to make
> > sysupgrade produce bootable kernels.
> >
> > reorder_kernel output lands in some log, but running config(8) in sysupgrade
> > would print on stdout, which looks ugly, so hide the output we're not really
> > interested in, anyway:
> >
> > # cat /etc/bsd.re-config
> > disable arc
> > # config -e -c /etc/bsd.re-config -f /bsd.rd
> > OpenBSD 7.2-beta (RAMDISK) #1377: Fri Sep 2 19:05:24 MDT 2022
> >
> > [email protected]:/usr/src/sys/arch/sparc64/compile/RAMDISK
> > disable arc
> > 83 arc* disabled
> > Saving modified kernel.
> >
> >
> > Feedback? Objection? OK?
> >
> > Index: sysupgrade.sh
> > ===================================================================
> > RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v
> > retrieving revision 1.48
> > diff -u -p -r1.48 sysupgrade.sh
> > --- sysupgrade.sh 8 Jun 2022 09:03:11 -0000 1.48
> > +++ sysupgrade.sh 6 Sep 2022 15:00:49 -0000
> > @@ -208,6 +208,8 @@ fi
> > VNAME="${_NEXTKERNV[0]}" fw_update -p ${FW_URL} || true
> >
> > install -F -m 700 bsd.rd /bsd.upgrade
> > +if [ -f /etc/bsd.re-config ] &&
> > + config -e -c /etc/bsd.re-config -f /bsd.upgrade >/dev/null
> > logger -t sysupgrade -p kern.info "installed new /bsd.upgrade. Old kernel
> > version: $(sysctl -n kern.version)"
> > sync
> >
>
> I think you meant
>
> if [ -f /etc/bsd.re-config ]; then
> config -e -c /etc/bsd.re-config -f /bsd.upgrade >/dev/null
> fi
>
> in here. Given that the script is `set -e` at the very beginning, you
> can't use && without making the script fail if /etc/bsd.re-config
> doesn't exists.
Yes I want it to fail, just like reorder_kernel.sh using `set -o errexit'
does with
[ -f /etc/bsd.re-config ] && config -e -c /etc/bsd.re-config -f bsd
If the config file exists but is invalid, I expect programs using it to fail.
>
> -Lucas
>