=================================================================== RCS file: /cvs/openbsd/update_openbsd/update_openbsd,v retrieving revision 1.40 retrieving revision 1.52 diff -u -r1.40 -r1.52 --- openbsd/update_openbsd/update_openbsd 2012/12/08 19:54:08 1.40 +++ openbsd/update_openbsd/update_openbsd 2013/10/20 01:26:35 1.52 @@ -1,5 +1,20 @@ #!/bin/sh -# $AFresh1: update_openbsd,v 1.39 2012/12/08 19:52:08 andrew Exp $ +# $AFresh1: update_openbsd,v 1.51 2013/10/20 00:23:05 andrew Exp $ +# +# Copyright (c) 2012 Andrew Fresh +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# installed_sets() { local misc=/usr/share/doc/README @@ -160,8 +175,8 @@ [ -e /boot.conf ] && sed -E '/^ *(set +image|boot) +/!d ; \ s///; s/^.*://; s/ .*$//' /boot.conf \ ) | tail -1` + BOOT_KERNEL=`follow_symlink /$BOOT_KERNEL` BOOT_KERNEL="/${BOOT_KERNEL#/}" - BOOT_KERNEL=`follow_symlink $BOOT_KERNEL` BOOT_KERNEL_VERSION=`kernel_file_version $BOOT_KERNEL` @@ -170,6 +185,10 @@ # We want to default to what we had INSTALL_KERNELS="${BOOT_KERNEL#/}" + # if the boot kernel was our specially named bsd.sp, we install from bsd + if [ X"$INSTALL_KERNELS" == X"bsd.sp" ]; then + INSTALL_KERNELS="bsd" + fi # with a second option of an mp kernel if is is a likely candidate if [ X"$INSTALL_KERNELS" != X"bsd.mp" ]; then local _ncpu=$(sysctl -n hw.ncpufound) @@ -196,7 +215,7 @@ local _v=$FILE_VER for _b in $INSTALL_KERNELS; do - if [ -e /${_b} -a ! -e ./${_b} ]; then + if [ ! -e ./${_b} ]; then echo $FTP_CMD ${FTP}/${_b} $FTP_CMD ${FTP}/${_b} fi @@ -314,11 +333,13 @@ exit 1 fi - echo "Backing up $BOOT_KERNEL to /obsd" - $SUDO ln -f $BOOT_KERNEL /obsd - if [ $? -ne 0 ]; then - echo "Error copying old kernel!" >&2 - exit 1 + if [ X"$BOOT_KERNEL_VERSION" != X"$NEW_KERNEL_VERSION" ]; then + echo "Backing up $BOOT_KERNEL to /obsd" + $SUDO ln -f $BOOT_KERNEL /obsd + if [ $? -ne 0 ]; then + echo "Error copying old kernel!" >&2 + exit 1 + fi fi cd $RELEASEDIR @@ -375,15 +396,6 @@ local _v=$FILE_VER - if [ $CUR_VER != $NEW_VER -a ! -e /sbin/oreboot ]; then - $SUDO cp /sbin/reboot /sbin/oreboot - if [ $? -ne 0 ]; then - echo "Error copying old reboot command!" >&2 - exit 1 - fi - echo "/sbin/reboot copied to /sbin/oreboot" - fi - local _sets=`ls *${_v}.tgz | grep -v ^base ` for _f in ${_sets} base${_v}.tgz; do _path=$DESTDIR @@ -403,7 +415,9 @@ done echo Extracted all sets. +} +install_sendmail_smtp_auth() { if [ -e ${RELEASEDIR}/sendmail-smtp_auth.gz ]; then gzcat ${RELEASEDIR}/sendmail-smtp_auth.gz > \ ${RELEASEDIR}/sendmail-smtp_auth @@ -424,55 +438,33 @@ update_etc() { echo '### UPDATING ETC ###' if [ ! -e $SYSMERGE ]; then - SYSMERGE= + echo "ERROR: Can't find sysmerge!" >&2 + exit 1; fi - if [ X"" == X"$SYSMERGE" ]; then - if [ -e /var/tmp/temproot ]; then - MERGEMASTER=`which mergemaster` + if [ X"" == X"$RELEASEDIR" ]; then + echo "ERROR: no source for etc!" >&2 + exit 1 + fi - if [ $? != 0 ]; then - $SUDO pkg_add -i mergemaster + cd $RELEASEDIR - MERGEMASTER=`which mergemaster` - if [ $? != 0 ]; then - echo ERROR: mergemaster not installed! >&2 - exit 1 - fi - fi - - echo '### RUNNING MERGEMASTER ###' - $SUDO $MERGEMASTER -irv - else - echo "ERROR: no source for etc!" >&2 - exit 1 - fi + local _v=$FILE_VER + local _args="" + if [ -e etc${_v}.tgz ]; then + _args="$_args -s etc${_v}.tgz" + fi + if [ -e xetc${_v}.tgz ]; then + _args="$_args -x xetc${_v}.tgz" + fi + if [ X"" == X"$_args" ]; then + echo ERROR: No upgrade sets found! >&2 else - if [ X"" == X"$RELEASEDIR" ]; then - echo "ERROR: no source for etc!" >&2 - exit 1 - else - cd $RELEASEDIR - fi - - local _v=$FILE_VER - local _args="" - if [ -e etc${_v}.tgz ]; then - _args="$_args -s etc${_v}.tgz" - fi - if [ -e xetc${_v}.tgz ]; then - _args="$_args -x xetc${_v}.tgz" - fi - if [ X"" == X"$_args" ]; then - echo ERROR: No upgrade sets found! >&2 - else - echo '### RUNNING SYSMERGE ###' - if sysmerge 2>&1 | grep -- -a >/dev/null; then - _args="-a $_args" - fi - $SUDO $SYSMERGE $_args - fi + echo '### RUNNING SYSMERGE ###' + $SUDO $SYSMERGE $_args fi + + cd $OLDPWD } @@ -541,16 +533,40 @@ read _temp fi -if [ X"" != X"$SUDO" ]; then - echo Please enter your sudo password if prompted. - echo You may be asked for it again later in the process. - $SUDO -v +if [ -n "$SUDO" -a $CUR_VER != $NEW_VER ]; then + echo >&2 + echo "!!! You are upgrading between OpenBSD versions. !!!" >&2 + echo "!!! You should make sure you have a root shell open !!!" >&2 + echo "!!! It is needed in order to run /sbin/oreboot. !!!" >&2 + echo "!!! sudo MAY NOT WORK after sets are extracted. !!!" >&2 + echo >&2 + echo "ctrl+C to cancel, enter to continue" >&2 + local _temp + read _temp fi +if [ -n "$SUDO" ]; then + echo + echo You may be asked for your sudo password multiple times. + $SUDO -v -p "sudo Password: " +fi + +if [ X"$BOOT_KERNEL_VERSION" != X"$BOOTED_KERNEL_VERSION" \ + -a ! -e /sbin/oreboot ]; then + $SUDO cp /sbin/reboot /sbin/oreboot + if [ $? -ne 0 ]; then + echo "Error copying old reboot command!" >&2 + exit 1 + fi + echo "/sbin/reboot copied to /sbin/oreboot" +fi + install_kernels install_sets -if [ $CUR_VER == $NEW_VER ]; then +if [ X"$BOOT_KERNEL_VERSION" == X"$BOOTED_KERNEL_VERSION" ]; then + install_sendmail_smtp_auth + if [ -e /sbin/oreboot ]; then echo Removing /sbin/oreboot $SUDO rm -f /sbin/oreboot @@ -572,14 +588,4 @@ echo New kernel installed. Please reboot! if [ -e /sbin/oreboot ]; then echo Possibly using /sbin/oreboot -fi - -local _send_dmesg=`dirname $0`/send_dmesg -if [ -e "$_send_dmesg" ]; then - if [ -e $RELEASEDIR/.send_dmesg ]; then - $_send_dmesg - rm -f $RELEASEDIR/.send_dmesg - elif [ X"$CUR_VER" != X"$NEW_VER" ]; then - touch $RELEASEDIR/.send_dmesg - fi fi