Changeset View
Standalone View
usr.sbin/freebsd-update/freebsd-update.sh
Show First 20 Lines • Show All 2,900 Lines • ▼ Show 20 Lines | |||||||||
# Install new files | # Install new files | ||||||||
install_from_index () { | install_from_index () { | ||||||||
# First pass: Do everything apart from setting file flags. We | # First pass: Do everything apart from setting file flags. We | ||||||||
# can't set flags yet, because schg inhibits hard linking. | # can't set flags yet, because schg inhibits hard linking. | ||||||||
sort -k 1,1 -t '|' $1 | | sort -k 1,1 -t '|' $1 | | ||||||||
tr '|' ' ' | | tr '|' ' ' | | ||||||||
while read FPATH TYPE OWNER GROUP PERM FLAGS HASH LINK; do | while read FPATH TYPE OWNER GROUP PERM FLAGS HASH LINK; do | ||||||||
if [ -e ${BASEDIR}/${FPATH} ]; then | |||||||||
if [ ${TYPE} = d ] && ! [ -d ${BASEDIR}/${FPATH} ]; then | |||||||||
rm -f ${BASEDIR}/${FPATH} | |||||||||
elif [ ${TYPE} = 'f' || ${TYPE} = 'L' ] && \ | |||||||||
emasteAuthorUnsubmitted Done Inline Actions
emaste: | |||||||||
Not Done Inline ActionsWould it make sense to first check if the entry in INDEX is a directory? /var/db/freebsd-update/install.i3wHbM# cut -f2 -d'|' INDEX-NEW | sort | uniq -c 23 L 41 d 9625 f In general the dir/files ration seems to be low. Since most of the files will exist (most files are upgraded, a few removed and some newly installed), we could save many path existence checks. While here, add a message to show instances of this problem. This might be removed in the final version: # A file may change to a directory on upgrade (PR273661). # If that happens rm the file first so that install can create # the directory in its place. if [ ${TYPE} = d ]; then if [ -e "${BASEDIR}/${FPATH}" ] && ! [ -d "${BASEDIR}/${FPATH}" ]; then echo "Warn: file ${BASEDIR}/${FPATH} has become a directory" rm -f -- "${BASEDIR}/${FPATH}" fi fi fernape: Would it make sense to first check if the entry in INDEX is a directory?
```
/var/db/freebsd… | |||||||||
Done Inline Actions
For this review it would, but the followup in D41945 will add file/symlink tests. emaste: > Would it make sense to first check if the entry in INDEX is a directory?
For this review it… | |||||||||
[ -d ${BASEDIR}/${FPATH} ]; then | |||||||||
rm -rf ${BASEDIR}/${FPATH} | |||||||||
Not Done Inline ActionsSo this will definitely kill off any customizations a user has in such a directory, which should become a file? It's probably tricky to check here, but maybe there needs to be some sort of prompt? dim: So this will definitely kill off any customizations a user has in such a directory, which… | |||||||||
Not Done Inline ActionsThis should probably be between double quotes to avoid problems should BASEDIR or FPATH have a space somewhere. rm -f "${BASEDIR}/${FPATH}" fernape: This should probably be between double quotes to avoid problems should `BASEDIR` or `FPATH`… | |||||||||
fi | |||||||||
fi | |||||||||
case ${TYPE} in | case ${TYPE} in | ||||||||
d) | d) | ||||||||
if [ -e ${BASEDIR}/${FPATH} ] && \ | |||||||||
! [ -d ${BASEDIR}/${FPATH} ]; then | |||||||||
# Exists but not a directory | |||||||||
rm -f ${BASEDIR}/${FPATH} | |||||||||
fi | |||||||||
# Create a directory | # Create a directory | ||||||||
install -d -o ${OWNER} -g ${GROUP} \ | install -d -o ${OWNER} -g ${GROUP} \ | ||||||||
-m ${PERM} ${BASEDIR}/${FPATH} | -m ${PERM} ${BASEDIR}/${FPATH} | ||||||||
;; | ;; | ||||||||
f) | f) | ||||||||
if [ -z "${LINK}" ]; then | if [ -z "${LINK}" ]; then | ||||||||
# Create a file, without setting flags. | # Create a file, without setting flags. | ||||||||
gunzip < files/${HASH}.gz > ${HASH} | gunzip < files/${HASH}.gz > ${HASH} | ||||||||
▲ Show 20 Lines • Show All 601 Lines • Show Last 20 Lines |