diff options
author | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2019-05-13 02:25:17 +0000 |
---|---|---|
committer | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2019-05-13 02:25:17 +0000 |
commit | f0a228c36239c6b5e1a9e760aa00c6643f439e23 (patch) | |
tree | af8e45a9c7716e45d8233f10e6b5e3fe85d4f28a | |
parent | 9131f5a7ac0fceee2ea1dac1b5f451cb133c6cce (diff) |
Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.
Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.
Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@
-rw-r--r-- | usr.sbin/sysupgrade/sysupgrade.sh | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/usr.sbin/sysupgrade/sysupgrade.sh b/usr.sbin/sysupgrade/sysupgrade.sh index b6081b0dfe8..6b16d494fb8 100644 --- a/usr.sbin/sysupgrade/sysupgrade.sh +++ b/usr.sbin/sysupgrade/sysupgrade.sh @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: sysupgrade.sh,v 1.19 2019/05/10 01:29:14 naddy Exp $ +# $OpenBSD: sysupgrade.sh,v 1.20 2019/05/13 02:25:16 ajacoutot Exp $ # # Copyright (c) 1997-2015 Todd Miller, Theo de Raadt, Ken Westerback # Copyright (c) 2015 Robert Peichaer <rpe@openbsd.org> @@ -24,7 +24,6 @@ set -e umask 0022 ARCH=$(uname -m) -SETSDIR=/home/_sysupgrade ug_err() { @@ -57,6 +56,17 @@ unpriv() return ${_rc} } +# df(1) is run twice to sort our prefered FS list first +get_prefetcharea() { + { df -kl /{tmp,home,usr{/local,}}; df -kl ;} | + while read a a a a m m; do + [[ $m == /@(tmp|home|usr/@(src,obj,xobj))@(|/*) ]] && + ((a > 524288)) && echo $m && break + [[ $m == @(|/*) ]] && + ((a > 524288 * 4)) && echo $m && break + done +} + # Remove all occurrences of first argument from list formed by the remaining # arguments. rmel() { @@ -118,16 +128,20 @@ else URL=${MIRROR}/${NEXT_VERSION}/${ARCH}/ fi -if [[ -e ${SETSDIR} ]]; then - eval $(stat -s ${SETSDIR}) - [[ $st_uid -eq 0 ]] || - ug_err "${SETSDIR} needs to be owned by root:wheel" - [[ $st_gid -eq 0 ]] || - ug_err "${SETSDIR} needs to be owned by root:wheel" - [[ $st_mode -eq 040755 ]] || - ug_err "${SETSDIR} is not a directory with permissions 0755" +SETSDIR=$(mktemp -d -p $(get_prefetcharea) .sysupgrade.XXXXXXXXXX) + +if [[ -n ${SETSDIR} ]]; then + install -d -o 0 -g 0 -m 0755 ${SETSDIR} + cat <<-__EOT >/auto_upgrade.conf + Location of sets = disk + Pathname to the sets = ${SETSDIR} + Set name(s) = done + Directory does not contain SHA256.sig. Continue without verification = yes + __EOT + ${KEEP} || echo "rm -rf -- \"${SETSDIR}\"" >>/etc/rc.firsttime + else - mkdir -p ${SETSDIR} + ug_err "Not enough space to fetch sets" fi cd ${SETSDIR} @@ -180,8 +194,6 @@ if [[ -n ${DL} ]]; then unpriv cksum -qC SHA256 ${DL} fi -${KEEP} && > keep - cp bsd.rd /nbsd.upgrade ln -f /nbsd.upgrade /bsd.upgrade rm /nbsd.upgrade |