diff options
author | B. Watson <yalhcru@gmail.com> | 2020-06-10 19:42:04 -0400 |
---|---|---|
committer | B. Watson <yalhcru@gmail.com> | 2020-06-10 19:42:04 -0400 |
commit | c3238e690a1f3254d282623e047f0124206de9b9 (patch) | |
tree | aad4069d37a258d2d641fef67abd7a3317fde111 /checkpkg | |
parent | fdab64c728d172419b3cc3f8a566a3fd134ab366 (diff) | |
download | sbostuff-c3238e690a1f3254d282623e047f0124206de9b9.tar.gz |
cleanup, wip for eventual release
Diffstat (limited to 'checkpkg')
-rwxr-xr-x | checkpkg | 44 |
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 |