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