From: Nathan Wagner Date: Sat, 15 Dec 2018 16:27:57 +0000 (+0000) Subject: use getopts in gc X-Git-Tag: v0.5.0~38 X-Git-Url: https://pd.if.org/git/?a=commitdiff_plain;ds=sidebyside;h=7c9e7e8d37a7d513a6815ddb2192c1dbdfb6570e;p=zpackage use getopts in gc --- diff --git a/zpm-gc b/zpm-gc index 06807ef..08ba1e1 100755 --- a/zpm-gc +++ b/zpm-gc @@ -42,7 +42,13 @@ remove_removed_packages=0 # -vV compactify the database file vacuum=1 -db=${1:-${ZPMDB:-/var/lib/zpm/local.db}} +db=${ZPMDB:-/var/lib/zpm/local.db} + +while getopts 'f:'; do + case $opt in + f) db="$OPTARG" ;; + esac +done if [ -z "$db" ]; then echo must specify database file @@ -58,19 +64,19 @@ export ZPMDB # remove failed packages for pkg in $(zpm list -s failed); do - zpm log -i -a 'gc removing' -t "$pkg" - zpm rmpackage "$pkg" + zpm rmpackage -m 'gc removed failed' "$pkg" done for pkg in $(zpm list -s dryrun); do - zpm log -i -a 'gc removing' -t "$pkg" - zpm rmpackage "$pkg" + zpm rmpackage -m 'gc removed dryrun' "$pkg" done # remove incomplete packages # TODO use temporary gc delete log trigger? if [ $remove_incomplete_packages -ne 0 ]; then - zpm shell $ZPMDB "delete from packages where hash is null" + for pkg in $(zpm list -F 'hash is null'); do + zpm rmpackage -m 'gc removed incomplete' $pkg + done fi # remove old version packages, unless preserved