Over time things that used to be files/directories/links can change
to something else. So add code to detect when things don't match and give the user choices about how to fix it. If we're using -P and something in the above check needs to be moved we need to have the directory there for it, so create it at the beginning and delete empty versions of it at the end. The case where something used to be a file or link and now is supposed to be a directory (e.g., /etc/security) is especially dangerous, so make failure to install a necessary directory in $DESTDIR a fatal error.
This commit is contained in:
parent
abdbb3fecd
commit
1b2aeedc64
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=200425
@ -345,6 +345,7 @@ done
|
|||||||
# Don't force the user to set this in the mergemaster rc file
|
# Don't force the user to set this in the mergemaster rc file
|
||||||
if [ -n "${PRESERVE_FILES}" -a -z "${PRESERVE_FILES_DIR}" ]; then
|
if [ -n "${PRESERVE_FILES}" -a -z "${PRESERVE_FILES_DIR}" ]; then
|
||||||
PRESERVE_FILES_DIR=/var/tmp/mergemaster/preserved-files-`date +%y%m%d-%H%M%S`
|
PRESERVE_FILES_DIR=/var/tmp/mergemaster/preserved-files-`date +%y%m%d-%H%M%S`
|
||||||
|
mkdir -p ${PRESERVE_FILES_DIR}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for the mtree database in DESTDIR
|
# Check for the mtree database in DESTDIR
|
||||||
@ -819,7 +820,8 @@ mm_install () {
|
|||||||
|
|
||||||
if [ -n "${DESTDIR}${INSTALL_DIR}" -a ! -d "${DESTDIR}${INSTALL_DIR}" ]; then
|
if [ -n "${DESTDIR}${INSTALL_DIR}" -a ! -d "${DESTDIR}${INSTALL_DIR}" ]; then
|
||||||
DIR_MODE=`find_mode "${TEMPROOT}/${INSTALL_DIR}"`
|
DIR_MODE=`find_mode "${TEMPROOT}/${INSTALL_DIR}"`
|
||||||
install -d -o root -g wheel -m "${DIR_MODE}" "${DESTDIR}${INSTALL_DIR}"
|
install -d -o root -g wheel -m "${DIR_MODE}" "${DESTDIR}${INSTALL_DIR}" ||
|
||||||
|
install_error $1 ${DESTDIR}${INSTALL_DIR}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FILE_MODE=`find_mode "${1}"`
|
FILE_MODE=`find_mode "${1}"`
|
||||||
@ -968,6 +970,57 @@ if [ -r "${MM_PRE_COMPARE_SCRIPT}" ]; then
|
|||||||
. "${MM_PRE_COMPARE_SCRIPT}"
|
. "${MM_PRE_COMPARE_SCRIPT}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Things that were files/directories/links in one version can sometimes
|
||||||
|
# change to something else in a newer version. So we need to explicitly
|
||||||
|
# test for this, and warn the user if what we find does not match.
|
||||||
|
#
|
||||||
|
for COMPFILE in `find .` ; do
|
||||||
|
if [ -e "${DESTDIR}${COMPFILE#.}" ]; then
|
||||||
|
INSTALLED_TYPE=`stat -f '%HT' ${DESTDIR}${COMPFILE#.}`
|
||||||
|
else
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
TEMPROOT_TYPE=`stat -f '%HT' $COMPFILE`
|
||||||
|
|
||||||
|
if [ ! "$TEMPROOT_TYPE" = "$INSTALLED_TYPE" ]; then
|
||||||
|
[ "$COMPFILE" = '.' ] && continue
|
||||||
|
TEMPROOT_TYPE=`echo $TEMPROOT_TYPE | tr [:upper:] [:lower:]`
|
||||||
|
INSTALLED_TYPE=`echo $INSTALLED_TYPE | tr [:upper:] [:lower:]`
|
||||||
|
|
||||||
|
echo "*** The installed file ${DESTDIR}${COMPFILE#.} has the type \"$INSTALLED_TYPE\""
|
||||||
|
echo " but the new version has the type \"$TEMPROOT_TYPE\""
|
||||||
|
echo ''
|
||||||
|
echo " How would you like to handle this?"
|
||||||
|
echo ''
|
||||||
|
echo " Use 'r' to remove ${DESTDIR}${COMPFILE#.}"
|
||||||
|
case "$TEMPROOT_TYPE" in
|
||||||
|
'symbolic link')
|
||||||
|
TARGET=`readlink $COMPFILE`
|
||||||
|
echo " and create a link to $TARGET in its place" ;;
|
||||||
|
*) echo " You will be able to install it as a \"$TEMPROOT_TYPE\"" ;;
|
||||||
|
esac
|
||||||
|
echo ''
|
||||||
|
echo " Use 'i' to ignore this"
|
||||||
|
echo ''
|
||||||
|
echo -n " How to proceed? [i] "
|
||||||
|
read ANSWER
|
||||||
|
case "$ANSWER" in
|
||||||
|
[rR]) case "${PRESERVE_FILES}" in
|
||||||
|
[Yy][Ee][Ss])
|
||||||
|
mv ${DESTDIR}${COMPFILE#.} ${PRESERVE_FILES_DIR}/ || exit 1 ;;
|
||||||
|
*) rm -rf ${DESTDIR}${COMPFILE#.} ;;
|
||||||
|
esac
|
||||||
|
case "$TEMPROOT_TYPE" in
|
||||||
|
'symbolic link') ln -sf $TARGET ${DESTDIR}${COMPFILE#.} ;;
|
||||||
|
esac ;;
|
||||||
|
*) echo ''
|
||||||
|
echo "*** See the man page about adding ${COMPFILE#.} to the list of IGNORE_FILES"
|
||||||
|
press_to_continue ;;
|
||||||
|
esac
|
||||||
|
echo ''
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
for COMPFILE in `find . -type f`; do
|
for COMPFILE in `find . -type f`; do
|
||||||
|
|
||||||
# First, check to see if the file exists in DESTDIR. If not, the
|
# First, check to see if the file exists in DESTDIR. If not, the
|
||||||
@ -1269,5 +1322,9 @@ case "${PRE_WORLD}" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exit 0
|
if [ -n "${PRESERVE_FILES}" ]; then
|
||||||
|
find -d $PRESERVE_FILES_DIR -type d -empty -delete 2>/dev/null
|
||||||
|
rmdir $PRESERVE_FILES_DIR 2>/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user