Index: usr.sbin/freebsd-update/freebsd-update.sh =================================================================== --- usr.sbin/freebsd-update/freebsd-update.sh +++ usr.sbin/freebsd-update/freebsd-update.sh @@ -2900,6 +2900,15 @@ set +f } +# Check for and remove an existing directory that conflicts with the file or +# symlink that we are going to install. +dir_conflict () { + if [ -e "$1" ] && [ -d "$1" ]; then + echo "Removing conflicting directory $1" + rm -rf -- "$1" + fi +} + # Install new files install_from_index () { # First pass: Do everything apart from setting file flags. We @@ -2920,6 +2929,7 @@ -m ${PERM} ${BASEDIR}/${FPATH} ;; f) + dir_conflict "${BASEDIR}/${FPATH}" if [ -z "${LINK}" ]; then # Create a file, without setting flags. gunzip < files/${HASH}.gz > ${HASH} @@ -2932,6 +2942,7 @@ fi ;; L) + dir_conflict "${BASEDIR}/${FPATH}" # Create a symlink ln -sfh ${HASH} ${BASEDIR}/${FPATH} ;; @@ -2967,11 +2978,8 @@ d) rmdir ${BASEDIR}/${FPATH} ;; - f) - rm ${BASEDIR}/${FPATH} - ;; - L) - rm ${BASEDIR}/${FPATH} + f|L) + rm -f "${BASEDIR}/${FPATH}" ;; esac done < killfiles