checkflist revision 1.23
1#! /bin/sh --
2#
3#	$NetBSD: checkflist,v 1.23 2003/10/26 14:21:49 dmcmahill 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: ${MKTEMP=mktemp}
15SDIR=$(${MKTEMP} -d /tmp/${prog}.XXXXXX)
16
17es=0
18cleanup()
19{
20	/bin/rm -rf $SDIR
21	if [ $es -gt 255 ] ; then
22		es=255
23	fi
24	exit $es
25}
26trap cleanup 0 2 3 13		# EXIT INT QUIT PIPE
27
28
29origin=.
30xargs=""
31dargs=""
32metalog=
33allowextra=false
34allowmissing=false
35
36# handle args
37while : ; 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
57Usage: ${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
63USAGE
64		exit 1
65		;;
66	*)
67		break
68		;;
69	esac
70	shift
71done
72
73if [ -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
83fi
84
85
86sh makeflist $xargs $dargs > $SDIR/flist
87
88(
89	cd $DESTDIR
90	find $origin \( -type d -o -type f -o -type l \) -print
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
103comm -23 $SDIR/flist $SDIR/files > $SDIR/missing
104comm -13 $SDIR/flist $SDIR/files > $SDIR/extra
105
106if [ -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 ""
120fi
121
122if [ -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 ""
136fi
137
138exit 0		# cleanup will exit with $es
139