| @@ -1,57 +1,63 @@ | | | @@ -1,57 +1,63 @@ |
1 | # $NetBSD: check-files.mk,v 1.45 2024/01/21 00:34:26 rillig Exp $ | | 1 | # $NetBSD: check-files.mk,v 1.46 2024/01/21 02:12:20 rillig Exp $ |
2 | # | | 2 | # |
3 | # This file checks that the list of installed files matches the PLIST. | | 3 | # This file checks that the list of installed files matches the PLIST. |
4 | # For that purpose it records the file list of LOCALBASE before and | | 4 | # For that purpose it records the file list of LOCALBASE before and |
5 | # after the installation of the package and compares these lists with | | 5 | # after the installation of the package and compares these lists with |
6 | # the PLIST. | | 6 | # the PLIST. |
7 | # | | 7 | # |
8 | # User-settable variables: | | 8 | # User-settable variables: |
9 | # | | 9 | # |
10 | # CHECK_FILES | | 10 | # CHECK_FILES |
11 | # "yes" to enable the check, "no" to disable it. | | 11 | # "yes" to enable the check, "no" to disable it. |
12 | # | | 12 | # |
13 | # Default value: "yes" | | 13 | # Default value: "yes" |
14 | # | | 14 | # |
15 | # CHECK_FILES_STRICT | | 15 | # CHECK_FILES_STRICT |
16 | # When set to "yes", VARBASE and PKG_SYSCONFDIR are checked in | | 16 | # When set to "yes", VARBASE and PKG_SYSCONFDIR are checked in |
17 | # addition to LOCALBASE. | | 17 | # addition to LOCALBASE. |
18 | # | | 18 | # |
| | | 19 | # CHECK_FILES_ONLY_PREFIX |
| | | 20 | # When set to "yes", the only directory below DESTDIR that may be |
| | | 21 | # modified during installation is PREFIX itself. |
| | | 22 | # |
19 | # Package-settable variables: | | 23 | # Package-settable variables: |
20 | # | | 24 | # |
21 | # CHECK_FILES_SKIP | | 25 | # CHECK_FILES_SKIP |
22 | # A list of regular expressions (FIXME: all other checks use shell | | 26 | # A list of regular expressions (FIXME: all other checks use shell |
23 | # patterns) that names files to be skipped. This is useful to | | 27 | # patterns) that names files to be skipped. This is useful to |
24 | # avoid getting errors triggered by changes in directories not | | 28 | # avoid getting errors triggered by changes in directories not |
25 | # really handled by pkgsrc. | | 29 | # really handled by pkgsrc. |
26 | # | | 30 | # |
27 | | | 31 | |
28 | _VARGROUPS+= check-files | | 32 | _VARGROUPS+= check-files |
29 | _USER_VARS.check-files= CHECK_FILES CHECK_FILES_STRICT | | 33 | _USER_VARS.check-files= \ |
| | | 34 | CHECK_FILES CHECK_FILES_STRICT CHECK_FILES_ONLY_PREFIX |
30 | _PKG_VARS.check-files= CHECK_FILES_SUPPORTED CHECK_FILES_SKIP | | 35 | _PKG_VARS.check-files= CHECK_FILES_SUPPORTED CHECK_FILES_SKIP |
31 | _USE_VARS.check-files= \ | | 36 | _USE_VARS.check-files= \ |
32 | DESTDIR PREFIX PKG_SYSCONFDIR VARBASE PKG_DBDIR DISTDIR PACKAGES \ | | 37 | DESTDIR PREFIX PKG_SYSCONFDIR VARBASE PKG_DBDIR DISTDIR PACKAGES \ |
33 | MAKE_DIRS MAKE_DIRS_PERMS OWN_DIRS OWN_DIRS_PERMS \ | | 38 | MAKE_DIRS MAKE_DIRS_PERMS OWN_DIRS OWN_DIRS_PERMS \ |
34 | FONTS_DIRS.x11 FONTS_DIRS.ttf FONTS_DIRS.type1 \ | | 39 | FONTS_DIRS.x11 FONTS_DIRS.ttf FONTS_DIRS.type1 \ |
35 | PERL5_INSTALLARCHLIB \ | | 40 | PERL5_INSTALLARCHLIB \ |
36 | WRKDIR ERROR_DIR \ | | 41 | WRKDIR ERROR_DIR \ |
37 | PLIST INFO_FILES ICON_THEMES | | 42 | PLIST INFO_FILES ICON_THEMES |
38 | _IGN_VARS.check-files= PKGNAME _CHECK_FILES_* | | 43 | _IGN_VARS.check-files= PKGNAME _CHECK_FILES_* |
39 | _LISTED_VARS.check-files= MAKE_DIRS MAKE_DIRS_PERMS OWN_DIRS OWN_DIRS_PERMS | | 44 | _LISTED_VARS.check-files= MAKE_DIRS MAKE_DIRS_PERMS OWN_DIRS OWN_DIRS_PERMS |
40 | _SORTED_VARS.check-files= CHECK_FILES_SKIP | | 45 | _SORTED_VARS.check-files= CHECK_FILES_SKIP |
41 | | | 46 | |
42 | | | 47 | |
43 | CHECK_FILES?= yes | | 48 | CHECK_FILES?= yes |
44 | CHECK_FILES_STRICT?= no | | 49 | CHECK_FILES_STRICT?= no |
| | | 50 | CHECK_FILES_ONLY_PREFIX?= no |
45 | | | 51 | |
46 | # Info index files updated when a new info file is added. | | 52 | # Info index files updated when a new info file is added. |
47 | .if defined(INFO_FILES) | | 53 | .if defined(INFO_FILES) |
48 | CHECK_FILES_SKIP+= ${PREFIX}/.*/dir | | 54 | CHECK_FILES_SKIP+= ${PREFIX}/.*/dir |
49 | .endif | | 55 | .endif |
50 | | | 56 | |
51 | # Perl's perllocal.pod index that is regenerated when a local module | | 57 | # Perl's perllocal.pod index that is regenerated when a local module |
52 | # is added. | | 58 | # is added. |
53 | # | | 59 | # |
54 | CHECK_FILES_SKIP+= ${PERL5_INSTALLARCHLIB}/perllocal.pod | | 60 | CHECK_FILES_SKIP+= ${PERL5_INSTALLARCHLIB}/perllocal.pod |
55 | | | 61 | |
56 | # R's index files that are regenerated when a local module | | 62 | # R's index files that are regenerated when a local module |
57 | # is added. | | 63 | # is added. |
| @@ -135,32 +141,37 @@ _CHECK_FILES_SKIP_FILTER= ${GREP} -vx ${ | | | @@ -135,32 +141,37 @@ _CHECK_FILES_SKIP_FILTER= ${GREP} -vx ${ |
135 | # | | 141 | # |
136 | _CHECK_FILES_ERRMSG.prefix= ${ERROR_DIR}/check-files-prefix | | 142 | _CHECK_FILES_ERRMSG.prefix= ${ERROR_DIR}/check-files-prefix |
137 | _CHECK_FILES_PRE.prefix= ${WRKDIR}/.check-files.prefix.pre | | 143 | _CHECK_FILES_PRE.prefix= ${WRKDIR}/.check-files.prefix.pre |
138 | _CHECK_FILES_POST.prefix= ${WRKDIR}/.check-files.prefix.post | | 144 | _CHECK_FILES_POST.prefix= ${WRKDIR}/.check-files.prefix.post |
139 | | | 145 | |
140 | _CHECK_FILES_ERRMSG.sysconfdir= ${ERROR_DIR}/.check-files-sysconfdir | | 146 | _CHECK_FILES_ERRMSG.sysconfdir= ${ERROR_DIR}/.check-files-sysconfdir |
141 | _CHECK_FILES_PRE.sysconfdir= ${WRKDIR}/.check-files.sysconfdir.pre | | 147 | _CHECK_FILES_PRE.sysconfdir= ${WRKDIR}/.check-files.sysconfdir.pre |
142 | _CHECK_FILES_POST.sysconfdir= ${WRKDIR}/.check-files.sysconfdir.post | | 148 | _CHECK_FILES_POST.sysconfdir= ${WRKDIR}/.check-files.sysconfdir.post |
143 | | | 149 | |
144 | _CHECK_FILES_ERRMSG.varbase= ${ERROR_DIR}/.check-files-varbase | | 150 | _CHECK_FILES_ERRMSG.varbase= ${ERROR_DIR}/.check-files-varbase |
145 | _CHECK_FILES_PRE.varbase= ${WRKDIR}/.check-files.varbase.pre | | 151 | _CHECK_FILES_PRE.varbase= ${WRKDIR}/.check-files.varbase.pre |
146 | _CHECK_FILES_POST.varbase= ${WRKDIR}/.check-files.varbase.post | | 152 | _CHECK_FILES_POST.varbase= ${WRKDIR}/.check-files.varbase.post |
147 | | | 153 | |
| | | 154 | _CHECK_FILES_ERRMSG.only-prefix= ${ERROR_DIR}/check-files-only-prefix |
| | | 155 | |
148 | _CHECK_FILES_ERRMSGS= # empty | | 156 | _CHECK_FILES_ERRMSGS= # empty |
149 | _CHECK_FILES_ERRMSGS+= ${_CHECK_FILES_ERRMSG.prefix} | | 157 | _CHECK_FILES_ERRMSGS+= ${_CHECK_FILES_ERRMSG.prefix} |
150 | .if ${CHECK_FILES_STRICT:tl} != no | | 158 | .if ${CHECK_FILES_STRICT:tl} != no |
151 | _CHECK_FILES_ERRMSGS+= ${_CHECK_FILES_ERRMSG.sysconfdir} | | 159 | _CHECK_FILES_ERRMSGS+= ${_CHECK_FILES_ERRMSG.sysconfdir} |
152 | _CHECK_FILES_ERRMSGS+= ${_CHECK_FILES_ERRMSG.varbase} | | 160 | _CHECK_FILES_ERRMSGS+= ${_CHECK_FILES_ERRMSG.varbase} |
153 | .endif | | 161 | .endif |
| | | 162 | .if ${CHECK_FILES_ONLY_PREFIX:tl} == yes |
| | | 163 | _CHECK_FILES_ERRMSGS+= ${_CHECK_FILES_ERRMSG.only-prefix} |
| | | 164 | .endif |
154 | | | 165 | |
155 | ########################################################################### | | 166 | ########################################################################### |
156 | # _CHECK_FILES_PRE holds the list of targets that are built as part of | | 167 | # _CHECK_FILES_PRE holds the list of targets that are built as part of |
157 | # building the check-files-pre target. These targets should cause the | | 168 | # building the check-files-pre target. These targets should cause the |
158 | # "pre" file lists to be generated. | | 169 | # "pre" file lists to be generated. |
159 | # | | 170 | # |
160 | _CHECK_FILES_PRE= # | | 171 | _CHECK_FILES_PRE= # |
161 | _CHECK_FILES_PRE+= ${_CHECK_FILES_PRE.prefix} | | 172 | _CHECK_FILES_PRE+= ${_CHECK_FILES_PRE.prefix} |
162 | .if ${CHECK_FILES_STRICT:tl} != no | | 173 | .if ${CHECK_FILES_STRICT:tl} != no |
163 | _CHECK_FILES_PRE+= ${_CHECK_FILES_PRE.sysconfdir} | | 174 | _CHECK_FILES_PRE+= ${_CHECK_FILES_PRE.sysconfdir} |
164 | _CHECK_FILES_PRE+= ${_CHECK_FILES_PRE.varbase} | | 175 | _CHECK_FILES_PRE+= ${_CHECK_FILES_PRE.varbase} |
165 | .endif | | 176 | .endif |
166 | | | 177 | |
| @@ -368,26 +379,37 @@ ${_CHECK_FILES_ERRMSG.varbase}: \ | | | @@ -368,26 +379,37 @@ ${_CHECK_FILES_ERRMSG.varbase}: \ |
368 | if ${CMP} -s ${_CHECK_FILES_PRE.varbase} \ | | 379 | if ${CMP} -s ${_CHECK_FILES_PRE.varbase} \ |
369 | ${_CHECK_FILES_POST.varbase}; then \ | | 380 | ${_CHECK_FILES_POST.varbase}; then \ |
370 | ${TRUE}; \ | | 381 | ${TRUE}; \ |
371 | else \ | | 382 | else \ |
372 | ${ECHO} "************************************************************"; \ | | 383 | ${ECHO} "************************************************************"; \ |
373 | ${ECHO} "The package has modified ${VARBASE}" \ | | 384 | ${ECHO} "The package has modified ${VARBASE}" \ |
374 | "contents directly!"; \ | | 385 | "contents directly!"; \ |
375 | ${ECHO} " The offending files/directories are:"; \ | | 386 | ${ECHO} " The offending files/directories are:"; \ |
376 | ${DIFF} -u ${_CHECK_FILES_PRE.varbase} \ | | 387 | ${DIFF} -u ${_CHECK_FILES_PRE.varbase} \ |
377 | ${_CHECK_FILES_POST.varbase} | \ | | 388 | ${_CHECK_FILES_POST.varbase} | \ |
378 | ${GREP} '^+[^+]' | ${SED} "s|^+| |"; \ | | 389 | ${GREP} '^+[^+]' | ${SED} "s|^+| |"; \ |
379 | fi > ${.TARGET} | | 390 | fi > ${.TARGET} |
380 | | | 391 | |
| | | 392 | ${_CHECK_FILES_ERRMSG.only-prefix}: |
| | | 393 | ${RUN} \ |
| | | 394 | files=${WRKDIR}/.check-files-only-prefix; \ |
| | | 395 | ${FIND} ${DESTDIR} \( -type f -o -type l \) -print \ |
| | | 396 | | ${GREP} -v '^${DESTDIR}${PREFIX}/' > "$$files" || :; \ |
| | | 397 | if [ -s "$$files" ]; then \ |
| | | 398 | ${ECHO} "************************************************************"; \ |
| | | 399 | ${ECHO} "The package has installed files outside ${PREFIX}:"; \ |
| | | 400 | ${SED} -e 's,^, ,' "$$files"; \ |
| | | 401 | fi > ${.TARGET} |
| | | 402 | |
381 | ########################################################################### | | 403 | ########################################################################### |
382 | # check-files-clean removes the state files related to the "check-files" | | 404 | # check-files-clean removes the state files related to the "check-files" |
383 | # target so that the check-files-{pre,post} targets may be re-run. | | 405 | # target so that the check-files-{pre,post} targets may be re-run. |
384 | # | | 406 | # |
385 | .PHONY: check-files-clean | | 407 | .PHONY: check-files-clean |
386 | check-clean: check-files-clean | | 408 | check-clean: check-files-clean |
387 | check-files-clean: | | 409 | check-files-clean: |
388 | ${RUN} \ | | 410 | ${RUN} \ |
389 | ${RM} -f ${_CHECK_FILES_ERRMSGS} \ | | 411 | ${RM} -f ${_CHECK_FILES_ERRMSGS} \ |
390 | ${_CHECK_FILES_PRE} ${_CHECK_FILES_POST} \ | | 412 | ${_CHECK_FILES_PRE} ${_CHECK_FILES_POST} \ |
391 | ${_CHECK_FILES_DIFF} ${_CHECK_FILES_ADDED} \ | | 413 | ${_CHECK_FILES_DIFF} ${_CHECK_FILES_ADDED} \ |
392 | ${_CHECK_FILES_DELETED} ${_CHECK_FILES_EXPECTED} \ | | 414 | ${_CHECK_FILES_DELETED} ${_CHECK_FILES_EXPECTED} \ |
393 | ${_CHECK_FILES_MISSING} ${_CHECK_FILES_MISSING_SKIP} \ | | 415 | ${_CHECK_FILES_MISSING} ${_CHECK_FILES_MISSING_SKIP} \ |