Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/freebsd/poudriere.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/share
diff options
context:
space:
mode:
authorBryan Drewery <bryan@shatow.net>2022-06-06 18:59:29 +0300
committerBryan Drewery <bryan@shatow.net>2022-06-06 20:27:45 +0300
commit230a0f53bed10fa2ac0b2a137c2baeb8bef9ec71 (patch)
tree6995e751a60fc45f0a5afd4973062d0863d492a5 /src/share
parentf6dc65591f2d7a8573551e5b203268907cc0ac96 (diff)
pkgclean: Add -C to allow deleting only specific packages.
Also add some clarifications in the manpage and output about how listed packages will be interpreted for deletion. The -C mode will only delete specified packages - it will not touch their dependencies even if they are orphaned. A second run without -C is needed to remove orphaned dependencies. This is because -C is intended for adhoc deletions where the package is still *wanted* but needs to be rebuilt. Fixes #310
Diffstat (limited to 'src/share')
-rwxr-xr-xsrc/share/poudriere/pkgclean.sh24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/share/poudriere/pkgclean.sh b/src/share/poudriere/pkgclean.sh
index d283527a..282effd1 100755
--- a/src/share/poudriere/pkgclean.sh
+++ b/src/share/poudriere/pkgclean.sh
@@ -37,6 +37,7 @@ Parameters:
[ports...] -- List of ports to keep on the command line
Options:
+ -C -- Delete packages listed on command line rather than keep
-j jail -- Which jail to use for packages
-J n -- Run n jobs in parallel (Defaults to the number of
CPUs times 1.25)
@@ -60,10 +61,11 @@ DRY_RUN=0
DO_ALL=0
BUILD_REPO=1
OVERLAYS=""
+CLEAN_LISTED=0
[ $# -eq 0 ] && usage
-while getopts "Aaj:J:f:nNO:p:Rvyz:" FLAG; do
+while getopts "AaCj:J:f:nNO:p:Rvyz:" FLAG; do
case "${FLAG}" in
A)
DO_ALL=1
@@ -71,6 +73,9 @@ while getopts "Aaj:J:f:nNO:p:Rvyz:" FLAG; do
a)
ALL=1
;;
+ C)
+ CLEAN_LISTED=1
+ ;;
j)
jail_exists ${OPTARG} || err 1 "No such jail: ${OPTARG}"
JAILNAME=${OPTARG}
@@ -127,6 +132,10 @@ post_getopts
[ -z "${JAILNAME}" ] && \
err 1 "Don't know on which jail to run please specify -j"
+if [ "${CLEAN_LISTED}" -eq 1 -a -n "${LISTPKGS}" ]; then
+ err ${EX_USAGE} "-C and -f should not be used together"
+fi
+
MASTERNAME=${JAILNAME}-${PTNAME}${SETNAME:+-${SETNAME}}
_mastermnt MASTERMNT
@@ -158,6 +167,11 @@ PKG_EXT='*' package_dir_exists_and_has_packages ||
maybe_run_queued "${saved_argv}"
msg "Gathering all expected packages"
+if [ "${CLEAN_LISTED}" -eq 0 ]; then
+ msg_warn "Will delete anything not listed. To delete listed use -C."
+else
+ msg_warn "Will delete anything listed. To keep listed do not use -C."
+fi
jail_start "${JAILNAME}" "${PTNAME}" "${SETNAME}"
prepare_ports
msg "Looking for unneeded packages"
@@ -188,7 +202,13 @@ for file in ${PACKAGES}/All/*; do
forbidden; then
msg_verbose "Found forbidden package (${forbidden}): ${file}"
echo "${file}" >> ${BADFILES_LIST}
- elif ! pkgbase_is_needed "${pkgname}"; then
+ elif [ "${CLEAN_LISTED}" -eq 0 ] &&
+ ! pkgbase_is_needed "${pkgname}"; then
+ msg_verbose "Found unwanted package: ${file}"
+ echo "${file}" >> ${BADFILES_LIST}
+ elif [ "${CLEAN_LISTED}" -eq 1 ] &&
+ pkgbase_is_needed "${pkgname}" &&
+ pkgname_is_listed "${pkgname}"; then
msg_verbose "Found unwanted package: ${file}"
echo "${file}" >> ${BADFILES_LIST}
else