The use case for this patch is that in our lab network we have NFS
automounted /home/* directories, so using /home/_sysupgrade
for sysupgrade does not work.

With this patch it is easy to modify /usr/sbin/sysupgrade and change
just the line SETSDIR=/home/_sysupgrade to point to some other local file
system that is outside hier(7) for example /opt/_sysupgrade
or /srv/_sysupgrade.

Even using /var/_sysupgrade or /usr/_sysupgrade should work.  As far as
I can tell the sysupgrade directory only has to be on a local file system,
and not get overwritten by the base system install.

The change for mkdir -p ${SETSDIR} is to make the script more defensive about
the result of mkdir, e.g in case the umask is wrong, or if the directory
containing the sysupgrade directory has got the wrong group, etc.


A follow-up to this patch, should it be accepted, could be to add an option
-d SysupgradeDir, but I do not know if that would be considered as a too odd
and error prone feature to merit an option.  Or?

The patch is on 6.6 stable.

Index: usr.sbin/sysupgrade/sysupgrade.sh
===================================================================
RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v
retrieving revision 1.25
diff -u -u -r1.25 sysupgrade.sh
--- usr.sbin/sysupgrade/sysupgrade.sh   28 Sep 2019 17:30:07 -0000      1.25
+++ usr.sbin/sysupgrade/sysupgrade.sh   14 Nov 2019 13:27:34 -0000
@@ -119,6 +119,7 @@
        URL=${MIRROR}/${NEXT_VERSION}/${ARCH}/
 fi
 
+[[ -e ${SETSDIR} ]] || mkdir -p ${SETSDIR}
 if [[ -e ${SETSDIR} ]]; then
        eval $(stat -s ${SETSDIR})
        [[ $st_uid -eq 0 ]] ||
@@ -127,8 +128,6 @@
                 ug_err "${SETSDIR} needs to be owned by root:wheel"
        [[ $st_mode -eq 040755 ]] || 
                ug_err "${SETSDIR} is not a directory with permissions 0755"
-else
-       mkdir -p ${SETSDIR}
 fi
 
 cd ${SETSDIR}
@@ -185,7 +184,7 @@
 
 cat <<__EOT >/auto_upgrade.conf
 Location of sets = disk
-Pathname to the sets = /home/_sysupgrade/
+Pathname to the sets = ${SETSDIR}/
 Set name(s) = done
 Directory does not contain SHA256.sig. Continue without verification = yes
 __EOT
@@ -193,7 +192,7 @@
 if ! ${KEEP}; then
        CLEAN=$(echo SHA256 ${SETS} | sed -e 's/ /,/g')
        cat <<__EOT > /etc/rc.firsttime
-rm -f /home/_sysupgrade/{${CLEAN}}
+rm -f ${SETSDIR}/{${CLEAN}}
 __EOT
 fi

Best regards
--  
/ Raimo Niskanen, Erlang/OTP, Ericsson AB

Reply via email to