checkflist revision 1.25
1#! /bin/sh -- 2# 3# $NetBSD: checkflist,v 1.25 2004/01/08 01:31:57 lukem Exp $ 4# 5# Verify output of makeflist against contents of $DESTDIR. 6 7if [ -z "$DESTDIR" ]; then 8 echo "DESTDIR must be set" 9 exit 1 10fi 11 12prog=${0##*/} 13 14: ${HOST_SH=sh} 15: ${MKTEMP=mktemp} 16SDIR=$(${MKTEMP} -d /tmp/${prog}.XXXXXX) 17 18es=0 19cleanup() 20{ 21 /bin/rm -rf $SDIR 22 if [ $es -gt 255 ] ; then 23 es=255 24 fi 25 exit $es 26} 27trap cleanup 0 2 3 13 # EXIT INT QUIT PIPE 28 29 30origin=. 31xargs="" 32dargs="" 33metalog= 34allowextra=false 35allowmissing=false 36 37# handle args 38while getopts xbM:em ch; do 39 case ${ch} in 40 x) 41 xargs="-x" 42 origin="./etc/X11 ./etc/fonts ./usr/X11R6" 43 ;; 44 b) 45 xargs="-b" 46 ;; 47 M) 48 metalog=${OPTARG} 49 ;; 50 e) 51 allowextra=true 52 ;; 53 m) 54 allowmissing=true 55 ;; 56 *) 57 cat 1>&2 <<USAGE 58Usage: ${prog} [-x|-b] [-M metalog] [-e] [-m] 59 -x check only x11 lists 60 -b check netbsd + x11 lists 61 -M metalog metalog file 62 -e extra files are not considered an error 63 -m missing files are not considered an error 64USAGE 65 exit 1 66 ;; 67 esac 68done 69shift $((${OPTIND} - 1)) 70 71if [ -n "$metalog" ]; then 72 case "$metalog" in 73 ${DESTDIR}/*) 74 # Metalog would be noticed, so make sure it gets 75 # ignored. 76 metalog="./${metalog#${DESTDIR}/}" 77 ;; 78 *) 79 metalog="" 80 esac 81fi 82 83 84${HOST_SH} ./makeflist $xargs $dargs > $SDIR/flist 85 86( 87 cd $DESTDIR 88 find $origin \( -type d -o -type f -o -type l \) -print 89) | ( 90 while read line; do 91 case "$line" in 92 $metalog) 93 ;; 94 *) 95 echo $line 96 ;; 97 esac 98 done 99) | sort > $SDIR/files 100 101comm -23 $SDIR/flist $SDIR/files > $SDIR/missing 102comm -13 $SDIR/flist $SDIR/files > $SDIR/extra 103 104if [ -s $SDIR/extra ]; then 105 count=$(awk 'END {print NR}' $SDIR/extra) 106 echo "" 107 echo "============ ${count} extra files ===============" 108 echo "Files in DESTDIR but missing from flist." 109 echo "File is obsolete or flist is out of date ?" 110 if ${allowextra}; then 111 echo "This is non-fatal." 112 else 113 es=1 114 fi 115 echo "------------------------------------------" 116 cat $SDIR/extra 117 echo "========= end of ${count} extra files ===========" 118 echo "" 119fi 120 121if [ -s $SDIR/missing ]; then 122 count=$(awk 'END {print NR}' $SDIR/missing) 123 echo "" 124 echo "=========== ${count} missing files ==============" 125 echo "Files in flist but missing from DESTDIR." 126 echo "File wasn't installed ?" 127 if ${allowmissing}; then 128 echo "This is non-fatal." 129 else 130 es=1 131 fi 132 echo "------------------------------------------" 133 cat $SDIR/missing 134 echo "======== end of ${count} missing files ==========" 135 echo "" 136fi 137 138exit 0 # cleanup will exit with $es 139