1 # $NetBSD: bsd.pkginstall.mk,v 1.49 2010/05/07 14:29:36 jmmv 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
326 _INSTALL_USERGROUP_CHECK= \
327 ${SETENV} PERL5=${PERL5:Q} \
328 ${SH} ${PKGSRCDIR}/mk/pkginstall/usergroup-check
330 .PHONY: create-usergroup
331 create-usergroup: su-target
332 @${STEP_MSG} "Requiring users and groups for ${PKGNAME}"
334 PRE_CMD.su-create-usergroup= \
335 if ${_INSTALL_USERGROUP_CHECK} -g ${_PKG_GROUPS:C/\:*$//} && \
336 ${_INSTALL_USERGROUP_CHECK} -u ${_PKG_USERS:C/\:*$//}; then \
340 .PHONY: su-create-usergroup
341 su-create-usergroup: ${_INSTALL_USERGROUP_UNPACKER}
343 cd ${_PKGINSTALL_DIR} && \
344 ${SH} ${_INSTALL_USERGROUP_UNPACKER}; \
346 if ${TEST} -f ./+USERGROUP && \
347 ./+USERGROUP ADD ${_PKG_DBDIR}/${PKGNAME} && \
348 ./+USERGROUP CHECK-ADD ${_PKG_DBDIR}/${PKGNAME}; then \
351 ${RM} -f ${_INSTALL_USERGROUP_FILE:Q} \
352 ${_INSTALL_USERGROUP_DATAFILE:Q} \
353 ${_INSTALL_USERGROUP_UNPACKER:Q} \
357 # SPECIAL_PERMS are lists that look like:
358 # file user group mode
359 # At post-install time, <file> (it may be a directory) is changed
360 # to be owned by <user>:<group> with <mode> permissions. If a file
361 # pathname is relative, then it is taken to be relative to ${PREFIX}.
363 # SPECIAL_PERMS should be used primarily to change permissions of
364 # files or directories listed in the PLIST. This may be used to
365 # make certain files set-uid or to change the ownership or a
368 # Note that when USE_DESTDIR is in effect, the special permissions
369 # are not directly recorded (as file attributes) in the binary
372 # SETUID_ROOT_PERMS is a convenience definition to note an executable is
373 # meant to be setuid-root, and should be used as follows:
375 # SPECIAL_PERMS+= /path/to/suidroot ${SETUID_ROOT_PERMS}
377 # SETGID_GAMES_PERMS is a convenience definition to note an executable is
378 # meant to be setgid-game, and should be used as follows:
380 # SPECIAL_PERMS+= /path/to/sgidgame ${SETGID_GAMES_PERMS}
382 # Keywords: setuid setgid st_mode perms
384 SPECIAL_PERMS?= # empty
385 SETUID_ROOT_PERMS?= ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 4511
386 SETGID_GAMES_PERMS?= ${GAMES_USER} ${GAMES_GROUP} ${GAMEMODE}
388 _INSTALL_PERMS_FILE= ${_PKGINSTALL_DIR}/perms
389 _INSTALL_PERMS_DATAFILE= ${_PKGINSTALL_DIR}/perms-data
390 _INSTALL_UNPACK_TMPL+= ${_INSTALL_PERMS_FILE}
391 _INSTALL_DATA_TMPL+= ${_INSTALL_PERMS_DATAFILE}
393 ${_INSTALL_PERMS_DATAFILE}:
394 ${RUN}${MKDIR} ${.TARGET:H}
395 ${RUN}${_FUNC_STRIP_PREFIX}; \
396 set -- dummy ${SPECIAL_PERMS}; shift; \
397 exec 1>>${.TARGET}; \
398 while ${TEST} $$# -gt 0; do \
399 file="$$1"; owner="$$2"; group="$$3"; mode="$$4"; \
400 shift; shift; shift; shift; \
401 file=`strip_prefix "$$file"`; \
402 ${ECHO} "# PERMS: $$file $$mode $$owner $$group"; \
405 ${_INSTALL_PERMS_FILE}: ${_INSTALL_PERMS_DATAFILE}
406 ${_INSTALL_PERMS_FILE}: ../../mk/pkginstall/perms
407 ${RUN}${MKDIR} ${.TARGET:H}
409 ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/perms > ${.TARGET}
411 if ${_ZERO_FILESIZE_P} ${_INSTALL_PERMS_DATAFILE}; then \
412 ${RM} -f ${.TARGET}; \
413 ${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
418 # Pairs of example and true config files, used much like MLINKS in
419 # the NetBSD base system. At post-install time, if the true config
420 # file doesn't exist, then the example one is copied into place. At
421 # deinstall time, the true one is removed if it doesn't differ from the
422 # example one. REQD_FILES is the same as CONF_FILES but the value
423 # of PKG_CONFIG is ignored.
425 # However, all files listed in REQD_FILES should be under ${PREFIX}.
428 # CONF_FILES_MODE and REQD_FILES_MODE are the file permissions for the
429 # files in CONF_FILES and REQD_FILES, respectively.
433 # Lists that look like:
435 # example_file config_file user group mode
437 # This works like CONF_FILES and REQD_FILES, except that the config
438 # files are owned by user:group and have mode permissions.
439 # REQD_FILES_PERMS is the same as CONF_FILES_PERMS but the value of
440 # PKG_CONFIG is ignored;
442 # However, all files listed in REQD_FILES_PERMS should be under
443 # ${PREFIX}. (XXX: Why?)
445 # RCD_SCRIPTS lists the basenames of the rc.d scripts. They are
446 # expected to be found in ${PREFIX}/share/examples/rc.d, and
447 # the scripts will be copied into ${RCD_SCRIPTS_DIR} with
448 # ${RCD_SCRIPTS_MODE} permissions.
450 # If any file pathnames are relative, then they are taken to be relative
453 # Keywords: etc conf configuration
457 CONF_FILES_MODE?= 0644
458 CONF_FILES_PERMS?= # empty
459 RCD_SCRIPTS?= # empty
460 RCD_SCRIPTS_MODE?= 0755
461 RCD_SCRIPTS_EXAMPLEDIR= share/examples/rc.d
462 RCD_SCRIPTS_SHELL?= ${SH}
463 FILES_SUBST+= RCD_SCRIPTS_SHELL=${RCD_SCRIPTS_SHELL:Q}
464 MESSAGE_SUBST+= RCD_SCRIPTS_DIR=${RCD_SCRIPTS_DIR}
465 MESSAGE_SUBST+= RCD_SCRIPTS_EXAMPLEDIR=${RCD_SCRIPTS_EXAMPLEDIR}
467 _INSTALL_FILES_FILE= ${_PKGINSTALL_DIR}/files
468 _INSTALL_FILES_DATAFILE= ${_PKGINSTALL_DIR}/files-data
469 _INSTALL_UNPACK_TMPL+= ${_INSTALL_FILES_FILE}
470 _INSTALL_DATA_TMPL+= ${_INSTALL_FILES_DATAFILE}
472 privileged-install-hook: _pkginstall-postinstall-check
473 _pkginstall-postinstall-check: .PHONY
474 ${RUN} p="${DESTDIR}${PREFIX}"; \
475 ${_FUNC_STRIP_PREFIX}; \
476 canon() { f=`strip_prefix "$$1"`; case $$f in [!/]*) f="$$p/$$f"; esac; echo "$$f"; }; \
477 needargs() { [ $$3 -ge $$2 ] || ${FAIL_MSG} "[bsd.pkginstall.mk] $$1 must have a multiple of $$2 words. Rest: $$4"; }; \
478 set args ${RCD_SCRIPTS}; shift; \
479 while [ $$# -gt 0 ]; do \
480 egfile=`canon "${RCD_SCRIPTS_EXAMPLEDIR}/$$1"`; shift; \
481 [ -f "$$egfile" ] || [ -c "$$egfile" ] || ${FAIL_MSG} "RCD_SCRIPT $$egfile does not exist."; \
483 set args ${CONF_FILES}; shift; \
484 while [ $$# -gt 0 ]; do \
485 needargs CONF_FILES 2 $$# "$$*"; \
486 egfile=`canon "$$1"`; shift 2; \
487 [ -f "$$egfile" ] || [ -c "$$egfile" ] || ${FAIL_MSG} "CONF_FILE $$egfile does not exist."; \
489 set args ${REQD_FILES}; shift; \
490 while [ $$# -gt 0 ]; do \
491 needargs REDQ_FILES 2 $$# "$$*"; \
492 egfile=`canon "$$1"`; shift 2; \
493 [ -f "$$egfile" ] || [ -c "$$egfile" ] || ${FAIL_MSG} "REQD_FILE $$egfile does not exist."; \
495 set args ${CONF_FILES_PERMS}; shift; \
496 while [ $$# -gt 0 ]; do \
497 needargs CONF_FILES_PERMS 5 $$# "$$*"; \
498 egfile=`canon "$$1"`; shift 5; \
499 [ -f "$$egfile" ] || [ -c "$$egfile" ] || ${FAIL_MSG} "CONF_FILES_PERMS $$egfile does not exist."; \
501 set args ${REQD_FILES_PERMS}; shift; \
502 while [ $$# -gt 0 ]; do \
503 needargs REQD_FILES_PERMS 5 $$# "$$*"; \
504 egfile=`canon "$$1"`; shift 5; \
505 [ -f "$$egfile" ] || [ -c "$$egfile" ] || ${FAIL_MSG} "REQD_FILES_PERMS $$egfile does not exist."; \
508 ${_INSTALL_FILES_DATAFILE}:
509 ${RUN}${MKDIR} ${.TARGET:H}
510 ${RUN}${_FUNC_STRIP_PREFIX}; \
511 set -- dummy ${RCD_SCRIPTS}; shift; \
512 exec 1>>${.TARGET}; \
513 while ${TEST} $$# -gt 0; do \
514 script="$$1"; shift; \
515 file="${RCD_SCRIPTS_DIR:S/^${PREFIX}\///}/$$script"; \
516 egfile="${RCD_SCRIPTS_EXAMPLEDIR}/$$script"; \
517 ${ECHO} "# FILE: $$file cr $$egfile ${RCD_SCRIPTS_MODE}"; \
519 ${RUN}${_FUNC_STRIP_PREFIX}; \
520 set -- dummy ${CONF_FILES}; shift; \
521 exec 1>>${.TARGET}; \
522 while ${TEST} $$# -gt 0; do \
523 egfile="$$1"; file="$$2"; \
525 egfile=`strip_prefix "$$egfile"`; \
526 file=`strip_prefix "$$file"`; \
527 ${ECHO} "# FILE: $$file c $$egfile ${CONF_FILES_MODE}"; \
529 ${RUN}${_FUNC_STRIP_PREFIX}; \
530 set -- dummy ${REQD_FILES}; shift; \
531 exec 1>>${.TARGET}; \
532 while ${TEST} $$# -gt 0; do \
533 egfile="$$1"; file="$$2"; \
535 egfile=`strip_prefix "$$egfile"`; \
536 file=`strip_prefix "$$file"`; \
537 ${ECHO} "# FILE: $$file cf $$egfile ${REQD_FILES_MODE}"; \
539 ${RUN}${_FUNC_STRIP_PREFIX}; \
540 set -- dummy ${CONF_FILES_PERMS}; shift; \
541 exec 1>>${.TARGET}; \
542 while ${TEST} $$# -gt 0; do \
543 egfile="$$1"; file="$$2"; \
544 owner="$$3"; group="$$4"; mode="$$5"; \
545 shift; shift; shift; shift; shift; \
546 egfile=`strip_prefix "$$egfile"`; \
547 file=`strip_prefix "$$file"`; \
548 ${ECHO} "# FILE: $$file c $$egfile $$mode $$owner $$group"; \
550 ${RUN}${_FUNC_STRIP_PREFIX}; \
551 set -- dummy ${REQD_FILES_PERMS}; shift; \
552 exec 1>>${.TARGET}; \
553 while ${TEST} $$# -gt 0; do \
554 egfile="$$1"; file="$$2"; \
555 owner="$$3"; group="$$4"; mode="$$5"; \
556 shift; shift; shift; shift; shift; \
557 egfile=`strip_prefix "$$egfile"`; \
558 file=`strip_prefix "$$file"`; \
559 ${ECHO} "# FILE: $$file cf $$egfile $$mode $$owner $$group"; \
562 ${_INSTALL_FILES_FILE}: ${_INSTALL_FILES_DATAFILE}
563 ${_INSTALL_FILES_FILE}: ../../mk/pkginstall/files
564 ${RUN}${MKDIR} ${.TARGET:H}
566 ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/files > ${.TARGET}
568 if ${_ZERO_FILESIZE_P} ${_INSTALL_FILES_DATAFILE}; then \
569 ${RM} -f ${.TARGET}; \
570 ${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
573 # OWN_DIRS contains a list of directories for this package that should be
574 # created and should attempt to be destroyed by the INSTALL/DEINSTALL
575 # scripts. MAKE_DIRS is used the same way, but the package admin
576 # isn't prompted to remove the directory at post-deinstall time if it
577 # isn't empty. REQD_DIRS is like MAKE_DIRS but the value of PKG_CONFIG
578 # is ignored; however, all directories listed in REQD_DIRS should
579 # be under ${PREFIX}.
581 # OWN_DIRS_PERMS contains a list of "directory owner group mode" sublists
582 # representing directories for this package that should be
583 # created/destroyed by the INSTALL/DEINSTALL scripts. MAKE_DIRS_PERMS
584 # is used the same way but the package admin isn't prompted to remove
585 # the directory at post-deinstall time if it isn't empty.
586 # REQD_DIRS_PERMS is like MAKE_DIRS but the value of PKG_CONFIG is
587 # ignored; however, all directories listed in REQD_DIRS should be
590 # PKG_SYSCONFDIR_PERMS contains a list of "owner group mode" for
591 # ${PKG_SYSCONFDIR}, and only takes effect if PKG_SYSCONFSUBDIR
592 # is non-empty. This is a special case to handle setting
593 # special permissions for ${PKG_SYSCONFDIR}, as ${PKG_SYSCONFDIR}
594 # is (effectively) automatically added to MAKE_DIRS_PERMS.
596 # If any directory pathnames are relative, then they are taken to be
597 # relative to ${PREFIX}.
600 MAKE_DIRS_PERMS?= # empty
602 REQD_DIRS_PERMS?= # empty
604 OWN_DIRS_PERMS?= # empty
606 _INSTALL_DIRS_FILE= ${_PKGINSTALL_DIR}/dirs
607 _INSTALL_DIRS_DATAFILE= ${_PKGINSTALL_DIR}/dirs-data
608 _INSTALL_UNPACK_TMPL+= ${_INSTALL_DIRS_FILE}
609 _INSTALL_DATA_TMPL+= ${_INSTALL_DIRS_DATAFILE}
611 ${_INSTALL_DIRS_DATAFILE}:
612 ${RUN}${MKDIR} ${.TARGET:H}
613 ${RUN}${_FUNC_STRIP_PREFIX}; \
614 exec 1>>${.TARGET}; \
615 case ${PKG_SYSCONFSUBDIR:M*:Q}${CONF_FILES:M*:Q}${CONF_FILES_PERMS:M*:Q}"" in \
617 *) case ${PKG_SYSCONFSUBDIR:M*:Q}"" in \
618 "") ${ECHO} "# DIR: ${PKG_SYSCONFDIR:S/${PREFIX}\///} m" ;; \
619 *) set -- dummy ${PKG_SYSCONFDIR} ${PKG_SYSCONFDIR_PERMS}; shift; \
620 while ${TEST} $$# -gt 0; do \
621 dir="$$1"; owner="$$2"; \
622 group="$$3"; mode="$$4"; \
623 shift; shift; shift; shift; \
624 dir=`strip_prefix "$$dir"`; \
625 ${ECHO} "# DIR: $$dir m $$mode $$owner $$group"; \
632 exec 1>>${.TARGET}; \
633 case ${RCD_SCRIPTS:M*:Q}"" in \
635 *) ${ECHO} "# DIR: ${RCD_SCRIPTS_DIR:S/${PREFIX}\///} m" ;; \
637 ${RUN}${_FUNC_STRIP_PREFIX}; \
638 set -- dummy ${MAKE_DIRS}; shift; \
639 exec 1>>${.TARGET}; \
640 while ${TEST} $$# -gt 0; do \
642 dir=`strip_prefix "$$dir"`; \
643 ${ECHO} "# DIR: $$dir m"; \
645 ${RUN}${_FUNC_STRIP_PREFIX}; \
646 set -- dummy ${REQD_DIRS}; shift; \
647 exec 1>>${.TARGET}; \
648 while ${TEST} $$# -gt 0; do \
650 dir=`strip_prefix "$$dir"`; \
651 ${ECHO} "# DIR: $$dir fm"; \
653 ${RUN}${_FUNC_STRIP_PREFIX}; \
654 set -- dummy ${OWN_DIRS}; shift; \
655 exec 1>>${.TARGET}; \
656 while ${TEST} $$# -gt 0; do \
658 dir=`strip_prefix "$$dir"`; \
659 ${ECHO} "# DIR: $$dir mo"; \
661 ${RUN}${_FUNC_STRIP_PREFIX}; \
662 set -- dummy ${MAKE_DIRS_PERMS}; shift; \
663 exec 1>>${.TARGET}; \
664 while ${TEST} $$# -gt 0; do \
665 dir="$$1"; owner="$$2"; group="$$3"; mode="$$4"; \
666 shift; shift; shift; shift; \
667 dir=`strip_prefix "$$dir"`; \
668 ${ECHO} "# DIR: $$dir m $$mode $$owner $$group"; \
670 ${RUN}${_FUNC_STRIP_PREFIX}; \
671 set -- dummy ${REQD_DIRS_PERMS}; shift; \
672 exec 1>>${.TARGET}; \
673 while ${TEST} $$# -gt 0; do \
674 dir="$$1"; owner="$$2"; group="$$3"; mode="$$4"; \
675 shift; shift; shift; shift; \
676 dir=`strip_prefix "$$dir"`; \
677 ${ECHO} "# DIR: $$dir fm $$mode $$owner $$group"; \
679 ${RUN}${_FUNC_STRIP_PREFIX}; \
680 set -- dummy ${OWN_DIRS_PERMS}; shift; \
681 exec 1>>${.TARGET}; \
682 while ${TEST} $$# -gt 0; do \
683 dir="$$1"; owner="$$2"; group="$$3"; mode="$$4"; \
684 shift; shift; shift; shift; \
685 dir=`strip_prefix "$$dir"`; \
686 ${ECHO} "# DIR: $$dir mo $$mode $$owner $$group"; \
689 ${_INSTALL_DIRS_FILE}: ${_INSTALL_DIRS_DATAFILE}
690 ${_INSTALL_DIRS_FILE}: ../../mk/pkginstall/dirs
691 ${RUN}${MKDIR} ${.TARGET:H}
693 ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/dirs > ${.TARGET}
695 if ${_ZERO_FILESIZE_P} ${_INSTALL_DIRS_DATAFILE}; then \
696 ${RM} -f ${.TARGET}; \
697 ${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
701 # If defined, specifies the directory path containing the "dir"
702 # index file that should be updated. If the pathname is relative,
703 # then it is taken to be relative to ${PREFIX}. This shouldn't
704 # be needed unless "dir" is not in the same directory as the
705 # installed info files.
708 _INSTALL_INFO_FILES_FILE= ${_PKGINSTALL_DIR}/info-files
709 _INSTALL_INFO_FILES_DATAFILE= ${_PKGINSTALL_DIR}/info-files-data
710 _INSTALL_UNPACK_TMPL+= ${_INSTALL_INFO_FILES_FILE}
711 _INSTALL_DATA_TMPL+= ${_INSTALL_INFO_FILES_DATAFILE}
713 .if defined(INFO_FILES)
714 USE_TOOLS+= install-info:run
715 FILES_SUBST+= INSTALL_INFO=${INSTALL_INFO:Q}
718 ${_INSTALL_INFO_FILES_DATAFILE}:
719 ${RUN}${MKDIR} ${.TARGET:H}
720 ${RUN}${RM} -f ${.TARGET}
721 ${RUN}${TOUCH} ${TOUCH_ARGS} ${.TARGET}
723 ${_INSTALL_INFO_FILES_FILE}: ${_INSTALL_INFO_FILES_DATAFILE}
724 ${_INSTALL_INFO_FILES_FILE}: ../../mk/pkginstall/info-files
725 ${RUN}${MKDIR} ${.TARGET:H}
727 ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/info-files > ${.TARGET}
728 .if !defined(INFO_FILES)
730 if ${_ZERO_FILESIZE_P} ${_INSTALL_INFO_FILES_DATAFILE}; then \
731 ${RM} -f ${.TARGET}; \
732 ${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
736 .PHONY: install-script-data-info-files
737 install-script-data: install-script-data-info-files
738 install-script-data-info-files:
739 .if defined(INFO_FILES)
740 ${RUN}${_FUNC_STRIP_PREFIX}; \
741 if ${TEST} -x ${INSTALL_FILE}; then \
742 ${INFO_FILES_cmd} | \
743 while read file; do \
744 infodir=${INFO_DIR:Q}; \
745 infodir=`strip_prefix "$$infodir"`; \
746 case "$$infodir" in \
747 "") ${ECHO} "# INFO: $$file" \
748 >> ${INSTALL_FILE} ;; \
749 *) ${ECHO} "# INFO: $$file $$infodir" \
750 >> ${INSTALL_FILE} ;; \
753 cd ${PKG_DB_TMPDIR} && ${SETENV} ${INSTALL_SCRIPTS_ENV} \
754 ${_PKG_DEBUG_SCRIPT} ${INSTALL_FILE} ${PKGNAME} \
755 UNPACK +INFO_FILES; \
759 # PKG_SHELL contains the pathname of the shell that should be added or
760 # removed from the shell database, /etc/shells. If a pathname
761 # is relative, then it is taken to be relative to ${PREFIX}.
765 _INSTALL_SHELL_FILE= ${_PKGINSTALL_DIR}/shell
766 _INSTALL_SHELL_DATAFILE= ${_PKGINSTALL_DIR}/shell-data
767 _INSTALL_UNPACK_TMPL+= ${_INSTALL_SHELL_FILE}
768 _INSTALL_DATA_TMPL+= ${_INSTALL_SHELL_DATAFILE}
770 ${_INSTALL_SHELL_DATAFILE}:
771 ${RUN}${MKDIR} ${.TARGET:H}
772 ${RUN}${_FUNC_STRIP_PREFIX}; \
773 set -- dummy ${PKG_SHELL}; shift; \
774 exec 1>>${.TARGET}; \
775 while ${TEST} $$# -gt 0; do \
776 shell="$$1"; shift; \
777 shell=`strip_prefix "$$shell"`; \
778 ${ECHO} "# SHELL: $$shell"; \
781 ${_INSTALL_SHELL_FILE}: ${_INSTALL_SHELL_DATAFILE}
782 ${_INSTALL_SHELL_FILE}: ../../mk/pkginstall/shell
783 ${RUN}${MKDIR} ${.TARGET:H}
785 ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/shell > ${.TARGET}
787 if ${_ZERO_FILESIZE_P} ${_INSTALL_SHELL_DATAFILE}; then \
788 ${RM} -f ${.TARGET}; \
789 ${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
793 # The type of shared library supported by the platform.
795 # Default value: ${_OPSYS_SHLIB_TYPE}
798 # LDCONFIG_REMOVE_CMD
799 # Command-line to be invoked to update the system run-time library
800 # search paths database when adding and removing a package.
802 # Default value: ${LDCONFIG}
804 SHLIB_TYPE= ${_SHLIB_TYPE_cmd:sh}
806 sh ${.CURDIR}/../../mk/scripts/shlib-type \
807 ${_OPSYS_SHLIB_TYPE:Q} ${PKG_INFO_CMD:Q}
809 LDCONFIG_ADD_CMD?= ${_LDCONFIG_ADD_CMD.${OPSYS}}
810 LDCONFIG_REMOVE_CMD?= ${_LDCONFIG_REMOVE_CMD.${OPSYS}}
811 _LDCONFIG_ADD_CMD.${OPSYS}?= ${LDCONFIG}
812 _LDCONFIG_REMOVE_CMD.${OPSYS}?= ${LDCONFIG}
813 FILES_SUBST+= LDCONFIG_ADD_CMD=${LDCONFIG_ADD_CMD:Q}
814 FILES_SUBST+= LDCONFIG_REMOVE_CMD=${LDCONFIG_REMOVE_CMD:Q}
816 .if ${SHLIB_TYPE} == "a.out"
822 _INSTALL_SHLIBS_FILE= ${_PKGINSTALL_DIR}/shlibs
823 .if !empty(RUN_LDCONFIG:M[Yy][Ee][Ss])
824 _INSTALL_UNPACK_TMPL+= ${_INSTALL_SHLIBS_FILE}
827 ${_INSTALL_SHLIBS_FILE}: ../../mk/pkginstall/shlibs
828 ${RUN}${MKDIR} ${.TARGET:H}
830 ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/shlibs > ${.TARGET}
832 # FONTS_DIRS.<type> are lists of directories in which the font databases
833 # are updated. If this is non-empty, then the appropriate tools are
834 # used to update the fonts database for the font type. The supported
839 # x11 Generic X fonts, e.g. PCF, SNF, BDF, etc.
841 FONTS_DIRS.ttf?= # empty
842 FONTS_DIRS.type1?= # empty
843 FONTS_DIRS.x11?= # empty
845 _INSTALL_FONTS_FILE= ${_PKGINSTALL_DIR}/fonts
846 _INSTALL_FONTS_DATAFILE= ${_PKGINSTALL_DIR}/fonts-data
847 _INSTALL_UNPACK_TMPL+= ${_INSTALL_FONTS_FILE}
848 _INSTALL_DATA_TMPL+= ${_INSTALL_FONTS_DATAFILE}
850 # Directories with TTF and Type1 fonts also need to run mkfontdir, so
851 # list them as "x11" font directories as well.
853 .if !empty(FONTS_DIRS.ttf:M*)
854 .if ${X11_TYPE} == "modular"
855 USE_TOOLS+= mkfontscale:run
856 FILES_SUBST+= TTF_INDEX_CMD=${TOOLS_PATH.mkfontscale:Q}
858 USE_TOOLS+= ttmkfdir:run
859 FILES_SUBST+= TTF_INDEX_CMD=${TOOLS_PATH.ttmkfdir:Q}
861 FONTS_DIRS.x11+= ${FONTS_DIRS.ttf}
863 .if !empty(FONTS_DIRS.type1:M*)
864 .if ${X11_TYPE} == "modular"
865 USE_TOOLS+= mkfontscale:run
866 FILES_SUBST+= TYPE1_INDEX_CMD=${TOOLS_PATH.type1inst:Q}
867 FILES_SUBST+= TYPE1_POSTINDEX_CMD=
869 USE_TOOLS+= type1inst:run
870 FILES_SUBST+= TYPE1_INDEX_CMD=${TOOLS_PATH.type1inst:Q}
871 FILES_SUBST+= TYPE1_POSTINDEX_CMD="\$${RM} type1inst.log"
873 FONTS_DIRS.x11+= ${FONTS_DIRS.type1}
875 .if !empty(FONTS_DIRS.x11:M*)
876 USE_TOOLS+= mkfontdir:run
877 FILES_SUBST+= MKFONTDIR=${TOOLS_PATH.mkfontdir:Q}
879 .if ${X11_TYPE} == "modular"
880 DEPENDS+= encodings-[0-9]*:../../fonts/encodings
884 FILES_SUBST+= X11_ENCODINGSDIR=${X11_ENCODINGSDIR:Q}
886 ${_INSTALL_FONTS_DATAFILE}:
887 ${RUN}${MKDIR} ${.TARGET:H}
888 ${RUN}${_FUNC_STRIP_PREFIX}; \
889 set -- dummy ${FONTS_DIRS.ttf}; shift; \
890 exec 1>>${.TARGET}; \
891 while ${TEST} $$# -gt 0; do \
893 dir=`strip_prefix "$$dir"`; \
894 ${ECHO} "# FONTS: $$dir ttf"; \
896 ${RUN}${_FUNC_STRIP_PREFIX}; \
897 set -- dummy ${FONTS_DIRS.type1}; shift; \
898 exec 1>>${.TARGET}; \
899 while ${TEST} $$# -gt 0; do \
901 dir=`strip_prefix "$$dir"`; \
902 ${ECHO} "# FONTS: $$dir type1"; \
904 ${RUN}${_FUNC_STRIP_PREFIX}; \
905 set -- dummy ${FONTS_DIRS.x11}; shift; \
906 exec 1>>${.TARGET}; \
907 while ${TEST} $$# -gt 0; do \
909 dir=`strip_prefix "$$dir"`; \
910 ${ECHO} "# FONTS: $$dir x11"; \
913 ${_INSTALL_FONTS_FILE}: ${_INSTALL_FONTS_DATAFILE}
914 ${_INSTALL_FONTS_FILE}: ../../mk/pkginstall/fonts
915 ${RUN}${MKDIR} ${.TARGET:H}
917 ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/fonts > ${.TARGET}
919 if ${_ZERO_FILESIZE_P} ${_INSTALL_FONTS_DATAFILE}; then \
920 ${RM} -f ${.TARGET}; \
921 ${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
924 # PKG_CREATE_USERGROUP indicates whether the INSTALL script should
925 # automatically add any needed users/groups to the system using
926 # useradd/groupadd. It is either YES or NO and defaults to YES.
928 # PKG_CONFIG indicates whether the INSTALL/DEINSTALL scripts should do
929 # automatic config file and directory handling, or if it should
930 # merely inform the admin of the list of required files and
931 # directories needed to use the package. It is either YES or NO
932 # and defaults to YES.
934 # PKG_CONFIG_PERMS indicates whether to automatically correct permissions
935 # and ownership on pre-existing files and directories, or if it
936 # should merely inform the admin of the list of files and
937 # directories whose permissions and ownership need to be fixed. It
938 # is either YES or NO and defaults to NO.
940 # PKG_RCD_SCRIPTS indicates whether to automatically install rc.d scripts
941 # to ${RCD_SCRIPTS_DIR}. It is either YES or NO and defaults to
942 # NO. This variable only takes effect if ${PKG_CONFIG} == "YES".
944 # PKG_REGISTER_SHELLS indicates whether to automatically register shells
945 # in /etc/shells. It is either YES or NO and defaults to YES.
947 # PKG_UPDATE_FONTS_DB indicates whether to automatically update the fonts
948 # databases in directories where fonts have been installed or
949 # removed. It is either YES or NO and defaults to YES.
951 # These values merely set the defaults for INSTALL/DEINSTALL scripts, but
952 # they may be overridden by resetting them in the environment.
954 PKG_CREATE_USERGROUP?= YES
956 PKG_CONFIG_PERMS?= NO
958 PKG_REGISTER_SHELLS?= YES
959 PKG_UPDATE_FONTS_DB?= YES
960 FILES_SUBST+= PKG_CREATE_USERGROUP=${PKG_CREATE_USERGROUP:Q}
961 FILES_SUBST+= PKG_CONFIG=${PKG_CONFIG:Q}
962 FILES_SUBST+= PKG_CONFIG_PERMS=${PKG_CONFIG_PERMS:Q}
963 FILES_SUBST+= PKG_RCD_SCRIPTS=${PKG_RCD_SCRIPTS:Q}
964 FILES_SUBST+= PKG_REGISTER_SHELLS=${PKG_REGISTER_SHELLS:Q}
965 FILES_SUBST+= PKG_UPDATE_FONTS_DB=${PKG_UPDATE_FONTS_DB:Q}
967 .if defined(PKG_DEVELOPER)
968 PKGINSTALL_VERBOSE?= all
970 PKGINSTALL_VERBOSE?= # empty
972 .if !empty(PKGINSTALL_VERBOSE:Mall) || !empty(PKGINSTALL_VERBOSE:Mfonts)
973 FILES_SUBST+= FONTS_VERBOSE=yes
975 FILES_SUBST+= FONTS_VERBOSE=no
977 .if !empty(PKGINSTALL_VERBOSE:Mall) || !empty(PKGINSTALL_VERBOSE:Minfo-files)
978 FILES_SUBST+= INFO_FILES_VERBOSE=yes
980 FILES_SUBST+= INFO_FILES_VERBOSE=no
983 # Substitute for various programs used in the DEINSTALL/INSTALL scripts and
984 # in the rc.d scripts.
986 FILES_SUBST+= AWK=${AWK:Q}
987 FILES_SUBST+= BASENAME=${BASENAME:Q}
988 FILES_SUBST+= CAT=${CAT:Q}
989 FILES_SUBST+= CHGRP=${CHGRP:Q}
990 FILES_SUBST+= CHMOD=${CHMOD:Q}
991 FILES_SUBST+= CHOWN=${CHOWN:Q}
992 FILES_SUBST+= CMP=${CMP:Q}
993 FILES_SUBST+= CP=${CP:Q}
994 FILES_SUBST+= DIRNAME=${DIRNAME:Q}
995 FILES_SUBST+= ECHO=${ECHO:Q}
996 FILES_SUBST+= ECHO_N=${ECHO_N:Q}
997 FILES_SUBST+= EGREP=${EGREP:Q}
998 FILES_SUBST+= EXPR=${EXPR:Q}
999 FILES_SUBST+= FALSE=${FALSE:Q}
1000 FILES_SUBST+= FIND=${FIND:Q}
1001 FILES_SUBST+= GREP=${GREP:Q}
1002 FILES_SUBST+= GROUPADD=${GROUPADD:Q}
1003 FILES_SUBST+= GTAR=${GTAR:Q}
1004 FILES_SUBST+= HEAD=${HEAD:Q}
1005 FILES_SUBST+= ID=${ID:Q}
1006 FILES_SUBST+= INSTALL_INFO=${INSTALL_INFO:Q}
1007 FILES_SUBST+= LINKFARM=${LINKFARM:Q}
1008 FILES_SUBST+= LN=${LN:Q}
1009 FILES_SUBST+= LS=${LS:Q}
1010 FILES_SUBST+= MKDIR=${MKDIR:Q}
1011 FILES_SUBST+= MV=${MV:Q}
1012 FILES_SUBST+= PERL5=${PERL5:Q}
1013 FILES_SUBST+= PKG_ADMIN=${PKG_ADMIN_CMD:Q}
1014 FILES_SUBST+= PKG_INFO=${PKG_INFO_CMD:Q}
1015 FILES_SUBST+= PW=${PW:Q}
1016 FILES_SUBST+= PWD_CMD=${PWD_CMD:Q}
1017 FILES_SUBST+= RM=${RM:Q}
1018 FILES_SUBST+= RMDIR=${RMDIR:Q}
1019 FILES_SUBST+= SED=${SED:Q}
1020 FILES_SUBST+= SETENV=${SETENV:Q}
1021 FILES_SUBST+= SH=${SH:Q}
1022 FILES_SUBST+= SORT=${SORT:Q}
1023 FILES_SUBST+= SU=${SU:Q}
1024 FILES_SUBST+= TEST=${TEST:Q}
1025 FILES_SUBST+= TOUCH=${TOUCH:Q}
1026 FILES_SUBST+= TR=${TR:Q}
1027 FILES_SUBST+= TRUE=${TRUE:Q}
1028 FILES_SUBST+= USERADD=${USERADD:Q}
1029 FILES_SUBST+= XARGS=${XARGS:Q}
1031 FILES_SUBST_SED= ${FILES_SUBST:S/=/@!/:S/$/!g/:S/^/ -e s!@/}
1033 PKG_REFCOUNT_DBDIR?= ${PKG_DBDIR}.refcount
1035 INSTALL_SCRIPTS_ENV= PKG_PREFIX=${PREFIX}
1036 INSTALL_SCRIPTS_ENV+= PKG_METADATA_DIR=${_PKG_DBDIR}/${PKGNAME}
1037 INSTALL_SCRIPTS_ENV+= PKG_REFCOUNT_DBDIR=${PKG_REFCOUNT_DBDIR}
1039 .PHONY: pre-install-script post-install-script
1041 DEINSTALL_FILE= ${PKG_DB_TMPDIR}/+DEINSTALL
1042 INSTALL_FILE= ${PKG_DB_TMPDIR}/+INSTALL
1043 _DEINSTALL_FILE= ${_PKGINSTALL_DIR}/DEINSTALL
1044 _INSTALL_FILE= ${_PKGINSTALL_DIR}/INSTALL
1045 _DEINSTALL_FILE_DFLT= ${_PKGINSTALL_DIR}/DEINSTALL.default
1046 _INSTALL_FILE_DFLT= ${_PKGINSTALL_DIR}/INSTALL.default
1048 .PHONY: generate-install-scripts
1049 generate-install-scripts: \
1050 ${_DEINSTALL_FILE} ${_INSTALL_FILE} \
1051 ${_DEINSTALL_FILE_DFLT} ${_INSTALL_FILE_DFLT}
1052 .if !exists(${DEINSTALL_FILE}) || !exists(${INSTALL_FILE})
1053 ${RUN}${MKDIR} ${INSTALL_FILE:H}
1054 ${RUN}${MKDIR} ${DEINSTALL_FILE:H}
1056 if ${CMP} -s ${_INSTALL_FILE_DFLT:Q} ${_INSTALL_FILE:Q}; then \
1059 ${CP} -f ${_INSTALL_FILE} ${INSTALL_FILE}; \
1060 ${CP} -f ${_DEINSTALL_FILE} ${DEINSTALL_FILE}; \
1063 if ${CMP} -s ${_DEINSTALL_FILE_DFLT:Q} ${_DEINSTALL_FILE:Q}; then \
1066 ${CP} -f ${_DEINSTALL_FILE} ${DEINSTALL_FILE}; \
1070 ${_DEINSTALL_FILE_DFLT}: ${_DEINSTALL_TEMPLATES_DFLT}
1071 ${RUN}${MKDIR} ${.TARGET:H}
1072 ${RUN}${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} > ${.TARGET}
1073 ${RUN}${CHMOD} +x ${.TARGET}
1075 ${_INSTALL_FILE_DFLT}: ${_INSTALL_TEMPLATES_DFLT}
1076 ${RUN}${MKDIR} ${.TARGET:H}
1077 ${RUN}${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} > ${.TARGET}
1078 ${RUN}${CHMOD} +x ${.TARGET}
1080 ${_DEINSTALL_FILE}: ${DEINSTALL_SRC}
1081 ${RUN}${MKDIR} ${.TARGET:H}
1083 exec 1>>${.TARGET}; \
1084 case ${.ALLSRC:Q}"" in \
1085 "") ${ECHO} "#!${SH}" ; \
1086 ${ECHO} "exit 0" ;; \
1087 *) ${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} ;; \
1089 ${RUN}${CHMOD} +x ${.TARGET}
1091 ${_INSTALL_FILE}: ${INSTALL_SRC}
1092 ${RUN}${MKDIR} ${.TARGET:H}
1094 exec 1>>${.TARGET}; \
1095 case ${.ALLSRC:Q}"" in \
1096 "") ${ECHO} "#!${SH}" ; \
1097 ${ECHO} "exit 0" ;; \
1098 *) ${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} ;; \
1100 ${RUN}${CHMOD} +x ${.TARGET}
1104 if ${TEST} -x ${INSTALL_FILE}; then \
1105 ${STEP_MSG} "Running PRE-INSTALL script actions"; \
1106 cd ${PKG_DB_TMPDIR} && ${SETENV} ${INSTALL_SCRIPTS_ENV} \
1107 ${_PKG_DEBUG_SCRIPT} ${INSTALL_FILE} ${PKGNAME} \
1111 post-install-script:
1113 if ${TEST} -x ${INSTALL_FILE}; then \
1114 ${STEP_MSG} "Running POST-INSTALL script actions"; \
1115 cd ${PKG_DB_TMPDIR} && ${SETENV} ${INSTALL_SCRIPTS_ENV} \
1116 ${_PKG_DEBUG_SCRIPT} ${INSTALL_FILE} ${PKGNAME} \
1120 # rc.d scripts are automatically generated and installed into the rc.d
1121 # scripts example directory at the post-install step. The following
1122 # variables are relevent to this process:
1124 # RCD_SCRIPTS lists the basenames of the rc.d scripts
1126 # RCD_SCRIPT_SRC.<script> the source file for <script>; this will
1127 # be run through FILES_SUBST to generate
1128 # the rc.d script (defaults to
1129 # ${FILESDIR}/<script>.sh)
1131 # If the source rc.d script is not present, then the automatic handling
1134 .PHONY: generate-rcd-scripts
1135 generate-rcd-scripts: # do nothing
1137 .PHONY: install-rcd-scripts
1138 post-install: install-rcd-scripts
1139 install-rcd-scripts: # do nothing
1141 .for _script_ in ${RCD_SCRIPTS}
1142 RCD_SCRIPT_SRC.${_script_}?= ${FILESDIR}/${_script_}.sh
1143 RCD_SCRIPT_WRK.${_script_}?= ${WRKDIR}/${_script_}
1145 . if !empty(RCD_SCRIPT_SRC.${_script_})
1146 generate-rcd-scripts: ${RCD_SCRIPT_WRK.${_script_}}
1147 ${RCD_SCRIPT_WRK.${_script_}}: ${RCD_SCRIPT_SRC.${_script_}}
1148 @${STEP_MSG} "Creating ${.TARGET}"
1149 ${RUN}${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} > ${.TARGET}
1150 ${RUN}${CHMOD} +x ${.TARGET}
1152 install-rcd-scripts: install-rcd-${_script_}
1153 install-rcd-${_script_}: ${RCD_SCRIPT_WRK.${_script_}}
1155 if [ -f ${RCD_SCRIPT_WRK.${_script_}} ]; then \
1156 ${MKDIR} ${DESTDIR}${PREFIX}/${RCD_SCRIPTS_EXAMPLEDIR}; \
1157 ${INSTALL_SCRIPT} ${RCD_SCRIPT_WRK.${_script_}} \
1158 ${DESTDIR}${PREFIX}/${RCD_SCRIPTS_EXAMPLEDIR}/${_script_}; \
1163 _PKGINSTALL_TARGETS+= acquire-pkginstall-lock
1164 _PKGINSTALL_TARGETS+= real-pkginstall
1165 _PKGINSTALL_TARGETS+= release-pkginstall-lock
1167 .PHONY: pkginstall install-script-data
1168 pkginstall: ${_PKGINSTALL_TARGETS}
1170 .PHONY: acquire-pkginstall-lock release-pkginstall-lock
1171 acquire-pkginstall-lock: acquire-lock
1172 release-pkginstall-lock: release-lock
1174 .PHONY: real-pkginstall
1175 real-pkginstall: generate-rcd-scripts generate-install-scripts