On 2022-02-27 21:33 -08, Andrew Hewus Fresh <afre...@zarniwoop.home.hewus.com> 
wrote:
> So, sdk@ noticed that sysupgrade didn't get updated for the new logic in
> the firmware directories.  Specifically that the only time we use
> "snapshots" directory is with -current.  The rest of the time, including
> during -beta we use the version directory.  This diff should handle that
> case, installing the correct firmware for the system we are about to
> install.
>
> This also uses a secret feature of fw_update(8) where if you set "VNAME"
> in the environment, it uses that instead of asking sysctl to calculate
> the name of the signify key to use.   Probably that could use an
> improvement, maybe trusting the untrusted comment at the top of the
> file..
>
> I'm not sure if there's a better way to find the version string from a
> bsd kernel, so I used the one I knew about.

I think you can just look at _KERNV which is populated thusly:


    98  set -A _KERNV -- $(sysctl -n kern.version |
    99          sed 's/^OpenBSD \([1-9][0-9]*\.[0-9]\)\([^ ]*\).*/\1 \2/;q')

$ sysctl kern.version
kern.version=OpenBSD 7.0-current (GENERIC.MP) #370: Sat Feb 19 10:36:59 MST 2022
    dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP

$ set -A _KERNV -- $(sysctl -n kern.version |
>         sed 's/^OpenBSD \([1-9][0-9]*\.[0-9]\)\([^ ]*\).*/\1 \2/;q')

$ echo ${_KERNV[1]}
-current

>
> Comments, OK?
>
> Index: sysupgrade.sh
> ===================================================================
> RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v
> retrieving revision 1.45
> diff -u -p -r1.45 sysupgrade.sh
> --- sysupgrade.sh     11 Feb 2022 12:58:18 -0000      1.45
> +++ sysupgrade.sh     28 Feb 2022 05:24:48 -0000
> @@ -123,10 +123,8 @@ fi
>  
>  if $SNAP; then
>       URL=${MIRROR}/snapshots/${ARCH}/
> -     FW_URL=http://firmware.openbsd.org/firmware/snapshots/
>  else
>       URL=${MIRROR}/${NEXT_VERSION}/${ARCH}/
> -     FW_URL=http://firmware.openbsd.org/firmware/${NEXT_VERSION}/
>  fi
>  
>  install -d -o 0 -g 0 -m 0755 ${SETSDIR}
> @@ -196,7 +194,15 @@ __EOT
>  fi
>  
>  echo Fetching updated firmware.
> -fw_update -p ${FW_URL} || true
> +VTYPE="$( echo exit | config -eo /dev/null bsd |
> +    sed -n "/^OpenBSD $NEXT_VERSION\([^ ]*\).*$/s//\1/p" )"
> +
> +if [ "$VTYPE" = "-current" ]; then
> +     FW_URL=http://firmware.openbsd.org/firmware/snapshots/
> +else
> +     FW_URL=http://firmware.openbsd.org/firmware/${NEXT_VERSION}/
> +fi
> +VNAME="${NEXT_VERSION}" fw_update -p ${FW_URL} || true
>  
>  install -F -m 700 bsd.rd /bsd.upgrade
>  logger -t sysupgrade -p kern.info "installed new /bsd.upgrade. Old kernel 
> version: $(sysctl -n kern.version)"
>

-- 
I'm not entirely sure you are real.

Reply via email to