Index: usr.sbin/freebsd-update/freebsd-update.sh =================================================================== --- usr.sbin/freebsd-update/freebsd-update.sh +++ usr.sbin/freebsd-update/freebsd-update.sh @@ -2628,6 +2628,32 @@ echo "To install the downloaded upgrades, run \"$0 install\"." } +# Perform system sanity checks to ensure +# the file system can be modified as expected +install_verify_system () { + # Verify there are read-write permissions on / and /usr + if mount -p | + sed -E "s,[[:blank:]]+, ,g" | + cut -d' ' -f 2,4 | + grep -E '^/(usr)? ' | + grep -vqE 'rw$'; then + echo -n "Either '/' or '/usr' " + echo "are not mounted with read-write permissions." + return 1 + fi + + # Ensure that the file system supports chflags + touch "${BASEDIR}/chflags_test" + if ! chflags 0 "${BASEDIR}/chflags_test"; then + echo "chflags is not supported on the file system of ${BASEDIR}." + echo -n "If an NFS filesystem is being used, " + echo "update on the source file system and then export it." + rm -f "${BASEDIR}/chflags_test" + return 1 + fi + rm -f "${BASEDIR}/chflags_test" +} + # Make sure that all the file hashes mentioned in $@ have corresponding # gzipped files stored in /files/. install_verify () { @@ -2978,6 +3004,8 @@ # Actually install updates install_run () { echo -n "Installing updates..." + # Make sure the system is configured correctly + install_verify_system || return 1 # Make sure we have all the files we should have install_verify ${BDHASH}-install/INDEX-OLD \ @@ -3069,6 +3097,9 @@ rm ${BDHASH}-install fi + # Make sure the system is configured correctly + install_verify_system || return 1 + # Make sure we have all the files we should have install_verify ${BDHASH}-rollback/INDEX-NEW \ ${BDHASH}-rollback/INDEX-OLD || return 1