pkgfoster: save the list of adopted packages in a tidy format
This commit is contained in:
parent
150c874481
commit
0485af9be2
|
@ -10,24 +10,25 @@
|
||||||
.fam T
|
.fam T
|
||||||
.fi
|
.fi
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
\fBpkgfoster\fP is a simple interactive script you can use to clean up orphaned packages (i.e.,
|
\fBpkgfoster\fP is a simple interactive script you can use to clean up orphaned
|
||||||
packages not listed in the "Depends on: " line of any other installed package). It uses
|
packages (i.e., packages not listed in the "Depends on: " line of any other installed
|
||||||
prt-cache by default, so remember to build the cache with "prt-get cache". You can also
|
package). It uses prt-cache by default, so remember to build the cache with "prt-get
|
||||||
use normal prt-get by modifying the PRT_GET variable. The bash array FOSTERED
|
cache". You can also use normal prt-get by modifying the PRT_GET variable. The file
|
||||||
is read from and written to ~/.config/pkgfoster.conf, as a means of preserving your choices
|
~/.config/pkgfoster.keep is used to preserve your decisions regarding which packages
|
||||||
regarding which packages to keep. If you run \fBpkgfoster\fP as a non-root user, make sure the user
|
to keep. If you run \fBpkgfoster\fP as a non-root user, make sure the user is able to
|
||||||
is able to elevate permissions using sudo, doas, or 'su -c'.
|
elevate permissions using sudo, doas, or 'su -c'.
|
||||||
.PP
|
.PP
|
||||||
Packages from the core collection are never considered for deletion, since some of them
|
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
|
might provide runtime dependencies yet not be listed in the "Depends on: " line. See
|
||||||
\fBPkgfile\fP(5) for an explanation of this practice.
|
\fBPkgfile\fP(5) for an explanation of this practice.
|
||||||
.PP
|
.PP
|
||||||
Some packages flagged by \fBpkgfoster\fP might actually be optional (soft) dependencies of other
|
Some packages flagged by \fBpkgfoster\fP might actually be optional (soft)
|
||||||
packages on your system. Use \fBrevdep\fP(1) to identify any breakage that you introduce by
|
dependencies of other packages on your system. Use \fBrevdep\fP(1) to identify any
|
||||||
removing these misidentified orphans, and rebuild the affected ports using
|
breakage that you introduce by removing these misidentified orphans, and rebuild the
|
||||||
|
affected ports using
|
||||||
.B prt\-get update \-fr
|
.B prt\-get update \-fr
|
||||||
(see \fBprt\-get\fP(8) for more detailed examples).
|
(see \fBprt\-get\fP(8) for more detailed examples).
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
Jukka Heino <jukka@karsikkopuu.net>
|
Jukka Heino <jukka@karsikkopuu.net>
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
\fBprt\-cache\fP(8), \fBprt\-get\fP(8), \fBrevdep\fP(1)
|
\fBprt\-cache\fP(8), \fBprt\-get\fP(8), \fBPkgfile\fP(5), \fBrevdep\fP(1)
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
# Jukka Heino <jukka@karsikkopuu.net>
|
# Jukka Heino <jukka@karsikkopuu.net>
|
||||||
#
|
#
|
||||||
# pkgfoster is a simple script you can use to clean up orphaned packages (i.e.
|
# 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
|
# packages which do not appear in the "Depends on: " line of any other installed
|
||||||
# remember to build the cache with "prt-get cache". You can also use normal
|
# package). It uses prt-cache by default, so remember to build the cache with
|
||||||
# prt-get by modifying the PRT_GET variable. An array of packages to keep
|
# "prt-get cache". You can also use normal prt-get by modifying the PRT_GET
|
||||||
# is stored in the FOSTERED variable. Packages from core are never considered
|
# variable. The file ~/.config/pkgfoster.keep contains a list of all packages
|
||||||
# for deletion.
|
# you've decided to keep. Packages from core are never considered for deletion.
|
||||||
#
|
#
|
||||||
|
|
||||||
PRT_GET=prt-cache
|
PRT_GET=prt-cache
|
||||||
|
@ -26,17 +26,20 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
BASE=$(awk '/^[[:space:]]*prtdir.*\/core/ {print $2}' /etc/prt-get.conf)
|
BASE=$(awk '/^[[:space:]]*prtdir.*\/core/ {print $2}' /etc/prt-get.conf)
|
||||||
CONF=${XDG_CONFIG_HOME:="$HOME/.config"}/pkgfoster.conf
|
CONF="${XDG_CONFIG_HOME:="$HOME/.config"}/pkgfoster.keep"
|
||||||
[ -f $CONF ] && . $CONF || mkdir -p ${XDG_CONFIG_HOME}
|
if [ ! -f "$CONF" ]; then
|
||||||
|
mkdir -p "${XDG_CONFIG_HOME}"
|
||||||
|
touch "$CONF"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Checking packages for orphans..."
|
echo "Checking packages for orphans..."
|
||||||
|
|
||||||
while true ; do
|
while true ; do
|
||||||
RECHECK=0
|
RECHECK=0
|
||||||
|
|
||||||
orphans=$(comm -13 <(cat <(find "$BASE" -maxdepth 1 -type d -printf "%f\n") \
|
orphans=$(comm -23 <($PRT_GET listorphans | sort) \
|
||||||
<(for (( k=0; k<${#FOSTERED[@]}; k++ )); do echo "${FOSTERED[$k]}"; done) \
|
<(cat <(find "$BASE" -maxdepth 1 -type d -printf "%f\n") "$CONF" \
|
||||||
| sort -u) <($PRT_GET listorphans | sort) | tr '\n' ' ')
|
| sort -u) | tr '\n' ' ')
|
||||||
|
|
||||||
for PACKAGE in ${orphans[@]}; do
|
for PACKAGE in ${orphans[@]}; do
|
||||||
echo
|
echo
|
||||||
|
@ -50,16 +53,11 @@ while true ; do
|
||||||
$PKGRM $PACKAGE
|
$PKGRM $PACKAGE
|
||||||
RECHECK=1
|
RECHECK=1
|
||||||
else
|
else
|
||||||
FOSTERED=( $PACKAGE ${FOSTERED[@]} )
|
echo $PACKAGE >> "$CONF"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$RECHECK" = "0" ] ; then
|
if [ "$RECHECK" = "0" ] ; then
|
||||||
echo -n "FOSTERED=(" > $CONF
|
|
||||||
for (( k=0; k<${#FOSTERED[@]}; k++ )); do
|
|
||||||
echo -n "${FOSTERED[$k]} " >> $CONF
|
|
||||||
done
|
|
||||||
echo ")" >> $CONF
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue