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
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
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')
-rw-r--r--src/man/poudriere-pkgclean.818
-rwxr-xr-xsrc/share/poudriere/pkgclean.sh24
2 files changed, 39 insertions, 3 deletions
diff --git a/src/man/poudriere-pkgclean.8 b/src/man/poudriere-pkgclean.8
index b6a14c6a..658e1c8e 100644
--- a/src/man/poudriere-pkgclean.8
+++ b/src/man/poudriere-pkgclean.8
@@ -28,7 +28,7 @@
.\"
.\" Note: The date here should be updated whenever a non-trivial
.\" change is made to the manual page.
-.Dd July 28, 2021
+.Dd June 6, 2022
.Dt POUDRIERE-PKGCLEAN 8
.Os
.Sh NAME
@@ -44,6 +44,18 @@
.Op Ar origin2 Op Ar ...
.Sh DESCRIPTION
This command is used to delete all packages not specified to build.
+By default packages
+.Em not listed
+will be deleted;
+Listed packages, and their dependencies, will be kept.
+.Pp
+If
+.Fl C
+is specified then packages listed on the command line will be deleted
+rather than kept.
+Their orphaned dependencies will not be deleted.
+A second run with a full list of wanted packages is needed to
+cleanup orphaned dependencies.
.Pp
Either a subcommand or a list of port origins must be supplied.
.Sh SUBCOMMANDS
@@ -63,6 +75,10 @@ arguments may be specified at once.
.El
.Sh OPTIONS
.Bl -tag -width "-f conffile"
+.It Fl C
+Delete the listed packages rather than keep them.
+This can be used to delete specific packages that need to be rebuilt
+while keeping them in the port list file.
.It Fl J Ar number
This argument specifies how many
.Ar number
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