From 322f808abebc2aa439d5012ce3037cc2cd1f94ef Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Mon, 6 Jun 2022 09:26:52 -0700 Subject: pkgclean -C: Need to delete by origin not pkgname. This handles deleting older packages that the port no longer produces. Issue #310 --- src/share/poudriere/common.sh | 20 ++++++++++++++++++++ src/share/poudriere/pkgclean.sh | 28 ++++++++++++++++------------ 2 files changed, 36 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/share/poudriere/common.sh b/src/share/poudriere/common.sh index 892d3acd..d39f4207 100755 --- a/src/share/poudriere/common.sh +++ b/src/share/poudriere/common.sh @@ -7692,6 +7692,26 @@ originspec_is_needed_and_not_ignored() { }' "${MASTER_DATADIR}/all_pkgs" } +# Port was listed to be built +originspec_is_listed() { + [ $# -eq 1 ] || eargs originspec_is_listed originspec + local originspec="$1" + + if [ "${ALL}" -eq 1 ]; then + return 0 + fi + + awk -voriginspec="${originspec}" ' + $3 == "listed" && $2 == originspec { + found=1 + exit 0 + } + END { + if (found != 1) + exit 1 + }' "${MASTER_DATADIR}/all_pkgs" +} + get_porttesting() { [ $# -eq 1 ] || eargs get_porttesting pkgname local pkgname="$1" diff --git a/src/share/poudriere/pkgclean.sh b/src/share/poudriere/pkgclean.sh index 5cf25382..22ef6377 100755 --- a/src/share/poudriere/pkgclean.sh +++ b/src/share/poudriere/pkgclean.sh @@ -201,22 +201,26 @@ for file in ${PACKAGES}/All/*; do if ! pkg_get_origin origin "${file}"; then msg_verbose "Found corrupt package: ${file}" echo "${file}" >> ${BADFILES_LIST} - elif shash_remove pkgname-forbidden "${pkgname}" \ - forbidden; then - msg_verbose "Found forbidden package (${forbidden}): ${file}" - echo "${file}" >> ${BADFILES_LIST} - elif [ "${CLEAN_LISTED}" -eq 0 ] && - ! pkgbase_is_needed "${pkgname}"; then - msg_verbose "Found unwanted package: ${file}" - echo "${file}" >> ${BADFILES_LIST} + continue + fi + if [ "${CLEAN_LISTED}" -eq 0 ]; then + if shash_remove pkgname-forbidden "${pkgname}" \ + forbidden; then + msg_verbose "Found forbidden package (${forbidden}): ${file}" + echo "${file}" >> ${BADFILES_LIST} + continue + elif ! pkgbase_is_needed "${pkgname}"; then + msg_verbose "Found unwanted package: ${file}" + echo "${file}" >> ${BADFILES_LIST} + continue + fi elif [ "${CLEAN_LISTED}" -eq 1 ] && - pkgbase_is_needed "${pkgname}" && - pkgname_is_listed "${pkgname}"; then + originspec_is_listed "${origin}"; then msg_verbose "Found unwanted package: ${file}" echo "${file}" >> ${BADFILES_LIST} - else - echo "${file} ${origin}" >> ${FOUND_ORIGINS} + continue fi + echo "${file} ${origin}" >> ${FOUND_ORIGINS} ;; *.txz) if [ -L "${file}" ]; then -- cgit v1.2.3