1 # $NetBSD: bsd.pkginstall.mk,v 1.50 2010/06/15 19:23:56 joerg Exp $
3 # This Makefile fragment is included by bsd.pkg.mk and implements the
4 # common INSTALL/DEINSTALL scripts framework. To use the pkginstall
5 # framework, simply set the relevant variables to customize the install
6 # scripts to the package.
8 # User-settable variables:
11 # A list of scriptlets that will be verbose and output a message
12 # noting the actions taken.
14 # * "all" is a special value that implies all of the other items
15 # * "fonts" for +FONTS
16 # * "info-files" for +INFO_FILES
18 # Default value: "all" for PKG_DEVELOPERs, empty otherwise.
21 _VARGROUPS+= pkginstall
22 _USER_VARS.pkginstall= \
24 PKG_CREATE_USERGROUP \
25 PKG_CONFIG PKG_CONFIG_PERMS \
29 _PKG_VARS.pkginstall= \
30 DEINSTALL_TEMPLATES INSTALL_TEMPLATES \
31 DEINSTALL_SRC INSTALL_SRC \
33 PKG_USERS PKG_GROUPS USERGROUP_PHASE
34 .for u in ${PKG_USERS}
35 _PKG_VARS.pkginstall+= PKG_UID.${u} PKG_GECOS.${u} PKG_HOME.${u} PKG_SHELL.${u}
37 .for g in ${PKG_GROUPS}
38 _PKG_VARS.pkginstall+= PKG_GID.${g}
40 _PKG_VARS.pkginstall+= \
42 CONF_FILES REQD_FILES \
43 CONF_FILES_MODE REQD_FILES_MODE \
44 CONF_FILES_PERMS REQD_FILES_PERMS \
45 RCD_SCRIPTS ${RCD_SCRIPTS:@s@RCD_SCRIPT_SRC.${s}@} \
46 OWN_DIRS MAKE_DIRS REQD_DIRS \
47 OWN_DIRS_PERMS MAKE_DIRS_PERMS REQD_DIRS_PERMS \
48 PKG_SYSCONFDIR_PERMS \
50 FONTS_DIRS.ttf FONTS_DIRS.type1 FONTS_DIRS.x11 \
51 _SYS_VARS.pkginstall= \
58 # The Solaris /bin/sh does not know the ${foo#bar} shell substitution.
59 # This shell function serves a similar purpose, but is specialized on
60 # stripping ${PREFIX}/ from a pathname.
64 plen = length(prefix); \
65 if (substr(s, 1, plen) == prefix) { \
66 s = substr(s, 1 + plen, length(s) - plen); \
69 }' s="$$1" prefix=${PREFIX:Q}/ /dev/null; \
72 _PKGINSTALL_DIR= ${WRKDIR}/.pkginstall
74 # XXX This should not be duplicated from the install module, but we
75 # XXX need this until pkginstall is refactored.
77 PKG_DB_TMPDIR?= ${WRKDIR}/.pkgdb
79 # These are the template scripts for the INSTALL/DEINSTALL scripts.
80 # Packages may do additional work in the INSTALL/DEINSTALL scripts by
81 # overriding the variables DEINSTALL_TEMPLATES and INSTALL_TEMPLATES to
82 # point to additional script fragments. These bits are included after
83 # the main install/deinstall script fragments.
85 _HEADER_TMPL?= ${.CURDIR}/../../mk/pkginstall/header
86 HEADER_TEMPLATES?= # empty
87 .if exists(${PKGDIR}/HEADER) && \
88 empty(HEADER_TEMPLATES:M${PKGDIR}/HEADER)
89 HEADER_TEMPLATES+= ${PKGDIR}/HEADER
91 _DEINSTALL_PRE_TMPL?= ${.CURDIR}/../../mk/pkginstall/deinstall-pre
92 DEINSTALL_TEMPLATES?= # empty
93 .if exists(${PKGDIR}/DEINSTALL) && \
94 empty(DEINSTALL_TEMPLATES:M${PKGDIR}/DEINSTALL)
95 DEINSTALL_TEMPLATES+= ${PKGDIR}/DEINSTALL
97 _DEINSTALL_TMPL?= ${.CURDIR}/../../mk/pkginstall/deinstall
98 _INSTALL_UNPACK_TMPL?= # empty
99 _INSTALL_TMPL?= ${.CURDIR}/../../mk/pkginstall/install
100 INSTALL_TEMPLATES?= # empty
101 .if exists(${PKGDIR}/INSTALL) && \
102 empty(INSTALL_TEMPLATES:M${PKGDIR}/INSTALL)
103 INSTALL_TEMPLATES+= ${PKGDIR}/INSTALL
105 _INSTALL_POST_TMPL?= ${.CURDIR}/../../mk/pkginstall/install-post
106 _INSTALL_DATA_TMPL?= # empty
107 _FOOTER_TMPL?= ${.CURDIR}/../../mk/pkginstall/footer
109 # _DEINSTALL_TEMPLATES and _INSTALL_TEMPLATES are the list of source
110 # files that are concatenated to form the DEINSTALL/INSTALL
113 # _DEINSTALL_TEMPLATES_DFLT and _INSTALL_TEMPLATES_DFLT are the list of
114 # template files minus any user-supplied templates.
116 _DEINSTALL_TEMPLATES= ${_HEADER_TMPL} ${HEADER_TEMPLATES} \
117 ${_DEINSTALL_PRE_TMPL} \
118 ${DEINSTALL_TEMPLATES} \
121 _INSTALL_TEMPLATES= ${_HEADER_TMPL} ${HEADER_TEMPLATES} \
122 ${_INSTALL_UNPACK_TMPL} \
124 ${INSTALL_TEMPLATES} \
125 ${_INSTALL_POST_TMPL} \
127 ${_INSTALL_DATA_TMPL} \
129 _DEINSTALL_TEMPLATES_DFLT= ${_HEADER_TMPL} \
130 ${_DEINSTALL_PRE_TMPL} \
133 _INSTALL_TEMPLATES_DFLT= ${_HEADER_TMPL} \
135 ${_INSTALL_POST_TMPL} \
138 # These are the list of source files that are concatenated to form the
139 # INSTALL/DEINSTALL scripts.
141 DEINSTALL_SRC?= ${_DEINSTALL_TEMPLATES}
142 INSTALL_SRC?= ${_INSTALL_TEMPLATES}
144 # FILES_SUBST lists what to substitute in DEINSTALL/INSTALL scripts and in
147 FILES_SUBST+= PREFIX=${PREFIX:Q}
148 FILES_SUBST+= LOCALBASE=${LOCALBASE:Q}
149 FILES_SUBST+= X11BASE=${X11BASE:Q}
150 FILES_SUBST+= DEPOTBASE=${DEPOTBASE:Q}
151 FILES_SUBST+= VARBASE=${VARBASE:Q}
152 FILES_SUBST+= PKG_SYSCONFBASE=${PKG_SYSCONFBASE:Q}
153 FILES_SUBST+= PKG_SYSCONFDEPOTBASE=${PKG_SYSCONFDEPOTBASE:Q}
154 FILES_SUBST+= PKG_SYSCONFBASEDIR=${PKG_SYSCONFBASEDIR:Q}
155 FILES_SUBST+= PKG_SYSCONFDIR=${PKG_SYSCONFDIR:Q}
156 FILES_SUBST+= CONF_DEPENDS=${CONF_DEPENDS:C/:.*//:Q}
157 FILES_SUBST+= PKGBASE=${PKGBASE:Q}
158 FILES_SUBST+= PKG_INSTALLATION_TYPE=${PKG_INSTALLATION_TYPE:Q}
160 # PKG_USERS represents the users to create for the package. It is a
161 # space-separated list of elements of the form
165 # The following variables are optional and specify further details of
166 # the user accounts listed in PKG_USERS:
168 # PKG_UID.<user> is the hardcoded numeric UID for <user>.
169 # PKG_GECOS.<user> is <user>'s description, as well as contact info.
170 # PKG_HOME.<user> is the home directory for <user>.
171 # PKG_SHELL.<user> is the login shell for <user>.
174 # PKG_GROUPS represents the groups to create for the package. It is a
175 # space-separated list of elements of the form
179 # The following variables are optional and specify further details of
180 # the user accounts listed in PKG_GROUPS:
182 # PKG_GID.<group> is the hardcoded numeric GID for <group>.
187 # PKG_USERS+= courier:mail
189 # PKG_GECOS.courier= Courier authlib and mail user
191 # USERGROUP_PHASE is set to the phase just before which users and
192 # groups need to be created. Valid values are "configure" and
193 # "build". If not defined, then by default users and groups
194 # are created prior to installation by the pre-install-script
195 # target. If this is defined, then the numeric UIDs and GIDs
196 # of users and groups required by this package are hardcoded
197 # into the +INSTALL script.
201 _PKG_USER_HOME?= /nonexistent
202 _PKG_USER_SHELL?= ${NOLOGIN}
203 FILES_SUBST+= PKG_USER_HOME=${_PKG_USER_HOME:Q}
204 FILES_SUBST+= PKG_USER_SHELL=${_PKG_USER_SHELL:Q}
206 # If SETGIDGAME == yes, then we need the "games" user and group.
207 .if defined(SETGIDGAME) && !empty(SETGIDGAME:M[yY][eE][sS])
208 PKG_GROUPS+= ${GAMES_USER}
209 PKG_USERS+= ${GAMES_USER}:${GAMES_GROUP}
212 # Interix is very special in that users and groups cannot have the
213 # same name. Interix.mk tries to work around this by overriding
214 # some specific package defaults. If we get here and there's still a
215 # conflict, add a breakage indicator to make sure the package won't
216 # compile without changing something.
218 .if !empty(OPSYS:MInterix)
219 . for user in ${PKG_USERS:C/\\\\//g:C/:.*//}
220 . if !empty(PKG_GROUPS:M${user})
221 PKG_FAIL_REASON+= "User and group '${user}' cannot have the same name on Interix"
226 .if !empty(PKG_USERS) || !empty(PKG_GROUPS)
227 DEPENDS+= ${_USER_DEPENDS}
230 _INSTALL_USERGROUP_FILE= ${_PKGINSTALL_DIR}/usergroup
231 .if exists(../../mk/pkginstall/usergroupfuncs.${OPSYS})
232 _INSTALL_USERGROUPFUNCS_FILE?= ../../mk/pkginstall/usergroupfuncs.${OPSYS}
234 _INSTALL_USERGROUPFUNCS_FILE?= ../../mk/pkginstall/usergroupfuncs
236 _INSTALL_USERGROUP_DATAFILE= ${_PKGINSTALL_DIR}/usergroup-data
237 _INSTALL_UNPACK_TMPL+= ${_INSTALL_USERGROUP_FILE}
238 _INSTALL_DATA_TMPL+= ${_INSTALL_USERGROUP_DATAFILE}
240 .for _group_ in ${PKG_GROUPS}
241 . if defined(USERGROUP_PHASE)
242 # Determine the numeric GID of each group.
244 PKG_GID.${_group_}_cmd= \
245 if ${TEST} ! -x ${PERL5}; then ${ECHO} ""; exit 0; fi; \
246 ${PERL5} -le 'print scalar getgrnam shift' ${_group_}
247 PKG_GID.${_group_}?= ${PKG_GID.${_group_}_cmd:sh:M*}
249 _PKG_GROUPS+= ${_group_}:${PKG_GID.${_group_}}
252 .for _entry_ in ${PKG_USERS}
253 . for e in ${_entry_:C/\:.*//}
254 . if defined(USERGROUP_PHASE)
255 # Determine the numeric UID of each user.
258 if ${TEST} ! -x ${PERL5}; then ${ECHO} ""; exit 0; fi; \
259 ${PERL5} -le 'print scalar getpwnam shift' ${e}
260 PKG_UID.${e}?= ${PKG_UID.${e}_cmd:sh:M*}
262 _PKG_USERS+= ${_entry_}:${PKG_UID.${e}}:${PKG_GECOS.${e}:Q}:${PKG_HOME.${e}:Q}:${PKG_SHELL.${e}:Q}
266 ${_INSTALL_USERGROUP_DATAFILE}:
267 ${RUN}${MKDIR} ${.TARGET:H}
269 set -- dummy ${_PKG_GROUPS:C/\:*$//}; shift; \
270 exec 1>>${.TARGET}; \
271 while ${TEST} $$# -gt 0; do \
273 ${ECHO} "# GROUP: $$i"; \
276 set -- dummy ${_PKG_USERS:C/\:*$//}; shift; \
277 exec 1>>${.TARGET}; \
278 while ${TEST} $$# -gt 0; do \
280 ${ECHO} "# USER: $$i"; \
283 ${_INSTALL_USERGROUP_FILE}: ${_INSTALL_USERGROUP_DATAFILE}
284 ${_INSTALL_USERGROUP_FILE}: \
285 ../../mk/pkginstall/usergroup \
286 ${INSTALL_USERGROUPFUNCS_FILE}
287 ${RUN}${MKDIR} ${.TARGET:H}
289 ${SED} -e "/^# platform-specific adduser\/addgroup functions/r${_INSTALL_USERGROUPFUNCS_FILE}" ../../mk/pkginstall/usergroup | \
290 ${SED} ${FILES_SUBST_SED} > ${.TARGET}
292 if ${_ZERO_FILESIZE_P} ${_INSTALL_USERGROUP_DATAFILE}; then \
293 ${RM} -f ${.TARGET}; \
294 ${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
297 _INSTALL_USERGROUP_UNPACKER= ${_PKGINSTALL_DIR}/usergroup-unpack
299 ${_INSTALL_USERGROUP_UNPACKER}: \
300 ${_INSTALL_USERGROUP_FILE} \
301 ${_INSTALL_USERGROUP_DATAFILE}
302 ${RUN}${MKDIR} ${.TARGET:H}
307 ${ECHO} "CAT="${CAT:Q}; \
308 ${ECHO} "CHMOD="${CHMOD:Q}; \
309 ${ECHO} "SED="${SED:Q}; \
311 ${ECHO} "SELF=\$$0"; \
312 ${ECHO} "STAGE=UNPACK"; \
314 ${CAT} ${_INSTALL_USERGROUP_FILE} \
315 ${_INSTALL_USERGROUP_DATAFILE}
316 ${RUN}${CHMOD} +x ${.TARGET}
318 .if defined(USERGROUP_PHASE)
319 . if !empty(USERGROUP_PHASE:M*configure)
320 pre-configure: create-usergroup
321 . elif !empty(USERGROUP_PHASE:M*build)
322 pre-build: create-usergroup
323 . elif !empty(USERGROUP_PHASE:Mpre-install) && ${_USE_DESTDIR} != "no"
324 pre-install: create-usergroup
328 _INSTALL_USERGROUP_CHECK= \
329 ${SETENV} PERL5=${PERL5:Q} \
330 ${SH} ${PKGSRCDIR}/mk/pkginstall/usergroup-check
332 .PHONY: create-usergroup
333 create-usergroup: su-target
334 @${STEP_MSG} "Requiring users and groups for ${PKGNAME}"
336 PRE_CMD.su-create-usergroup= \
337 if ${_INSTALL_USERGROUP_CHECK} -g ${_PKG_GROUPS:C/\:*$//} && \
338 ${_INSTALL_USERGROUP_CHECK} -u ${_PKG_USERS:C/\:*$//}; then \
342 .PHONY: su-create-usergroup
343 su-create-usergroup: ${_INSTALL_USERGROUP_UNPACKER}
345 cd ${_PKGINSTALL_DIR} && \
346 ${SH} ${_INSTALL_USERGROUP_UNPACKER}; \
348 if ${TEST} -f ./+USERGROUP && \
349 ./+USERGROUP ADD ${_PKG_DBDIR}/${PKGNAME} && \
350 ./+USERGROUP CHECK-ADD ${_PKG_DBDIR}/${PKGNAME}; then \
353 ${RM} -f ${_INSTALL_USERGROUP_FILE:Q} \
354 ${_INSTALL_USERGROUP_DATAFILE:Q} \
355 ${_INSTALL_USERGROUP_UNPACKER:Q} \
359 # SPECIAL_PERMS are lists that look like:
360 # file user group mode
361 # At post-install time, <file> (it may be a directory) is changed
362 # to be owned by <user>:<group> with <mode> permissions. If a file
363 # pathname is relative, then it is taken to be relative to ${PREFIX}.
365 # SPECIAL_PERMS should be used primarily to change permissions of
366 # files or directories listed in the PLIST. This may be used to
367 # make certain files set-uid or to change the ownership or a
370 # Note that when USE_DESTDIR is in effect, the special permissions
371 # are not directly recorded (as file attributes) in the binary
374 # SETUID_ROOT_PERMS is a convenience definition to note an executable is
375 # meant to be setuid-root, and should be used as follows:
377 # SPECIAL_PERMS+= /path/to/suidroot ${SETUID_ROOT_PERMS}
379 # SETGID_GAMES_PERMS is a convenience definition to note an executable is
380 # meant to be setgid-game, and should be used as follows:
382 # SPECIAL_PERMS+= /path/to/sgidgame ${SETGID_GAMES_PERMS}
384 # Keywords: setuid setgid st_mode perms
386 SPECIAL_PERMS?= # empty
387 SETUID_ROOT_PERMS?= ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 4511
388 SETGID_GAMES_PERMS?= ${GAMES_USER} ${GAMES_GROUP} ${GAMEMODE}
390 _INSTALL_PERMS_FILE= ${_PKGINSTALL_DIR}/perms
391 _INSTALL_PERMS_DATAFILE= ${_PKGINSTALL_DIR}/perms-data
392 _INSTALL_UNPACK_TMPL+= ${_INSTALL_PERMS_FILE}
393 _INSTALL_DATA_TMPL+= ${_INSTALL_PERMS_DATAFILE}
395 ${_INSTALL_PERMS_DATAFILE}:
396 ${RUN}${MKDIR} ${.TARGET:H}
397 ${RUN}${_FUNC_STRIP_PREFIX}; \
398 set -- dummy ${SPECIAL_PERMS}; shift; \
399 exec 1>>${.TARGET}; \
400 while ${TEST} $$# -gt 0; do \
401 file="$$1"; owner="$$2"; group="$$3"; mode="$$4"; \
402 shift; shift; shift; shift; \
403 file=`strip_prefix "$$file"`; \
404 ${ECHO} "# PERMS: $$file $$mode $$owner $$group"; \
407 ${_INSTALL_PERMS_FILE}: ${_INSTALL_PERMS_DATAFILE}
408 ${_INSTALL_PERMS_FILE}: ../../mk/pkginstall/perms
409 ${RUN}${MKDIR} ${.TARGET:H}
411 ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/perms > ${.TARGET}
413 if ${_ZERO_FILESIZE_P} ${_INSTALL_PERMS_DATAFILE}; then \
414 ${RM} -f ${.TARGET}; \
415 ${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
420 # Pairs of example and true config files, used much like MLINKS in
421 # the NetBSD base system. At post-install time, if the true config
422 # file doesn't exist, then the example one is copied into place. At
423 # deinstall time, the true one is removed if it doesn't differ from the
424 # example one. REQD_FILES is the same as CONF_FILES but the value
425 # of PKG_CONFIG is ignored.
427 # However, all files listed in REQD_FILES should be under ${PREFIX}.
430 # CONF_FILES_MODE and REQD_FILES_MODE are the file permissions for the
431 # files in CONF_FILES and REQD_FILES, respectively.
435 # Lists that look like:
437 # example_file config_file user group mode
439 # This works like CONF_FILES and REQD_FILES, except that the config
440 # files are owned by user:group and have mode permissions.
441 # REQD_FILES_PERMS is the same as CONF_FILES_PERMS but the value of
442 # PKG_CONFIG is ignored;
444 # However, all files listed in REQD_FILES_PERMS should be under
445 # ${PREFIX}. (XXX: Why?)
447 # RCD_SCRIPTS lists the basenames of the rc.d scripts. They are
448 # expected to be found in ${PREFIX}/share/examples/rc.d, and
449 # the scripts will be copied into ${RCD_SCRIPTS_DIR} with
450 # ${RCD_SCRIPTS_MODE} permissions.
452 # If any file pathnames are relative, then they are taken to be relative
455 # Keywords: etc conf configuration
459 CONF_FILES_MODE?= 0644
460 CONF_FILES_PERMS?= # empty
461 RCD_SCRIPTS?= # empty
462 RCD_SCRIPTS_MODE?= 0755
463 RCD_SCRIPTS_EXAMPLEDIR= share/examples/rc.d
464 RCD_SCRIPTS_SHELL?= ${SH}
465 FILES_SUBST+= RCD_SCRIPTS_SHELL=${RCD_SCRIPTS_SHELL:Q}
466 MESSAGE_SUBST+= RCD_SCRIPTS_DIR=${RCD_SCRIPTS_DIR}
467 MESSAGE_SUBST+= RCD_SCRIPTS_EXAMPLEDIR=${RCD_SCRIPTS_EXAMPLEDIR}
469 _INSTALL_FILES_FILE= ${_PKGINSTALL_DIR}/files
470 _INSTALL_FILES_DATAFILE= ${_PKGINSTALL_DIR}/files-data
471 _INSTALL_UNPACK_TMPL+= ${_INSTALL_FILES_FILE}
472 _INSTALL_DATA_TMPL+= ${_INSTALL_FILES_DATAFILE}
474 privileged-install-hook: _pkginstall-postinstall-check
475 _pkginstall-postinstall-check: .PHONY
476 ${RUN} p="${DESTDIR}${PREFIX}"; \
477 ${_FUNC_STRIP_PREFIX}; \
478 canon() { f=`strip_prefix "$$1"`; case $$f in [!/]*) f="$$p/$$f"; esac; echo "$$f"; }; \
479 needargs() { [ $$3 -ge $$2 ] || ${FAIL_MSG} "[bsd.pkginstall.mk] $$1 must have a multiple of $$2 words. Rest: $$4"; }; \
480 set args ${RCD_SCRIPTS}; shift; \
481 while [ $$# -gt 0 ]; do \
482 egfile=`canon "${RCD_SCRIPTS_EXAMPLEDIR}/$$1"`; shift; \
483 [ -f "$$egfile" ] || [ -c "$$egfile" ] || ${FAIL_MSG} "RCD_SCRIPT $$egfile does not exist."; \
485 set args ${CONF_FILES}; shift; \
486 while [ $$# -gt 0 ]; do \
487 needargs CONF_FILES 2 $$# "$$*"; \
488 egfile=`canon "$$1"`; shift 2; \
489 [ -f "$$egfile" ] || [ -c "$$egfile" ] || ${FAIL_MSG} "CONF_FILE $$egfile does not exist."; \
491 set args ${REQD_FILES}; shift; \
492 while [ $$# -gt 0 ]; do \
493 needargs REDQ_FILES 2 $$# "$$*"; \
494 egfile=`canon "$$1"`; shift 2; \
495 [ -f "$$egfile" ] || [ -c "$$egfile" ] || ${FAIL_MSG} "REQD_FILE $$egfile does not exist."; \
497 set args ${CONF_FILES_PERMS}; shift; \
498 while [ $$# -gt 0 ]; do \
499 needargs CONF_FILES_PERMS 5 $$# "$$*"; \
500 egfile=`canon "$$1"`; shift 5; \
501 [ -f "$$egfile" ] || [ -c "$$egfile" ] || ${FAIL_MSG} "CONF_FILES_PERMS $$egfile does not exist."; \
503 set args ${REQD_FILES_PERMS}; shift; \
504 while [ $$# -gt 0 ]; do \
505 needargs REQD_FILES_PERMS 5 $$# "$$*"; \
506 egfile=`canon "$$1"`; shift 5; \
507 [ -f "$$egfile" ] || [ -c "$$egfile" ] || ${FAIL_MSG} "REQD_FILES_PERMS $$egfile does not exist."; \
510 ${_INSTALL_FILES_DATAFILE}:
511 ${RUN}${MKDIR} ${.TARGET:H}
512 ${RUN}${_FUNC_STRIP_PREFIX}; \
513 set -- dummy ${RCD_SCRIPTS}; shift; \
514 exec 1>>${.TARGET}; \
515 while ${TEST} $$# -gt 0; do \
516 script="$$1"; shift; \
517 file="${RCD_SCRIPTS_DIR:S/^${PREFIX}\///}/$$script"; \
518 egfile="${RCD_SCRIPTS_EXAMPLEDIR}/$$script"; \
519 ${ECHO} "# FILE: $$file cr $$egfile ${RCD_SCRIPTS_MODE}"; \
521 ${RUN}${_FUNC_STRIP_PREFIX}; \
522 set -- dummy ${CONF_FILES}; shift; \
523 exec 1>>${.TARGET}; \
524 while ${TEST} $$# -gt 0; do \
525 egfile="$$1"; file="$$2"; \
527 egfile=`strip_prefix "$$egfile"`; \
528 file=`strip_prefix "$$file"`; \
529 ${ECHO} "# FILE: $$file c $$egfile ${CONF_FILES_MODE}"; \
531 ${RUN}${_FUNC_STRIP_PREFIX}; \
532 set -- dummy ${REQD_FILES}; shift; \
533 exec 1>>${.TARGET}; \
534 while ${TEST} $$# -gt 0; do \
535 egfile="$$1"; file="$$2"; \
537 egfile=`strip_prefix "$$egfile"`; \
538 file=`strip_prefix "$$file"`; \
539 ${ECHO} "# FILE: $$file cf $$egfile ${REQD_FILES_MODE}"; \
541 ${RUN}${_FUNC_STRIP_PREFIX}; \
542 set -- dummy ${CONF_FILES_PERMS}; shift; \
543 exec 1>>${.TARGET}; \
544 while ${TEST} $$# -gt 0; do \
545 egfile="$$1"; file="$$2"; \
546 owner="$$3"; group="$$4"; mode="$$5"; \
547 shift; shift; shift; shift; shift; \
548 egfile=`strip_prefix "$$egfile"`; \
549 file=`strip_prefix "$$file"`; \
550 ${ECHO} "# FILE: $$file c $$egfile $$mode $$owner $$group"; \
552 ${RUN}${_FUNC_STRIP_PREFIX}; \
553 set -- dummy ${REQD_FILES_PERMS}; shift; \
554 exec 1>>${.TARGET}; \
555 while ${TEST} $$# -gt 0; do \
556 egfile="$$1"; file="$$2"; \
557 owner="$$3"; group="$$4"; mode="$$5"; \
558 shift; shift; shift; shift; shift; \
559 egfile=`strip_prefix "$$egfile"`; \
560 file=`strip_prefix "$$file"`; \
561 ${ECHO} "# FILE: $$file cf $$egfile $$mode $$owner $$group"; \
564 ${_INSTALL_FILES_FILE}: ${_INSTALL_FILES_DATAFILE}
565 ${_INSTALL_FILES_FILE}: ../../mk/pkginstall/files
566 ${RUN}${MKDIR} ${.TARGET:H}
568 ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/files > ${.TARGET}
570 if ${_ZERO_FILESIZE_P} ${_INSTALL_FILES_DATAFILE}; then \
571 ${RM} -f ${.TARGET}; \
572 ${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
575 # OWN_DIRS contains a list of directories for this package that should be
576 # created and should attempt to be destroyed by the INSTALL/DEINSTALL
577 # scripts. MAKE_DIRS is used the same way, but the package admin
578 # isn't prompted to remove the directory at post-deinstall time if it
579 # isn't empty. REQD_DIRS is like MAKE_DIRS but the value of PKG_CONFIG
580 # is ignored; however, all directories listed in REQD_DIRS should
581 # be under ${PREFIX}.
583 # OWN_DIRS_PERMS contains a list of "directory owner group mode" sublists
584 # representing directories for this package that should be
585 # created/destroyed by the INSTALL/DEINSTALL scripts. MAKE_DIRS_PERMS
586 # is used the same way but the package admin isn't prompted to remove
587 # the directory at post-deinstall time if it isn't empty.
588 # REQD_DIRS_PERMS is like MAKE_DIRS but the value of PKG_CONFIG is
589 # ignored; however, all directories listed in REQD_DIRS should be
592 # PKG_SYSCONFDIR_PERMS contains a list of "owner group mode" for
593 # ${PKG_SYSCONFDIR}, and only takes effect if PKG_SYSCONFSUBDIR
594 # is non-empty. This is a special case to handle setting
595 # special permissions for ${PKG_SYSCONFDIR}, as ${PKG_SYSCONFDIR}
596 # is (effectively) automatically added to MAKE_DIRS_PERMS.
598 # If any directory pathnames are relative, then they are taken to be
599 # relative to ${PREFIX}.
602 MAKE_DIRS_PERMS?= # empty
604 REQD_DIRS_PERMS?= # empty
606 OWN_DIRS_PERMS?= # empty
608 _INSTALL_DIRS_FILE= ${_PKGINSTALL_DIR}/dirs
609 _INSTALL_DIRS_DATAFILE= ${_PKGINSTALL_DIR}/dirs-data
610 _INSTALL_UNPACK_TMPL+= ${_INSTALL_DIRS_FILE}
611 _INSTALL_DATA_TMPL+= ${_INSTALL_DIRS_DATAFILE}
613 ${_INSTALL_DIRS_DATAFILE}:
614 ${RUN}${MKDIR} ${.TARGET:H}
615 ${RUN}${_FUNC_STRIP_PREFIX}; \
616 exec 1>>${.TARGET}; \
617 case ${PKG_SYSCONFSUBDIR:M*:Q}${CONF_FILES:M*:Q}${CONF_FILES_PERMS:M*:Q}"" in \
619 *) case ${PKG_SYSCONFSUBDIR:M*:Q}"" in \
620 "") ${ECHO} "# DIR: ${PKG_SYSCONFDIR:S/${PREFIX}\///} m" ;; \
621 *) set -- dummy ${PKG_SYSCONFDIR} ${PKG_SYSCONFDIR_PERMS}; shift; \
622 while ${TEST} $$# -gt 0; do \
623 dir="$$1"; owner="$$2"; \
624 group="$$3"; mode="$$4"; \
625 shift; shift; shift; shift; \
626 dir=`strip_prefix "$$dir"`; \
627 ${ECHO} "# DIR: $$dir m $$mode $$owner $$group"; \
634 exec 1>>${.TARGET}; \
635 case ${RCD_SCRIPTS:M*:Q}"" in \
637 *) ${ECHO} "# DIR: ${RCD_SCRIPTS_DIR:S/${PREFIX}\///} m" ;; \
639 ${RUN}${_FUNC_STRIP_PREFIX}; \
640 set -- dummy ${MAKE_DIRS}; shift; \
641 exec 1>>${.TARGET}; \
642 while ${TEST} $$# -gt 0; do \
644 dir=`strip_prefix "$$dir"`; \
645 ${ECHO} "# DIR: $$dir m"; \
647 ${RUN}${_FUNC_STRIP_PREFIX}; \
648 set -- dummy ${REQD_DIRS}; shift; \
649 exec 1>>${.TARGET}; \
650 while ${TEST} $$# -gt 0; do \
652 dir=`strip_prefix "$$dir"`; \
653 ${ECHO} "# DIR: $$dir fm"; \
655 ${RUN}${_FUNC_STRIP_PREFIX}; \
656 set -- dummy ${OWN_DIRS}; shift; \
657 exec 1>>${.TARGET}; \
658 while ${TEST} $$# -gt 0; do \
660 dir=`strip_prefix "$$dir"`; \
661 ${ECHO} "# DIR: $$dir mo"; \
663 ${RUN}${_FUNC_STRIP_PREFIX}; \
664 set -- dummy ${MAKE_DIRS_PERMS}; shift; \
665 exec 1>>${.TARGET}; \
666 while ${TEST} $$# -gt 0; do \
667 dir="$$1"; owner="$$2"; group="$$3"; mode="$$4"; \
668 shift; shift; shift; shift; \
669 dir=`strip_prefix "$$dir"`; \
670 ${ECHO} "# DIR: $$dir m $$mode $$owner $$group"; \
672 ${RUN}${_FUNC_STRIP_PREFIX}; \
673 set -- dummy ${REQD_DIRS_PERMS}; shift; \
674 exec 1>>${.TARGET}; \
675 while ${TEST} $$# -gt 0; do \
676 dir="$$1"; owner="$$2"; group="$$3"; mode="$$4"; \
677 shift; shift; shift; shift; \
678 dir=`strip_prefix "$$dir"`; \
679 ${ECHO} "# DIR: $$dir fm $$mode $$owner $$group"; \
681 ${RUN}${_FUNC_STRIP_PREFIX}; \
682 set -- dummy ${OWN_DIRS_PERMS}; shift; \
683 exec 1>>${.TARGET}; \
684 while ${TEST} $$# -gt 0; do \
685 dir="$$1"; owner="$$2"; group="$$3"; mode="$$4"; \
686 shift; shift; shift; shift; \
687 dir=`strip_prefix "$$dir"`; \
688 ${ECHO} "# DIR: $$dir mo $$mode $$owner $$group"; \
691 ${_INSTALL_DIRS_FILE}: ${_INSTALL_DIRS_DATAFILE}
692 ${_INSTALL_DIRS_FILE}: ../../mk/pkginstall/dirs
693 ${RUN}${MKDIR} ${.TARGET:H}
695 ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/dirs > ${.TARGET}
697 if ${_ZERO_FILESIZE_P} ${_INSTALL_DIRS_DATAFILE}; then \
698 ${RM} -f ${.TARGET}; \
699 ${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
703 # If defined, specifies the directory path containing the "dir"
704 # index file that should be updated. If the pathname is relative,
705 # then it is taken to be relative to ${PREFIX}. This shouldn't
706 # be needed unless "dir" is not in the same directory as the
707 # installed info files.
710 _INSTALL_INFO_FILES_FILE= ${_PKGINSTALL_DIR}/info-files
711 _INSTALL_INFO_FILES_DATAFILE= ${_PKGINSTALL_DIR}/info-files-data
712 _INSTALL_UNPACK_TMPL+= ${_INSTALL_INFO_FILES_FILE}
713 _INSTALL_DATA_TMPL+= ${_INSTALL_INFO_FILES_DATAFILE}
715 .if defined(INFO_FILES)
716 USE_TOOLS+= install-info:run
717 FILES_SUBST+= INSTALL_INFO=${INSTALL_INFO:Q}
720 ${_INSTALL_INFO_FILES_DATAFILE}:
721 ${RUN}${MKDIR} ${.TARGET:H}
722 ${RUN}${RM} -f ${.TARGET}
723 ${RUN}${TOUCH} ${TOUCH_ARGS} ${.TARGET}
725 ${_INSTALL_INFO_FILES_FILE}: ${_INSTALL_INFO_FILES_DATAFILE}
726 ${_INSTALL_INFO_FILES_FILE}: ../../mk/pkginstall/info-files
727 ${RUN}${MKDIR} ${.TARGET:H}
729 ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/info-files > ${.TARGET}
730 .if !defined(INFO_FILES)
732 if ${_ZERO_FILESIZE_P} ${_INSTALL_INFO_FILES_DATAFILE}; then \
733 ${RM} -f ${.TARGET}; \
734 ${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
738 .PHONY: install-script-data-info-files
739 install-script-data: install-script-data-info-files
740 install-script-data-info-files:
741 .if defined(INFO_FILES)
742 ${RUN}${_FUNC_STRIP_PREFIX}; \
743 if ${TEST} -x ${INSTALL_FILE}; then \
744 ${INFO_FILES_cmd} | \
745 while read file; do \
746 infodir=${INFO_DIR:Q}; \
747 infodir=`strip_prefix "$$infodir"`; \
748 case "$$infodir" in \
749 "") ${ECHO} "# INFO: $$file" \
750 >> ${INSTALL_FILE} ;; \
751 *) ${ECHO} "# INFO: $$file $$infodir" \
752 >> ${INSTALL_FILE} ;; \
755 cd ${PKG_DB_TMPDIR} && ${SETENV} ${INSTALL_SCRIPTS_ENV} \
756 ${_PKG_DEBUG_SCRIPT} ${INSTALL_FILE} ${PKGNAME} \
757 UNPACK +INFO_FILES; \
761 # PKG_SHELL contains the pathname of the shell that should be added or
762 # removed from the shell database, /etc/shells. If a pathname
763 # is relative, then it is taken to be relative to ${PREFIX}.
767 _INSTALL_SHELL_FILE= ${_PKGINSTALL_DIR}/shell
768 _INSTALL_SHELL_DATAFILE= ${_PKGINSTALL_DIR}/shell-data
769 _INSTALL_UNPACK_TMPL+= ${_INSTALL_SHELL_FILE}
770 _INSTALL_DATA_TMPL+= ${_INSTALL_SHELL_DATAFILE}
772 ${_INSTALL_SHELL_DATAFILE}:
773 ${RUN}${MKDIR} ${.TARGET:H}
774 ${RUN}${_FUNC_STRIP_PREFIX}; \
775 set -- dummy ${PKG_SHELL}; shift; \
776 exec 1>>${.TARGET}; \
777 while ${TEST} $$# -gt 0; do \
778 shell="$$1"; shift; \
779 shell=`strip_prefix "$$shell"`; \
780 ${ECHO} "# SHELL: $$shell"; \
783 ${_INSTALL_SHELL_FILE}: ${_INSTALL_SHELL_DATAFILE}
784 ${_INSTALL_SHELL_FILE}: ../../mk/pkginstall/shell
785 ${RUN}${MKDIR} ${.TARGET:H}
787 ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/shell > ${.TARGET}
789 if ${_ZERO_FILESIZE_P} ${_INSTALL_SHELL_DATAFILE}; then \
790 ${RM} -f ${.TARGET}; \
791 ${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
795 # The type of shared library supported by the platform.
797 # Default value: ${_OPSYS_SHLIB_TYPE}
800 # LDCONFIG_REMOVE_CMD
801 # Command-line to be invoked to update the system run-time library
802 # search paths database when adding and removing a package.
804 # Default value: ${LDCONFIG}
806 SHLIB_TYPE= ${_SHLIB_TYPE_cmd:sh}
808 sh ${.CURDIR}/../../mk/scripts/shlib-type \
809 ${_OPSYS_SHLIB_TYPE:Q} ${PKG_INFO_CMD:Q}
811 LDCONFIG_ADD_CMD?= ${_LDCONFIG_ADD_CMD.${OPSYS}}
812 LDCONFIG_REMOVE_CMD?= ${_LDCONFIG_REMOVE_CMD.${OPSYS}}
813 _LDCONFIG_ADD_CMD.${OPSYS}?= ${LDCONFIG}
814 _LDCONFIG_REMOVE_CMD.${OPSYS}?= ${LDCONFIG}
815 FILES_SUBST+= LDCONFIG_ADD_CMD=${LDCONFIG_ADD_CMD:Q}
816 FILES_SUBST+= LDCONFIG_REMOVE_CMD=${LDCONFIG_REMOVE_CMD:Q}
818 .if ${SHLIB_TYPE} == "a.out"
824 _INSTALL_SHLIBS_FILE= ${_PKGINSTALL_DIR}/shlibs
825 .if !empty(RUN_LDCONFIG:M[Yy][Ee][Ss])
826 _INSTALL_UNPACK_TMPL+= ${_INSTALL_SHLIBS_FILE}
829 ${_INSTALL_SHLIBS_FILE}: ../../mk/pkginstall/shlibs
830 ${RUN}${MKDIR} ${.TARGET:H}
832 ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/shlibs > ${.TARGET}
834 # FONTS_DIRS.<type> are lists of directories in which the font databases
835 # are updated. If this is non-empty, then the appropriate tools are
836 # used to update the fonts database for the font type. The supported
841 # x11 Generic X fonts, e.g. PCF, SNF, BDF, etc.
843 FONTS_DIRS.ttf?= # empty
844 FONTS_DIRS.type1?= # empty
845 FONTS_DIRS.x11?= # empty
847 _INSTALL_FONTS_FILE= ${_PKGINSTALL_DIR}/fonts
848 _INSTALL_FONTS_DATAFILE= ${_PKGINSTALL_DIR}/fonts-data
849 _INSTALL_UNPACK_TMPL+= ${_INSTALL_FONTS_FILE}
850 _INSTALL_DATA_TMPL+= ${_INSTALL_FONTS_DATAFILE}
852 # Directories with TTF and Type1 fonts also need to run mkfontdir, so
853 # list them as "x11" font directories as well.
855 .if !empty(FONTS_DIRS.ttf:M*)
856 .if ${X11_TYPE} == "modular"
857 USE_TOOLS+= mkfontscale:run
858 FILES_SUBST+= TTF_INDEX_CMD=${TOOLS_PATH.mkfontscale:Q}
860 USE_TOOLS+= ttmkfdir:run
861 FILES_SUBST+= TTF_INDEX_CMD=${TOOLS_PATH.ttmkfdir:Q}
863 FONTS_DIRS.x11+= ${FONTS_DIRS.ttf}
865 .if !empty(FONTS_DIRS.type1:M*)
866 .if ${X11_TYPE} == "modular"
867 USE_TOOLS+= mkfontscale:run
868 FILES_SUBST+= TYPE1_INDEX_CMD=${TOOLS_PATH.type1inst:Q}
869 FILES_SUBST+= TYPE1_POSTINDEX_CMD=
871 USE_TOOLS+= type1inst:run
872 FILES_SUBST+= TYPE1_INDEX_CMD=${TOOLS_PATH.type1inst:Q}
873 FILES_SUBST+= TYPE1_POSTINDEX_CMD="\$${RM} type1inst.log"
875 FONTS_DIRS.x11+= ${FONTS_DIRS.type1}
877 .if !empty(FONTS_DIRS.x11:M*)
878 USE_TOOLS+= mkfontdir:run
879 FILES_SUBST+= MKFONTDIR=${TOOLS_PATH.mkfontdir:Q}
881 .if ${X11_TYPE} == "modular"
882 DEPENDS+= encodings-[0-9]*:../../fonts/encodings
886 FILES_SUBST+= X11_ENCODINGSDIR=${X11_ENCODINGSDIR:Q}
888 ${_INSTALL_FONTS_DATAFILE}:
889 ${RUN}${MKDIR} ${.TARGET:H}
890 ${RUN}${_FUNC_STRIP_PREFIX}; \
891 set -- dummy ${FONTS_DIRS.ttf}; shift; \
892 exec 1>>${.TARGET}; \
893 while ${TEST} $$# -gt 0; do \
895 dir=`strip_prefix "$$dir"`; \
896 ${ECHO} "# FONTS: $$dir ttf"; \
898 ${RUN}${_FUNC_STRIP_PREFIX}; \
899 set -- dummy ${FONTS_DIRS.type1}; shift; \
900 exec 1>>${.TARGET}; \
901 while ${TEST} $$# -gt 0; do \
903 dir=`strip_prefix "$$dir"`; \
904 ${ECHO} "# FONTS: $$dir type1"; \
906 ${RUN}${_FUNC_STRIP_PREFIX}; \
907 set -- dummy ${FONTS_DIRS.x11}; shift; \
908 exec 1>>${.TARGET}; \
909 while ${TEST} $$# -gt 0; do \
911 dir=`strip_prefix "$$dir"`; \
912 ${ECHO} "# FONTS: $$dir x11"; \
915 ${_INSTALL_FONTS_FILE}: ${_INSTALL_FONTS_DATAFILE}
916 ${_INSTALL_FONTS_FILE}: ../../mk/pkginstall/fonts
917 ${RUN}${MKDIR} ${.TARGET:H}
919 ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/fonts > ${.TARGET}
921 if ${_ZERO_FILESIZE_P} ${_INSTALL_FONTS_DATAFILE}; then \
922 ${RM} -f ${.TARGET}; \
923 ${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
926 # PKG_CREATE_USERGROUP indicates whether the INSTALL script should
927 # automatically add any needed users/groups to the system using
928 # useradd/groupadd. It is either YES or NO and defaults to YES.
930 # PKG_CONFIG indicates whether the INSTALL/DEINSTALL scripts should do
931 # automatic config file and directory handling, or if it should
932 # merely inform the admin of the list of required files and
933 # directories needed to use the package. It is either YES or NO
934 # and defaults to YES.
936 # PKG_CONFIG_PERMS indicates whether to automatically correct permissions
937 # and ownership on pre-existing files and directories, or if it
938 # should merely inform the admin of the list of files and
939 # directories whose permissions and ownership need to be fixed. It
940 # is either YES or NO and defaults to NO.
942 # PKG_RCD_SCRIPTS indicates whether to automatically install rc.d scripts
943 # to ${RCD_SCRIPTS_DIR}. It is either YES or NO and defaults to
944 # NO. This variable only takes effect if ${PKG_CONFIG} == "YES".
946 # PKG_REGISTER_SHELLS indicates whether to automatically register shells
947 # in /etc/shells. It is either YES or NO and defaults to YES.
949 # PKG_UPDATE_FONTS_DB indicates whether to automatically update the fonts
950 # databases in directories where fonts have been installed or
951 # removed. It is either YES or NO and defaults to YES.
953 # These values merely set the defaults for INSTALL/DEINSTALL scripts, but
954 # they may be overridden by resetting them in the environment.
956 PKG_CREATE_USERGROUP?= YES
958 PKG_CONFIG_PERMS?= NO
960 PKG_REGISTER_SHELLS?= YES
961 PKG_UPDATE_FONTS_DB?= YES
962 FILES_SUBST+= PKG_CREATE_USERGROUP=${PKG_CREATE_USERGROUP:Q}
963 FILES_SUBST+= PKG_CONFIG=${PKG_CONFIG:Q}
964 FILES_SUBST+= PKG_CONFIG_PERMS=${PKG_CONFIG_PERMS:Q}
965 FILES_SUBST+= PKG_RCD_SCRIPTS=${PKG_RCD_SCRIPTS:Q}
966 FILES_SUBST+= PKG_REGISTER_SHELLS=${PKG_REGISTER_SHELLS:Q}
967 FILES_SUBST+= PKG_UPDATE_FONTS_DB=${PKG_UPDATE_FONTS_DB:Q}
969 .if defined(PKG_DEVELOPER)
970 PKGINSTALL_VERBOSE?= all
972 PKGINSTALL_VERBOSE?= # empty
974 .if !empty(PKGINSTALL_VERBOSE:Mall) || !empty(PKGINSTALL_VERBOSE:Mfonts)
975 FILES_SUBST+= FONTS_VERBOSE=yes
977 FILES_SUBST+= FONTS_VERBOSE=no
979 .if !empty(PKGINSTALL_VERBOSE:Mall) || !empty(PKGINSTALL_VERBOSE:Minfo-files)
980 FILES_SUBST+= INFO_FILES_VERBOSE=yes
982 FILES_SUBST+= INFO_FILES_VERBOSE=no
985 # Substitute for various programs used in the DEINSTALL/INSTALL scripts and
986 # in the rc.d scripts.
988 FILES_SUBST+= AWK=${AWK:Q}
989 FILES_SUBST+= BASENAME=${BASENAME:Q}
990 FILES_SUBST+= CAT=${CAT:Q}
991 FILES_SUBST+= CHGRP=${CHGRP:Q}
992 FILES_SUBST+= CHMOD=${CHMOD:Q}
993 FILES_SUBST+= CHOWN=${CHOWN:Q}
994 FILES_SUBST+= CMP=${CMP:Q}
995 FILES_SUBST+= CP=${CP:Q}
996 FILES_SUBST+= DIRNAME=${DIRNAME:Q}
997 FILES_SUBST+= ECHO=${ECHO:Q}
998 FILES_SUBST+= ECHO_N=${ECHO_N:Q}
999 FILES_SUBST+= EGREP=${EGREP:Q}
1000 FILES_SUBST+= EXPR=${EXPR:Q}
1001 FILES_SUBST+= FALSE=${FALSE:Q}
1002 FILES_SUBST+= FIND=${FIND:Q}
1003 FILES_SUBST+= GREP=${GREP:Q}
1004 FILES_SUBST+= GROUPADD=${GROUPADD:Q}
1005 FILES_SUBST+= GTAR=${GTAR:Q}
1006 FILES_SUBST+= HEAD=${HEAD:Q}
1007 FILES_SUBST+= ID=${ID:Q}
1008 FILES_SUBST+= INSTALL_INFO=${INSTALL_INFO:Q}
1009 FILES_SUBST+= LINKFARM=${LINKFARM:Q}
1010 FILES_SUBST+= LN=${LN:Q}
1011 FILES_SUBST+= LS=${LS:Q}
1012 FILES_SUBST+= MKDIR=${MKDIR:Q}
1013 FILES_SUBST+= MV=${MV:Q}
1014 FILES_SUBST+= PERL5=${PERL5:Q}
1015 FILES_SUBST+= PKG_ADMIN=${PKG_ADMIN_CMD:Q}
1016 FILES_SUBST+= PKG_INFO=${PKG_INFO_CMD:Q}
1017 FILES_SUBST+= PW=${PW:Q}
1018 FILES_SUBST+= PWD_CMD=${PWD_CMD:Q}
1019 FILES_SUBST+= RM=${RM:Q}
1020 FILES_SUBST+= RMDIR=${RMDIR:Q}
1021 FILES_SUBST+= SED=${SED:Q}
1022 FILES_SUBST+= SETENV=${SETENV:Q}
1023 FILES_SUBST+= SH=${SH:Q}
1024 FILES_SUBST+= SORT=${SORT:Q}
1025 FILES_SUBST+= SU=${SU:Q}
1026 FILES_SUBST+= TEST=${TEST:Q}
1027 FILES_SUBST+= TOUCH=${TOUCH:Q}
1028 FILES_SUBST+= TR=${TR:Q}
1029 FILES_SUBST+= TRUE=${TRUE:Q}
1030 FILES_SUBST+= USERADD=${USERADD:Q}
1031 FILES_SUBST+= XARGS=${XARGS:Q}
1033 FILES_SUBST_SED= ${FILES_SUBST:S/=/@!/:S/$/!g/:S/^/ -e s!@/}
1035 PKG_REFCOUNT_DBDIR?= ${PKG_DBDIR}.refcount
1037 INSTALL_SCRIPTS_ENV= PKG_PREFIX=${PREFIX}
1038 INSTALL_SCRIPTS_ENV+= PKG_METADATA_DIR=${_PKG_DBDIR}/${PKGNAME}
1039 INSTALL_SCRIPTS_ENV+= PKG_REFCOUNT_DBDIR=${PKG_REFCOUNT_DBDIR}
1041 .PHONY: pre-install-script post-install-script
1043 DEINSTALL_FILE= ${PKG_DB_TMPDIR}/+DEINSTALL
1044 INSTALL_FILE= ${PKG_DB_TMPDIR}/+INSTALL
1045 _DEINSTALL_FILE= ${_PKGINSTALL_DIR}/DEINSTALL
1046 _INSTALL_FILE= ${_PKGINSTALL_DIR}/INSTALL
1047 _DEINSTALL_FILE_DFLT= ${_PKGINSTALL_DIR}/DEINSTALL.default
1048 _INSTALL_FILE_DFLT= ${_PKGINSTALL_DIR}/INSTALL.default
1050 .PHONY: generate-install-scripts
1051 generate-install-scripts: \
1052 ${_DEINSTALL_FILE} ${_INSTALL_FILE} \
1053 ${_DEINSTALL_FILE_DFLT} ${_INSTALL_FILE_DFLT}
1054 .if !exists(${DEINSTALL_FILE}) || !exists(${INSTALL_FILE})
1055 ${RUN}${MKDIR} ${INSTALL_FILE:H}
1056 ${RUN}${MKDIR} ${DEINSTALL_FILE:H}
1058 if ${CMP} -s ${_INSTALL_FILE_DFLT:Q} ${_INSTALL_FILE:Q}; then \
1061 ${CP} -f ${_INSTALL_FILE} ${INSTALL_FILE}; \
1062 ${CP} -f ${_DEINSTALL_FILE} ${DEINSTALL_FILE}; \
1065 if ${CMP} -s ${_DEINSTALL_FILE_DFLT:Q} ${_DEINSTALL_FILE:Q}; then \
1068 ${CP} -f ${_DEINSTALL_FILE} ${DEINSTALL_FILE}; \
1072 ${_DEINSTALL_FILE_DFLT}: ${_DEINSTALL_TEMPLATES_DFLT}
1073 ${RUN}${MKDIR} ${.TARGET:H}
1074 ${RUN}${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} > ${.TARGET}
1075 ${RUN}${CHMOD} +x ${.TARGET}
1077 ${_INSTALL_FILE_DFLT}: ${_INSTALL_TEMPLATES_DFLT}
1078 ${RUN}${MKDIR} ${.TARGET:H}
1079 ${RUN}${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} > ${.TARGET}
1080 ${RUN}${CHMOD} +x ${.TARGET}
1082 ${_DEINSTALL_FILE}: ${DEINSTALL_SRC}
1083 ${RUN}${MKDIR} ${.TARGET:H}
1085 exec 1>>${.TARGET}; \
1086 case ${.ALLSRC:Q}"" in \
1087 "") ${ECHO} "#!${SH}" ; \
1088 ${ECHO} "exit 0" ;; \
1089 *) ${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} ;; \
1091 ${RUN}${CHMOD} +x ${.TARGET}
1093 ${_INSTALL_FILE}: ${INSTALL_SRC}
1094 ${RUN}${MKDIR} ${.TARGET:H}
1096 exec 1>>${.TARGET}; \
1097 case ${.ALLSRC:Q}"" in \
1098 "") ${ECHO} "#!${SH}" ; \
1099 ${ECHO} "exit 0" ;; \
1100 *) ${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} ;; \
1102 ${RUN}${CHMOD} +x ${.TARGET}
1106 if ${TEST} -x ${INSTALL_FILE}; then \
1107 ${STEP_MSG} "Running PRE-INSTALL script actions"; \
1108 cd ${PKG_DB_TMPDIR} && ${SETENV} ${INSTALL_SCRIPTS_ENV} \
1109 ${_PKG_DEBUG_SCRIPT} ${INSTALL_FILE} ${PKGNAME} \
1113 post-install-script:
1115 if ${TEST} -x ${INSTALL_FILE}; then \
1116 ${STEP_MSG} "Running POST-INSTALL script actions"; \
1117 cd ${PKG_DB_TMPDIR} && ${SETENV} ${INSTALL_SCRIPTS_ENV} \
1118 ${_PKG_DEBUG_SCRIPT} ${INSTALL_FILE} ${PKGNAME} \
1122 # rc.d scripts are automatically generated and installed into the rc.d
1123 # scripts example directory at the post-install step. The following
1124 # variables are relevent to this process:
1126 # RCD_SCRIPTS lists the basenames of the rc.d scripts
1128 # RCD_SCRIPT_SRC.<script> the source file for <script>; this will
1129 # be run through FILES_SUBST to generate
1130 # the rc.d script (defaults to
1131 # ${FILESDIR}/<script>.sh)
1133 # If the source rc.d script is not present, then the automatic handling
1136 .PHONY: generate-rcd-scripts
1137 generate-rcd-scripts: # do nothing
1139 .PHONY: install-rcd-scripts
1140 post-install: install-rcd-scripts
1141 install-rcd-scripts: # do nothing
1143 .for _script_ in ${RCD_SCRIPTS}
1144 RCD_SCRIPT_SRC.${_script_}?= ${FILESDIR}/${_script_}.sh
1145 RCD_SCRIPT_WRK.${_script_}?= ${WRKDIR}/${_script_}
1147 . if !empty(RCD_SCRIPT_SRC.${_script_})
1148 generate-rcd-scripts: ${RCD_SCRIPT_WRK.${_script_}}
1149 ${RCD_SCRIPT_WRK.${_script_}}: ${RCD_SCRIPT_SRC.${_script_}}
1150 @${STEP_MSG} "Creating ${.TARGET}"
1151 ${RUN}${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} > ${.TARGET}
1152 ${RUN}${CHMOD} +x ${.TARGET}
1154 install-rcd-scripts: install-rcd-${_script_}
1155 install-rcd-${_script_}: ${RCD_SCRIPT_WRK.${_script_}}
1157 if [ -f ${RCD_SCRIPT_WRK.${_script_}} ]; then \
1158 ${MKDIR} ${DESTDIR}${PREFIX}/${RCD_SCRIPTS_EXAMPLEDIR}; \
1159 ${INSTALL_SCRIPT} ${RCD_SCRIPT_WRK.${_script_}} \
1160 ${DESTDIR}${PREFIX}/${RCD_SCRIPTS_EXAMPLEDIR}/${_script_}; \
1165 _PKGINSTALL_TARGETS+= acquire-pkginstall-lock
1166 _PKGINSTALL_TARGETS+= real-pkginstall
1167 _PKGINSTALL_TARGETS+= release-pkginstall-lock
1169 .PHONY: pkginstall install-script-data
1170 pkginstall: ${_PKGINSTALL_TARGETS}
1172 .PHONY: acquire-pkginstall-lock release-pkginstall-lock
1173 acquire-pkginstall-lock: acquire-lock
1174 release-pkginstall-lock: release-lock
1176 .PHONY: real-pkginstall
1177 real-pkginstall: generate-rcd-scripts generate-install-scripts