On Sat, Apr 27, 2019 at 01:23:20PM +0100, Marco Bonetti wrote:
> Hello folks,
> 
> First of all congratulations on a new OpenBSD release and thanks for
> introducing sysupgrade in -current.
> 
> Before sysupgrade, I was using a custom script for achieving the same
> result with only difference that I was checking if a new snapshot (or
> release) is available by looking at BUILDINFO before starting the
> upgrade process.
> 
> Patch below introduce the same behaviour using SHA256.sig as control
> file. If you believe there is a valid use case for reinstalling already
> applied sets to the running system please let me know and I can add a
> -f force option.
> 
> Cheers,
> Marco

With a recent commit the installer helps us out by keeping the last
used SHA256.sig around. I have been convinced that that is indeed the
correct way of doing this.

With the help of the installer Marco's diff is much simpler now.

OK?

diff --git sysupgrade.8 sysupgrade.8
index 88c8a43b034..d4454d1c4e3 100644
--- sysupgrade.8
+++ sysupgrade.8
@@ -23,12 +23,13 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl c
+.Op Fl f
 .Op Ar installurl
 .Sh DESCRIPTION
 .Nm
 is a utility to upgrade
 .Ox
-to the next release or a new snapshot.
+to the next release or a new snapshot if available.
 .Pp
 .Nm
 downloads the necessary files to
@@ -52,6 +53,10 @@ The default is to find out if the system is running a 
release or a snapshot.
 In case of release
 .Nm
 downloads the next release.
+.It Fl f
+force an already applied upgrade.
+The default is to upgrade to latest snapshot only if available.
+This option has no effect on releases.
 .El
 .Sh FILES
 .Bl -tag -width "/home/_sysupgrade" -compact
diff --git sysupgrade.sh sysupgrade.sh
index e532d7f94d1..5e868791a8b 100644
--- sysupgrade.sh
+++ sysupgrade.sh
@@ -33,7 +33,7 @@ ug_err()
 
 usage()
 {
-       ug_err "usage: ${0##*/} [-c] [installurl]"
+       ug_err "usage: ${0##*/} [-cf] [installurl]"
 }
 
 unpriv()
@@ -63,12 +63,14 @@ rmel() {
 }
 
 CURRENT=false
-
-while getopts c arg; do
-        case ${arg} in
-        c)      CURRENT=true;;
-        *)      usage;;
-        esac
+FORCE=false
+
+while getopts cf arg; do
+       case ${arg} in
+       c)      CURRENT=true;;
+       f)      FORCE=true;;
+       *)      usage;;
+       esac
 done
 
 set -A _KERNV -- $(sysctl -n kern.version |
@@ -112,6 +114,10 @@ cd ${SETSDIR}
 
 unpriv -f SHA256.sig ftp -Vmo SHA256.sig ${URL}SHA256.sig
 
+if cmp -s /var/db/installed.SHA256.sig SHA256.sig && ! $FORCE; then
+       ug_err "Already on latest snapshot."
+fi
+
 _KEY=openbsd-${_KERNV[0]%.*}${_KERNV[0]#*.}-base.pub
 _NEXTKEY=openbsd-${NEXT_VERSION%.*}${NEXT_VERSION#*.}-base.pub
 


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

Reply via email to