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