renamed pacman-repairs to pacman-doctor + added pacman-reinstall-all
[mirrors/Programs.git] / bash / pacman-doctor / pacman-orphans.sh
diff --git a/bash/pacman-doctor/pacman-orphans.sh b/bash/pacman-doctor/pacman-orphans.sh
new file mode 100755 (executable)
index 0000000..a506697
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/bash
+db="$(mktemp)"
+fs="$(mktemp)"
+orphans="$(mktemp)"
+
+echo "[*] Saving list of files owned by pacman to $db ..." >&2
+time /usr/bin/pacman -Qlq | sort -u > "$db"
+echo >&2
+echo "[*] Saving list of files in filesystem to $fs ..." >&2
+time find /arch /bin /boot /etc /lib /opt /sbin /usr 2>/dev/null | while read i; do
+       if [ ! -d "$i" ]; then
+               echo "$i"
+       fi;
+done | sort -u > "$fs"
+echo >&2
+echo "[*] Comparing db ( $db ) and fs ( $fs ) ..." >&2
+time comm -23 "$fs" "$db" | tee "$orphans"
+rm -- "$db" "$fs"
+echo >&2
+echo "[!] List of files not owned by any package were saved to: $orphans" >&2
+
+#test it:
+#cat "$orphans" | while read i; do pacman -Qo "$i" 2>&1; done | tee /tmp/orphantest.txt
This page took 0.549693 seconds and 4 git commands to generate.