1 # $NetBSD: check-perms.mk,v 1.12 2008/06/22 22:05:19 joerg Exp $
3 # This file checks that after installation of a package, all files and
4 # directories of that package have sensible permissions set.
6 # To use this check in bulk builds, add
7 # BULK_PREREQ+= sysutils/checkperms
8 # to your mk.conf file.
10 # User-settable variables:
13 # Specifies whether the permissions check should be run at all.
15 # Possible values: yes, no.
17 # Default value: yes for PKG_DEVELOPER, no otherwise.
19 # Package-settable variables:
22 # A list of shell patterns (like man/*) that should be excluded
23 # from the check. Note that a * in a pattern also matches a slash
26 # Default value: empty.
29 # If set to yes, any unusual permissions are fixed automatically.
31 # Possible values: yes, no.
34 _VARGROUPS
+= check-perms
35 _USER_VARS.check-perms
= CHECK_PERMS
36 _PKG_VARS.check-perms
= CHECK_PERMS_SKIP CHECK_PERMS_AUTOSKIP
38 .if defined
(PKG_DEVELOPER
) && ${PKG_DEVELOPER} != "no"
44 CHECK_PERMS_SKIP?
= # none
45 CHECK_PERMS_AUTOFIX?
= no
47 # The checkperms command does not yet support Interix with the -c flag.
49 .if
!empty
(MACHINE_PLATFORM
:MInterix-
*-*)
51 .elif
!empty
(CHECK_PERMS_AUTOFIX
:M
[Yy
][Ee
][Ss
])
52 _CHECK_PERMS_FLAGS
= -cff
54 _CHECK_PERMS_FLAGS
= -c
57 .if
!empty
(CHECK_PERMS
:M
[Yy
][Ee
][Ss
])
58 BUILD_DEPENDS
+= checkperms
>=1.1:..
/..
/sysutils
/checkperms
60 privileged-install-hook
: _check-perms
63 _CHECK_PERMS_CMD
= ${LOCALBASE}/bin
/checkperms
64 _CHECK_PERMS_GETDIRS_AWK
= \
68 while
(sub
("/[^/]*$$", "", dir) && dir != "") { \
69 if
(!(dir in dirs
)) { \
77 @
${STEP_MSG} "Checking file permissions in ${PKGNAME}"
78 ${RUN} ${PKG_INFO} -qe
"checkperms>=1.1" \
80 ${WARNING_MSG} "[check-perms.mk] Skipping file permissions check."; \
81 ${WARNING_MSG} "[check-perms.mk] Install sysutils/checkperms to enable this check."; \
86 | sed
-e
's,\\,\\\\,g' \
87 | while read file
; do \
89 ${CHECK_PERMS_SKIP
:@p@
${PREFIX}/${p}|
${p}) continue
;;@
}\
92 printf
"%s\\n" "${DESTDIR}$$file"; \
94 | awk
${_CHECK_PERMS_GETDIRS_AWK
:Q
} \
95 |
${_CHECK_PERMS_CMD} ${_CHECK_PERMS_FLAGS}