From 8a32134cdd6d0039c6be2f734daeeaa4744b407d Mon Sep 17 00:00:00 2001 From: Alexander Leidinger Date: Sat, 18 Feb 2006 16:58:21 +0000 Subject: [PATCH] A file can also be a link, so check not only for a file, but also for a link in the delete-old and check-old targets. We don't install a lib (libXY.so.Z) as a link, but an user may have created something like this. This is dangerous if this link points to a different version of the lib. So check for a link also in the *-lib targets (an annoyed user which absolutely wants this redirection of a lib should use libmap.conf instead of a link). A directory can also be a link, but in this case just echo a message to remove it by hand. --- Makefile.inc1 | 50 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index 8d6f327bae09..fc909aac5806 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -1079,11 +1079,14 @@ delete-old-files: .for file in ${OLD_FILES} # Ask for every old file if the user really wants to remove it. # It's annoying, but better safe than sorry. - @[ ! -f "${DESTDIR}/${file}" ] || (rm ${RM_I} "${DESTDIR}/${file}" \ - || ([ -f "${DESTDIR}/${file}" ] \ - && echo "Removing schg flag on ${DESTDIR}/${file}" \ - && chflags noschg "${DESTDIR}/${file}" \ - && rm ${RM_I} "${DESTDIR}/${file}")) + @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \ + rm ${RM_I} "${DESTDIR}/${file}" || true; \ + if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then\ + echo "Removing schg flag on ${DESTDIR}/${file}"; \ + chflags noschg "${DESTDIR}/${file}"; \ + rm ${RM_I} "${DESTDIR}/${file}"; \ + fi; \ + fi .endfor # Remove catpages without corresponding manpages. @3<&0; \ @@ -1100,7 +1103,9 @@ delete-old-files: check-old-files: @echo ">>> Checking for old files" .for file in ${OLD_FILES} - @[ ! -f "${DESTDIR}/${file}" ] || echo "${DESTDIR}/${file}" + @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \ + echo "${DESTDIR}/${file}"; \ + fi .endfor # Check for catpages without corresponding manpages. @find ${DESTDIR}/usr/share/man/cat* ! -type d | \ @@ -1116,32 +1121,49 @@ delete-old-libs: @echo ">>> Removing old libraries" @echo "${OLD_LIBS_MESSAGE}" | fmt .for file in ${OLD_LIBS} - @[ ! -f "${DESTDIR}/${file}" ] || (rm ${RM_I} "${DESTDIR}/${file}" \ - || ([ -f "${DESTDIR}/${file}" ] \ - && echo "Removing schg flag on ${DESTDIR}/${file}" \ - && chflags noschg "${DESTDIR}/${file}" \ - && rm ${RM_I} "${DESTDIR}/${file}")) + @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \ + rm ${RM_I} "${DESTDIR}/${file}" || true; \ + if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then\ + echo "Removing schg flag on ${DESTDIR}/${file}"; \ + chflags noschg "${DESTDIR}/${file}"; \ + rm ${RM_I} "${DESTDIR}/${file}"; \ + fi; \ + fi .endfor @echo ">>> Old libraries removed" check-old-libs: @echo ">>> Checking for old libraries" .for file in ${OLD_LIBS} - @[ ! -f "${DESTDIR}/${file}" ] || echo "${DESTDIR}/${file}" + @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \ + echo "${DESTDIR}/${file}"; \ + fi .endfor delete-old-dirs: @echo ">>> Removing old directories" .for dir in ${OLD_DIRS} # Don't fail if an old directory isn't empty. - @[ ! -d "${DESTDIR}/${dir}" ] || (rmdir -v "${DESTDIR}/${dir}" || true) + @if [ -d "${DESTDIR}/${dir}" ]; then \ + rmdir -v "${DESTDIR}/${dir}" || true; \ + else \ + if [ -L "${DESTDIR}/${dir}" ]; then \ + echo "${DESTDIR}/${dir} is a link, please remove everything manually."; \ + fi; \ + fi .endfor @echo ">>> Old directories removed" check-old-dirs: @echo ">>> Checking for old directories" .for dir in ${OLD_DIRS} - @[ ! -d "${DESTDIR}/${dir}" ] || echo "${DESTDIR}/${dir}" + @if [ -d "${DESTDIR}/${dir}" ]; then \ + echo "${DESTDIR}/${dir}"; \ + else \ + if [ -L "${DESTDIR}/${dir}" ]; then \ + echo "${DESTDIR}/${dir} is a link, please remove everything manually."; \ + fi; \ + fi .endfor delete-old: delete-old-files delete-old-dirs