Changeset View
Standalone View
usr.sbin/freebsd-update/freebsd-update.sh
| Show First 20 Lines • Show All 2,903 Lines • ▼ Show 20 Lines | |||||||||
| 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 | ||||||||
| case ${TYPE} in | case ${TYPE} in | ||||||||
| d) | d) | ||||||||
| # Create a directory | # Create a directory. A file may change to a directory | ||||||||
| # on upgrade (PR273661). If that happens, remove the | |||||||||
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
fifernape: 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… | |||||||||
| # file first. | |||||||||
| if [ -e "${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`… | |||||||||
| ! [ -d "${BASEDIR}/${FPATH}" ]; then | |||||||||
| rm -f -- "${BASEDIR}/${FPATH}" | |||||||||
| fi | |||||||||
| 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} | ||||||||
| install -S -o ${OWNER} -g ${GROUP} \ | install -S -o ${OWNER} -g ${GROUP} \ | ||||||||
| ▲ Show 20 Lines • Show All 601 Lines • Show Last 20 Lines | |||||||||