| @@ -1,385 +1,389 @@ | | | @@ -1,385 +1,389 @@ |
1 | # $NetBSD: install.mk,v 1.71 2017/08/07 15:49:44 jlam Exp $ | | 1 | # $NetBSD: install.mk,v 1.72 2017/08/08 17:17:25 jlam Exp $ |
2 | # | | 2 | # |
3 | # This file provides the code for the "install" phase. | | 3 | # This file provides the code for the "install" phase. |
4 | # | | 4 | # |
5 | # Public targets: | | 5 | # Public targets: |
6 | # | | 6 | # |
7 | # stage-install: | | 7 | # stage-install: |
8 | # Installs the package files into LOCALBASE or ${DESTDIR}${LOCALBASE}. | | 8 | # Installs the package files into LOCALBASE or ${DESTDIR}${LOCALBASE}. |
9 | # | | 9 | # |
10 | | | 10 | |
11 | # Interface for other infrastructure components: | | 11 | # Interface for other infrastructure components: |
12 | # | | 12 | # |
13 | # Hooks for use by the infrastructure: | | 13 | # Hooks for use by the infrastructure: |
14 | # | | 14 | # |
15 | # privileged-install-hook: | | 15 | # privileged-install-hook: |
16 | # This hook is placed after the package has been installed, | | 16 | # This hook is placed after the package has been installed, |
17 | # before leaving the privileged mode. | | 17 | # before leaving the privileged mode. |
18 | # | | 18 | # |
19 | # unprivileged-install-hook: | | 19 | # unprivileged-install-hook: |
20 | # This hook is placed _before_ switching to privileged mode | | 20 | # This hook is placed _before_ switching to privileged mode |
21 | # in order to install the package. | | 21 | # in order to install the package. |
22 | # | | 22 | # |
23 | | | 23 | |
24 | # === User-settable variables === | | 24 | # === User-settable variables === |
25 | # | | 25 | # |
26 | # INSTALL_UNSTRIPPED | | 26 | # INSTALL_UNSTRIPPED |
27 | # If "yes", all binaries and shared libraries are installed | | 27 | # If "yes", all binaries and shared libraries are installed |
28 | # unstripped. Otherwise they are stripped while being installed. | | 28 | # unstripped. Otherwise they are stripped while being installed. |
29 | # This option is not supported by all packages. | | 29 | # This option is not supported by all packages. |
30 | # | | 30 | # |
31 | # STRIP_DEBUG | | 31 | # STRIP_DEBUG |
32 | # If set to "yes", call ${STRIP} -g to remove debug information | | 32 | # If set to "yes", call ${STRIP} -g to remove debug information |
33 | # from all files. The symbol tables are still preserved. | | 33 | # from all files. The symbol tables are still preserved. |
34 | # | | 34 | # |
35 | # Keywords: strip unstripped | | 35 | # Keywords: strip unstripped |
36 | # | | 36 | # |
37 | # === Package-settable variables === | | 37 | # === Package-settable variables === |
38 | # | | 38 | # |
39 | # INSTALLATION_DIRS | | 39 | # INSTALLATION_DIRS |
40 | # A list of directories that should be created at the very | | 40 | # A list of directories that should be created at the very |
41 | # beginning of the install phase. These directories MUST either | | 41 | # beginning of the install phase. These directories MUST either |
42 | # be paths that contain a leading {PREFIX}/ or be relative | | 42 | # be paths that contain a leading {PREFIX}/ or be relative |
43 | # paths. As a convenience, a leading gnu/ is transformed to | | 43 | # paths. As a convenience, a leading gnu/ is transformed to |
44 | # ${PKGGNUDIR} and a leading man/ is transformed to ${PKGMANDIR}, | | 44 | # ${PKGGNUDIR} and a leading man/ is transformed to ${PKGMANDIR}, |
45 | # to save package authors from typing too much. | | 45 | # to save package authors from typing too much. |
46 | # | | 46 | # |
47 | # AUTO_MKDIRS | | 47 | # AUTO_MKDIRS |
48 | # INSTALLATION_DIRS_FROM_PLIST | | 48 | # INSTALLATION_DIRS_FROM_PLIST |
49 | # In most (or even all?) cases the PLIST files in the package | | 49 | # In most (or even all?) cases the PLIST files in the package |
50 | # directory already contain all directories that are needed. | | 50 | # directory already contain all directories that are needed. |
51 | # When this variable is set to "yes", all directories mentioned | | 51 | # When this variable is set to "yes", all directories mentioned |
52 | # in the PLIST files will be created like in INSTALLATION_DIRS. | | 52 | # in the PLIST files will be created like in INSTALLATION_DIRS. |
53 | # | | 53 | # |
54 | # DESTDIR_VARNAME | | 54 | # DESTDIR_VARNAME |
55 | # A variable name that should be set as staged installation location | | 55 | # A variable name that should be set as staged installation location |
56 | # presented as ${DESTDIR} at install phase. | | 56 | # presented as ${DESTDIR} at install phase. |
57 | # "DESTDIR" is set by default. | | 57 | # "DESTDIR" is set by default. |
58 | | | 58 | |
59 | ###################################################################### | | 59 | ###################################################################### |
60 | ### install (PUBLIC) | | 60 | ### install (PUBLIC) |
61 | ###################################################################### | | 61 | ###################################################################### |
62 | ### install is a public target to install the package. It will | | 62 | ### install is a public target to install the package. It will |
63 | ### acquire elevated privileges just-in-time. | | 63 | ### acquire elevated privileges just-in-time. |
64 | ### | | 64 | ### |
65 | _INSTALL_TARGETS+= check-vulnerable | | 65 | _INSTALL_TARGETS+= check-vulnerable |
66 | _INSTALL_TARGETS+= ${_PKGSRC_BUILD_TARGETS} | | 66 | _INSTALL_TARGETS+= ${_PKGSRC_BUILD_TARGETS} |
67 | _INSTALL_TARGETS+= acquire-install-lock | | 67 | _INSTALL_TARGETS+= acquire-install-lock |
68 | _INSTALL_TARGETS+= ${_COOKIE.install} | | 68 | _INSTALL_TARGETS+= ${_COOKIE.install} |
69 | _INSTALL_TARGETS+= release-install-lock | | 69 | _INSTALL_TARGETS+= release-install-lock |
70 | | | 70 | |
71 | .PHONY: stage-install | | 71 | .PHONY: stage-install |
72 | .if !target(stage-install) | | 72 | .if !target(stage-install) |
73 | . if exists(${_COOKIE.install}) | | 73 | . if exists(${_COOKIE.install}) |
74 | stage-install: | | 74 | stage-install: |
75 | @${DO_NADA} | | 75 | @${DO_NADA} |
76 | . elif defined(_PKGSRC_BARRIER) | | 76 | . elif defined(_PKGSRC_BARRIER) |
77 | stage-install: ${_INSTALL_TARGETS} | | 77 | stage-install: ${_INSTALL_TARGETS} |
78 | . else | | 78 | . else |
79 | stage-install: barrier | | 79 | stage-install: barrier |
80 | . endif | | 80 | . endif |
81 | .endif | | 81 | .endif |
82 | | | 82 | |
83 | .PHONY: acquire-install-lock release-install-lock | | 83 | .PHONY: acquire-install-lock release-install-lock |
84 | acquire-install-lock: acquire-lock | | 84 | acquire-install-lock: acquire-lock |
85 | release-install-lock: release-lock | | 85 | release-install-lock: release-lock |
86 | | | 86 | |
87 | .if exists(${_COOKIE.install}) | | 87 | .if exists(${_COOKIE.install}) |
88 | ${_COOKIE.install}: | | 88 | ${_COOKIE.install}: |
89 | @${DO_NADA} | | 89 | @${DO_NADA} |
90 | .else | | 90 | .else |
91 | ${_COOKIE.install}: real-install | | 91 | ${_COOKIE.install}: real-install |
92 | .endif | | 92 | .endif |
93 | | | 93 | |
94 | ###################################################################### | | 94 | ###################################################################### |
95 | ### real-install (PRIVATE) | | 95 | ### real-install (PRIVATE) |
96 | ###################################################################### | | 96 | ###################################################################### |
97 | ### real-install is a helper target onto which one can hook all of the | | 97 | ### real-install is a helper target onto which one can hook all of the |
98 | ### targets that do the actual installing of the built objects. | | 98 | ### targets that do the actual installing of the built objects. |
99 | ### | | 99 | ### |
100 | _REAL_INSTALL_TARGETS+= install-check-interactive | | 100 | _REAL_INSTALL_TARGETS+= install-check-interactive |
101 | _REAL_INSTALL_TARGETS+= install-check-version | | 101 | _REAL_INSTALL_TARGETS+= install-check-version |
102 | _REAL_INSTALL_TARGETS+= install-message | | 102 | _REAL_INSTALL_TARGETS+= install-message |
103 | _REAL_INSTALL_TARGETS+= stage-install-vars | | 103 | _REAL_INSTALL_TARGETS+= stage-install-vars |
104 | _REAL_INSTALL_TARGETS+= unprivileged-install-hook | | 104 | _REAL_INSTALL_TARGETS+= unprivileged-install-hook |
105 | _REAL_INSTALL_TARGETS+= install-all | | 105 | _REAL_INSTALL_TARGETS+= install-all |
106 | _REAL_INSTALL_TARGETS+= install-cookie | | 106 | _REAL_INSTALL_TARGETS+= install-cookie |
107 | | | 107 | |
108 | .PHONY: real-install | | 108 | .PHONY: real-install |
109 | real-install: ${_REAL_INSTALL_TARGETS} | | 109 | real-install: ${_REAL_INSTALL_TARGETS} |
110 | | | 110 | |
111 | .PHONY: install-message | | 111 | .PHONY: install-message |
112 | install-message: | | 112 | install-message: |
113 | @${PHASE_MSG} "Installing for ${PKGNAME}" | | 113 | @${PHASE_MSG} "Installing for ${PKGNAME}" |
114 | | | 114 | |
115 | ###################################################################### | | 115 | ###################################################################### |
116 | ### install-check-interactive (PRIVATE) | | 116 | ### install-check-interactive (PRIVATE) |
117 | ###################################################################### | | 117 | ###################################################################### |
118 | ### install-check-interactive checks whether we must do an interactive | | 118 | ### install-check-interactive checks whether we must do an interactive |
119 | ### install or not. | | 119 | ### install or not. |
120 | ### | | 120 | ### |
121 | install-check-interactive: .PHONY | | 121 | install-check-interactive: .PHONY |
122 | .if !empty(INTERACTIVE_STAGE:Minstall) && defined(BATCH) | | 122 | .if !empty(INTERACTIVE_STAGE:Minstall) && defined(BATCH) |
123 | @${ERROR_MSG} "The installation stage of this package requires user interaction" | | 123 | @${ERROR_MSG} "The installation stage of this package requires user interaction" |
124 | @${ERROR_MSG} "Please install manually with:" | | 124 | @${ERROR_MSG} "Please install manually with:" |
125 | @${ERROR_MSG} " \"cd ${.CURDIR} && ${MAKE} install\"" | | 125 | @${ERROR_MSG} " \"cd ${.CURDIR} && ${MAKE} install\"" |
126 | ${RUN} ${FALSE} | | 126 | ${RUN} ${FALSE} |
127 | .else | | 127 | .else |
128 | @${DO_NADA} | | 128 | @${DO_NADA} |
129 | .endif | | 129 | .endif |
130 | | | 130 | |
131 | .PHONY: unprivileged-install-hook | | 131 | .PHONY: unprivileged-install-hook |
132 | unprivileged-install-hook: | | 132 | unprivileged-install-hook: |
133 | @${DO_NADA} | | 133 | @${DO_NADA} |
134 | | | 134 | |
135 | ###################################################################### | | 135 | ###################################################################### |
136 | ### install-check-version (PRIVATE) | | 136 | ### install-check-version (PRIVATE) |
137 | ###################################################################### | | 137 | ###################################################################### |
138 | ### install-check-version will verify that the built package located in | | 138 | ### install-check-version will verify that the built package located in |
139 | ### ${WRKDIR} matches the version specified in the package Makefile. | | 139 | ### ${WRKDIR} matches the version specified in the package Makefile. |
140 | ### This is a check against stale work directories. | | 140 | ### This is a check against stale work directories. |
141 | ### | | 141 | ### |
142 | .PHONY: install-check-version | | 142 | .PHONY: install-check-version |
143 | install-check-version: ${_COOKIE.extract} | | 143 | install-check-version: ${_COOKIE.extract} |
144 | ${RUN} \ | | 144 | ${RUN} \ |
145 | extractname=`${CAT} ${_COOKIE.extract}`; \ | | 145 | extractname=`${CAT} ${_COOKIE.extract}`; \ |
146 | pkgname=${PKGNAME}; \ | | 146 | pkgname=${PKGNAME}; \ |
147 | case "$$extractname" in \ | | 147 | case "$$extractname" in \ |
148 | "") ${WARNING_MSG} "${WRKDIR} may contain an older version of ${PKGBASE}" ;; \ | | 148 | "") ${WARNING_MSG} "${WRKDIR} may contain an older version of ${PKGBASE}" ;; \ |
149 | "$$pkgname") ;; \ | | 149 | "$$pkgname") ;; \ |
150 | *) ${WARNING_MSG} "Package version $$extractname in ${WRKDIR}"; \ | | 150 | *) ${WARNING_MSG} "Package version $$extractname in ${WRKDIR}"; \ |
151 | ${WARNING_MSG} "Current version $$pkgname in ${PKGPATH}"; \ | | 151 | ${WARNING_MSG} "Current version $$pkgname in ${PKGPATH}"; \ |
152 | ${WARNING_MSG} "Cleaning and rebuilding $$pkgname..."; \ | | 152 | ${WARNING_MSG} "Cleaning and rebuilding $$pkgname..."; \ |
153 | ${RECURSIVE_MAKE} ${MAKEFLAGS} clean; \ | | 153 | ${RECURSIVE_MAKE} ${MAKEFLAGS} clean; \ |
154 | ${RECURSIVE_MAKE} ${MAKEFLAGS} build ;; \ | | 154 | ${RECURSIVE_MAKE} ${MAKEFLAGS} build ;; \ |
155 | esac | | 155 | esac |
156 | | | 156 | |
157 | ###################################################################### | | 157 | ###################################################################### |
158 | ### install-all, su-install-all (PRIVATE) | | 158 | ### install-all, su-install-all (PRIVATE) |
159 | ###################################################################### | | 159 | ###################################################################### |
160 | ### install-all is a helper target to run the install target of | | 160 | ### install-all is a helper target to run the install target of |
161 | ### the built software, register the software installation, and run | | 161 | ### the built software, register the software installation, and run |
162 | ### some sanity checks. | | 162 | ### some sanity checks. |
163 | ### | | 163 | ### |
164 | _INSTALL_ALL_TARGETS+= install-check-umask | | 164 | _INSTALL_ALL_TARGETS+= install-check-umask |
165 | .if empty(CHECK_FILES:M[nN][oO]) && !empty(CHECK_FILES_SUPPORTED:M[Yy][Ee][Ss]) | | 165 | .if empty(CHECK_FILES:M[nN][oO]) && !empty(CHECK_FILES_SUPPORTED:M[Yy][Ee][Ss]) |
166 | _INSTALL_ALL_TARGETS+= check-files-pre | | 166 | _INSTALL_ALL_TARGETS+= check-files-pre |
167 | .endif | | 167 | .endif |
168 | _INSTALL_ALL_TARGETS+= install-makedirs | | 168 | _INSTALL_ALL_TARGETS+= install-makedirs |
169 | .if defined(INSTALLATION_DIRS_FROM_PLIST) && \ | | 169 | .if defined(INSTALLATION_DIRS_FROM_PLIST) && \ |
170 | !empty(INSTALLATION_DIRS_FROM_PLIST:M[Yy][Ee][Ss]) | | 170 | !empty(INSTALLATION_DIRS_FROM_PLIST:M[Yy][Ee][Ss]) |
171 | _INSTALL_ALL_TARGETS+= install-dirs-from-PLIST | | 171 | _INSTALL_ALL_TARGETS+= install-dirs-from-PLIST |
172 | .elif defined(AUTO_MKDIRS) && !empty(AUTO_MKDIRS:M[Yy][Ee][Ss]) | | 172 | .elif defined(AUTO_MKDIRS) && !empty(AUTO_MKDIRS:M[Yy][Ee][Ss]) |
173 | _INSTALL_ALL_TARGETS+= install-dirs-from-PLIST | | 173 | _INSTALL_ALL_TARGETS+= install-dirs-from-PLIST |
174 | .endif | | 174 | .endif |
175 | _INSTALL_ALL_TARGETS+= pre-install | | 175 | _INSTALL_ALL_TARGETS+= pre-install |
176 | _INSTALL_ALL_TARGETS+= do-install | | 176 | _INSTALL_ALL_TARGETS+= do-install |
177 | _INSTALL_ALL_TARGETS+= post-install | | 177 | _INSTALL_ALL_TARGETS+= post-install |
178 | _INSTALL_ALL_TARGETS+= plist | | 178 | _INSTALL_ALL_TARGETS+= plist |
179 | .if !empty(STRIP_DEBUG:M[Yy][Ee][Ss]) | | 179 | .if !empty(STRIP_DEBUG:M[Yy][Ee][Ss]) |
180 | _INSTALL_ALL_TARGETS+= install-strip-debug | | 180 | _INSTALL_ALL_TARGETS+= install-strip-debug |
181 | .endif | | 181 | .endif |
182 | _INSTALL_ALL_TARGETS+= install-doc-handling | | 182 | _INSTALL_ALL_TARGETS+= install-doc-handling |
183 | .if ${_USE_NEW_PKGINSTALL:Uno} == "no" | | 183 | .if ${_USE_NEW_PKGINSTALL:Uno} == "no" |
184 | _INSTALL_ALL_TARGETS+= install-script-data | | 184 | _INSTALL_ALL_TARGETS+= install-script-data |
185 | .endif | | 185 | .endif |
186 | .if empty(CHECK_FILES:M[nN][oO]) && !empty(CHECK_FILES_SUPPORTED:M[Yy][Ee][Ss]) | | 186 | .if empty(CHECK_FILES:M[nN][oO]) && !empty(CHECK_FILES_SUPPORTED:M[Yy][Ee][Ss]) |
187 | _INSTALL_ALL_TARGETS+= check-files-post | | 187 | _INSTALL_ALL_TARGETS+= check-files-post |
188 | .endif | | 188 | .endif |
189 | _INSTALL_ALL_TARGETS+= _pkgformat-generate-metadata | | 189 | _INSTALL_ALL_TARGETS+= _pkgformat-generate-metadata |
190 | _INSTALL_ALL_TARGETS+= privileged-install-hook | | 190 | _INSTALL_ALL_TARGETS+= privileged-install-hook |
191 | _INSTALL_ALL_TARGETS+= error-check | | 191 | _INSTALL_ALL_TARGETS+= error-check |
192 | | | 192 | |
193 | .PHONY: install-all su-install-all | | 193 | .PHONY: install-all su-install-all |
194 | . if !empty(_MAKE_INSTALL_AS_ROOT:M[Yy][Ee][Ss]) | | 194 | . if !empty(_MAKE_INSTALL_AS_ROOT:M[Yy][Ee][Ss]) |
195 | install-all: su-target | | 195 | install-all: su-target |
196 | . else | | 196 | . else |
197 | install-all: su-install-all | | 197 | install-all: su-install-all |
198 | . endif | | 198 | . endif |
199 | su-install-all: ${_INSTALL_ALL_TARGETS} | | 199 | su-install-all: ${_INSTALL_ALL_TARGETS} |
200 | | | 200 | |
201 | ###################################################################### | | 201 | ###################################################################### |
202 | ### install-check-umask (PRIVATE) | | 202 | ### install-check-umask (PRIVATE) |
203 | ###################################################################### | | 203 | ###################################################################### |
204 | ### install-check-umask tests whether the umask is properly set and | | 204 | ### install-check-umask tests whether the umask is properly set and |
205 | ### emits a non-fatal warning otherwise. | | 205 | ### emits a non-fatal warning otherwise. |
206 | ### | | 206 | ### |
207 | .PHONY: install-check-umask | | 207 | .PHONY: install-check-umask |
208 | install-check-umask: | | 208 | install-check-umask: |
209 | ${RUN} \ | | 209 | ${RUN} \ |
210 | umask=`${SH} -c umask`; \ | | 210 | umask=`${SH} -c umask`; \ |
211 | if [ "$$umask" -ne ${DEF_UMASK} ]; then \ | | 211 | if [ "$$umask" -ne ${DEF_UMASK} ]; then \ |
212 | ${WARNING_MSG} "Your umask is \`\`$$umask''."; \ | | 212 | ${WARNING_MSG} "Your umask is \`\`$$umask''."; \ |
213 | ${WARNING_MSG} "If this is not desired, set it to an appropriate value (${DEF_UMASK}) and install"; \ | | 213 | ${WARNING_MSG} "If this is not desired, set it to an appropriate value (${DEF_UMASK}) and install"; \ |
214 | ${WARNING_MSG} "this package again by \`\`${MAKE} deinstall reinstall''."; \ | | 214 | ${WARNING_MSG} "this package again by \`\`${MAKE} deinstall reinstall''."; \ |
215 | fi | | 215 | fi |
216 | | | 216 | |
217 | ###################################################################### | | 217 | ###################################################################### |
218 | ### install-makedirs (PRIVATE) | | 218 | ### install-makedirs (PRIVATE) |
219 | ###################################################################### | | 219 | ###################################################################### |
220 | ### install-makedirs is a target to create directories expected to | | 220 | ### install-makedirs is a target to create directories expected to |
221 | ### exist prior to installation. The package is supposed to create | | 221 | ### exist prior to installation. The package is supposed to create |
222 | ### all directories not listed in INSTALLATION_DIRS. | | 222 | ### all directories not listed in INSTALLATION_DIRS. |
223 | ### | | 223 | ### |
224 | | | 224 | |
225 | # A shell command that creates the directory ${DESTDIR}${PREFIX}/$$dir | | 225 | # A shell command that creates the directory ${DESTDIR}${PREFIX}/$$dir |
226 | # with appropriate permissions and ownership. | | 226 | # with appropriate permissions and ownership. |
227 | # | | 227 | # |
228 | _INSTALL_ONE_DIR_CMD= { \ | | 228 | _INSTALL_ONE_DIR_CMD= { \ |
229 | ddir="${DESTDIR}${PREFIX}/$$dir"; \ | | 229 | ddir="${DESTDIR}${PREFIX}/$$dir"; \ |
230 | [ ! -f "$$ddir" ] || ${FAIL_MSG} "[install.mk] $$ddir should be a directory, but is a file."; \ | | 230 | [ ! -f "$$ddir" ] || ${FAIL_MSG} "[install.mk] $$ddir should be a directory, but is a file."; \ |
231 | case "$$dir" in \ | | 231 | case "$$dir" in \ |
232 | *bin|*bin/*|*libexec|*libexec/*) \ | | 232 | *bin|*bin/*|*libexec|*libexec/*) \ |
233 | ${INSTALL_PROGRAM_DIR} "$$ddir" ;; \ | | 233 | ${INSTALL_PROGRAM_DIR} "$$ddir" ;; \ |
234 | ${PKGMANDIR}/*) \ | | 234 | ${PKGMANDIR}/*) \ |
235 | ${INSTALL_MAN_DIR} "$$ddir" ;; \ | | 235 | ${INSTALL_MAN_DIR} "$$ddir" ;; \ |
236 | *) \ | | 236 | *) \ |
237 | ${INSTALL_DATA_DIR} "$$ddir" ;; \ | | 237 | ${INSTALL_DATA_DIR} "$$ddir" ;; \ |
238 | esac; \ | | 238 | esac; \ |
239 | } | | 239 | } |
240 | | | 240 | |
241 | # _INSTALLATION_DIRS | | 241 | # _INSTALLATION_DIRS |
242 | # Contains the items listed in ${INSTALLATION_DIRS} with the | | 242 | # Contains the items listed in ${INSTALLATION_DIRS} with the |
243 | # following transformations performed, in order: | | 243 | # following transformations performed, in order: |
244 | # | | 244 | # |
245 | # 1. Leading "${PREFIX}/" is stripped. | | 245 | # 1. Leading "${PREFIX}/" is stripped. |
246 | # 2. Leading "gnu/" is transformed into "${PKGGNUDIR}". | | 246 | # 2. Leading "gnu/" is transformed into "${PKGGNUDIR}". |
247 | # 3. Leading "man/" is transformed into "${PKGMANDIR}/". | | 247 | # 3. Leading "man/" is transformed into "${PKGMANDIR}/". |
248 | # | | 248 | # |
249 | # ASSERT: Paths listed in ${_INSTALLATION_DIRS} must be relative paths. | | 249 | # Check that paths listed in ${_INSTALLATION_DIRS} are relative paths. |
| | | 250 | # This can't be an assertion because some variables used when listing |
| | | 251 | # directories in INSTALLATION_DIRS are not expanded until they are |
| | | 252 | # used. |
250 | # | | 253 | # |
251 | _INSTALLATION_DIRS= ${INSTALLATION_DIRS:C,^${PREFIX}/,,:C,^gnu/,${PKGGNUDIR},:C,^man/,${PKGMANDIR}/,} | | 254 | _INSTALLATION_DIRS= ${INSTALLATION_DIRS:C,^${PREFIX}/,,:C,^gnu/,${PKGGNUDIR},:C,^man/,${PKGMANDIR}/,} |
252 | .if !empty(_INSTALLATION_DIRS:M/*) | | | |
253 | PKG_FAIL_REASON+= "INSTALLATION_DIRS items must begin with "${PREFIX:Q}" or be relative paths." | | | |
254 | .endif | | | |
255 | | | 255 | |
256 | .PHONY: install-makedirs | | 256 | .PHONY: install-makedirs |
257 | install-makedirs: | | 257 | install-makedirs: |
258 | ${RUN} ${INSTALL_DATA_DIR} ${DESTDIR}${PREFIX} | | 258 | ${RUN} ${INSTALL_DATA_DIR} ${DESTDIR}${PREFIX} |
259 | .if defined(INSTALLATION_DIRS) && !empty(INSTALLATION_DIRS) | | 259 | .if defined(INSTALLATION_DIRS) && !empty(INSTALLATION_DIRS) |
260 | @${STEP_MSG} "Creating installation directories" | | 260 | @${STEP_MSG} "Creating installation directories" |
261 | ${RUN} \ | | 261 | ${RUN} set -- args ${_INSTALLATION_DIRS}; shift; \ |
262 | for dir in ${_INSTALLATION_DIRS}; do \ | | 262 | while ${TEST} "$$#" -gt 0; do \ |
263 | ${_INSTALL_ONE_DIR_CMD}; \ | | 263 | dir="$$1"; shift; \ |
| | | 264 | case "$$dir" in \ |
| | | 265 | /*) ${FAIL_MSG} "INSTALLATION_DIRS: $$dir must be in "${PREFIX:Q}"." ;; \ |
| | | 266 | *) ${_INSTALL_ONE_DIR_CMD} ;; \ |
| | | 267 | esac; \ |
264 | done | | 268 | done |
265 | .endif # INSTALLATION_DIRS | | 269 | .endif # INSTALLATION_DIRS |
266 | | | 270 | |
267 | # Creates the directories for all files that are mentioned in the static | | 271 | # Creates the directories for all files that are mentioned in the static |
268 | # PLIST files of the package, to make the declaration of | | 272 | # PLIST files of the package, to make the declaration of |
269 | # INSTALLATION_DIRS redundant in some cases. | | 273 | # INSTALLATION_DIRS redundant in some cases. |
270 | # | | 274 | # |
271 | # To enable this, the variable INSTALLATION_DIRS_FROM_PLIST must be set | | 275 | # To enable this, the variable INSTALLATION_DIRS_FROM_PLIST must be set |
272 | # to "yes". | | 276 | # to "yes". |
273 | # | | 277 | # |
274 | .PHONY: install-dirs-from-PLIST | | 278 | .PHONY: install-dirs-from-PLIST |
275 | install-dirs-from-PLIST: | | 279 | install-dirs-from-PLIST: |
276 | @${STEP_MSG} "Creating installation directories from PLIST files" | | 280 | @${STEP_MSG} "Creating installation directories from PLIST files" |
277 | ${RUN} \ | | 281 | ${RUN} \ |
278 | ${CAT} ${PLIST_SRC} \ | | 282 | ${CAT} ${PLIST_SRC} \ |
279 | | sed -n \ | | 283 | | sed -n \ |
280 | -e 's,\\,\\\\,' \ | | 284 | -e 's,\\,\\\\,' \ |
281 | -e 's,^gnu/man/,${PKGGNUDIR}${PKGMANDIR}/,' \ | | 285 | -e 's,^gnu/man/,${PKGGNUDIR}${PKGMANDIR}/,' \ |
282 | -e 's,^gnu/,${PKGGNUDIR},' \ | | 286 | -e 's,^gnu/,${PKGGNUDIR},' \ |
283 | -e 's,^man/,${PKGMANDIR}/,' \ | | 287 | -e 's,^man/,${PKGMANDIR}/,' \ |
284 | -e 's,^info/,${PKGINFODIR}/,' \ | | 288 | -e 's,^info/,${PKGINFODIR}/,' \ |
285 | -e 's,^share/locale/,${PKGLOCALEDIR}/locale/,' \ | | 289 | -e 's,^share/locale/,${PKGLOCALEDIR}/locale/,' \ |
286 | -e 's,^\([^$$@]*\)/[^/]*$$,\1,p' \ | | 290 | -e 's,^\([^$$@]*\)/[^/]*$$,\1,p' \ |
287 | | while read dir; do \ | | 291 | | while read dir; do \ |
288 | ${_INSTALL_ONE_DIR_CMD}; \ | | 292 | ${_INSTALL_ONE_DIR_CMD}; \ |
289 | done | | 293 | done |
290 | | | 294 | |
291 | ###################################################################### | | 295 | ###################################################################### |
292 | ### pre-install, do-install, post-install (PUBLIC, override) | | 296 | ### pre-install, do-install, post-install (PUBLIC, override) |
293 | ###################################################################### | | 297 | ###################################################################### |
294 | ### {pre,do,post}-install are the heart of the package-customizable | | 298 | ### {pre,do,post}-install are the heart of the package-customizable |
295 | ### install targets, and may be overridden within a package Makefile. | | 299 | ### install targets, and may be overridden within a package Makefile. |
296 | ### | | 300 | ### |
297 | .PHONY: pre-install do-install post-install | | 301 | .PHONY: pre-install do-install post-install |
298 | | | 302 | |
299 | INSTALL_DIRS?= ${BUILD_DIRS} | | 303 | INSTALL_DIRS?= ${BUILD_DIRS} |
300 | INSTALL_MAKE_FLAGS?= # none | | 304 | INSTALL_MAKE_FLAGS?= # none |
301 | INSTALL_TARGET?= install ${USE_IMAKE:D${NO_INSTALL_MANPAGES:D:Uinstall.man}} | | 305 | INSTALL_TARGET?= install ${USE_IMAKE:D${NO_INSTALL_MANPAGES:D:Uinstall.man}} |
302 | DESTDIR_VARNAME?= DESTDIR | | 306 | DESTDIR_VARNAME?= DESTDIR |
303 | .if !empty(DESTDIR_VARNAME) | | 307 | .if !empty(DESTDIR_VARNAME) |
304 | INSTALL_ENV+= ${DESTDIR_VARNAME}=${DESTDIR:Q} | | 308 | INSTALL_ENV+= ${DESTDIR_VARNAME}=${DESTDIR:Q} |
305 | INSTALL_MAKE_FLAGS+= ${DESTDIR_VARNAME}=${DESTDIR:Q} | | 309 | INSTALL_MAKE_FLAGS+= ${DESTDIR_VARNAME}=${DESTDIR:Q} |
306 | .endif | | 310 | .endif |
307 | | | 311 | |
308 | .if !target(do-install) | | 312 | .if !target(do-install) |
309 | do-install: | | 313 | do-install: |
310 | . for _dir_ in ${INSTALL_DIRS} | | 314 | . for _dir_ in ${INSTALL_DIRS} |
311 | ${RUN} ${_ULIMIT_CMD} \ | | 315 | ${RUN} ${_ULIMIT_CMD} \ |
312 | cd ${WRKSRC} && cd ${_dir_} && \ | | 316 | cd ${WRKSRC} && cd ${_dir_} && \ |
313 | ${PKGSRC_SETENV} ${INSTALL_ENV} ${MAKE_ENV} \ | | 317 | ${PKGSRC_SETENV} ${INSTALL_ENV} ${MAKE_ENV} \ |
314 | ${MAKE_PROGRAM} ${MAKE_FLAGS} ${INSTALL_MAKE_FLAGS} \ | | 318 | ${MAKE_PROGRAM} ${MAKE_FLAGS} ${INSTALL_MAKE_FLAGS} \ |
315 | -f ${MAKE_FILE} ${INSTALL_TARGET} | | 319 | -f ${MAKE_FILE} ${INSTALL_TARGET} |
316 | . endfor | | 320 | . endfor |
317 | .endif | | 321 | .endif |
318 | | | 322 | |
319 | .if !target(pre-install) | | 323 | .if !target(pre-install) |
320 | pre-install: | | 324 | pre-install: |
321 | @${DO_NADA} | | 325 | @${DO_NADA} |
322 | .endif | | 326 | .endif |
323 | .if !target(post-install) | | 327 | .if !target(post-install) |
324 | post-install: | | 328 | post-install: |
325 | @${DO_NADA} | | 329 | @${DO_NADA} |
326 | .endif | | 330 | .endif |
327 | | | 331 | |
328 | ###################################################################### | | 332 | ###################################################################### |
329 | ### install-strip-debug (PRIVATE) | | 333 | ### install-strip-debug (PRIVATE) |
330 | ###################################################################### | | 334 | ###################################################################### |
331 | ### install-strip-debug tries to strip debug information from | | 335 | ### install-strip-debug tries to strip debug information from |
332 | ### the files in PLIST. | | 336 | ### the files in PLIST. |
333 | ### | | 337 | ### |
334 | .PHONY: install-strip-debug | | 338 | .PHONY: install-strip-debug |
335 | install-strip-debug: plist | | 339 | install-strip-debug: plist |
336 | @${STEP_MSG} "Automatic stripping of debug information" | | 340 | @${STEP_MSG} "Automatic stripping of debug information" |
337 | ${RUN}${CAT} ${_PLIST_NOKEYWORDS} \ | | 341 | ${RUN}${CAT} ${_PLIST_NOKEYWORDS} \ |
338 | | ${SED} -e 's|^|${DESTDIR}${PREFIX}/|' \ | | 342 | | ${SED} -e 's|^|${DESTDIR}${PREFIX}/|' \ |
339 | | while read f; do \ | | 343 | | while read f; do \ |
340 | tmp_f="$${f}.XXX"; \ | | 344 | tmp_f="$${f}.XXX"; \ |
341 | if ${STRIP} -g -o "$${tmp_f}" "$${f}" 2> /dev/null; then \ | | 345 | if ${STRIP} -g -o "$${tmp_f}" "$${f}" 2> /dev/null; then \ |
342 | [ ! -f "$${f}" ] || \ | | 346 | [ ! -f "$${f}" ] || \ |
343 | ${MV} "$${tmp_f}" "$${f}"; \ | | 347 | ${MV} "$${tmp_f}" "$${f}"; \ |
344 | else \ | | 348 | else \ |
345 | ${RM} -f "$${tmp_f}"; \ | | 349 | ${RM} -f "$${tmp_f}"; \ |
346 | fi \ | | 350 | fi \ |
347 | done | | 351 | done |
348 | | | 352 | |
349 | ###################################################################### | | 353 | ###################################################################### |
350 | ### install-doc-handling (PRIVATE) | | 354 | ### install-doc-handling (PRIVATE) |
351 | ###################################################################### | | 355 | ###################################################################### |
352 | ### install-doc-handling does automatic document (de)compression based | | 356 | ### install-doc-handling does automatic document (de)compression based |
353 | ### on the contents of the PLIST. | | 357 | ### on the contents of the PLIST. |
354 | ### | | 358 | ### |
355 | _PLIST_REGEXP.info= \ | | 359 | _PLIST_REGEXP.info= \ |
356 | ^([^\/]*\/)*${PKGINFODIR}/[^/]*(\.info)?(-[0-9]+)?(\.gz)?$$ | | 360 | ^([^\/]*\/)*${PKGINFODIR}/[^/]*(\.info)?(-[0-9]+)?(\.gz)?$$ |
357 | _PLIST_REGEXP.man= \ | | 361 | _PLIST_REGEXP.man= \ |
358 | ^([^/]*/)+((man|html)[1-9ln](am|f)?/[^/]*\.([1-9ln](am|f)?|html)|cat[1-9ln](am|f)?/[^/]*\.[0-9])(\.gz)?$$ | | 362 | ^([^/]*/)+((man|html)[1-9ln](am|f)?/[^/]*\.([1-9ln](am|f)?|html)|cat[1-9ln](am|f)?/[^/]*\.[0-9])(\.gz)?$$ |
359 | | | 363 | |
360 | _DOC_COMPRESS= \ | | 364 | _DOC_COMPRESS= \ |
361 | ${PKGSRC_SETENV} PATH=${PATH:Q} \ | | 365 | ${PKGSRC_SETENV} PATH=${PATH:Q} \ |
362 | MANZ=${_MANZ} \ | | 366 | MANZ=${_MANZ} \ |
363 | PKG_VERBOSE=${PKG_VERBOSE} \ | | 367 | PKG_VERBOSE=${PKG_VERBOSE} \ |
364 | TEST=${TOOLS_TEST:Q} \ | | 368 | TEST=${TOOLS_TEST:Q} \ |
365 | ${SH} ${PKGSRCDIR}/mk/plist/doc-compress ${DESTDIR}${PREFIX} | | 369 | ${SH} ${PKGSRCDIR}/mk/plist/doc-compress ${DESTDIR}${PREFIX} |
366 | | | 370 | |
367 | .PHONY: install-doc-handling | | 371 | .PHONY: install-doc-handling |
368 | install-doc-handling: plist | | 372 | install-doc-handling: plist |
369 | @${STEP_MSG} "Automatic manual page handling" | | 373 | @${STEP_MSG} "Automatic manual page handling" |
370 | ${RUN} \ | | 374 | ${RUN} \ |
371 | ${CAT} ${_PLIST_NOKEYWORDS} \ | | 375 | ${CAT} ${_PLIST_NOKEYWORDS} \ |
372 | | ${EGREP} ${_PLIST_REGEXP.man:Q} \ | | 376 | | ${EGREP} ${_PLIST_REGEXP.man:Q} \ |
373 | | ${_DOC_COMPRESS} | | 377 | | ${_DOC_COMPRESS} |
374 | | | 378 | |
375 | privileged-install-hook: .PHONY | | 379 | privileged-install-hook: .PHONY |
376 | @${DO_NADA} | | 380 | @${DO_NADA} |
377 | | | 381 | |
378 | ###################################################################### | | 382 | ###################################################################### |
379 | ### install-clean (PRIVATE) | | 383 | ### install-clean (PRIVATE) |
380 | ###################################################################### | | 384 | ###################################################################### |
381 | ### install-clean removes the state files for the "install" and | | 385 | ### install-clean removes the state files for the "install" and |
382 | ### later phases so that the "install" target may be re-invoked. | | 386 | ### later phases so that the "install" target may be re-invoked. |
383 | ### | | 387 | ### |
384 | install-clean: .PHONY package-eat-cookie check-clean _pkgformat-install-clean | | 388 | install-clean: .PHONY package-eat-cookie check-clean _pkgformat-install-clean |
385 | ${RUN} ${RM} -f ${PLIST} ${_COOKIE.install} ${_DEPENDS_PLIST} | | 389 | ${RUN} ${RM} -f ${PLIST} ${_COOKIE.install} ${_DEPENDS_PLIST} |