From c3238e690a1f3254d282623e047f0124206de9b9 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 10 Jun 2020 19:42:04 -0400 Subject: cleanup, wip for eventual release --- checkpkg | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 checkpkg (limited to 'checkpkg') 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 <