aboutsummaryrefslogtreecommitdiff
path: root/checkpkg
diff options
context:
space:
mode:
Diffstat (limited to 'checkpkg')
-rwxr-xr-xcheckpkg44
1 files changed, 44 insertions, 0 deletions
diff --git a/checkpkg b/checkpkg
new file mode 100755
index 0000000..b596e72
--- /dev/null
+++ b/checkpkg
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+# check one or more package lists from /var/log/packages to see if the
+# files listed there actually exist on the filesystem.
+# ROOT variable is respected, same as installpkg.
+# .new config files are checked for without their .new ending.
+# known issue: any file whose name has a colon in it, won't be checked.
+
+# exit status of this script will be 0 for OK, non-zero if one or
+# more file was missing.
+exitstatus=0
+
+# package filenames are ASCII, this will speed things up slightly.
+LANG="C"
+LC_ALL="C"
+export LANG LC_ALL
+
+check_pkg() {
+ if [ ! -e "$1" ]; then
+ echo "$0: $1 not found" 1>&2
+ exitstatus=1
+ return
+ fi
+
+ grep -v -e ":" -e "^install" "$1" | sed 's,\.new$,,' > "$tmpfile"
+
+ ( while read line; do
+ [ -e "$ROOT"/"$line" ] || ( exitstatus=1 && echo "$1: missing $line" )
+ done ) < "$tmpfile"
+}
+
+if [ -z "$*" -o "$1" = "--help" ]; then
+ cat <<EOF
+Usage: $0 [ package-list-file(s) ]
+EOF
+ exit 0
+fi
+
+for pkg in "$@"; do
+ tmpfile="$( mktemp -t checkpkg.XXXXXX )"
+ check_pkg "$pkg"
+ rm -f "$tmpfile"
+done
+exit $exitstatus