]> pd.if.org Git - zpackage/blobdiff - zpm-gc
add makefile as shell dependency
[zpackage] / zpm-gc
diff --git a/zpm-gc b/zpm-gc
index f07cdaffd969d6c6bf4188cd672a123bf7e55be2..bc84e342c4b83171eb8e33531403659832406589 100755 (executable)
--- a/zpm-gc
+++ b/zpm-gc
@@ -3,6 +3,27 @@
 # garbage collect a package database
 # flags to skip phases
 
+# -C clear all phases
+# -n dry run
+# -a all phases
+# default is failed packages, orphaned elf, vacuum
+# 
+# phases
+# -cC remove command history by date
+# -dD remove dry run
+# -eE remove orphaned elf
+# -fF remove failed
+# -hH fix file content hash
+# -hH remove install history by date
+# -lL remove old logs, given by date
+# -nN remove acked notes
+# -oO remove outdated packages, unless preserved
+# -pP remove history for removed packages
+# -rR remove orphaned rows in files table packagefiles, notes, scripts, ...
+# -hH remove all file content that is not scripts or configs
+# -rR remove removed packages, unless preserved
+# -vV compactify the database file
+
 db=${1:-${ZPMDB:-/var/lib/zpm/local.db}}
 
 if [ -z "$db" ]; then
@@ -38,6 +59,8 @@ done
 # remove orphaned rows in files table
 # references in packagefiles, notes, scripts, possibly others
 
+zpm shell $ZPMDB 'delete from files where hash in (select hash from filerefs where refcount = 0);'
+
 # remove old logs, given by date
 
 # remove acked notes
@@ -49,4 +72,10 @@ done
 # remove command history by date
 
 # compactify the database file
+osize=$(zpm stat -f '%s' $ZPMDB)
+zpm log -v -i -a 'gc compacting' -t $ZPMDB
+zpm shell $ZPMDB vacuum
+nsize=$(zpm stat -f '%s' $ZPMDB)
 
+printf 'original size %s\n' $osize
+printf 'new size %s\n' $nsize