pkgfoster: initial commit

This commit is contained in:
John McQuah 2022-05-28 12:49:20 -04:00
parent 4a0ed983ed
commit aedef1fb39
3 changed files with 349 additions and 0 deletions

man1/pkgfoster.1 Normal file
View File

@ -0,0 +1,33 @@
." Text automatically generated by txt2man-1.4.7
.TH pkgfoster 1 "April 23, 2006" "" ""
\fBpkgfoster \fP- clean orphaned packages
.fam C
.fam T
\fBpkgfoster\fP is a simple interactive script you can use to clean up orphaned packages (i.e.,
packages not listed in the "Depends on: " line of any other installed package). It uses
prt-cache by default, so remember to build the cache with "prt-get cache". You can also
use normal prt-get by modifying the PRT_GET variable. The bash array FOSTERED
is read from and written to ~/.config/pkgfoster.conf, as a means of preserving your choices
regarding which packages to keep. If you run \fBpkgfoster\fP as a non-root user, make sure the user
is able to elevate permissions using sudo, doas, or 'su -c'.
Packages from the core collection are never considered for deletion, since some of them
might provide runtime dependencies yet not be listed in the "Depends on: " line. See
\fBPkgfile\fP(5) for an explanation of this practice.
Some packages flagged by \fBpkgfoster\fP might actually be optional (soft) dependencies of other
packages on your system. Use \fBrevdep\fP(1) to identify any breakage that you introduce by
removing these misidentified orphans, and rebuild the affected ports using
.B prt\-get update \-fr
(see \fBprt\-get\fP(8) for more detailed examples).
Jukka Heino <>
\fBprt\-cache\fP(8), \fBprt\-get\fP(8), \fBrevdep\fP(1)

scripts/CHANGES Normal file
View File

@ -0,0 +1,248 @@
1.2 -> 1.2.1
- prtsweep, prtwash: rewritten in perl
- prtcheck: test that all sources are signed
- pkgfoster: save the list of adoptees in ~/.config rather than cluttering $HOME;
recognize opendoas as a possible privilege escalation utility
All patches by John McQuah
1.1.4 -> 1.2
- dllist: enable the download listing tool to recognize already-downloaded sources
- portspage: augment portspage with the ability to find and print the signify public key
- prtsweep: enable the cleanup tool to recognize sources that have been renamed
- prtwash: enable the cleanup tool to recognize sources that have been renamed
All patches by John McQuah
1.1.3 -> 1.1.4
- oldfiles: use .signature instead of .mdsum to find the required sources
- prtwash: replace .md5sum with .signature
1.1.2 -> 1.1.3
- prtsweep: add .signature to KEEP_FILES
- prtsweep: remove .md5sum from KEEP_FILES
- prtsweep: only sweep directories, ignore regular files
- prtcreate: add feature to define the maintainer in /etc/prtcreate.conf
Patch by Tim Biermann
1.1.1 -> 1.1.2
- prtverify: whitelist update
- revdep: add ARM AArch64 support
Patch by Matt Housh
- pkgexport: use -T to support file paths with spaces
Patch by Thomas Penteker
- finddeps: add lib32 to the library path
Patch by Danny Rawlins
1.1 -> 1.1.1
- prtverify: only allow /usr/share/man for man-page location
- prtverify: check for .signature instead of .md5sum files
- prtverify: whitelist update
- revdep: use pkg-config to find required libraries
Patch by Danny Rawlins
- revdep: replace deprecated readdir_r with readdir
Patch by James Buren
1.0.2 -> 1.1
- revdep: new version 2.0 by James Buren
- Rewrite in C++
- much improved speed
- new config directory /etc/revdep.d to add non-standard library
locations, see man-page for details
Again many thanks for the contribution
- prtrej, prtcheck, pkgexport: fix shebang line, we are a bash script
Patch by Tilman Sauerbeck
1.0.1 -> 1.0.2
- pkgsize: is a bash and not a sh script
Reported via IRC by onodera
- pkgsize: select port dirs from httpup and rsync files in /etc/ports
Reported via IRC by rmull
- pkgsize: style cleanup, allow spaces in filenames
- Makefile: install man-pages into /usr/share/man
- prtverify: as of CRUX 3.2 we changed the location of man-pages
from /usr/man to /usr/share/man. Allow both directories for now
1.0 -> 1.0.1
+ revdep: add support for ARM
Patch by James Buren
0.9.8 -> 1.0
+ new revdep written in C by James Buren, ryuo @ freenode
+ much faster than the old bash version
+ gained a new option -i to ignore ports
Many thanks for the contribution
0.9.7 -> 0.9.8
- findredundantdeps: fix for dependencies that are listed more than
once in the Pkgfile. Reported by Danny Rawlins.
+ prtverify: add /usr/share/info to invalid_dirs
+ prtverify: whitelist update
- prtverify: prtverify is a bash script, so call it so
+ prtverify: new test to see if we have the same dependency more
than once in the Pkgfile
0.9.6 -> 0.9.7
- revdep: fix false errors for libraries in non-standard locations.
Patch by Matt Housh
- prtwash: default compression mode should be .gz not .xz.
Reported by Maximilian Dietrich
0.9.5 -> 0.9.6
- finddeps: use realpath to sanitize filepaths like /usr/lib/../lib
or /usr/lib64
0.9.4 -> 0.9.5
- prtsweep: add .32bit to the files to keep
- prtwash: add .32bit to the files to keep
+ pkgexport: use mktemp to create temporary file
+ pkgexport: remove temporary file more reliable
- pkgexport: fix test for $PKGMK_COMPRESSION_MODE
- finddeps: prepend /lib to LD_LIBRARY_PATH
0.9.3 -> 0.9.4
+ prtverify: allow use of group users
+ prtverify: whitelist update
- prtverify: set explicit LC_ALL to "C"
- prtverify: error world-writable directories only if sticky bit is
not set. Patch by Markus Schnalke
- finddeps: make exclusion of caller name more explicit
- oldfiles, pkgexport, prtreverse, prtwash: use the compression mode
defined in pkgmk.conf. Patches by Jose V Beneyto
- prtsweep: packages might be either gz or xz compressed.
Patch by Jose V Beneyto
0.9.2 -> 0.9.3
+ finddeps: optimize awk usage a bit, some minor adjustments
+ revdep: optimize awk usage a bit, make error output more consistent
+ revdep: allow unprivileged user to run revdep, patch by Lucas Hazel
+ prtwash: allow multiple port-directories as commandline parameters
- prtwash: add .nostrip to tosave array, some smaller fixes
- prtsweep: fix automatic mode to use rsync and httpup files
- prtsweep: keep pre-install files
+ prtsweep: remove non-working -p option
- prtorphan: fix parsing of /etc/prt-get.conf for port directories,
<path>:<port>,<port> definitions are handled correctly now
0.9.1 -> 0.9.2
- Bugfix: fix regexp for finding rm/cd commands in prtverify
- prtverify: WHITELIST is now a array of files, so it's possible
to add additional lists or even a special directory.
Default is /usr/lib/prtverify/*.wl
- prtverify: whitelist update
- prtverify: new test to detect non-ASCII characters
- pkgfoster: dynamically build core port list
- pkgfoster: add Jonas patch for better sudo usage
- portspage: fix XHTML incompatibility (thanks romster and pitillo)
0.9.0 -> 0.9.1
- Bugfix: complete list of core ports for pkgfoster
- prtverify: new test for permission-collisions with directories
provided by core/filesystem, suggested by Mark Rosenstand
- prtverify: compatibility improvements, patch by Han Boetes
- prtverify: new rule to find localized man-pages
- pkgsize: forced -k option, call /usr/bin/du to avoid aliasing
- Added prt-utils man page
0.8.0 -> 0.9.0
- Added prtverify by Juergen Daubert
0.7.1 -> 0.8.0
- Added revdep by Johannes Winkelmann
- Added portspage by Jukka Heino
- Added pkgfoster by Jukka Heino
- oldfiles: merged with pkgclean by Mark Rosenstand;
added custom keep list /etc/oldfiles.conf
0.7.0 -> 0.7.1
- Removed warnings from oldfiles
0.6.5 -> 0.7.0
- added findredundantdeps script
- added pkg_installed script
0.6.4 -> 0.6.5
- fixed config parser bug in prtorphan (trailing space
and / or comment in the middle of the line)
0.6.3 -> 0.6.4
- fixed bug in prtwash config parser. Thanks to Jason Pacheco
for the patch
- prtwash: fixed spelling
0.6.2 -> 0.6.3
- added "oldfiles" by Simone Rota (simone)
- added "finddeps" by Johannes Winkelmann (simone)
- added "dllist" by Johannes Winkelmann (simone)
0.6.1 -> 0.6.2
- prtreverse replaced by pkgexport by Andrew Green (simone)
0.6.0 -> 0.6.1
- prtrej now checks if /var/lib/pkg/rejected exists (simone)
0.5.1 -> 0.6
- prtalien: new script, which does the same as "prtorphan -d"
- prtsweep doesn't remove .nostrip file (opel)
- prtorphan reads /etc/prt-get.conf instead of /etc/prt-wash.conf.
prtwash.conf was removed though. (opel)
- prtrej now calls "diff -u"
- scripts that need to cycle through the port tree now read
port directories from /etc/prt-get.conf.
- prtcheckmissing is a new script, which scans the package db
/var/lib/pkg/db and looks in your filesystem, if the files really exist.
The most port is based on A. Pagaltzis' program published on the mailing
0.5 -> 0.5.1
- prtorphan has a new option "-d directory" and scans the directory for
orphaned files.
0.4.1 -> 0.5
- new script prtorphan: script to list all orphaned packages. An orpaned
package is a package, for which no port exists in /usr/ports/base,
/usr/ports/opt, ...
0.4 -> 0.4.1
- pkgsize bugfixes
0.3.x -> 0.4
- pkgsize by Damir Saric <> was added.
0.2.5 -> 0.3.0
- prtreverse by Simone Rota was added.
0.2.4 -> 0.2.5
- prtwash.conf was adopted to the new clc scheme: contrib/unmaintained

scripts/pkgfoster Executable file
View File

@ -0,0 +1,68 @@
# pkgfoster 2005-11-27
# Jukka Heino <>
# pkgfoster is a simple script you can use to clean up orphaned packages (i.e.
# packages which no other package depends on). It uses prt-cache by default, so
# remember to build the cache with "prt-get cache". You can also use normal
# prt-get by modifying the PRT_GET variable. An array of packages to keep
# is stored in the FOSTERED variable. Packages from core are never considered
# for deletion.
if [ $UID = 0 ]; then
if command -v doas; then
PKGRM="doas pkgrm"
elif command -v sudo; then
PKGRM="sudo pkgrm"
PKGRM="su -c pkgrm"
BASE=$(awk '/^[[:space:]]*prtdir.*\/core/ {print $2}' /etc/prt-get.conf)
[ -f $CONF ] && . $CONF || mkdir -p ${XDG_CONFIG_HOME}
echo "Checking packages for orphans..."
while true ; do
orphans=$(comm -13 <(cat <(find "$BASE" -maxdepth 1 -type d -printf "%f\n") \
<(for (( k=0; k<${#FOSTERED[@]}; k++ )); do echo "${FOSTERED[$k]}"; done) \
| sort -u) <($PRT_GET listorphans | sort) | tr '\n' ' ')
for PACKAGE in ${orphans[@]}; do
echo -n "Uninstall $PACKAGE? (y/N) "
if [ "$ANSWER" = "y" ] ; then
if [ "$RECHECK" = "0" ] ; then
echo -n "FOSTERED=(" > $CONF
for (( k=0; k<${#FOSTERED[@]}; k++ )); do
echo -n "${FOSTERED[$k]} " >> $CONF
echo ")" >> $CONF
exit 0
echo "Re-checking packages for new orphans..."