Tue Aug 8 17:17:25 2017 UTC ()
Check, don't assert, that INSTALLATION_DIRS are all in ${PREFIX}.

Change the assertion into an install-time check that the paths
listed in INSTALLATION_DIRS are relative paths or are in ${PREFIX}.
This delays the check so that some common variables used when
listing directories in INSTALLATION_DIRS are fully-expanded.


(jlam)
diff -r1.71 -r1.72 pkgsrc/mk/install/install.mk

cvs diff -r1.71 -r1.72 pkgsrc/mk/install/install.mk (switch to unified diff)

--- pkgsrc/mk/install/install.mk 2017/08/07 15:49:44 1.71
+++ pkgsrc/mk/install/install.mk 2017/08/08 17:17:25 1.72
@@ -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})
74stage-install: 74stage-install:
75 @${DO_NADA} 75 @${DO_NADA}
76. elif defined(_PKGSRC_BARRIER) 76. elif defined(_PKGSRC_BARRIER)
77stage-install: ${_INSTALL_TARGETS} 77stage-install: ${_INSTALL_TARGETS}
78. else 78. else
79stage-install: barrier 79stage-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
84acquire-install-lock: acquire-lock 84acquire-install-lock: acquire-lock
85release-install-lock: release-lock 85release-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
109real-install: ${_REAL_INSTALL_TARGETS} 109real-install: ${_REAL_INSTALL_TARGETS}
110 110
111.PHONY: install-message 111.PHONY: install-message
112install-message: 112install-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###
121install-check-interactive: .PHONY 121install-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
132unprivileged-install-hook: 132unprivileged-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
143install-check-version: ${_COOKIE.extract} 143install-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])
195install-all: su-target 195install-all: su-target
196. else 196. else
197install-all: su-install-all 197install-all: su-install-all
198. endif 198. endif
199su-install-all: ${_INSTALL_ALL_TARGETS} 199su-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
208install-check-umask: 208install-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/*) 
253PKG_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
257install-makedirs: 257install-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
275install-dirs-from-PLIST: 279install-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
299INSTALL_DIRS?= ${BUILD_DIRS} 303INSTALL_DIRS?= ${BUILD_DIRS}
300INSTALL_MAKE_FLAGS?= # none 304INSTALL_MAKE_FLAGS?= # none
301INSTALL_TARGET?= install ${USE_IMAKE:D${NO_INSTALL_MANPAGES:D:Uinstall.man}} 305INSTALL_TARGET?= install ${USE_IMAKE:D${NO_INSTALL_MANPAGES:D:Uinstall.man}}
302DESTDIR_VARNAME?= DESTDIR 306DESTDIR_VARNAME?= DESTDIR
303.if !empty(DESTDIR_VARNAME) 307.if !empty(DESTDIR_VARNAME)
304INSTALL_ENV+= ${DESTDIR_VARNAME}=${DESTDIR:Q} 308INSTALL_ENV+= ${DESTDIR_VARNAME}=${DESTDIR:Q}
305INSTALL_MAKE_FLAGS+= ${DESTDIR_VARNAME}=${DESTDIR:Q} 309INSTALL_MAKE_FLAGS+= ${DESTDIR_VARNAME}=${DESTDIR:Q}
306.endif 310.endif
307 311
308.if !target(do-install) 312.if !target(do-install)
309do-install: 313do-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)
320pre-install: 324pre-install:
321 @${DO_NADA} 325 @${DO_NADA}
322.endif 326.endif
323.if !target(post-install) 327.if !target(post-install)
324post-install: 328post-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
335install-strip-debug: plist 339install-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
368install-doc-handling: plist 372install-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
375privileged-install-hook: .PHONY 379privileged-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###
384install-clean: .PHONY package-eat-cookie check-clean _pkgformat-install-clean 388install-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}