=================================================================== RCS file: /cvs/openbsd/update_openbsd/update_openbsd,v retrieving revision 1.109 retrieving revision 1.115 diff -u -r1.109 -r1.115 --- openbsd/update_openbsd/update_openbsd 2018/02/08 19:08:01 1.109 +++ openbsd/update_openbsd/update_openbsd 2018/12/16 20:55:03 1.115 @@ -1,5 +1,5 @@ #!/bin/sh -# $AFresh1: update_openbsd,v 1.108 2018/02/08 19:07:06 andrew Exp $ +# $AFresh1: update_openbsd,v 1.114 2018/12/16 20:49:58 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,' ) @@ -103,18 +103,12 @@ [ "$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 } @@ -149,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 @@ -241,6 +235,21 @@ [ -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 ) @@ -268,6 +277,14 @@ done cd $OLDPWD + + EFI_BOOT="" + if [ -d "/mnt/efi/boot" ]; then + _d=$( cd "/mnt/efi/boot" && ls -1 *.{efi,EFI} 2>/dev/null ) + # assume an MSDOS filesystem and so case insensitive + [ "$_d" ] && EFI_BOOT=$( echo $_d | tr a-z A-Z ) + fi + umount_boot_device BOOT_KERNELS=$INSTALL_KERNELS @@ -286,6 +303,16 @@ local _v=$FILE_VER + if [ "$EFI_BOOT" ]; then + _b="$EFI_BOOT" + if [ ! -e ./${_b} ]; then + echo "===> $FTP_CMD ${FTP}/${_b}" + $FTP_CMD ${FTP}/${_b} + else + echo "===> Have ${_b}" + fi + fi + for _b in $INSTALL_KERNELS; do if [ ! -e ./${_b} ]; then echo "===> $FTP_CMD ${FTP}/${_b}" @@ -424,16 +451,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" @@ -444,7 +471,7 @@ umount_boot_device - install_kernels $default_mount + install_kernels / return fi @@ -455,10 +482,19 @@ exit 1 fi + [ $_d != / ] && _d=${_d%/}/ [ $_d != / ] && mount | grep -q " on ${_d%/} .* msdos" && mount_is_msdos=1 + if [ "$EFI_BOOT" -a -d /mnt/efi/boot ]; then + echo "Copying $EFI_BOOT to /mnt/efi/boot/$EFI_BOOT" + ( cd /mnt/efi/boot \ + && cp "$RELEASEDIR/$EFI_BOOT" "n$EFI_BOOT" + && mv "n$EFI_BOOT" "$EFI_BOOT" + ) + fi + if [ X"$BOOT_KERNEL_VERSION" != X"$NEW_KERNEL_VERSION" ]; then - echo "===> Backing up $BOOT_KERNEL to ${_d}obsd" + echo "===> Backing up ${_d}$BOOT_KERNEL to ${_d}obsd" if [ $mount_is_msdos ]; then cp ${_d}$BOOT_KERNEL ${_d}obsd else @@ -645,6 +681,7 @@ echo " RELEASEDIR: $RELEASEDIR" echo " DESTDIR: $DESTDIR" echo " BOOT_DEVICE: $BOOT_DEVICE" +[ "$EFI_BOOT" ] && echo " EFI_BOOT: $EFI_BOOT" echo " BOOT_KERNEL: $BOOT_KERNEL" echo " INSTALL_KERNELS: $INSTALL_KERNELS" echo " INSTALLED_SETS: $INSTALLED_SETS" @@ -655,9 +692,11 @@ echo mount_boot_device +l=$KERNEL_ROOT +[ "$l" = / ] || l="$BOOT_DEVICE:" for k in $INSTALL_KERNELS; do if [ -e $KERNEL_ROOT$k ]; then - echo "Existing $BOOT_DEVICE:$k" + echo "Existing $l$k" kernel_file_version $KERNEL_ROOT$k fi done