Home | History | Annotate | Line # | Download | only in sets
checkflist revision 1.29
      1   1.3    mikel #! /bin/sh --
      2   1.3    mikel #
      3  1.29      apb #	$NetBSD: checkflist,v 1.29 2006/01/03 18:31:09 apb Exp $
      4   1.3    mikel #
      5  1.29      apb # Verify output of makeflist against contents of ${DESTDIR}.
      6   1.1      cgd 
      7  1.29      apb if [ -z "${DESTDIR}" ]; then
      8  1.15    lukem 	echo "DESTDIR must be set"
      9   1.1      cgd 	exit 1
     10  1.15    lukem fi
     11  1.15    lukem 
     12  1.29      apb prog="${0##*/}"
     13  1.27      apb rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
     14  1.27      apb . "${rundir}/sets.subr"
     15   1.1      cgd 
     16  1.29      apb SDIR="$(${MKTEMP} -d "/tmp/${prog}.XXXXXX")"
     17  1.20    lukem 
     18  1.20    lukem es=0
     19  1.20    lukem cleanup()
     20  1.20    lukem {
     21  1.29      apb 	/bin/rm -rf "${SDIR}"
     22  1.29      apb 	if [ ${es} -gt 255 ] ; then
     23  1.20    lukem 		es=255
     24  1.20    lukem 	fi
     25  1.29      apb 	exit ${es}
     26  1.20    lukem }
     27  1.20    lukem trap cleanup 0 2 3 13		# EXIT INT QUIT PIPE
     28  1.20    lukem 
     29  1.20    lukem 
     30   1.9     ross origin=.
     31  1.10    perry xargs=""
     32  1.10    perry dargs=""
     33  1.15    lukem metalog=
     34  1.22    lukem allowextra=false
     35  1.22    lukem allowmissing=false
     36  1.10    perry 
     37  1.10    perry # handle args
     38  1.24    lukem while getopts xbM:em ch; do
     39  1.24    lukem 	case ${ch} in
     40  1.24    lukem 	x)
     41  1.10    perry 		xargs="-x"
     42  1.18     tron 		origin="./etc/X11 ./etc/fonts ./usr/X11R6"
     43  1.10    perry 		;;
     44  1.24    lukem 	b)
     45  1.10    perry 		xargs="-b"
     46  1.10    perry 		;;
     47  1.24    lukem 	M)
     48  1.29      apb 		metalog="${OPTARG}"
     49  1.15    lukem 		;;
     50  1.24    lukem 	e)
     51  1.22    lukem 		allowextra=true
     52  1.22    lukem 		;;
     53  1.24    lukem 	m)
     54  1.22    lukem 		allowmissing=true
     55  1.22    lukem 		;;
     56  1.24    lukem 	*)
     57  1.10    perry 		cat 1>&2 <<USAGE
     58  1.24    lukem Usage: ${prog} [-x|-b] [-M metalog] [-e] [-m]
     59  1.24    lukem 	-x		check only x11 lists
     60  1.24    lukem 	-b		check netbsd + x11 lists
     61  1.15    lukem 	-M metalog	metalog file
     62  1.22    lukem 	-e		extra files are not considered an error
     63  1.22    lukem 	-m		missing files are not considered an error
     64  1.10    perry USAGE
     65  1.10    perry 		exit 1
     66  1.10    perry 		;;
     67  1.10    perry 	esac
     68  1.10    perry done
     69  1.24    lukem shift $((${OPTIND} - 1))
     70  1.10    perry 
     71  1.29      apb if [ -n "${metalog}" ]; then
     72  1.29      apb 	case "${metalog}" in
     73  1.29      apb 	"${DESTDIR}"/*)
     74  1.17  thorpej 		# Metalog would be noticed, so make sure it gets
     75  1.17  thorpej 		# ignored.
     76  1.29      apb 		metalog="./${metalog#"${DESTDIR}"/}"
     77  1.15    lukem 		;;
     78  1.17  thorpej 	*)
     79  1.17  thorpej 		metalog=""
     80  1.15    lukem 	esac
     81  1.15    lukem fi
     82  1.15    lukem 
     83  1.15    lukem 
     84  1.29      apb ${HOST_SH} ./makeflist ${xargs} ${dargs} > "${SDIR}/flist"
     85  1.10    perry 
     86  1.15    lukem (
     87  1.29      apb 	cd "${DESTDIR}"
     88  1.29      apb 	${FIND} ${origin} \( -type d -o -type f -o -type l \) -print
     89  1.17  thorpej ) | (
     90  1.17  thorpej 	while read line; do
     91  1.29      apb 		case "${line}" in
     92  1.29      apb 		"${metalog}")
     93  1.19    lukem 			;;
     94  1.19    lukem 		*)
     95  1.29      apb 			echo "${line}"
     96  1.19    lukem 			;;
     97  1.19    lukem 		esac
     98  1.17  thorpej 	done
     99  1.29      apb ) | ${SORT} > "${SDIR}/files"
    100  1.15    lukem 
    101  1.29      apb ${COMM} -23 "${SDIR}/flist}" "${SDIR}/files}" > "${SDIR}/missing}"
    102  1.29      apb ${COMM} -13 "${SDIR}/flist}" "${SDIR}/files}" > "${SDIR}/extra}"
    103  1.15    lukem 
    104  1.29      apb if [ -s "${SDIR}/extra" ]; then
    105  1.29      apb 	count="$(${AWK} 'END {print NR}' "${SDIR}/extra")"
    106  1.20    lukem 	echo ""
    107  1.25    lukem 	echo "============  ${count} extra files  ==============="
    108  1.20    lukem 	echo "Files in DESTDIR but missing from flist."
    109  1.20    lukem 	echo "File is obsolete or flist is out of date ?"
    110  1.22    lukem 	if ${allowextra}; then
    111  1.22    lukem 		echo "This is non-fatal."
    112  1.22    lukem 	else
    113  1.22    lukem 		es=1
    114  1.22    lukem 	fi
    115  1.20    lukem 	echo "------------------------------------------"
    116  1.29      apb 	cat "${SDIR}/extra"
    117  1.25    lukem 	echo "=========  end of ${count} extra files  ==========="
    118  1.20    lukem 	echo ""
    119  1.20    lukem fi
    120  1.20    lukem 
    121  1.29      apb if [ -s "${SDIR}/missing" ]; then
    122  1.29      apb 	count="$(${AWK} 'END {print NR}' "${SDIR}/missing")"
    123  1.20    lukem 	echo ""
    124  1.25    lukem 	echo "===========  ${count} missing files  =============="
    125  1.20    lukem 	echo "Files in flist but missing from DESTDIR."
    126  1.20    lukem 	echo "File wasn't installed ?"
    127  1.22    lukem 	if ${allowmissing}; then
    128  1.22    lukem 		echo "This is non-fatal."
    129  1.22    lukem 	else
    130  1.22    lukem 		es=1
    131  1.22    lukem 	fi
    132  1.20    lukem 	echo "------------------------------------------"
    133  1.29      apb 	cat "${SDIR}/missing"
    134  1.25    lukem 	echo "========  end of ${count} missing files  =========="
    135  1.20    lukem 	echo ""
    136  1.15    lukem fi
    137  1.20    lukem 
    138  1.29      apb exit 0		# cleanup will exit with ${es}
    139