Add list-old-{dirs,files,libs} targets.

These targets generate a raw list of the candidate old files roughly
corresponding to the values of OLD_DIRS, OLD_FILES, and OLD_LIBS.
Currently list-old-files also includes uncompressed manpages in
addition to compressed manpages.

Use these targets in the implementation of check-old-* and
delete-old-* to replace duplicated logic.

Reviewed by:	imp, emaste
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33327
This commit is contained in:
John Baldwin
2022-01-11 11:38:11 -08:00
parent a91a57846b
commit 21baf42c57
2 changed files with 29 additions and 15 deletions
+4
View File
@@ -33,6 +33,9 @@
# delete-old-dirs - Delete obsolete directories. # delete-old-dirs - Delete obsolete directories.
# delete-old-files - Delete obsolete files. # delete-old-files - Delete obsolete files.
# delete-old-libs - Delete obsolete libraries. # delete-old-libs - Delete obsolete libraries.
# list-old-dirs - Raw list of possibly obsolete directories.
# list-old-files - Raw list of possibly obsolete files.
# list-old-libs - Raw list of possibly obsolete libraries.
# targets - Print a list of supported TARGET/TARGET_ARCH pairs # targets - Print a list of supported TARGET/TARGET_ARCH pairs
# for world and kernel targets. # for world and kernel targets.
# toolchains - Build a toolchain for all world and kernel targets. # toolchains - Build a toolchain for all world and kernel targets.
@@ -154,6 +157,7 @@ TGTS= all all-man buildenv buildenvvars buildkernel buildworld \
installkernel.debug packagekernel packageworld \ installkernel.debug packagekernel packageworld \
reinstallkernel reinstallkernel.debug \ reinstallkernel reinstallkernel.debug \
installworld kernel-toolchain libraries maninstall \ installworld kernel-toolchain libraries maninstall \
list-old-dirs list-old-files list-old-libs \
obj objlink showconfig tags toolchain \ obj objlink showconfig tags toolchain \
makeman sysent \ makeman sysent \
_worldtmp _legacy _bootstrap-tools _cleanobj _obj \ _worldtmp _legacy _bootstrap-tools _cleanobj _obj \
+25 -15
View File
@@ -3193,7 +3193,8 @@ SUBDIR_PARALLEL=
.if make(check-old) || make(check-old-dirs) || \ .if make(check-old) || make(check-old-dirs) || \
make(check-old-files) || make(check-old-libs) || \ make(check-old-files) || make(check-old-libs) || \
make(delete-old) || make(delete-old-dirs) || \ make(delete-old) || make(delete-old-dirs) || \
make(delete-old-files) || make(delete-old-libs) make(delete-old-files) || make(delete-old-libs) || \
make(list-old-dirs) || make(list-old-files) || make(list-old-libs)
# #
# check for / delete old files section # check for / delete old files section
@@ -3212,6 +3213,11 @@ RM_I=-i
RM_I=-v RM_I=-v
.endif .endif
list-old-files: .PHONY
@cd ${.CURDIR}; \
${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
-V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | sort
delete-old-files: .PHONY delete-old-files: .PHONY
@echo ">>> Removing old files (only deletes safe to delete libs)" @echo ">>> Removing old files (only deletes safe to delete libs)"
# Ask for every old file if the user really wants to remove it. # Ask for every old file if the user really wants to remove it.
@@ -3221,8 +3227,7 @@ delete-old-files: .PHONY
# the Makefile parser segfault. # the Makefile parser segfault.
@exec 3<&0; \ @exec 3<&0; \
cd ${.CURDIR}; \ cd ${.CURDIR}; \
${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-files | \
-V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | sort | \
while read file; do \ while read file; do \
if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \ chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
@@ -3251,8 +3256,7 @@ delete-old-files: .PHONY
check-old-files: .PHONY check-old-files: .PHONY
@echo ">>> Checking for old files" @echo ">>> Checking for old files"
@cd ${.CURDIR}; \ @cd ${.CURDIR}; \
${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-files | \
-V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
while read file; do \ while read file; do \
if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
echo "${DESTDIR}/$${file}"; \ echo "${DESTDIR}/$${file}"; \
@@ -3262,7 +3266,7 @@ check-old-files: .PHONY
echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \ echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
fi; \ fi; \
done; \ done; \
done | sort done
# Check for catpages without corresponding manpages. # Check for catpages without corresponding manpages.
@find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \ @find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \
sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \ sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
@@ -3273,13 +3277,17 @@ check-old-files: .PHONY
fi; \ fi; \
done | sort done | sort
list-old-libs: .PHONY
@cd ${.CURDIR}; \
${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
-V OLD_LIBS | xargs -n1 | sort
delete-old-libs: .PHONY delete-old-libs: .PHONY
@echo ">>> Removing old libraries" @echo ">>> Removing old libraries"
@echo "${OLD_LIBS_MESSAGE}" | fmt @echo "${OLD_LIBS_MESSAGE}" | fmt
@exec 3<&0; \ @exec 3<&0; \
cd ${.CURDIR}; \ cd ${.CURDIR}; \
${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-libs | \
-V OLD_LIBS | xargs -n1 | sort | \
while read file; do \ while read file; do \
if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \ chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
@@ -3298,8 +3306,7 @@ delete-old-libs: .PHONY
check-old-libs: .PHONY check-old-libs: .PHONY
@echo ">>> Checking for old libraries" @echo ">>> Checking for old libraries"
@cd ${.CURDIR}; \ @cd ${.CURDIR}; \
${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-libs | \
-V OLD_LIBS | xargs -n1 | \
while read file; do \ while read file; do \
if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
echo "${DESTDIR}/$${file}"; \ echo "${DESTDIR}/$${file}"; \
@@ -3309,13 +3316,17 @@ check-old-libs: .PHONY
echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \ echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
fi; \ fi; \
done; \ done; \
done | sort done
list-old-dirs: .PHONY
@cd ${.CURDIR}; \
${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
-V OLD_DIRS | xargs -n1 | sort -r
delete-old-dirs: .PHONY delete-old-dirs: .PHONY
@echo ">>> Removing old directories" @echo ">>> Removing old directories"
@cd ${.CURDIR}; \ @cd ${.CURDIR}; \
${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-dirs | \
-V OLD_DIRS | xargs -n1 | sort -r | \
while read dir; do \ while read dir; do \
if [ -d "${DESTDIR}/$${dir}" ]; then \ if [ -d "${DESTDIR}/$${dir}" ]; then \
rmdir -v "${DESTDIR}/$${dir}" || true; \ rmdir -v "${DESTDIR}/$${dir}" || true; \
@@ -3333,8 +3344,7 @@ delete-old-dirs: .PHONY
check-old-dirs: .PHONY check-old-dirs: .PHONY
@echo ">>> Checking for old directories" @echo ">>> Checking for old directories"
@cd ${.CURDIR}; \ @cd ${.CURDIR}; \
${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-dirs | \
-V OLD_DIRS | xargs -n1 | sort -r | \
while read dir; do \ while read dir; do \
if [ -d "${DESTDIR}/$${dir}" ]; then \ if [ -d "${DESTDIR}/$${dir}" ]; then \
echo "${DESTDIR}/$${dir}"; \ echo "${DESTDIR}/$${dir}"; \