Home | History | Annotate | Line # | Download | only in sets
checkflist revision 1.19
      1 #! /bin/sh --
      2 #
      3 #	$NetBSD: checkflist,v 1.19 2003/07/10 03:19:15 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 origin=.
     15 tmpname=/tmp/_CHECK.$$
     16 
     17 xargs=""
     18 dargs=""
     19 diffargs=""
     20 metalog=
     21 
     22 # handle args
     23 while : ; do
     24 	case $1 in
     25 	-x11)
     26 		xargs="-x"
     27 		origin="./etc/X11 ./etc/fonts ./usr/X11R6"
     28 		;;
     29 	-both)
     30 		xargs="-b"
     31 		;;
     32 	-u)
     33 		diffargs="-u"
     34 		;;
     35 	-c)
     36 		diffargs="-c"
     37 		;;
     38 	-M*)
     39 		metalog=$2; shift
     40 		;;
     41 	-*)
     42 		cat 1>&2 <<USAGE
     43 Usage: ${prog} [-x11|-both] [-u|-c] [-M metalog]
     44 	-x11		check only x11 lists
     45 	-both		check netbsd + x11 lists
     46 	-u		output differences in "unified diff" style
     47 	-c		output differences in "context diff" style
     48 	-M metalog	metalog file
     49 USAGE
     50 		exit 1
     51 		;;
     52 	*)
     53 		break
     54 		;;
     55 	esac
     56 	shift
     57 done
     58 
     59 if [ -n "$metalog" ]; then
     60 	case "$metalog" in
     61 	${DESTDIR}/*)
     62 		# Metalog would be noticed, so make sure it gets
     63 		# ignored.
     64 		metalog="./${metalog#${DESTDIR}/}"
     65 		;;
     66 	*)
     67 		metalog=""
     68 	esac
     69 fi
     70 
     71 
     72 sh makeflist $xargs $dargs > $tmpname
     73 
     74 (
     75 	cd $DESTDIR
     76 	find $origin \( -type d -o -type f -o -type l \)
     77 ) | (
     78 	while read line; do
     79 		case "$line" in
     80 		$metalog)
     81 			;;
     82 		*)
     83 			echo $line
     84 			;;
     85 		esac
     86 	done
     87 ) | sort | diff $diffargs $tmpname -
     88 rv=$?
     89 
     90 /bin/rm -f $tmpname
     91 
     92 if [ $rv -ne 0 ]; then
     93 	echo "${prog}: flist inconsistencies found"
     94 	if [ -z "$diffargs" ]; then
     95 		echo "${prog}: key to output:"
     96 		echo "  <  file is in flist but missing from DESTDIR"
     97 		echo "     (file wasn't installed ?)"
     98 		echo "  >  file is in DESTDIR but missing from flist"
     99 		echo "     (file is obsolete or flist is out of date ?)"
    100 	fi
    101 fi
    102 exit $rv
    103