Expand PMF_FN_* macros.
[netbsd-mini2440.git] / distrib / sets / checkflist
blobdfec74d482ea4cf56520679ae3986661d8567974
1 #! /bin/sh --
3 # $NetBSD$
5 # Verify output of makeflist against contents of ${DESTDIR} and ${metalog}.
7 if [ -z "${DESTDIR}" ]; then
8 echo "DESTDIR must be set"
9 exit 1
12 prog="${0##*/}"
13 rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
14 . "${rundir}/sets.subr"
17 # * ${SETS_DLIST}: files present in DESTDIR.
18 # * ${SETS_FLIST}: files mentioned in flist;
19 # * ${SETS_MLIST}: files mentioned in metalog;
21 SETS_DLIST="${DESTDIR}/SETS.dlist"
22 SETS_FLIST="${DESTDIR}/SETS.flist"
23 SETS_MLIST="${DESTDIR}/SETS.mlist"
26 # * ${SETS_METALOG_EXTRA}: Files in METALOG but missing from DESTDIR."
27 # * ${SETS_METALOG_MISSING}: Files in DESTDIR but missing from METALOG."
28 # * ${SETS_DESTDIR_EXTRA}: Files in DESTDIR but missing from setlist."
29 # * ${SETS_DESTDIR_MISSING}: Files in setlist but missing from DESTDIR."
31 SETS_METALOG_EXTRA="${DESTDIR}/SETS.metalog.extra"
32 SETS_METALOG_MISSING="${DESTDIR}/SETS.metalog.missing"
33 SETS_DESTDIR_EXTRA="${DESTDIR}/SETS.destdir.extra"
34 SETS_DESTDIR_MISSING="${DESTDIR}/SETS.destdir.missing"
36 es=0
37 cleanup()
39 if [ ${es} -gt 255 ]; then
40 es=255
42 exit ${es}
44 trap cleanup 0 2 3 13 # EXIT INT QUIT PIPE
46 origin=.
47 xargs=""
48 dargs=""
49 metalog=
50 allowextra=false
51 allowmissing=false
53 # handle args
54 while getopts xybL:M:em ch; do
55 case ${ch} in
57 xargs="-x"
58 origin="./etc/X11 ./etc/fonts ./usr/X11R6"
61 xargs="-y"
62 origin="./etc/ext ./usr/ext"
64 # backward compat
66 xargs="-b"
69 xargs="-L ${OPTARG}"
72 metalog="${OPTARG}"
75 allowextra=true
78 allowmissing=true
81 cat 1>&2 <<USAGE
82 Usage: ${prog} [-x|-y|-b|-L lists] [-M metalog] [-e] [-m]
83 -x check only x11 lists
84 -y check only extsrc lists
85 -b check netbsd + x11 lists
86 -L base,x,ext check specified lists
87 -M metalog metalog file
88 -e extra files are not considered an error
89 -m missing files are not considered an error
90 USAGE
91 exit 1
93 esac
94 done
95 shift $((${OPTIND} - 1))
98 # Exceptions to flist checking (all begin with "./"):
100 # * ignore var/db/syspkg and its contents
101 # * ignore METALOG and METALOG.*
102 # * ignore etc/mtree/set.*
104 ignore_exceptions()
106 IGNORE_REGEXP_SYSPKG="^\./var/db/syspkg(\$|/)"
107 IGNORE_REGEXP_METALOG="^\./METALOG(\..*)?\$"
108 IGNORE_REGEXP_SETS="^\./SETS\..*\$"
109 IGNORE_REGEXP_MTREE="^\./etc/mtree/set\.[a-z]*\$"
111 ${EGREP} -v \
112 -e "${IGNORE_REGEXP_SYSPKG}" \
113 -e "${IGNORE_REGEXP_METALOG}" \
114 -e "${IGNORE_REGEXP_SETS}" \
115 -e "${IGNORE_REGEXP_MTREE}"
119 # Here would be a good place to add custom exceptions to flist checking.
123 # Make three lists:
125 # All three lists are filtered against ${IGNORE_REGEXP}.
128 generate_dlist()
130 ( cd "${DESTDIR}" && ${FIND} ${origin} \
131 \( -type d -o -type f -o -type l \) -print ) \
132 | ${SORT} -u | ignore_exceptions >"${SETS_DLIST}"
135 generate_flist()
137 ${HOST_SH} "${rundir}/makeflist" ${xargs} ${dargs} \
138 | ${SORT} -u | ignore_exceptions >"${SETS_FLIST}"
141 generate_mlist()
143 if [ -n "${metalog}" ]; then
144 ${AWK} '{print $1}' <"${metalog}" \
145 | ${SORT} -u | ignore_exceptions >"${SETS_MLIST}"
149 generate_mlist_missing()
151 ${COMM} -23 "${SETS_DLIST}" "${SETS_MLIST}" > "${SETS_METALOG_MISSING}"
154 generate_mlist_extra()
156 ${COMM} -13 "${SETS_DLIST}" "${SETS_MLIST}" > "${SETS_METALOG_EXTRA}"
159 generate_dlist_missing()
161 ${COMM} -23 "${SETS_FLIST}" "${SETS_DLIST}" > "${SETS_DESTDIR_MISSING}"
164 generate_dlist_extra()
166 ${COMM} -13 "${SETS_FLIST}" "${SETS_DLIST}" > "${SETS_DESTDIR_EXTRA}"
169 exist_case_insensitive()
171 while read f; do
172 [ -f "${DESTDIR}/${f}" ] || \
173 [ -d "${DESTDIR}/${f}" ] || \
174 [ -L "${DESTDIR}/${f}" ] || \
175 echo "$f"
176 done
180 # compare DESTDIR with METALOG, and report on differences.
182 compare_metalog()
184 # Handle case insensitive filesystems
185 mv -f "${SETS_METALOG_EXTRA}" "${SETS_METALOG_EXTRA}.all"
186 exist_case_insensitive < "${SETS_METALOG_EXTRA}.all" > "${SETS_METALOG_EXTRA}"
187 rm -f "${SETS_METALOG_EXTRA}.all"
189 check_metalog_extra
190 check_metalog_missing
193 check_metalog_extra()
195 if [ -s "${SETS_METALOG_EXTRA}" ]; then
196 count="$(${AWK} 'END {print NR}' "${SETS_METALOG_EXTRA}")"
197 echo ""
198 echo "======= ${count} extra files in METALOG ========="
199 echo "Files in METALOG but missing from DESTDIR."
200 echo "File was deleted after installation ?"
201 echo "------------------------------------------"
202 cat "${SETS_METALOG_EXTRA}"
203 echo "========= end of ${count} extra files ==========="
204 echo ""
205 es=1 # this is fatal even if ${allowextra} is true
209 check_metalog_missing()
211 if [ -s "${SETS_METALOG_MISSING}" ]; then
212 count="$(${AWK} 'END {print NR}' "${SETS_METALOG_MISSING}")"
213 echo ""
214 echo "====== ${count} missing files in METALOG ========"
215 echo "Files in DESTDIR but missing from METALOG."
216 echo "File installed but not registered in METALOG ?"
217 echo "------------------------------------------"
218 cat "${SETS_METALOG_MISSING}"
219 echo "======== end of ${count} missing files =========="
220 echo ""
221 es=1 # this is fatal even if ${allowmissing} is true
226 # compare flist with DESTDIR, and report on differences.
228 compare_destdir()
230 # Handle case insensitive filesystems
231 mv -f "${SETS_DESTDIR_MISSING}" "${SETS_DESTDIR_MISSING}.all"
232 exist_case_insensitive < "${SETS_DESTDIR_MISSING}.all" > "${SETS_DESTDIR_MISSING}"
233 rm -f "${SETS_DESTDIR_MISSING}.all"
235 check_destdir_extra
236 check_destdir_missing
239 check_destdir_extra()
241 if [ -s "${SETS_DESTDIR_EXTRA}" ]; then
242 count="$(${AWK} 'END {print NR}' "${SETS_DESTDIR_EXTRA}")"
243 echo ""
244 echo "======= ${count} extra files in DESTDIR ========="
245 echo "Files in DESTDIR but missing from flist."
246 echo "File is obsolete or flist is out of date ?"
247 if ${allowextra}; then
248 echo "This is non-fatal, due to '-e' option."
249 else
250 es=1
252 echo "------------------------------------------"
253 cat "${SETS_DESTDIR_EXTRA}"
254 echo "========= end of ${count} extra files ==========="
255 echo ""
259 check_destdir_missing()
261 if [ -s "${SETS_DESTDIR_MISSING}" ]; then
262 count="$(${AWK} 'END {print NR}' "${SETS_DESTDIR_MISSING}")"
263 echo ""
264 echo "====== ${count} missing files in DESTDIR ========"
265 echo "Files in flist but missing from DESTDIR."
266 echo "File wasn't installed ?"
267 if ${allowmissing}; then
268 echo "This is non-fatal, due to '-m' option."
269 else
270 es=1
272 echo "------------------------------------------"
273 cat "${SETS_DESTDIR_MISSING}"
274 echo "======== end of ${count} missing files =========="
275 echo ""
279 generate_dlist
280 generate_flist
281 generate_mlist
283 generate_mlist_missing
284 generate_mlist_extra
286 generate_dlist_missing
287 generate_dlist_extra
289 if false && [ -n "${metalog}" ]; then
290 # XXX: Temporarily disabled due to problems with obsolete files in metalog
291 compare_metalog
292 else
293 compare_destdir
296 exit 0 # cleanup will exit with ${es}