Index | Thread | Search

From:
Manuel Giraud <manuel@ledu-giraud.fr>
Subject:
sysupgrade -c
To:
tech <tech@openbsd.org>
Date:
Fri, 03 Jul 2026 09:40:32 +0200

Download raw body.

Thread
  • Manuel Giraud:

    sysupgrade -c

Hi,

From a discussion on misc@ some days ago, here's my attempt at
supporting a "check new version" feature in sysupgrade:

Index: sysupgrade.8
===================================================================
RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.8,v
diff -u -p -r1.23 sysupgrade.8
--- sysupgrade.8	11 Nov 2025 15:18:30 -0000	1.23
+++ sysupgrade.8	3 Jul 2026 07:33:14 -0000
@@ -22,7 +22,7 @@
 .Nd upgrade system to the next release or a new snapshot
 .Sh SYNOPSIS
 .Nm
-.Op Fl fkns
+.Op Fl cfkns
 .Op Fl b Ar base-directory
 .Op Fl R Ar version
 .Op Ar installurl | path
@@ -54,6 +54,9 @@ Download files to
 .Ar base-directory Ns / Ns Pa _sysupgrade
 instead of
 .Pa /home/_sysupgrade .
+.It Fl c
+Print availability of a new version.
+The sets are not downloaded.
 .It Fl f
 For snapshots, force an already applied upgrade.
 This option has no effect on releases.
Index: sysupgrade.sh
===================================================================
RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v
diff -u -p -r1.62 sysupgrade.sh
--- sysupgrade.sh	21 Mar 2026 01:34:25 -0000	1.62
+++ sysupgrade.sh	3 Jul 2026 07:33:14 -0000
@@ -74,6 +74,7 @@ rmel() {
 
 SNAP=false
 FILE=false
+CHECK=false
 FORCE=false
 FORCE_VERSION=false
 KEEP=false
@@ -83,9 +84,10 @@ WHAT='release'
 VERSION=$(uname -r)
 NEXT_VERSION=$(echo ${VERSION} + 0.1 | bc)
 
-while getopts b:fknrR:s arg; do
+while getopts b:cfknrR:s arg; do
 	case ${arg} in
 	b)	SETSDIR=${OPTARG}/_sysupgrade;;
+	c)	CHECK=true;;
 	f)	FORCE=true;;
 	k)	KEEP=true;;
 	n)	REBOOT=false;;
@@ -186,10 +188,22 @@ unpriv cksum -qC SHA256 BUILDINFO
 if [[ -e /var/db/installed.BUILDINFO ]]; then
 	installed_build_ts=$(cut -f3 -d' ' /var/db/installed.BUILDINFO)
 	build_ts=$(cut -f3 -d' ' BUILDINFO)
-	if (( $build_ts <= $installed_build_ts )) && ! $FORCE; then
+	if $CHECK; then
+	    build_human_ts=$(cut -f5- -d' ' BUILDINFO)
+	    if (( $build_ts > $installed_build_ts )); then
+		echo "A new version ($build_human_ts) is available."
+		exit 0
+	    else
+		echo "No new version available."
+		exit 0
+	    fi
+	elif (( $build_ts <= $installed_build_ts )) && ! $FORCE; then
 		echo "Downloaded ${WHAT} is older than installed system. Use -f to force downgrade."
 		exit 1
 	fi
+elif $CHECK; then
+    echo "Cannot find installed version."
+    exit 1
 fi
 
 # INSTALL.*, bsd*, *.tgz

-- 
Manuel Giraud