=================================================================== RCS file: /cvs/openbsd/update_openbsd/update_openbsd,v retrieving revision 1.105 retrieving revision 1.112 diff -u -r1.105 -r1.112 --- openbsd/update_openbsd/update_openbsd 2017/12/11 02:58:57 1.105 +++ openbsd/update_openbsd/update_openbsd 2018/12/16 20:23:38 1.112 @@ -1,5 +1,5 @@ #!/bin/sh -# $AFresh1: update_openbsd,v 1.103 2017/12/11 02:50:09 andrew Exp $ +# $AFresh1: update_openbsd,v 1.111 2018/12/16 20:12:16 andrew Exp $ # # Copyright (c) 2012 Andrew Fresh # @@ -84,7 +84,7 @@ } set_boot_device() { - BOOT_DEVICE=$( df -nP /bsd | sed -ne 's! .*/$!!p' ) + BOOT_DEVICE=$( df -lnP /bsd | sed -ne 's! .*/$!!p' ) root_disk=$( echo $BOOT_DEVICE | sed -e 's,/dev/\([a-z]*[0-9]\)[a-z].*,\1,' ) @@ -101,19 +101,14 @@ boot_device_mounted="" mount_boot_device() { [ "$boot_device_mounted" ] && return + [ "$BOOT_DEVICE" ] || return - local default_mount=$( df -lnP /bsd | sed -ne 's!/dev/.* !!p' ) local boot_mount=$( mount | sed -ne "s!^$BOOT_DEVICE on \([^ ]*\).*!\1!p" ) if [ ! "$boot_mount" ]; then mount $BOOT_DEVICE /mnt boot_device_mounted=1 - KERNEL_ROOT=/mnt - elif [ "$boot_mount" != "$default_mount" ]; then - KERNEL_ROOT=$boot_mount/ - else - KERNEL_ROOT=${default_mount%/}/ fi } @@ -148,7 +143,7 @@ local _cv=`echo $CUR_VER | sed -e 's/\.//'` local _nv=`echo $NEW_VER | sed -e 's/\.//'` - local _v + local _v _d _pkr if [ X"No" != X"$FORCE_DIR" -a -d $FORCE_DIR ]; then _dir=$FORCE_DIR @@ -240,12 +235,27 @@ [ -z "$BOOT_DEVICE" ] && set_boot_device mount_boot_device + + # _pkr == possible_kernel_roots + _pkr=/ + [ "$BOOT_DEVICE" ] && _pkr="/mnt/ $_pkr" + + for _d in $_pkr; do + KERNEL_ROOT=$( df -lnP ${_d}bsd 2>/dev/null | sed -ne 's!/dev/.* !!p' ) + [ "$KERNEL_ROOT" ] && break + done + + if ! [ "$KERNEL_ROOT" ]; then + echo "Unable to find KERNEL_ROOT, tried $_pkr" >&2 + exit 2 + fi + cd $KERNEL_ROOT BOOT_KERNEL=$( find_boot_kernel ) BOOT_KERNEL_VERSION=$( kernel_file_version $BOOT_KERNEL ) - kernel_is_multiprocessor $BOOT_KERNEL && BOOT_KERNEL=bsd.mp - cd $OLDPWD - umount_boot_device + if [ $(sysctl -n hw.ncpufound) -gt 1 ] || kernel_is_multiprocessor $BOOT_KERNEL; then + BOOT_KERNEL=bsd.mp + fi BOOTED_KERNEL_VERSION=`sysctl -n kern.version` NEW_KERNEL_VERSION="" @@ -256,15 +266,19 @@ 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) - [ $_ncpu -gt 1 ] && INSTALL_KERNELS="$INSTALL_KERNELS bsd.mp" - fi - # or just bsd otherwise - if [ X"${INSTALL_KERNELS% *}" != X"bsd" ]; then - INSTALL_KERNELS="$INSTALL_KERNELS bsd" - fi + + # We want to update all kernels that exist + # either in the $KERNEL_ROOT or in / + for b in bsd bsd.mp; do + [ -e $b -o -e /$b ] || continue + if [ X"${INSTALL_KERNELS% *}" != X"$b" ]; then + INSTALL_KERNELS="$INSTALL_KERNELS $b" + fi + done + + cd $OLDPWD + umount_boot_device + BOOT_KERNELS=$INSTALL_KERNELS INSTALL_KERNELS="$INSTALL_KERNELS bsd.rd" } @@ -419,16 +433,16 @@ install_kernels() { - local _d=$1 - local default_mount + local _d="$1" local boot_mount local mount_is_msdos - if [ ! "$_d" ]; then - default_mount=$( df -lnP /bsd | sed -ne 's!/dev/.* !!p' ) + if [ "$_d" ]; then + _d=$( readlink -nf "$_d" ) + else mount_boot_device - if [ "$KERNEL_ROOT" != "$default_mount" ]; then + if [ "$KERNEL_ROOT" != "/" ]; then local _ik="$INSTALL_KERNELS" INSTALL_KERNELS="$BOOT_KERNEL bsd.rd" @@ -439,7 +453,7 @@ umount_boot_device - install_kernels $default_mount + install_kernels / return fi @@ -450,14 +464,15 @@ exit 1 fi + [ $_d != / ] && _d=${_d%/}/ [ $_d != / ] && mount | grep -q " on ${_d%/} .* msdos" && mount_is_msdos=1 if [ X"$BOOT_KERNEL_VERSION" != X"$NEW_KERNEL_VERSION" ]; then echo "===> Backing up $BOOT_KERNEL to ${_d}obsd" if [ $mount_is_msdos ]; then - cp $BOOT_KERNEL ${_d}obsd + cp ${_d}$BOOT_KERNEL ${_d}obsd else - ln -f $BOOT_KERNEL ${_d}obsd + ln -f ${_d}$BOOT_KERNEL ${_d}obsd fi if [ $? -ne 0 ]; then echo "Error copying old kernel!" >&2 @@ -605,7 +620,7 @@ . ${HOME}/.update_openbsdrc fi -MIRROR=${MIRROR:=http://fastly.cdn.openbsd.org/pub/OpenBSD} +MIRROR=${MIRROR:=http://cdn.openbsd.org/pub/OpenBSD} FTP_CMD=${FTP_CMD:=ftp -V} DESTDIR=${DESTDIR:=/}