From: florian Date: Tue, 24 Sep 2024 07:33:35 +0000 (+0000) Subject: Remove -r toggle and generally be less smart. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8aa961cf3a4215206ca98474d59581375916c430;p=openbsd Remove -r toggle and generally be less smart. The default is to install the next release. Snapshots are only installed when invoked with -s. The logic on what to do per default got out of hand and it was very difficult to reason about what sysupgrade(8) actually did. deraadt@ then suggested that we should dumb it all down, sysupgrade(8) is there to upgrade from one release to the next. More advance usage needs to be requested by the user. With all this simplification we can now be a bit more smart to work out what the next release is. With that, snapshots right before a release can be sysupgrade(8)'ed to the official release. OK sthen on a previous version that was much more complicated but allowed shortly-before-release -> release upgrade testing sthen on this version Guidance, prodding & OK deraadt --- diff --git a/usr.sbin/sysupgrade/sysupgrade.8 b/usr.sbin/sysupgrade/sysupgrade.8 index 7fb1f18b430..3f03b7ca626 100644 --- a/usr.sbin/sysupgrade/sysupgrade.8 +++ b/usr.sbin/sysupgrade/sysupgrade.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sysupgrade.8,v 1.14 2024/09/05 06:39:54 jmc Exp $ +.\" $OpenBSD: sysupgrade.8,v 1.15 2024/09/24 07:33:35 florian Exp $ .\" .\" Copyright (c) 2019 Florian Obser .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: September 5 2024 $ +.Dd $Mdocdate: September 24 2024 $ .Dt SYSUPGRADE 8 .Os .Sh NAME @@ -22,8 +22,7 @@ .Nd upgrade system to the next release or a new snapshot .Sh SYNOPSIS .Nm -.Op Fl fkn -.Op Fl r | s +.Op Fl fkns .Op Fl b Ar base-directory .Op Ar installurl .Sh DESCRIPTION @@ -66,12 +65,9 @@ By default they will be deleted after the upgrade. Fetch and verify the files and create .Pa /bsd.upgrade but do not reboot. -.It Fl r -Upgrade to the next release. -This is the default if the system is currently running a release. .It Fl s Upgrade to a snapshot. -This is the default if the system is currently running a snapshot. +The default is to upgrade to the next release. .El .Pp See diff --git a/usr.sbin/sysupgrade/sysupgrade.sh b/usr.sbin/sysupgrade/sysupgrade.sh index 0b9624aac53..71aa32104a5 100644 --- a/usr.sbin/sysupgrade/sysupgrade.sh +++ b/usr.sbin/sysupgrade/sysupgrade.sh @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: sysupgrade.sh,v 1.52 2024/06/19 05:22:33 otto Exp $ +# $OpenBSD: sysupgrade.sh,v 1.53 2024/09/24 07:33:35 florian Exp $ # # Copyright (c) 1997-2015 Todd Miller, Theo de Raadt, Ken Westerback # Copyright (c) 2015 Robert Peichaer @@ -35,7 +35,7 @@ err() usage() { - echo "usage: ${0##*/} [-fkn] [-r | -s] [-b base-directory] [installurl]" 1>&2 + echo "usage: ${0##*/} [-fkns] [-b base-directory] [installurl]" 1>&2 return 1 } @@ -72,11 +72,11 @@ rmel() { echo -n "$_c" } -RELEASE=false SNAP=false FORCE=false KEEP=false REBOOT=true +WHAT='release' while getopts b:fknrs arg; do case ${arg} in @@ -84,7 +84,7 @@ while getopts b:fknrs arg; do f) FORCE=true;; k) KEEP=true;; n) REBOOT=false;; - r) RELEASE=true;; + r) ;; s) SNAP=true;; *) usage;; esac @@ -92,13 +92,6 @@ done (($(id -u) != 0)) && err "need root privileges" -if $RELEASE && $SNAP; then - usage -fi - -set -A _KERNV -- $(sysctl -n kern.version | - sed 's/^OpenBSD \([1-9][0-9]*\.[0-9]\)\([^ ]*\).*/\1 \2/;q') - shift $(( OPTIND -1 )) case $# in @@ -112,58 +105,57 @@ esac [[ $MIRROR == @(file|ftp|http|https)://* ]] || err "invalid installurl: $MIRROR" -if ! $RELEASE && [[ ${#_KERNV[*]} == 2 ]]; then - if [[ ${_KERNV[1]} != '-stable' ]]; then - SNAP=true - fi +if $SNAP; then + WHAT='snapshot' fi -if $RELEASE && [[ ${_KERNV[1]} == '-beta' ]]; then - NEXT_VERSION=${_KERNV[0]} -else - NEXT_VERSION=$(echo ${_KERNV[0]} + 0.1 | bc) -fi +VERSION=$(uname -r) +NEXT_VERSION=$(echo ${VERSION} + 0.1 | bc) if $SNAP; then URL=${MIRROR}/snapshots/${ARCH}/ else URL=${MIRROR}/${NEXT_VERSION}/${ARCH}/ + ALT_URL=${MIRROR}/${VERSION}/${ARCH}/ fi install -d -o 0 -g 0 -m 0755 ${SETSDIR} cd ${SETSDIR} echo "Fetching from ${URL}" -unpriv -f SHA256.sig ftp -N sysupgrade -Vmo SHA256.sig ${URL}SHA256.sig - -_KEY=openbsd-${_KERNV[0]%.*}${_KERNV[0]#*.}-base.pub -_NEXTKEY=openbsd-${NEXT_VERSION%.*}${NEXT_VERSION#*.}-base.pub - -if $SNAP; then - unpriv -f SHA256 signify -Ve -x SHA256.sig -m SHA256 +if ! $SNAP; then + if ! unpriv -f SHA256.sig ftp -N sysupgrade -Vmo SHA256.sig ${URL}SHA256.sig; then + echo "Fetching from ${ALT_URL}" + unpriv -f SHA256.sig ftp -N sysupgrade -Vmo SHA256.sig ${ALT_URL}SHA256.sig + URL=${ALT_URL} + fi else - read _LINE /auto_upgrade.conf Location of sets = disk Pathname to the sets = ${SETSDIR}/