Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/freebsd-update/freebsd-update.sh
Show First 20 Lines • Show All 2,792 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 | ||||
_FILE_INSTALL_STATUS=0 | |||||
case ${TYPE} in | case ${TYPE} in | ||||
d) | d) | ||||
# 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} | ||||
_FILE_INSTALL_STATUS=$? | |||||
;; | ;; | ||||
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} | ||||
_FILE_INSTALL_STATUS=$? | |||||
if [ ${_FILE_INSTALL_STATUS} -eq 0 ]; then | |||||
install -S -o ${OWNER} -g ${GROUP} \ | install -S -o ${OWNER} -g ${GROUP} \ | ||||
-m ${PERM} ${HASH} ${BASEDIR}/${FPATH} | -m ${PERM} ${HASH} ${BASEDIR}/${FPATH} | ||||
_FILE_INSTALL_STATUS=$? | |||||
rm ${HASH} | rm ${HASH} | ||||
fi | |||||
else | else | ||||
# Create a hard link. | # Create a hard link. | ||||
ln -f ${BASEDIR}/${LINK} ${BASEDIR}/${FPATH} | ln -f ${BASEDIR}/${LINK} ${BASEDIR}/${FPATH} | ||||
_FILE_INSTALL_STATUS=$? | |||||
fi | fi | ||||
;; | ;; | ||||
L) | L) | ||||
# Create a symlink | # Create a symlink | ||||
ln -sfh ${HASH} ${BASEDIR}/${FPATH} | ln -sfh ${HASH} ${BASEDIR}/${FPATH} | ||||
_FILE_INSTALL_STATUS=$? | |||||
;; | ;; | ||||
esac | esac | ||||
if [ ${_FILE_INSTALL_STATUS} -ne 0 ]; then | |||||
cat <<- EOF | |||||
Failed to install file ${BASEDIR}/${FPATH}. | |||||
Please verify that there is enough space available in | |||||
${BASEDIR} to install new files. | |||||
EOF | |||||
return 1 | |||||
fi | |||||
done | done | ||||
# Perform a second pass, adding file flags. | # Perform a second pass, adding file flags. | ||||
tr '|' ' ' < $1 | | tr '|' ' ' < $1 | | ||||
while read FPATH TYPE OWNER GROUP PERM FLAGS HASH LINK; do | while read FPATH TYPE OWNER GROUP PERM FLAGS HASH LINK; do | ||||
if [ ${TYPE} = "f" ] && | if [ ${TYPE} = "f" ] && | ||||
! [ ${FLAGS} = "0" ]; then | ! [ ${FLAGS} = "0" ]; then | ||||
chflags ${FLAGS} ${BASEDIR}/${FPATH} | chflags ${FLAGS} ${BASEDIR}/${FPATH} | ||||
Show All 13 Lines | sort -k 1,1 -t '|' $1 | | ||||
sort -r -k 1,1 -t '|' | | sort -r -k 1,1 -t '|' | | ||||
cut -f 1,2 -d '|' | | cut -f 1,2 -d '|' | | ||||
tr '|' ' ' > killfiles | tr '|' ' ' > killfiles | ||||
# Remove the offending bits | # Remove the offending bits | ||||
while read FPATH TYPE; do | while read FPATH TYPE; do | ||||
case ${TYPE} in | case ${TYPE} in | ||||
d) | d) | ||||
rmdir ${BASEDIR}/${FPATH} | rmdir ${BASEDIR}/${FPATH} || return 1 | ||||
;; | ;; | ||||
f) | f) | ||||
rm ${BASEDIR}/${FPATH} | rm ${BASEDIR}/${FPATH} || return 1 | ||||
;; | ;; | ||||
L) | L) | ||||
rm ${BASEDIR}/${FPATH} | rm ${BASEDIR}/${FPATH} || return 1 | ||||
;; | ;; | ||||
esac | esac | ||||
done < killfiles | done < killfiles | ||||
# Clean up | # Clean up | ||||
rm newfiles killfiles | rm newfiles killfiles | ||||
} | } | ||||
▲ Show 20 Lines • Show All 483 Lines • Show Last 20 Lines |