5 # Verify output of makeflist against contents of ${DESTDIR} and ${metalog}.
7 if [ -z "${DESTDIR}" ]; then
8 echo "DESTDIR must be set"
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"
39 if [ ${es} -gt 255 ]; then
44 trap cleanup
0 2 3 13 # EXIT INT QUIT PIPE
54 while getopts xybL
:M
:em ch
; do
58 origin
="./etc/X11 ./etc/fonts ./usr/X11R6"
62 origin
="./etc/ext ./usr/ext"
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
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.*
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]*\$"
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.
125 # All three lists are filtered against ${IGNORE_REGEXP}.
130 ( cd "${DESTDIR}" && ${FIND} ${origin} \
131 \( -type d -o -type f -o -type l \) -print ) \
132 | ${SORT} -u | ignore_exceptions >"${SETS_DLIST}"
137 ${HOST_SH} "${rundir}/makeflist" ${xargs} ${dargs} \
138 | ${SORT} -u | ignore_exceptions >"${SETS_FLIST}"
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()
172 [ -f "${DESTDIR}/${f}" ] || \
173 [ -d "${DESTDIR}/${f}" ] || \
174 [ -L "${DESTDIR}/${f}" ] || \
180 # compare DESTDIR with METALOG, and report on differences.
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
"
190 check_metalog_missing
193 check_metalog_extra()
195 if [ -s "${SETS_METALOG_EXTRA}" ]; then
196 count="$
(${AWK} 'END {print NR}' "${SETS_METALOG_EXTRA}")"
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
==========="
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}")"
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
=========="
221 es=1 # this is fatal even if ${allowmissing} is true
226 # compare flist with DESTDIR, and report on differences.
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
"
236 check_destdir_missing
239 check_destdir_extra()
241 if [ -s "${SETS_DESTDIR_EXTRA}" ]; then
242 count="$
(${AWK} 'END {print NR}' "${SETS_DESTDIR_EXTRA}")"
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.
"
252 echo "------------------------------------------"
253 cat "${SETS_DESTDIR_EXTRA}"
254 echo "========= end of
${count} extra files
==========="
259 check_destdir_missing()
261 if [ -s "${SETS_DESTDIR_MISSING}" ]; then
262 count="$
(${AWK} 'END {print NR}' "${SETS_DESTDIR_MISSING}")"
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."
272 echo "------------------------------------------"
273 cat "${SETS_DESTDIR_MISSING}"
274 echo "======== end of ${count} missing files =========="
283 generate_mlist_missing
286 generate_dlist_missing
289 if false && [ -n "${metalog}" ]; then
290 # XXX: Temporarily disabled due to problems with obsolete files in metalog
296 exit 0 # cleanup will exit with ${es}