pkgfoster: small refactoring
This commit is contained in:
parent
15a8fcc3f3
commit
56a8fc12d4
@ -29,6 +29,6 @@ affected ports using
|
||||
.B prt\-get update \-fr
|
||||
(see \fBprt\-get\fP(8) for more detailed examples).
|
||||
.SH AUTHORS
|
||||
Jukka Heino <jukka@karsikkopuu.net>
|
||||
Jukka Heino <jukka@karsikkopuu.net>, John McQuah <jmcquah@disroot.org>
|
||||
.SH SEE ALSO
|
||||
\fBprt\-cache\fP(8), \fBprt\-get\fP(8), \fBPkgfile\fP(5), \fBrevdep\fP(1)
|
||||
|
@ -12,6 +12,7 @@
|
||||
#
|
||||
|
||||
PRT_GET=prt-cache
|
||||
RECHECK=1
|
||||
|
||||
if [ $UID = 0 ]; then
|
||||
PKGRM=pkgrm
|
||||
@ -32,35 +33,29 @@ if [ ! -f "$CONF" ]; then
|
||||
touch "$CONF"
|
||||
fi
|
||||
|
||||
echo "Checking packages for orphans..."
|
||||
|
||||
while true ; do
|
||||
while [ $RECHECK = 1 ] ; do
|
||||
echo
|
||||
echo "(Re-)checking packages for orphans..."
|
||||
RECHECK=0
|
||||
|
||||
orphans=$(comm -23 <($PRT_GET listorphans | sort) \
|
||||
mapfile -t orphans < <(comm -23 <($PRT_GET listorphans | sort) \
|
||||
<(cat <(find "$BASE" -maxdepth 1 -type d -printf "%f\n") "$CONF" \
|
||||
| sort -u) | tr '\n' ' ')
|
||||
| sort -u) )
|
||||
|
||||
for PACKAGE in ${orphans[@]}; do
|
||||
echo
|
||||
$PRT_GET info $PACKAGE
|
||||
$PRT_GET info "$PACKAGE"
|
||||
echo
|
||||
|
||||
echo -n "Uninstall $PACKAGE? (y/N) "
|
||||
read ANSWER
|
||||
read -r ANSWER
|
||||
|
||||
if [ "$ANSWER" = "y" ] ; then
|
||||
$PKGRM $PACKAGE
|
||||
$PKGRM "$PACKAGE"
|
||||
RECHECK=1
|
||||
else
|
||||
echo $PACKAGE >> "$CONF"
|
||||
echo "$PACKAGE" >> "$CONF"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$RECHECK" = "0" ] ; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Re-checking packages for new orphans..."
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user