~sircmpwn/sr.ht-pkgbuilds

f8a4975f602e316291c56ade84384da96ee6a434 — Eli Schwartz 2 months ago 0e47cd5
Add a dry-run mode to the cleanup script
1 files changed, 8 insertions(+), 1 deletions(-)

M cleanup-old-packages
M cleanup-old-packages => cleanup-old-packages +8 -1
@@ 7,6 7,13 @@

set -e

case $1 in
    -d|--dry-run)
        shift
        rm_dryrun=echo
        ;;
esac

cd "$1"

persistent_statefile='./staging-cleanup'


@@ 19,7 26,7 @@ done | sort -u > "$workdir"/needed

if [ -f "$persistent_statefile" ]; then
    comm -23 "$persistent_statefile" "$workdir"/needed | while read -r line; do
        rm -f "$line" "$line.sig"
        $rm_dryrun rm -f "$line" "$line.sig"
    done
    rm "$persistent_statefile"
fi