Thu Aug 10 05:37:44 2017 UTC ()
mk/pkgtasks: Make the assertion comments more obvious.


(jlam)
diff -r1.2 -r1.3 pkgsrc/mk/pkgtasks/directories.mk
diff -r1.5 -r1.6 pkgsrc/mk/pkgtasks/files.mk
diff -r1.1 -r1.2 pkgsrc/mk/pkgtasks/permissions.mk

cvs diff -r1.2 -r1.3 pkgsrc/mk/pkgtasks/directories.mk (switch to unified diff)

--- pkgsrc/mk/pkgtasks/directories.mk 2017/08/10 05:37:32 1.2
+++ pkgsrc/mk/pkgtasks/directories.mk 2017/08/10 05:37:44 1.3
@@ -1,169 +1,169 @@ @@ -1,169 +1,169 @@
1# $NetBSD: directories.mk,v 1.2 2017/08/10 05:37:32 jlam Exp $ 1# $NetBSD: directories.mk,v 1.3 2017/08/10 05:37:44 jlam Exp $
2# 2#
3# Copyright (c) 2017 The NetBSD Foundation, Inc. 3# Copyright (c) 2017 The NetBSD Foundation, Inc.
4# All rights reserved. 4# All rights reserved.
5# 5#
6# This code is derived from software contributed to The NetBSD Foundation 6# This code is derived from software contributed to The NetBSD Foundation
7# by Johnny C. Lam. 7# by Johnny C. Lam.
8# 8#
9# Redistribution and use in source and binary forms, with or without 9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions 10# modification, are permitted provided that the following conditions
11# are met: 11# are met:
12# 1. Redistributions of source code must retain the above copyright 12# 1. Redistributions of source code must retain the above copyright
13# notice, this list of conditions and the following disclaimer. 13# notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright 14# 2. Redistributions in binary form must reproduce the above copyright
15# notice, this list of conditions and the following disclaimer in the 15# notice, this list of conditions and the following disclaimer in the
16# documentation and/or other materials provided with the distribution. 16# documentation and/or other materials provided with the distribution.
17# 17#
18# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28# POSSIBILITY OF SUCH DAMAGE. 28# POSSIBILITY OF SUCH DAMAGE.
29 29
30# Generate the data file for the directories package task. 30# Generate the data file for the directories package task.
31 31
32# MAKE_DIRS 32# MAKE_DIRS
33# OWN_DIRS 33# OWN_DIRS
34# REQD_DIRS 34# REQD_DIRS
35# List of directories that should be created and destroyed when 35# List of directories that should be created and destroyed when
36# the package is installed and removed. 36# the package is installed and removed.
37# 37#
38# OWN_DIRS is for directories owned by the package and the user 38# OWN_DIRS is for directories owned by the package and the user
39# is prompted to remove the directory if it isn't empty. The 39# is prompted to remove the directory if it isn't empty. The
40# directories are created or removed only if PKG_CONFIG is "yes". 40# directories are created or removed only if PKG_CONFIG is "yes".
41# 41#
42# MAKE_DIRS is for directories used by the package and the user 42# MAKE_DIRS is for directories used by the package and the user
43# is never prompted to remove non-empty directories. The 43# is never prompted to remove non-empty directories. The
44# directories are created or removed only if PKG_CONFIG is "yes". 44# directories are created or removed only if PKG_CONFIG is "yes".
45# 45#
46# REQD_DIRS is for directories used by the package that must 46# REQD_DIRS is for directories used by the package that must
47# always be created (PKG_CONFIG is ignored), and the user is 47# always be created (PKG_CONFIG is ignored), and the user is
48# never prompted to remove non-empty directories. All 48# never prompted to remove non-empty directories. All
49# directories listed in REQD_DIRS should be under ${PREFIX}. 49# directories listed in REQD_DIRS should be under ${PREFIX}.
50# The use-case for REQD_DIRS is very specialized, and most 50# The use-case for REQD_DIRS is very specialized, and most
51# packages should be using either OWN_DIRS or MAKE_DIRS instead. 51# packages should be using either OWN_DIRS or MAKE_DIRS instead.
52# 52#
53# If the directory pathname is a relative path, then it is taken 53# If the directory pathname is a relative path, then it is taken
54# to be relative to ${PREFIX}. 54# to be relative to ${PREFIX}.
55# 55#
56# MAKE_DIRS_PERMS 56# MAKE_DIRS_PERMS
57# OWN_DIRS_PERMS 57# OWN_DIRS_PERMS
58# REQD_DIRS_PERMS 58# REQD_DIRS_PERMS
59# List of sublists representing directories with ownership and 59# List of sublists representing directories with ownership and
60# explicit modes that should be created and destroyed when the 60# explicit modes that should be created and destroyed when the
61# package is installed and removed. The sublists are of the 61# package is installed and removed. The sublists are of the
62# form: 62# form:
63# 63#
64# <directory> <owner> <group> <mode> 64# <directory> <owner> <group> <mode>
65# 65#
66# These variables have the same usage as the similarly-named 66# These variables have the same usage as the similarly-named
67# variables that don't end in "_PERMS". 67# variables that don't end in "_PERMS".
68# 68#
69_PKG_VARS.pkgtasks+= MAKE_DIRS MAKE_DIRS_PERMS \ 69_PKG_VARS.pkgtasks+= MAKE_DIRS MAKE_DIRS_PERMS \
70 OWN_DIRS OWN_DIRS_PERMS \ 70 OWN_DIRS OWN_DIRS_PERMS \
71 REQD_DIRS REQD_DIRS_PERMS 71 REQD_DIRS REQD_DIRS_PERMS
72MAKE_DIRS?= # empty 72MAKE_DIRS?= # empty
73MAKE_DIRS_PERMS?= # empty 73MAKE_DIRS_PERMS?= # empty
74OWN_DIRS?= # empty 74OWN_DIRS?= # empty
75OWN_DIRS_PERMS?= # empty 75OWN_DIRS_PERMS?= # empty
76REQD_DIRS?= # empty 76REQD_DIRS?= # empty
77REQD_DIRS_PERMS?= # empty 77REQD_DIRS_PERMS?= # empty
78 78
79# Trigger pkgtasks dependency if needed. 79# Trigger pkgtasks dependency if needed.
80_PKGTASKS_DATAVARS.directories= \ 80_PKGTASKS_DATAVARS.directories= \
81 MAKE_DIRS MAKE_DIRS_PERMS \ 81 MAKE_DIRS MAKE_DIRS_PERMS \
82 OWN_DIRS OWN_DIRS_PERMS \ 82 OWN_DIRS OWN_DIRS_PERMS \
83 REQD_DIRS REQD_DIRS_PERMS 83 REQD_DIRS REQD_DIRS_PERMS
84.for _var_ in ${_PKGTASKS_DATAVARS.directories} 84.for _var_ in ${_PKGTASKS_DATAVARS.directories}
85. if !empty(${_var_}) 85. if !empty(${_var_})
86USE_PKGTASKS= yes 86USE_PKGTASKS= yes
87. endif 87. endif
88.endfor 88.endfor
89 89
90# Strip leading "${PREFIX}/" from the directory pathnames. 90# Strip leading "${PREFIX}/" from the directory pathnames.
91_MAKE_DIRS= ${MAKE_DIRS:S|^${PREFIX}/||g} 91_MAKE_DIRS= ${MAKE_DIRS:S|^${PREFIX}/||g}
92_MAKE_DIRS_PERMS= ${MAKE_DIRS_PERMS:S|^${PREFIX}/||g} 92_MAKE_DIRS_PERMS= ${MAKE_DIRS_PERMS:S|^${PREFIX}/||g}
93_OWN_DIRS= ${OWN_DIRS:S|^${PREFIX}/||g} 93_OWN_DIRS= ${OWN_DIRS:S|^${PREFIX}/||g}
94_OWN_DIRS_PERMS= ${OWN_DIRS_PERMS:S|^${PREFIX}/||g} 94_OWN_DIRS_PERMS= ${OWN_DIRS_PERMS:S|^${PREFIX}/||g}
95_REQD_DIRS= ${REQD_DIRS:S|^${PREFIX}/||g} 95_REQD_DIRS= ${REQD_DIRS:S|^${PREFIX}/||g}
96_REQD_DIRS_PERMS= ${REQD_DIRS_PERMS:S|^${PREFIX}/||g} 96_REQD_DIRS_PERMS= ${REQD_DIRS_PERMS:S|^${PREFIX}/||g}
97 97
98# Assert that the variables have the right number of words and 98# ASSERT: The variables have the right number of words and that no
99# that no directory is listed in more than one variable. 99# directory is listed in more than one variable.
100# 100#
101# _ALL_DIRS.directories 101# _ALL_DIRS.directories
102# List of directories named in MAKE_DIRS, OWN_DIRS, REQD_DIRS, 102# List of directories named in MAKE_DIRS, OWN_DIRS, REQD_DIRS,
103# MAKE_DIRS_PERMS, OWN_DIRS_PERMS, and REQD_DIRS_PERMS. This 103# MAKE_DIRS_PERMS, OWN_DIRS_PERMS, and REQD_DIRS_PERMS. This
104# variable is used in pkgsrc/mk/pkgtasks/files.mk. 104# variable is used in pkgsrc/mk/pkgtasks/files.mk.
105# 105#
106_ALL_DIRS.directories= # empty 106_ALL_DIRS.directories= # empty
107.for _var_ in MAKE_DIRS OWN_DIRS REQD_DIRS 107.for _var_ in MAKE_DIRS OWN_DIRS REQD_DIRS
108. for d in ${${_var_}} 108. for d in ${${_var_}}
109_DIRS.${d}+= ${_var_} 109_DIRS.${d}+= ${_var_}
110_ALL_DIRS.directories+= ${d} 110_ALL_DIRS.directories+= ${d}
111. endfor 111. endfor
112.endfor 112.endfor
113.for _var_ in MAKE_DIRS_PERMS OWN_DIRS_PERMS REQD_DIRS_PERMS 113.for _var_ in MAKE_DIRS_PERMS OWN_DIRS_PERMS REQD_DIRS_PERMS
114. if empty(${_var_}) || empty(${_var_}:C/.*/4/:M*:S/4 4 4 4//gW) 114. if empty(${_var_}) || empty(${_var_}:C/.*/4/:M*:S/4 4 4 4//gW)
115# ${_var_} has a multiple of 4 words. 115# ${_var_} has a multiple of 4 words.
116. for d o g m in ${${_var_}} 116. for d o g m in ${${_var_}}
117_DIRS.${d}+= ${_var_} 117_DIRS.${d}+= ${_var_}
118_ALL_DIRS.directories+= ${d} 118_ALL_DIRS.directories+= ${d}
119. endfor 119. endfor
120. else 120. else
121PKG_FAIL_REASON+= ${_var_:Q}" must have a multiple of 4 words." 121PKG_FAIL_REASON+= ${_var_:Q}" must have a multiple of 4 words."
122. endif 122. endif
123.endfor 123.endfor
124.for d in ${_ALL_DIRS.directories:O:u} 124.for d in ${_ALL_DIRS.directories:O:u}
125. if ${_DIRS.${d}:[#]} != 1 125. if ${_DIRS.${d}:[#]} != 1
126PKG_FAIL_REASON+= ${d:Q}" is listed more than once: "${_DIRS.${d}:Q} 126PKG_FAIL_REASON+= ${d:Q}" is listed more than once: "${_DIRS.${d}:Q}
127. endif 127. endif
128.endfor 128.endfor
129 129
130_PKGTASKS_DATA.directories= ${_PKGTASKS_DIR}/directories 130_PKGTASKS_DATA.directories= ${_PKGTASKS_DIR}/directories
131_PKGTASKS_DATAFILES+= ${_PKGTASKS_DATA.directories} 131_PKGTASKS_DATAFILES+= ${_PKGTASKS_DATA.directories}
132 132
133${_PKGTASKS_DATA.directories}: 133${_PKGTASKS_DATA.directories}:
134 ${RUN}${MKDIR} ${.TARGET:H:Q} 134 ${RUN}${MKDIR} ${.TARGET:H:Q}
135 ${RUN}exec > ${.TARGET:Q}.tmp 135 ${RUN}exec > ${.TARGET:Q}.tmp
136 ${RUN}set -- args ${_MAKE_DIRS}; shift; \ 136 ${RUN}set -- args ${_MAKE_DIRS}; shift; \
137 while ${TEST} "$$#" -gt 0; do \ 137 while ${TEST} "$$#" -gt 0; do \
138 dir="$$1"; shift; \ 138 dir="$$1"; shift; \
139 ${ECHO} "# DIR: $$dir m" >> ${.TARGET:Q}.tmp; \ 139 ${ECHO} "# DIR: $$dir m" >> ${.TARGET:Q}.tmp; \
140 done 140 done
141 ${RUN}set -- args ${_MAKE_DIRS_PERMS}; shift; \ 141 ${RUN}set -- args ${_MAKE_DIRS_PERMS}; shift; \
142 while ${TEST} "$$#" -gt 0; do \ 142 while ${TEST} "$$#" -gt 0; do \
143 dir="$$1"; owner="$$2"; group="$$3"; mode="$$4"; shift 4; \ 143 dir="$$1"; owner="$$2"; group="$$3"; mode="$$4"; shift 4; \
144 ${ECHO} "# DIR: $$dir m $$mode $$owner $$group" \ 144 ${ECHO} "# DIR: $$dir m $$mode $$owner $$group" \
145 >> ${.TARGET:Q}.tmp; \ 145 >> ${.TARGET:Q}.tmp; \
146 done 146 done
147 ${RUN}set -- args ${_OWN_DIRS}; shift; \ 147 ${RUN}set -- args ${_OWN_DIRS}; shift; \
148 while ${TEST} "$$#" -gt 0; do \ 148 while ${TEST} "$$#" -gt 0; do \
149 dir="$$1"; shift; \ 149 dir="$$1"; shift; \
150 ${ECHO} "# DIR: $$dir mo" >> ${.TARGET:Q}.tmp; \ 150 ${ECHO} "# DIR: $$dir mo" >> ${.TARGET:Q}.tmp; \
151 done 151 done
152 ${RUN}set -- args ${_OWN_DIRS_PERMS}; shift; \ 152 ${RUN}set -- args ${_OWN_DIRS_PERMS}; shift; \
153 while ${TEST} "$$#" -gt 0; do \ 153 while ${TEST} "$$#" -gt 0; do \
154 dir="$$1"; owner="$$2"; group="$$3"; mode="$$4"; shift 4; \ 154 dir="$$1"; owner="$$2"; group="$$3"; mode="$$4"; shift 4; \
155 ${ECHO} "# DIR: $$dir mo $$mode $$owner $$group" \ 155 ${ECHO} "# DIR: $$dir mo $$mode $$owner $$group" \
156 >> ${.TARGET:Q}.tmp; \ 156 >> ${.TARGET:Q}.tmp; \
157 done 157 done
158 ${RUN}set -- args ${_REQD_DIRS}; shift; \ 158 ${RUN}set -- args ${_REQD_DIRS}; shift; \
159 while ${TEST} "$$#" -gt 0; do \ 159 while ${TEST} "$$#" -gt 0; do \
160 dir="$$1"; shift; \ 160 dir="$$1"; shift; \
161 ${ECHO} "# DIR: $$dir fm" >> ${.TARGET:Q}.tmp; \ 161 ${ECHO} "# DIR: $$dir fm" >> ${.TARGET:Q}.tmp; \
162 done 162 done
163 ${RUN}set -- args ${_REQD_DIRS_PERMS}; shift; \ 163 ${RUN}set -- args ${_REQD_DIRS_PERMS}; shift; \
164 while ${TEST} "$$#" -gt 0; do \ 164 while ${TEST} "$$#" -gt 0; do \
165 dir="$$1"; owner="$$2"; group="$$3"; mode="$$4"; shift 4; \ 165 dir="$$1"; owner="$$2"; group="$$3"; mode="$$4"; shift 4; \
166 ${ECHO} "# DIR: $$dir fm $$mode $$owner $$group" \ 166 ${ECHO} "# DIR: $$dir fm $$mode $$owner $$group" \
167 >> ${.TARGET:Q}.tmp; \ 167 >> ${.TARGET:Q}.tmp; \
168 done 168 done
169 ${RUN}${MV} ${.TARGET:Q}.tmp ${.TARGET:Q} 169 ${RUN}${MV} ${.TARGET:Q}.tmp ${.TARGET:Q}

cvs diff -r1.5 -r1.6 pkgsrc/mk/pkgtasks/files.mk (switch to unified diff)

--- pkgsrc/mk/pkgtasks/files.mk 2017/08/10 05:37:32 1.5
+++ pkgsrc/mk/pkgtasks/files.mk 2017/08/10 05:37:44 1.6
@@ -1,263 +1,263 @@ @@ -1,263 +1,263 @@
1# $NetBSD: files.mk,v 1.5 2017/08/10 05:37:32 jlam Exp $ 1# $NetBSD: files.mk,v 1.6 2017/08/10 05:37:44 jlam Exp $
2# 2#
3# Copyright (c) 2017 The NetBSD Foundation, Inc. 3# Copyright (c) 2017 The NetBSD Foundation, Inc.
4# All rights reserved. 4# All rights reserved.
5# 5#
6# This code is derived from software contributed to The NetBSD Foundation 6# This code is derived from software contributed to The NetBSD Foundation
7# by Johnny C. Lam. 7# by Johnny C. Lam.
8# 8#
9# Redistribution and use in source and binary forms, with or without 9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions 10# modification, are permitted provided that the following conditions
11# are met: 11# are met:
12# 1. Redistributions of source code must retain the above copyright 12# 1. Redistributions of source code must retain the above copyright
13# notice, this list of conditions and the following disclaimer. 13# notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright 14# 2. Redistributions in binary form must reproduce the above copyright
15# notice, this list of conditions and the following disclaimer in the 15# notice, this list of conditions and the following disclaimer in the
16# documentation and/or other materials provided with the distribution. 16# documentation and/or other materials provided with the distribution.
17# 17#
18# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28# POSSIBILITY OF SUCH DAMAGE. 28# POSSIBILITY OF SUCH DAMAGE.
29 29
30# Generate the data file for the files package task. 30# Generate the data file for the files package task.
31 31
32### 32###
33# CONF_FILES 33# CONF_FILES
34# REQD_FILES 34# REQD_FILES
35# _INIT_SCRIPTS 35# _INIT_SCRIPTS
36# List of pairs of files that should be copied and removed when 36# List of pairs of files that should be copied and removed when
37# the package is installed and removed. The pairs are of the 37# the package is installed and removed. The pairs are of the
38# form: 38# form:
39# 39#
40# <source> <target> 40# <source> <target>
41# 41#
42# During installation, if the target file does not exist, then the 42# During installation, if the target file does not exist, then the
43# source file is copied into place. During removal, if the target 43# source file is copied into place. During removal, if the target
44# file does not differ from the source file, then the target file 44# file does not differ from the source file, then the target file
45# is also removed. 45# is also removed.
46# 46#
47# CONF_FILES triggers system changes only if PKG_CONFIG is "yes". 47# CONF_FILES triggers system changes only if PKG_CONFIG is "yes".
48# REQD_FILES always trigger system changes (PKG_CONFIG is ignored). 48# REQD_FILES always trigger system changes (PKG_CONFIG is ignored).
49# _INIT_SCRIPTS trigger system changes only if PKG_CONFIG and 49# _INIT_SCRIPTS trigger system changes only if PKG_CONFIG and
50# PKG_INIT_SCRIPTS are both "yes". 50# PKG_INIT_SCRIPTS are both "yes".
51# 51#
52# The use-case for REQD_FILES is very specialized, and most packages 52# The use-case for REQD_FILES is very specialized, and most packages
53# should be using CONF_FILES instead. 53# should be using CONF_FILES instead.
54# 54#
55# If the source and target pathnames are relative paths, then they 55# If the source and target pathnames are relative paths, then they
56# are taken to be relative to ${PREFIX}. 56# are taken to be relative to ${PREFIX}.
57# 57#
58# CONF_FILES_MODE 58# CONF_FILES_MODE
59# REQD_FILES_MODE 59# REQD_FILES_MODE
60# _INIT_SCRIPTS_MODE 60# _INIT_SCRIPTS_MODE
61# These are the file modes for the target files listed in CONF_FILES, 61# These are the file modes for the target files listed in CONF_FILES,
62# REQD_FILES, and _INIT_SCRIPTS, respectively. 62# REQD_FILES, and _INIT_SCRIPTS, respectively.
63# 63#
64# CONF_FILES_PERMS 64# CONF_FILES_PERMS
65# REQD_FILES_PERMS 65# REQD_FILES_PERMS
66# _INIT_SCRIPTS_PERMS 66# _INIT_SCRIPTS_PERMS
67# List of sublists representing files with ownership and explicit 67# List of sublists representing files with ownership and explicit
68# modes that should be copied and removed when the package is 68# modes that should be copied and removed when the package is
69# installed and removed. The sublists are of the form: 69# installed and removed. The sublists are of the form:
70# 70#
71# <source> <target> <owner> <group> <mode> 71# <source> <target> <owner> <group> <mode>
72# 72#
73# These variables have the same usage as the similarly-named 73# These variables have the same usage as the similarly-named
74# variables that don't end in "_PERMS". 74# variables that don't end in "_PERMS".
75# 75#
76# The _INIT_SCRIPTS* variables are a hook for bsd.init.mk into the config 76# The _INIT_SCRIPTS* variables are a hook for bsd.init.mk into the config
77# file framework. They should not be used by packages. 77# file framework. They should not be used by packages.
78# 78#
79_PKG_VARS.pkgtasks+= CONF_FILES CONF_FILES_MODE CONF_FILES_PERMS \ 79_PKG_VARS.pkgtasks+= CONF_FILES CONF_FILES_MODE CONF_FILES_PERMS \
80 REQD_FILES REQD_FILES_MODE REQD_FILES_PERMS 80 REQD_FILES REQD_FILES_MODE REQD_FILES_PERMS
81CONF_FILES?= # empty 81CONF_FILES?= # empty
82CONF_FILES_MODE?= 0644 82CONF_FILES_MODE?= 0644
83CONF_FILES_PERMS?= # empty 83CONF_FILES_PERMS?= # empty
84REQD_FILES?= # empty 84REQD_FILES?= # empty
85REQD_FILES_MODE?= 0644 85REQD_FILES_MODE?= 0644
86REQD_FILES_PERMS?= # empty 86REQD_FILES_PERMS?= # empty
87_INIT_SCRIPTS?= # empty 87_INIT_SCRIPTS?= # empty
88_INIT_SCRIPTS_MODE?= 0755 88_INIT_SCRIPTS_MODE?= 0755
89_INIT_SCRIPTS_PERMS?= # empty 89_INIT_SCRIPTS_PERMS?= # empty
90 90
91# Trigger pkgtasks dependency if needed. 91# Trigger pkgtasks dependency if needed.
92_PKGTASKS_DATAVARS.files+= \ 92_PKGTASKS_DATAVARS.files+= \
93 CONF_FILES CONF_FILES_PERMS \ 93 CONF_FILES CONF_FILES_PERMS \
94 REQD_FILES REQD_FILES_PERMS \ 94 REQD_FILES REQD_FILES_PERMS \
95 _INIT_SCRIPTS _INIT_SCRIPTS_PERMS 95 _INIT_SCRIPTS _INIT_SCRIPTS_PERMS
96.for _var_ in ${_PKGTASKS_DATAVARS.files} 96.for _var_ in ${_PKGTASKS_DATAVARS.files}
97. if !empty(${_var_}) 97. if !empty(${_var_})
98USE_PKGTASKS= yes 98USE_PKGTASKS= yes
99. endif 99. endif
100.endfor 100.endfor
101 101
102# Strip leading "${PREFIX}/" from the file pathnames. 102# Strip leading "${PREFIX}/" from the file pathnames.
103_CONF_FILES= ${CONF_FILES:S|^${PREFIX}/||g} 103_CONF_FILES= ${CONF_FILES:S|^${PREFIX}/||g}
104_CONF_FILES_PERMS= ${CONF_FILES_PERMS:S|^${PREFIX}/||g} 104_CONF_FILES_PERMS= ${CONF_FILES_PERMS:S|^${PREFIX}/||g}
105_REQD_FILES= ${REQD_FILES:S|^${PREFIX}/||g} 105_REQD_FILES= ${REQD_FILES:S|^${PREFIX}/||g}
106_REQD_FILES_PERMS= ${REQD_FILES_PERMS:S|^${PREFIX}/||g} 106_REQD_FILES_PERMS= ${REQD_FILES_PERMS:S|^${PREFIX}/||g}
107__INIT_SCRIPTS= ${_INIT_SCRIPTS:S|^${PREFIX}/||g} 107__INIT_SCRIPTS= ${_INIT_SCRIPTS:S|^${PREFIX}/||g}
108__INIT_SCRIPTS_PERMS= ${_INIT_SCRIPTS_PERMS:S|^${PREFIX}/||g} 108__INIT_SCRIPTS_PERMS= ${_INIT_SCRIPTS_PERMS:S|^${PREFIX}/||g}
109 109
110# Assert that the variables have the right number of words and 110# ASSERT: The variables have the right number of words and that
111# that no target file is listed in more than one variable. 111# no target file is listed in more than one variable.
112# 112#
113_ALL_TARGET_FILES.files= # empty 113_ALL_TARGET_FILES.files= # empty
114.for _var_ in CONF_FILES REQD_FILES _INIT_SCRIPTS 114.for _var_ in CONF_FILES REQD_FILES _INIT_SCRIPTS
115. if empty(${_var_}) || empty(${_var_}:C/.*/2/:M*:S/2 2//gW) 115. if empty(${_var_}) || empty(${_var_}:C/.*/2/:M*:S/2 2//gW)
116# ${_var_} has a multiple of 2 words. 116# ${_var_} has a multiple of 2 words.
117. for s t in ${${_var_}} 117. for s t in ${${_var_}}
118_FILE_VARLIST.${t}+= ${_var_} 118_FILE_VARLIST.${t}+= ${_var_}
119_ALL_TARGET_FILES.files+= ${t} 119_ALL_TARGET_FILES.files+= ${t}
120. endfor 120. endfor
121. else 121. else
122PKG_FAIL_REASON+= ${_var_:Q}" must have a multiple of 2 words." 122PKG_FAIL_REASON+= ${_var_:Q}" must have a multiple of 2 words."
123. endif 123. endif
124.endfor 124.endfor
125.for _var_ in CONF_FILES_PERMS REQD_FILES_PERMS _INIT_SCRIPT_PERMS 125.for _var_ in CONF_FILES_PERMS REQD_FILES_PERMS _INIT_SCRIPT_PERMS
126. if empty(${_var_}) || empty(${_var_}:C/.*/5/:M*:S/5 5 5 5 5//gW) 126. if empty(${_var_}) || empty(${_var_}:C/.*/5/:M*:S/5 5 5 5 5//gW)
127# ${_var_} has a multiple of 5 words. 127# ${_var_} has a multiple of 5 words.
128. for s t o g m in ${${_var_}} 128. for s t o g m in ${${_var_}}
129_FILE_VARLIST.${t}+= ${_var_} 129_FILE_VARLIST.${t}+= ${_var_}
130_ALL_TARGET_FILES.files+= ${t} 130_ALL_TARGET_FILES.files+= ${t}
131. endfor 131. endfor
132. else 132. else
133PKG_FAIL_REASON+= ${_var_:Q}" must have a multiple of 5 words." 133PKG_FAIL_REASON+= ${_var_:Q}" must have a multiple of 5 words."
134. endif 134. endif
135.endfor 135.endfor
136.for t in ${_ALL_TARGET_FILES.files:O:u} 136.for t in ${_ALL_TARGET_FILES.files:O:u}
137. if ${_FILE_VARLIST.${t}:[#]} != 1 137. if ${_FILE_VARLIST.${t}:[#]} != 1
138PKG_FAIL_REASON+= ${t:Q}" is listed more than once: "${_FILE_VARLIST.${t}:Q} 138PKG_FAIL_REASON+= ${t:Q}" is listed more than once: "${_FILE_VARLIST.${t}:Q}
139. endif 139. endif
140.endfor 140.endfor
141 141
142# Hook into directories.mk to create ${PKG_SYSCONFDIR} in the package 142# Hook into directories.mk to create ${PKG_SYSCONFDIR} in the package
143# tasks. 143# tasks.
144# 144#
145# The following variables used are set within bsd.pkg.mk: 145# The following variables used are set within bsd.pkg.mk:
146# 146#
147# PKG_SYSCONFDIR 147# PKG_SYSCONFDIR
148# PKG_SYSCONFDIR_PERMS 148# PKG_SYSCONFDIR_PERMS
149# PKG_SYSCONFSUBDIR 149# PKG_SYSCONFSUBDIR
150# 150#
151.if defined(PKG_SYSCONFSUBDIR) && !empty(PKG_SYSCONFSUBDIR) 151.if defined(PKG_SYSCONFSUBDIR) && !empty(PKG_SYSCONFSUBDIR)
152# Always create ${PKG_SYSCONFDIR} if ${PKG_SYSCONFSUBDIR} is non-empty. 152# Always create ${PKG_SYSCONFDIR} if ${PKG_SYSCONFSUBDIR} is non-empty.
153MAKE_DIRS_PERMS+= ${PKG_SYSCONFDIR} ${PKG_SYSCONFDIR_PERMS} 153MAKE_DIRS_PERMS+= ${PKG_SYSCONFDIR} ${PKG_SYSCONFDIR_PERMS}
154_ALL_DIRS.directories+= ${PKG_SYSCONFDIR} 154_ALL_DIRS.directories+= ${PKG_SYSCONFDIR}
155.elif !empty(_ALL_TARGET_FILES.files:M${PKG_SYSCONFDIR}/*) 155.elif !empty(_ALL_TARGET_FILES.files:M${PKG_SYSCONFDIR}/*)
156# Create ${PKG_SYSCONFDIR} if any target files are in that directory. 156# Create ${PKG_SYSCONFDIR} if any target files are in that directory.
157MAKE_DIRS+= ${PKG_SYSCONFDIR} 157MAKE_DIRS+= ${PKG_SYSCONFDIR}
158_ALL_DIRS.directories+= ${PKG_SYSCONFDIR} 158_ALL_DIRS.directories+= ${PKG_SYSCONFDIR}
159.endif 159.endif
160 160
161# Assert that the directories that contain target files are listed in 161# ASSERT: The directories that contain target files are listed in
162# one of the directory variables. This makes use of 162# one of the directory variables. This makes use of
163# ${_ALL_DIRS.directories}, which is defined in directories.mk. 163# ${_ALL_DIRS.directories}, which is defined in directories.mk.
164# 164#
165.for t in ${_ALL_TARGET_FILES.files:O:u} 165.for t in ${_ALL_TARGET_FILES.files:O:u}
166_FILEMATCH.${t}= ${_ALL_DIRS.directories:@d@${t:M${d}/*}@} 166_FILEMATCH.${t}= ${_ALL_DIRS.directories:@d@${t:M${d}/*}@}
167. if empty(_FILEMATCH.${t}) 167. if empty(_FILEMATCH.${t})
168PKG_FAIL_REASON+= "This package may need MAKE_DIRS+="${t:C|/[^/]*$||:Q} 168PKG_FAIL_REASON+= "This package may need MAKE_DIRS+="${t:C|/[^/]*$||:Q}
169. endif 169. endif
170.endfor 170.endfor
171 171
172_PKGTASKS_DATA.files= ${_PKGTASKS_DIR}/files 172_PKGTASKS_DATA.files= ${_PKGTASKS_DIR}/files
173_PKGTASKS_DATAFILES+= ${_PKGTASKS_DATA.files} 173_PKGTASKS_DATAFILES+= ${_PKGTASKS_DATA.files}
174 174
175${_PKGTASKS_DATA.files}: 175${_PKGTASKS_DATA.files}:
176 ${RUN}${MKDIR} ${.TARGET:H:Q} 176 ${RUN}${MKDIR} ${.TARGET:H:Q}
177 ${RUN}exec > ${.TARGET:Q}.tmp 177 ${RUN}exec > ${.TARGET:Q}.tmp
178 ${RUN}set -- args ${_CONF_FILES}; shift; \ 178 ${RUN}set -- args ${_CONF_FILES}; shift; \
179 while ${TEST} "$$#" -gt 0; do \ 179 while ${TEST} "$$#" -gt 0; do \
180 egfile="$$1"; file="$$2"; shift 2; \ 180 egfile="$$1"; file="$$2"; shift 2; \
181 ${ECHO} "# FILE: $$file c $$egfile "${CONF_FILES_MODE:Q} \ 181 ${ECHO} "# FILE: $$file c $$egfile "${CONF_FILES_MODE:Q} \
182 >> ${.TARGET:Q}.tmp; \ 182 >> ${.TARGET:Q}.tmp; \
183 done 183 done
184 ${RUN}set -- args ${_CONF_FILES_PERMS}; shift; \ 184 ${RUN}set -- args ${_CONF_FILES_PERMS}; shift; \
185 while ${TEST} "$$#" -gt 0; do \ 185 while ${TEST} "$$#" -gt 0; do \
186 egfile="$$1"; file="$$2"; \ 186 egfile="$$1"; file="$$2"; \
187 owner="$$3"; group="$$4"; mode="$$5"; shift 5; \ 187 owner="$$3"; group="$$4"; mode="$$5"; shift 5; \
188 ${ECHO} "# FILE: $$file c $$egfile $$mode $$owner $$group" \ 188 ${ECHO} "# FILE: $$file c $$egfile $$mode $$owner $$group" \
189 >> ${.TARGET:Q}.tmp; \ 189 >> ${.TARGET:Q}.tmp; \
190 done 190 done
191 ${RUN}set -- args ${_REQD_FILES}; shift; \ 191 ${RUN}set -- args ${_REQD_FILES}; shift; \
192 while ${TEST} "$$#" -gt 0; do \ 192 while ${TEST} "$$#" -gt 0; do \
193 egfile="$$1"; file="$$2"; shift 2; \ 193 egfile="$$1"; file="$$2"; shift 2; \
194 ${ECHO} "# FILE: $$file cf $$egfile "${REQD_FILES_MODE:Q} \ 194 ${ECHO} "# FILE: $$file cf $$egfile "${REQD_FILES_MODE:Q} \
195 >> ${.TARGET:Q}.tmp; \ 195 >> ${.TARGET:Q}.tmp; \
196 done 196 done
197 ${RUN}set -- args ${_REQD_FILES_PERMS}; shift; \ 197 ${RUN}set -- args ${_REQD_FILES_PERMS}; shift; \
198 while ${TEST} "$$#" -gt 0; do \ 198 while ${TEST} "$$#" -gt 0; do \
199 egfile="$$1"; file="$$2"; \ 199 egfile="$$1"; file="$$2"; \
200 owner="$$3"; group="$$4"; mode="$$5"; shift 5; \ 200 owner="$$3"; group="$$4"; mode="$$5"; shift 5; \
201 ${ECHO} "# FILE: $$file cf $$egfile $$mode $$owner $$group" \ 201 ${ECHO} "# FILE: $$file cf $$egfile $$mode $$owner $$group" \
202 >> ${.TARGET:Q}.tmp; \ 202 >> ${.TARGET:Q}.tmp; \
203 done 203 done
204 ${RUN}set -- args ${__INIT_SCRIPTS}; shift; \ 204 ${RUN}set -- args ${__INIT_SCRIPTS}; shift; \
205 while ${TEST} "$$#" -gt 0; do \ 205 while ${TEST} "$$#" -gt 0; do \
206 egfile="$$1"; file="$$2"; shift 2; \ 206 egfile="$$1"; file="$$2"; shift 2; \
207 ${ECHO} "# FILE: $$file cr $$egfile "${_INIT_SCRIPTS_MODE:Q} \ 207 ${ECHO} "# FILE: $$file cr $$egfile "${_INIT_SCRIPTS_MODE:Q} \
208 >> ${.TARGET:Q}.tmp; \ 208 >> ${.TARGET:Q}.tmp; \
209 done 209 done
210 ${RUN}set -- args ${__INIT_SCRIPTS_PERMS}; shift; \ 210 ${RUN}set -- args ${__INIT_SCRIPTS_PERMS}; shift; \
211 while ${TEST} "$$#" -gt 0; do \ 211 while ${TEST} "$$#" -gt 0; do \
212 egfile="$$1"; file="$$2"; \ 212 egfile="$$1"; file="$$2"; \
213 owner="$$3"; group="$$4"; mode="$$5"; shift 5; \ 213 owner="$$3"; group="$$4"; mode="$$5"; shift 5; \
214 ${ECHO} "# FILE: $$file cr $$egfile $$mode $$owner $$group" \ 214 ${ECHO} "# FILE: $$file cr $$egfile $$mode $$owner $$group" \
215 >> ${.TARGET:Q}.tmp; \ 215 >> ${.TARGET:Q}.tmp; \
216 done 216 done
217 ${RUN}${MV} ${.TARGET:Q}.tmp ${.TARGET:Q} 217 ${RUN}${MV} ${.TARGET:Q}.tmp ${.TARGET:Q}
218 218
219privileged-install-hook: _pkgtasks-files-postinstall-check 219privileged-install-hook: _pkgtasks-files-postinstall-check
220 220
221_pkgtasks-files-postinstall-check: .PHONY 221_pkgtasks-files-postinstall-check: .PHONY
222 ${RUN}set -- args ${_CONF_FILES}; shift; \ 222 ${RUN}set -- args ${_CONF_FILES}; shift; \
223 while ${TEST} "$$#" -gt 0; do \ 223 while ${TEST} "$$#" -gt 0; do \
224 ${TEST} "$$#" -gt 2 || break; \ 224 ${TEST} "$$#" -gt 2 || break; \
225 egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1"; shift 2; \ 225 egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1"; shift 2; \
226 ${TEST} -f "$$egfile" || ${TEST} -c "$$egfile" || \ 226 ${TEST} -f "$$egfile" || ${TEST} -c "$$egfile" || \
227 ${FAIL_MSG} "CONF_FILES $$egfile does not exist."; \ 227 ${FAIL_MSG} "CONF_FILES $$egfile does not exist."; \
228 done 228 done
229 ${RUN}set -- args ${_CONF_FILES_PERMS}; shift; \ 229 ${RUN}set -- args ${_CONF_FILES_PERMS}; shift; \
230 while ${TEST} "$$#" -gt 0; do \ 230 while ${TEST} "$$#" -gt 0; do \
231 ${TEST} "$$#" -gt 5 || break; \ 231 ${TEST} "$$#" -gt 5 || break; \
232 egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1"; shift 5; \ 232 egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1"; shift 5; \
233 ${TEST} -f "$$egfile" || ${TEST} -c "$$egfile" || \ 233 ${TEST} -f "$$egfile" || ${TEST} -c "$$egfile" || \
234 ${FAIL_MSG} "CONF_FILES_PERMS $$egfile does not exist.";\ 234 ${FAIL_MSG} "CONF_FILES_PERMS $$egfile does not exist.";\
235 done 235 done
236 ${RUN}set -- args ${_REQD_FILES}; shift; \ 236 ${RUN}set -- args ${_REQD_FILES}; shift; \
237 while ${TEST} "$$#" -gt 0; do \ 237 while ${TEST} "$$#" -gt 0; do \
238 ${TEST} "$$#" -gt 2 || break; \ 238 ${TEST} "$$#" -gt 2 || break; \
239 egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1"; shift 2; \ 239 egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1"; shift 2; \
240 ${TEST} -f "$$egfile" || ${TEST} -c "$$egfile" || \ 240 ${TEST} -f "$$egfile" || ${TEST} -c "$$egfile" || \
241 ${FAIL_MSG} "REQD_FILES $$egfile does not exist."; \ 241 ${FAIL_MSG} "REQD_FILES $$egfile does not exist."; \
242 done 242 done
243 ${RUN}set -- args ${_REQD_FILES_PERMS}; shift; \ 243 ${RUN}set -- args ${_REQD_FILES_PERMS}; shift; \
244 while ${TEST} "$$#" -gt 0; do \ 244 while ${TEST} "$$#" -gt 0; do \
245 ${TEST} "$$#" -gt 5 || break; \ 245 ${TEST} "$$#" -gt 5 || break; \
246 egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1"; shift 5; \ 246 egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1"; shift 5; \
247 ${TEST} -f "$$egfile" || ${TEST} -c "$$egfile" || \ 247 ${TEST} -f "$$egfile" || ${TEST} -c "$$egfile" || \
248 ${FAIL_MSG} "REQD_FILES_PERMS $$egfile does not exist.";\ 248 ${FAIL_MSG} "REQD_FILES_PERMS $$egfile does not exist.";\
249 done 249 done
250 ${RUN}set -- args ${__INIT_SCRIPTS}; shift; \ 250 ${RUN}set -- args ${__INIT_SCRIPTS}; shift; \
251 while ${TEST} "$$#" -gt 0; do \ 251 while ${TEST} "$$#" -gt 0; do \
252 ${TEST} "$$#" -gt 2 || break; \ 252 ${TEST} "$$#" -gt 2 || break; \
253 egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1"; shift 2; \ 253 egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1"; shift 2; \
254 ${TEST} -f "$$egfile" || ${TEST} -c "$$egfile" || \ 254 ${TEST} -f "$$egfile" || ${TEST} -c "$$egfile" || \
255 ${FAIL_MSG} "REQD_FILES $$egfile does not exist."; \ 255 ${FAIL_MSG} "REQD_FILES $$egfile does not exist."; \
256 done 256 done
257 ${RUN}set -- args ${__INIT_SCRIPTS_PERMS}; shift; \ 257 ${RUN}set -- args ${__INIT_SCRIPTS_PERMS}; shift; \
258 while ${TEST} "$$#" -gt 0; do \ 258 while ${TEST} "$$#" -gt 0; do \
259 ${TEST} "$$#" -gt 5 || break; \ 259 ${TEST} "$$#" -gt 5 || break; \
260 egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1"; shift 5; \ 260 egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1"; shift 5; \
261 ${TEST} -f "$$egfile" || ${TEST} -c "$$egfile" || \ 261 ${TEST} -f "$$egfile" || ${TEST} -c "$$egfile" || \
262 ${FAIL_MSG} "REQD_FILES_PERMS $$egfile does not exist.";\ 262 ${FAIL_MSG} "REQD_FILES_PERMS $$egfile does not exist.";\
263 done 263 done

cvs diff -r1.1 -r1.2 pkgsrc/mk/pkgtasks/permissions.mk (switch to unified diff)

--- pkgsrc/mk/pkgtasks/permissions.mk 2017/06/01 02:06:04 1.1
+++ pkgsrc/mk/pkgtasks/permissions.mk 2017/08/10 05:37:44 1.2
@@ -1,112 +1,112 @@ @@ -1,112 +1,112 @@
1# $NetBSD: permissions.mk,v 1.1 2017/06/01 02:06:04 jlam Exp $ 1# $NetBSD: permissions.mk,v 1.2 2017/08/10 05:37:44 jlam Exp $
2# 2#
3# Copyright (c) 2017 The NetBSD Foundation, Inc. 3# Copyright (c) 2017 The NetBSD Foundation, Inc.
4# All rights reserved. 4# All rights reserved.
5# 5#
6# This code is derived from software contributed to The NetBSD Foundation 6# This code is derived from software contributed to The NetBSD Foundation
7# by Johnny C. Lam. 7# by Johnny C. Lam.
8# 8#
9# Redistribution and use in source and binary forms, with or without 9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions 10# modification, are permitted provided that the following conditions
11# are met: 11# are met:
12# 1. Redistributions of source code must retain the above copyright 12# 1. Redistributions of source code must retain the above copyright
13# notice, this list of conditions and the following disclaimer. 13# notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright 14# 2. Redistributions in binary form must reproduce the above copyright
15# notice, this list of conditions and the following disclaimer in the 15# notice, this list of conditions and the following disclaimer in the
16# documentation and/or other materials provided with the distribution. 16# documentation and/or other materials provided with the distribution.
17# 17#
18# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28# POSSIBILITY OF SUCH DAMAGE. 28# POSSIBILITY OF SUCH DAMAGE.
29 29
30# Generate the data file for the permissions package task. 30# Generate the data file for the permissions package task.
31 31
32# SPECIAL_PERMS 32# SPECIAL_PERMS
33# List of blocks of four words of the following form: 33# List of blocks of four words of the following form:
34# 34#
35# <file> <owner> <group> <mode> 35# <file> <owner> <group> <mode>
36# 36#
37# The <file> (it may be a directory) is changed to be owned by 37# The <file> (it may be a directory) is changed to be owned by
38# <owner>:<group> with <mode> permissions. If <file> is a 38# <owner>:<group> with <mode> permissions. If <file> is a
39# relative path, then it is taken to be relative to ${PREFIX}. 39# relative path, then it is taken to be relative to ${PREFIX}.
40# 40#
41# SPECIAL_PERMS should be used primarily to change permissions of 41# SPECIAL_PERMS should be used primarily to change permissions of
42# files or directories listed in the PLIST. This may be used to 42# files or directories listed in the PLIST. This may be used to
43# ensure certain files are set-uid or to change the ownership of a 43# ensure certain files are set-uid or to change the ownership of a
44# directory. 44# directory.
45# 45#
46_PKG_VARS.pkgtasks+= SPECIAL_PERMS 46_PKG_VARS.pkgtasks+= SPECIAL_PERMS
47SPECIAL_PERMS?= # empty 47SPECIAL_PERMS?= # empty
48 48
49# Trigger pkgtasks dependency if needed. 49# Trigger pkgtasks dependency if needed.
50_PKGTASKS_DATAVARS.permissions= SPECIAL_PERMS 50_PKGTASKS_DATAVARS.permissions= SPECIAL_PERMS
51.for _var_ in ${_PKGTASKS_DATAVARS.permissions} 51.for _var_ in ${_PKGTASKS_DATAVARS.permissions}
52. if !empty(${_var_}) 52. if !empty(${_var_})
53USE_PKGTASKS= yes 53USE_PKGTASKS= yes
54. endif 54. endif
55.endfor 55.endfor
56 56
57# Strip leading "${PREFIX}/" from pathnames. 57# Strip leading "${PREFIX}/" from pathnames.
58_SPECIAL_PERMS= ${SPECIAL_PERMS:S|^${PREFIX}/||g} 58_SPECIAL_PERMS= ${SPECIAL_PERMS:S|^${PREFIX}/||g}
59 59
60# SETUID_ROOT_PERMS 60# SETUID_ROOT_PERMS
61# Convenience variable used to note an executable should be setuid 61# Convenience variable used to note an executable should be setuid
62# root, and should be used as follows: 62# root, and should be used as follows:
63# 63#
64# SPECIAL_PERMS+= /path/to/suidroot ${SETUID_ROOT_PERMS} 64# SPECIAL_PERMS+= /path/to/suidroot ${SETUID_ROOT_PERMS}
65# 65#
66# SETGID_GAMES_PERMS 66# SETGID_GAMES_PERMS
67# Convenience variable used to note an executable should be setgid 67# Convenience variable used to note an executable should be setgid
68# games, and should be used as follows: 68# games, and should be used as follows:
69# 69#
70# SPECIAL_PERMS+= /path/to/sgidgame ${SETGID_GAMES_PERMS} 70# SPECIAL_PERMS+= /path/to/sgidgame ${SETGID_GAMES_PERMS}
71# 71#
72# GAMEDATA_PERMS 72# GAMEDATA_PERMS
73# GAMEDIR_PERMS 73# GAMEDIR_PERMS
74# Convenience variables for files or directories that should be 74# Convenience variables for files or directories that should be
75# accessible by executables that are setgid games. Since such 75# accessible by executables that are setgid games. Since such
76# files or directories should normally live under ${VARBASE}, 76# files or directories should normally live under ${VARBASE},
77# these definitions should be used roughly as follows: 77# these definitions should be used roughly as follows:
78# 78#
79# REQD_DIRS_PERMS+= /path/to/scoredir ${GAMEDIR_PERMS} 79# REQD_DIRS_PERMS+= /path/to/scoredir ${GAMEDIR_PERMS}
80# REQD_FILES_PERMS+= /dev/null /path/to/scorefile ${GAMEDATA_PERMS} 80# REQD_FILES_PERMS+= /dev/null /path/to/scorefile ${GAMEDATA_PERMS}
81# 81#
82# Keywords: setuid setgid st_mode perms 82# Keywords: setuid setgid st_mode perms
83# 83#
84_SYS_VARS.pkgtasks+= SETUID_ROOT_PERMS SETGID_GAMES_PERMS \ 84_SYS_VARS.pkgtasks+= SETUID_ROOT_PERMS SETGID_GAMES_PERMS \
85 GAMEDATA_PERMS GAMEDIR_PERMS 85 GAMEDATA_PERMS GAMEDIR_PERMS
86SETUID_ROOT_PERMS?= ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 4511 86SETUID_ROOT_PERMS?= ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 4511
87SETGID_GAMES_PERMS?= ${GAMES_USER} ${GAMES_GROUP} ${GAMEMODE} 87SETGID_GAMES_PERMS?= ${GAMES_USER} ${GAMES_GROUP} ${GAMEMODE}
88GAMEDATA_PERMS?= ${GAMES_USER} ${GAMES_GROUP} ${GAMEDATAMODE} 88GAMEDATA_PERMS?= ${GAMES_USER} ${GAMES_GROUP} ${GAMEDATAMODE}
89GAMEDIR_PERMS?= ${GAMES_USER} ${GAMES_GROUP} ${GAMEDIRMODE} 89GAMEDIR_PERMS?= ${GAMES_USER} ${GAMES_GROUP} ${GAMEDIRMODE}
90 90
91# Assert that the variables have the right number of words. 91# ASSERT: The variables have the right number of words.
92.for _var_ in SPECIAL_PERMS 92.for _var_ in SPECIAL_PERMS
93. if empty(${_var_}) || empty(${_var_}:C/.*/4/:M*:S/4 4 4 4//gW) 93. if empty(${_var_}) || empty(${_var_}:C/.*/4/:M*:S/4 4 4 4//gW)
94# ${_var_} has a multiple of 4 words. 94# ${_var_} has a multiple of 4 words.
95. else 95. else
96PKG_FAIL_REASON+= ${_var_:Q}" must have a multiple of 4 words." 96PKG_FAIL_REASON+= ${_var_:Q}" must have a multiple of 4 words."
97. endif 97. endif
98.endfor 98.endfor
99 99
100_PKGTASKS_DATA.permissions= ${_PKGTASKS_DIR}/permissions 100_PKGTASKS_DATA.permissions= ${_PKGTASKS_DIR}/permissions
101_PKGTASKS_DATAFILES+= ${_PKGTASKS_DATA.permissions} 101_PKGTASKS_DATAFILES+= ${_PKGTASKS_DATA.permissions}
102 102
103${_PKGTASKS_DATA.permissions}: 103${_PKGTASKS_DATA.permissions}:
104 ${RUN}${MKDIR} ${.TARGET:H:Q} 104 ${RUN}${MKDIR} ${.TARGET:H:Q}
105 ${RUN}exec > ${.TARGET}.tmp 105 ${RUN}exec > ${.TARGET}.tmp
106 ${RUN}set -- args ${_SPECIAL_PERMS}; shift; \ 106 ${RUN}set -- args ${_SPECIAL_PERMS}; shift; \
107 while ${TEST} "$$#" -gt 0; do \ 107 while ${TEST} "$$#" -gt 0; do \
108 path="$$1"; owner="$$2"; group="$$3"; mode="$$4"; shift 4; \ 108 path="$$1"; owner="$$2"; group="$$3"; mode="$$4"; shift 4; \
109 ${ECHO} "# PERMS: $$path $$mode $$owner $$group" \ 109 ${ECHO} "# PERMS: $$path $$mode $$owner $$group" \
110 >> ${.TARGET}.tmp; \ 110 >> ${.TARGET}.tmp; \
111 done 111 done
112 ${RUN}${MV} ${.TARGET:Q}.tmp ${.TARGET:Q} 112 ${RUN}${MV} ${.TARGET:Q}.tmp ${.TARGET:Q}