checkflist revision 1.24
1#! /bin/sh --
2#
3#	$NetBSD: checkflist,v 1.24 2003/12/29 03:13:25 lukem 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: ${HOST_SH=sh}
15: ${MKTEMP=mktemp}
16SDIR=$(${MKTEMP} -d /tmp/${prog}.XXXXXX)
17
18es=0
19cleanup()
20{
21	/bin/rm -rf $SDIR
22	if [ $es -gt 255 ] ; then
23		es=255
24	fi
25	exit $es
26}
27trap cleanup 0 2 3 13		# EXIT INT QUIT PIPE
28
29
30origin=.
31xargs=""
32dargs=""
33metalog=
34allowextra=false
35allowmissing=false
36
37# handle args
38while 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
58Usage: ${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
64USAGE
65		exit 1
66		;;
67	esac
68done
69shift $((${OPTIND} - 1))
70
71if [ -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
81fi
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
101comm -23 $SDIR/flist $SDIR/files > $SDIR/missing
102comm -13 $SDIR/flist $SDIR/files > $SDIR/extra
103
104if [ -s $SDIR/extra ]; then
105	echo ""
106	echo "============  extra files  ==============="
107	echo "Files in DESTDIR but missing from flist."
108	echo "File is obsolete or flist is out of date ?"
109	if ${allowextra}; then
110		echo "This is non-fatal."
111	else
112		es=1
113	fi
114	echo "------------------------------------------"
115	cat $SDIR/extra
116	echo "=========  end of extra files  ==========="
117	echo ""
118fi
119
120if [ -s $SDIR/missing ]; then
121	echo ""
122	echo "===========  missing files  =============="
123	echo "Files in flist but missing from DESTDIR."
124	echo "File wasn't installed ?"
125	if ${allowmissing}; then
126		echo "This is non-fatal."
127	else
128		es=1
129	fi
130	echo "------------------------------------------"
131	cat $SDIR/missing
132	echo "========  end of missing files  =========="
133	echo ""
134fi
135
136exit 0		# cleanup will exit with $es
137