xref: /netbsd/distrib/sets/checkflist (revision c4a72b64)
1#! /bin/sh --
2#
3#	$NetBSD: checkflist,v 1.17 2002/09/16 23:04:39 thorpej 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=./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		test "$metalog" = "$line" || echo $line
80	done
81) | sort | diff $diffargs $tmpname -
82rv=$?
83
84/bin/rm -f $tmpname
85
86if [ $rv -ne 0 ]; then
87	echo "${prog}: flist inconsistencies found"
88	if [ -z "$diffargs" ]; then
89		echo "${prog}: key to output:"
90		echo "  <  file is in flist but missing from DESTDIR"
91		echo "     (file wasn't installed ?)"
92		echo "  >  file is in DESTDIR but missing from flist"
93		echo "     (file is obsolete or flist is out of date ?)"
94	fi
95fi
96exit $rv
97