# check for incorrect hash file content
-# remove orphaned elf info
+# removes old packages
+zpm shell local.db.rehash "select package||'-'||version||'-'||release from package_age where age > 2 and status = 'updated'"|xargs -n1 zpm rmpackage -S installed -f local.db.rehash
+
+select
+EL.file, PF.path,
+PF.package || '-' || PF.version || '-' || PF.release as pkgid
+from elfneeded EL
+left join files F on F.hash = EL.file
+left join packagefiles PF on PF.hash = EL.file
+where F.hash is null
+and EL.file is not null
+and PF.path is not null
+;
+
# remove failed packages
for pkg in $(zpm list -s failed); do