Enhance the safety of the -U option:
1. In several places make sure that the mtree database is not empty using the -s argument to test instead of -f. (I thought I'd already changed this, but obviously not.) 2. When deriving the list of changed files use a colon-delimited list. 3. If the list of changed files is empty, unset the variable, and test for a non-empty CHANGED in diff_loop() before entering that routine. Enhance the speed of the -U option by using an internal case statement instead of echoing the variable to an external grep for every file. Fix indentation on one line.
This commit is contained in:
parent
e43c3a8bd9
commit
1b855ebe6c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=192230
@ -115,8 +115,10 @@ diff_loop () {
|
|||||||
while [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" -o \
|
while [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" -o \
|
||||||
"${HANDLE_COMPFILE}" = "NOT V" ]; do
|
"${HANDLE_COMPFILE}" = "NOT V" ]; do
|
||||||
if [ -f "${DESTDIR}${COMPFILE#.}" -a -f "${COMPFILE}" ]; then
|
if [ -f "${DESTDIR}${COMPFILE#.}" -a -f "${COMPFILE}" ]; then
|
||||||
if [ -n "${AUTO_UPGRADE}" ]; then
|
if [ -n "${AUTO_UPGRADE}" -a -n "${CHANGED}" ]; then
|
||||||
if echo "${CHANGED}" | grep -qsv ${DESTDIR}${COMPFILE#.}; then
|
case "${CHANGED}" in
|
||||||
|
*:${DESTDIR}${COMPFILE#.}:*) ;; # File has been modified
|
||||||
|
*)
|
||||||
echo ''
|
echo ''
|
||||||
echo " *** ${COMPFILE} has not been user modified."
|
echo " *** ${COMPFILE} has not been user modified."
|
||||||
echo ''
|
echo ''
|
||||||
@ -128,10 +130,11 @@ diff_loop () {
|
|||||||
AUTO_UPGRADED_FILES="${AUTO_UPGRADED_FILES} ${DESTDIR}${COMPFILE#.}
|
AUTO_UPGRADED_FILES="${AUTO_UPGRADED_FILES} ${DESTDIR}${COMPFILE#.}
|
||||||
"
|
"
|
||||||
else
|
else
|
||||||
echo " *** Problem upgrading ${COMPFILE}, it will remain to merge by hand"
|
echo " *** Problem upgrading ${COMPFILE}, it will remain to merge by hand"
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
if [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" ]; then
|
if [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" ]; then
|
||||||
echo ''
|
echo ''
|
||||||
@ -348,7 +351,7 @@ fi
|
|||||||
case "${AUTO_UPGRADE}" in
|
case "${AUTO_UPGRADE}" in
|
||||||
'') ;; # If the option is not set no need to run the test or warn the user
|
'') ;; # If the option is not set no need to run the test or warn the user
|
||||||
*)
|
*)
|
||||||
if [ ! -f "${DESTDIR}${MTREEFILE}" ]; then
|
if [ ! -s "${DESTDIR}${MTREEFILE}" ]; then
|
||||||
echo ''
|
echo ''
|
||||||
echo "*** Unable to find mtree database. Skipping auto-upgrade."
|
echo "*** Unable to find mtree database. Skipping auto-upgrade."
|
||||||
echo ''
|
echo ''
|
||||||
@ -459,14 +462,15 @@ MM_MAKE="make ${ARCHSTRING} -m ${SOURCEDIR}/share/mk"
|
|||||||
# Check DESTDIR against the mergemaster mtree database to see what
|
# Check DESTDIR against the mergemaster mtree database to see what
|
||||||
# files the user changed from the reference files.
|
# files the user changed from the reference files.
|
||||||
#
|
#
|
||||||
CHANGED=
|
if [ -n "${AUTO_UPGRADE}" -a -s "${DESTDIR}${MTREEFILE}" ]; then
|
||||||
if [ -n "${AUTO_UPGRADE}" -a -f "${DESTDIR}${MTREEFILE}" ]; then
|
CHANGED=:
|
||||||
for file in `mtree -eqL -f ${DESTDIR}${MTREEFILE} -p ${DESTDIR}/ \
|
for file in `mtree -eqL -f ${DESTDIR}${MTREEFILE} -p ${DESTDIR}/ \
|
||||||
2>/dev/null | awk '($2 == "changed") {print $1}'`; do
|
2>/dev/null | awk '($2 == "changed") {print $1}'`; do
|
||||||
if [ -f "${DESTDIR}/$file" ]; then
|
if [ -f "${DESTDIR}/$file" ]; then
|
||||||
CHANGED="${CHANGED} ${DESTDIR}/$file"
|
CHANGED="${CHANGED}${DESTDIR}/${file}:"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
[ "$CHANGED" = ':' ] && unset CHANGED
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check the width of the user's terminal
|
# Check the width of the user's terminal
|
||||||
@ -1055,7 +1059,7 @@ done # This is for the for way up there at the beginning of the comparison
|
|||||||
echo ''
|
echo ''
|
||||||
echo "*** Comparison complete"
|
echo "*** Comparison complete"
|
||||||
|
|
||||||
if [ -f "${MTREENEW}" ]; then
|
if [ -s "${MTREENEW}" ]; then
|
||||||
echo "*** Saving mtree database for future upgrades"
|
echo "*** Saving mtree database for future upgrades"
|
||||||
test -e "${DESTDIR}${MTREEFILE}" && unlink ${DESTDIR}${MTREEFILE}
|
test -e "${DESTDIR}${MTREEFILE}" && unlink ${DESTDIR}${MTREEFILE}
|
||||||
mv ${MTREENEW} ${DESTDIR}${MTREEFILE}
|
mv ${MTREENEW} ${DESTDIR}${MTREEFILE}
|
||||||
|
Loading…
Reference in New Issue
Block a user