[prev in list] [next in list] [prev in thread] [next in thread]
List: openbsd-tech
Subject: Re: Conditional sysupgrade
From: Marco Bonetti <sid77 () slackware ! it>
Date: 2019-04-29 21:12:23
Message-ID: 20190429211223.GA94896 () patollo ! casina
[Download RAW message or body]
On 04/29, Stuart Henderson wrote:
> On 2019/04/29 00:21, Marco Bonetti wrote:
> > > > +++ usr.sbin/sysupgrade/sysupgrade.sh 27 Apr 2019 11:54:48 -0000
> > > > @@ -110,7 +110,19 @@ fi
> > > >
> > > > cd ${SETSDIR}
> > > >
> > > > -unpriv -f SHA256.sig ftp -Vmo SHA256.sig ${URL}SHA256.sig
> > > > +unpriv -f SHA256.sig.tmp ftp -Vmo SHA256.sig.tmp ${URL}SHA256.sig
> > > > +TMP_SHA=$(sha256 -q SHA256.sig.tmp)
> > > > +
> > > > +unpriv touch SHA256.sig
> > > > +CUR_SHA=$(sha256 -q SHA256.sig)
> > > > +
> > > > +if [[ "${TMP_SHA}" = "${CUR_SHA}" ]]; then
> > >
> > > Why compare checksums?
> > >
> > > if cmp -s SHA256.sig SHA256.sig.tmp; then
> >
> > cmp exits 1 on different files, thus killing the script
>
> That's not the case:
>
> -e Errexit. Exit the shell immediately should an error occur or a
> command fail. For pipelines and && and || constructs, only exit
> if the last component fails. Errexit is ignored for while,
> until, if, and elif lists and pipelines beginning ???!???.
>
Right, my bad: I tested the suggeswtion using "if unpriv cmp ...",
triggering -e inside the unpriv function.
Patch below nukes the shasum comparison and switches to cmp.
Index: usr.sbin/sysupgrade/sysupgrade.8
===================================================================
RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.8,v
retrieving revision 1.2
diff -u -p -u -r1.2 sysupgrade.8
--- usr.sbin/sysupgrade/sysupgrade.8 26 Apr 2019 05:54:49 -0000 1.2
+++ usr.sbin/sysupgrade/sysupgrade.8 29 Apr 2019 21:05:33 -0000
@@ -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
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
Index: usr.sbin/sysupgrade/sysupgrade.sh
===================================================================
RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v
retrieving revision 1.7
diff -u -p -u -r1.7 sysupgrade.sh
--- usr.sbin/sysupgrade/sysupgrade.sh 28 Apr 2019 07:21:28 -0000 1.7
+++ usr.sbin/sysupgrade/sysupgrade.sh 29 Apr 2019 21:05:43 -0000
@@ -63,10 +63,12 @@ rmel() {
}
CURRENT=false
+FORCE=false
-while getopts c arg; do
+while getopts cf arg; do
case ${arg} in
c) CURRENT=true;;
+ f) FORCE=true;;
*) usage;;
esac
done
@@ -110,7 +112,19 @@ fi
cd ${SETSDIR}
-unpriv -f SHA256.sig ftp -Vmo SHA256.sig ${URL}SHA256.sig
+unpriv -f SHA256.sig.tmp ftp -Vmo SHA256.sig.tmp ${URL}SHA256.sig
+
+if [[ ! -f SHA256.sig ]]; then
+ unpriv -f SHA256.sig touch SHA256.sig
+fi
+
+if cmp -s SHA256.sig SHA256.sig.tmp; then
+ rm SHA256.sig.tmp
+ return 0
+fi
+
+cat SHA256.sig.tmp >SHA256.sig
+rm SHA256.sig.tmp
_KEY=openbsd-${_KERNV[0]%.*}${_KERNV[0]#*.}-base.pub
_NEXTKEY=openbsd-${NEXT_VERSION%.*}${NEXT_VERSION#*.}-base.pub
Cheers,
Marco
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic