From 56a8fc12d4101caa0900bf18ba2ab385e3d5dc51 Mon Sep 17 00:00:00 2001 From: John McQuah Date: Wed, 29 Nov 2023 01:07:03 +0000 Subject: [PATCH] pkgfoster: small refactoring --- man1/pkgfoster.1 | 2 +- scripts/pkgfoster | 25 ++++++++++--------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/man1/pkgfoster.1 b/man1/pkgfoster.1 index 0ee3e5e..3cb62ef 100644 --- a/man1/pkgfoster.1 +++ b/man1/pkgfoster.1 @@ -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 Heino , John McQuah .SH SEE ALSO \fBprt\-cache\fP(8), \fBprt\-get\fP(8), \fBPkgfile\fP(5), \fBrevdep\fP(1) diff --git a/scripts/pkgfoster b/scripts/pkgfoster index 69e4777..9b5726f 100755 --- a/scripts/pkgfoster +++ b/scripts/pkgfoster @@ -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