xref: /netbsd-src/distrib/sets/checkflist (revision a93ea220fcb3e34cdfdcd4d7a5d391e0b2b4f2ba)
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
7if [ -z "$DESTDIR" ]; then
8	echo "DESTDIR must be set"
9	exit 1
10fi
11
12prog=${0##*/}
13
14origin=.
15tmpname=/tmp/_CHECK.$$
16
17xargs=""
18dargs=""
19diffargs=""
20metalog=
21
22# handle args
23while : ; 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
43Usage: ${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
49USAGE
50		exit 1
51		;;
52	*)
53		break
54		;;
55	esac
56	shift
57done
58
59if [ -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
69fi
70
71
72sh 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 -
88rv=$?
89
90/bin/rm -f $tmpname
91
92if [ $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
101fi
102exit $rv
103