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 (expand / 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,14 +1,14 @@ @@ -1,14 +1,14 @@
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
@@ -85,28 +85,28 @@ _PKGTASKS_DATAVARS.directories= \ @@ -85,28 +85,28 @@ _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

cvs diff -r1.5 -r1.6 pkgsrc/mk/pkgtasks/files.mk (expand / 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,14 +1,14 @@ @@ -1,14 +1,14 @@
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
@@ -97,28 +97,28 @@ _PKGTASKS_DATAVARS.files+= \ @@ -97,28 +97,28 @@ _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
@@ -148,29 +148,29 @@ PKG_FAIL_REASON+= ${t:Q}" is liste @@ -148,29 +148,29 @@ PKG_FAIL_REASON+= ${t:Q}" is liste
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}

cvs diff -r1.1 -r1.2 pkgsrc/mk/pkgtasks/permissions.mk (expand / 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,14 +1,14 @@ @@ -1,14 +1,14 @@
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
@@ -78,27 +78,27 @@ _SPECIAL_PERMS= ${SPECIAL_PERMS:S|^${PR @@ -78,27 +78,27 @@ _SPECIAL_PERMS= ${SPECIAL_PERMS:S|^${PR
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}