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 7 if [ -z "$DESTDIR" ]; then 8 echo "DESTDIR must be set" 9 exit 1 10 fi 11 12 prog=${0##*/} 13 14 : ${HOST_SH=sh} 15 : ${MKTEMP=mktemp} 16 SDIR=$(${MKTEMP} -d /tmp/${prog}.XXXXXX) 17 18 es=0 19 cleanup() 20 { 21 /bin/rm -rf $SDIR 22 if [ $es -gt 255 ] ; then 23 es=255 24 fi 25 exit $es 26 } 27 trap cleanup 0 2 3 13 # EXIT INT QUIT PIPE 28 29 30 origin=. 31 xargs="" 32 dargs="" 33 metalog= 34 allowextra=false 35 allowmissing=false 36 37 # handle args 38 while 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 58 Usage: ${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 64 USAGE 65 exit 1 66 ;; 67 esac 68 done 69 shift $((${OPTIND} - 1)) 70 71 if [ -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 81 fi 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 101 comm -23 $SDIR/flist $SDIR/files > $SDIR/missing 102 comm -13 $SDIR/flist $SDIR/files > $SDIR/extra 103 104 if [ -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 "" 119 fi 120 121 if [ -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 "" 136 fi 137 138 exit 0 # cleanup will exit with $es 139