1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
# $NetBSD: bsd.pkg.install.mk,v 1.38 2002/10/23 17:43:16 jlam Exp $
#
# This Makefile fragment is included by package Makefiles to use the common
# INSTALL/DEINSTALL scripts. To use this Makefile fragment, simply:
#
# (1) Set the variables to customize the install scripts to the package, and
# (2) Include this Makefile fragment in the package Makefile.
#
# NOTE: This file must be included _before_ bsd.pkg.mk.
.if !defined(BSD_PKG_INSTALL_MK)
BSD_PKG_INSTALL_MK= 1
.include "../../mk/bsd.prefs.mk"
DEINSTALL_FILE= ${WRKDIR}/.DEINSTALL
INSTALL_FILE= ${WRKDIR}/.INSTALL
# These are the template scripts for the INSTALL/DEINSTALL scripts. Packages
# may do additional work in the INSTALL/DEINSTALL scripts by overriding the
# variables DEINSTALL_EXTRA_TMPL and INSTALL_EXTRA_TMPL to point to
# additional script fragments. These bits are included after the main
# install/deinstall script fragments. Packages may also override the
# variables DEINSTALL_TMPL and INSTALL_TMPL to completely customize the
# install/deinstall logic.
#
_HEADER_TMPL?= ${.CURDIR}/../../mk/install/header
.if !defined(DEINSTALL_EXTRA_TMPL) && exists(${.CURDIR}/DEINSTALL)
DEINSTALL_EXTRA_TMPL?= ${.CURDIR}/DEINSTALL
.else
DEINSTALL_EXTRA_TMPL?= # empty
.endif
DEINSTALL_TMPL?= ${.CURDIR}/../../mk/install/deinstall
INSTALL_TMPL?= ${.CURDIR}/../../mk/install/install
.if !defined(INSTALL_EXTRA_TMPL) && exists(${.CURDIR}/INSTALL)
INSTALL_EXTRA_TMPL?= ${.CURDIR}/INSTALL
.else
INSTALL_EXTRA_TMPL?= # empty
.endif
_FOOTER_TMPL?= ${.CURDIR}/../../mk/install/footer
# DEINSTALL_TEMPLATES and INSTALL_TEMPLATES are the default list of source
# files that are concatenated to form the DEINSTALL/INSTALL scripts.
#
DEINSTALL_TEMPLATES= ${_HEADER_TMPL}
DEINSTALL_TEMPLATES+= ${DEINSTALL_EXTRA_TMPL}
DEINSTALL_TEMPLATES+= ${DEINSTALL_TMPL}
DEINSTALL_TEMPLATES+= ${_FOOTER_TMPL}
INSTALL_TEMPLATES= ${_HEADER_TMPL}
INSTALL_TEMPLATES+= ${INSTALL_TMPL}
INSTALL_TEMPLATES+= ${INSTALL_EXTRA_TMPL}
INSTALL_TEMPLATES+= ${_FOOTER_TMPL}
# These are the list of source files that are concatenated to form the
# INSTALL/DEINSTALL scripts.
#
DEINSTALL_SRC?= ${DEINSTALL_TEMPLATES}
INSTALL_SRC?= ${INSTALL_TEMPLATES}
# FILES_SUBST lists what to substitute in DEINSTALL/INSTALL scripts and in
# rc.d scripts.
#
FILES_SUBST+= PREFIX=${PREFIX}
FILES_SUBST+= LOCALBASE=${LOCALBASE}
FILES_SUBST+= X11BASE=${X11BASE}
FILES_SUBST+= PKG_SYSCONFBASE=${PKG_SYSCONFBASE}
FILES_SUBST+= PKG_SYSCONFDIR=${PKG_SYSCONFDIR}
FILES_SUBST+= PKGBASE=${PKGBASE}
# PKG_USERS represents the users to create for the package. It is a
# space-separated list of elements of the form
#
# user:group[:[userid][:[descr][:[home][:shell]]]]
#
# Only the user and group are required; everything else is optional,
# but the colons must be in the right places when specifying optional
# bits. Note that if the description contains spaces, then spaces
# should be double backslash-escaped, e.g.
#
# foo:foogrp::The\\ Foomister
#
# PKG_GROUPS represents the groups to create for the package. It is a
# space-separated list of elements of the form
#
# group[:groupid]
#
# Only the group is required; the groupid is optional.
#
PKG_USERS?= # empty
_PKG_USER_HOME?= /nonexistent
_PKG_USER_SHELL?= ${NOLOGIN}
PKG_GROUPS?= # empty
FILES_SUBST+= PKG_USERS=${PKG_USERS:Q}
FILES_SUBST+= PKG_USER_HOME=${_PKG_USER_HOME}
FILES_SUBST+= PKG_USER_SHELL=${_PKG_USER_SHELL}
FILES_SUBST+= PKG_GROUPS=${PKG_GROUPS:Q}
.if !empty(PKG_USERS)
USE_USERADD= YES
.endif
.if !empty(PKG_GROUPS)
USE_USERGROUP= YES
.endif
# SPECIAL_PERMS are lists that look like:
# file user group mode
# At post-install time, file (it may be a directory) is changed to be
# owned by user:group with mode permissions.
#
# SPECIAL_PERMS should be used primarily to change permissions of files or
# directories listed in the PLIST. This may be used to make certain files
# set-uid or to change the ownership or a directory.
#
# SETUID_ROOT_PERMS is a convenience definition to note an executable is
# meant to be setuid-root, and should be used as follows:
#
# SPECIAL_PERMS+= /path/to/suidroot ${SETUID_ROOT_PERMS}
#
SPECIAL_PERMS?= # empty
SETUID_ROOT_PERMS?= ${ROOT_USER} ${ROOT_GROUP} 4711
FILES_SUBST+= SPECIAL_PERMS=${SPECIAL_PERMS:Q}
# CONF_FILES are pairs of example and true config files, used much like
# MLINKS in the base system. At post-install time, if the true config
# file doesn't exist, then the example one is copied into place. At
# deinstall time, the true one is removed if it doesn't differ from the
# example one. SUPPORT_FILES is used the same way, but the package
# admin isn't prompted to customize the file at post-install time.
#
# CONF_FILES_MODE and SUPPORT_FILES_MODE are the file permissions for the
# files in CONF_FILES and SUPPORT_FILES, respectively.
#
# CONF_FILES_PERMS are lists that look like:
# example_file config_file user group mode
# and works like CONF_FILES, except the config files are owned by
# user:group have mode permissions. SUPPORT_FILES_PERMS is used in the
# same way, but the package admin isn't prompted to customize the file
# at post-install time.
#
# RCD_SCRIPTS works lists the basenames of the rc.d scripts. They are
# expected to be found in ${RCD_SCRIPTS_EXAMPLEDIR}, and the scripts
# will be copied into ${RCD_SCRIPTS_DIR} with ${RCD_SCRIPTS_MODE}
# permissions.
#
CONF_FILES?= # empty
CONF_FILES_MODE?= 0644
CONF_FILES_PERMS?= # empty
SUPPORT_FILES?= # empty
SUPPORT_FILES_MODE?= 0644
SUPPORT_FILES_PERMS?= # empty
RCD_SCRIPTS?= # empty
RCD_SCRIPTS_MODE?= 0755
RCD_SCRIPTS_DIR?= /etc/rc.d
RCD_SCRIPTS_EXAMPLEDIR?= ${PREFIX}/etc/rc.d
RCD_SCRIPTS_SHELL?= ${SH}
FILES_SUBST+= CONF_FILES=${CONF_FILES:Q}
FILES_SUBST+= CONF_FILES_MODE=${CONF_FILES_MODE}
FILES_SUBST+= CONF_FILES_PERMS=${CONF_FILES_PERMS:Q}
FILES_SUBST+= SUPPORT_FILES=${SUPPORT_FILES:Q}
FILES_SUBST+= SUPPORT_FILES_MODE=${SUPPORT_FILES_MODE}
FILES_SUBST+= SUPPORT_FILES_PERMS=${SUPPORT_FILES_PERMS:Q}
FILES_SUBST+= RCD_SCRIPTS=${RCD_SCRIPTS:Q}
FILES_SUBST+= RCD_SCRIPTS_MODE=${RCD_SCRIPTS_MODE}
FILES_SUBST+= RCD_SCRIPTS_DIR=${RCD_SCRIPTS_DIR}
FILES_SUBST+= RCD_SCRIPTS_EXAMPLEDIR=${RCD_SCRIPTS_EXAMPLEDIR}
FILES_SUBST+= RCD_SCRIPTS_SHELL=${RCD_SCRIPTS_SHELL}
MESSAGE_SUBST+= RCD_SCRIPTS_DIR=${RCD_SCRIPTS_DIR}
# OWN_DIRS contains a list of directories for this package that should be
# created and should attempt to be destroyed by the INSTALL/DEINSTALL
# scripts. MAKE_DIRS is used the same way, but the package admin
# isn't prompted to remove the directory at post-deinstall time if it
# isn't empty. For convenience, ${PKG_SYSCONFDIR} is automatically
# added to MAKE_DIRS.
#
# OWN_DIRS_PERMS contains a list of "directory owner group mode" sublists
# representing directories for this package that should be
# created/destroyed by the INSTALL/DEINSTALL scripts. MAKE_DIRS_PERMS
# is used the same way but the package admin isn't prompted to remove
# the directory at post-deinstall time if it isn't empty.
#
MAKE_DIRS?= # empty
MAKE_DIRS_PERMS?= # empty
_MAKE_DIRS= ${PKG_SYSCONFDIR} ${MAKE_DIRS}
OWN_DIRS?= # empty
OWN_DIRS_PERMS?= # empty
FILES_SUBST+= MAKE_DIRS=${_MAKE_DIRS:Q}
FILES_SUBST+= MAKE_DIRS_PERMS=${MAKE_DIRS_PERMS:Q}
FILES_SUBST+= OWN_DIRS=${OWN_DIRS:Q}
FILES_SUBST+= OWN_DIRS_PERMS=${OWN_DIRS_PERMS:Q}
# PKG_CREATE_USERGROUP indicates whether the INSTALL script should
# automatically add any needed users/groups to the system using
# useradd/groupadd. It is either YES or NO and defaults to YES.
#
# PKG_CONFIG indicates whether the INSTALL/DEINSTALL scripts should do
# automatic config file and directory handling, or if it should
# merely inform the admin of the list of required files and
# directories needed to use the package. It is either YES or NO
# and defaults to YES.
#
# PKG_RCD_SCRIPTS indicates whether to automatically install rc.d scripts
# to ${RCD_SCRIPTS_DIR}. It is either YES or NO and defaults to
# NO. This variable only takes effect if ${PKG_CONFIG} == "YES".
#
# These values merely set the defaults for INSTALL/DEINSTALL scripts, but
# they may be overridden by resetting them in the environment.
#
PKG_CREATE_USERGROUP?= YES
PKG_CONFIG?= YES
PKG_RCD_SCRIPTS?= NO
FILES_SUBST+= PKG_CREATE_USERGROUP=${PKG_CREATE_USERGROUP}
FILES_SUBST+= PKG_CONFIG=${PKG_CONFIG}
FILES_SUBST+= PKG_RCD_SCRIPTS=${PKG_RCD_SCRIPTS}
# Substitute for various programs used in the DEINSTALL/INSTALL scripts and
# in the rc.d scripts.
#
FILES_SUBST+= AWK=${AWK:Q}
FILES_SUBST+= BASENAME=${BASENAME:Q}
FILES_SUBST+= CAT=${CAT:Q}
FILES_SUBST+= CHGRP=${CHGRP:Q}
FILES_SUBST+= CHMOD=${CHMOD:Q}
FILES_SUBST+= CHOWN=${CHOWN:Q}
FILES_SUBST+= CMP=${CMP:Q}
FILES_SUBST+= CP=${CP:Q}
FILES_SUBST+= DIRNAME=${DIRNAME:Q}
FILES_SUBST+= ECHO=${ECHO:Q}
FILES_SUBST+= EGREP=${EGREP:Q}
FILES_SUBST+= EXPR=${EXPR:Q}
FILES_SUBST+= FALSE=${FALSE:Q}
FILES_SUBST+= FIND=${FIND:Q}
FILES_SUBST+= GREP=${GREP:Q}
FILES_SUBST+= GROUPADD=${GROUPADD:Q}
FILES_SUBST+= GTAR=${GTAR:Q}
FILES_SUBST+= HEAD=${HEAD:Q}
FILES_SUBST+= ID=${ID:Q}
FILES_SUBST+= INSTALL_INFO=${INSTALL_INFO:Q}
FILES_SUBST+= LN=${LN:Q}
FILES_SUBST+= MKDIR=${MKDIR:Q}
FILES_SUBST+= MV=${MV:Q}
FILES_SUBST+= PERL5=${PERL5:Q}
FILES_SUBST+= RM=${RM:Q}
FILES_SUBST+= RMDIR=${RMDIR:Q}
FILES_SUBST+= SED=${SED:Q}
FILES_SUBST+= SETENV=${SETENV:Q}
FILES_SUBST+= SH=${SH:Q}
FILES_SUBST+= SORT=${SORT:Q}
FILES_SUBST+= SU=${SU:Q}
FILES_SUBST+= TOUCH=${TOUCH:Q}
FILES_SUBST+= TR=${TR:Q}
FILES_SUBST+= TRUE=${TRUE:Q}
FILES_SUBST+= USERADD=${USERADD:Q}
FILES_SUBST+= XARGS=${XARGS:Q}
FILES_SUBST_SED= ${FILES_SUBST:S/=/@!/:S/$/!g/:S/^/ -e s!@/}
INSTALL_SCRIPTS_ENV= PKG_PREFIX=${PREFIX}
pre-install-script: generate-install-scripts
${_PKG_SILENT}${_PKG_DEBUG}${SETENV} ${INSTALL_SCRIPTS_ENV} \
${_PKG_DEBUG_SCRIPT} ${INSTALL_FILE} ${PKGNAME} PRE-INSTALL
post-install-script: install-rcd-scripts
${_PKG_SILENT}${_PKG_DEBUG}${SETENV} ${INSTALL_SCRIPTS_ENV} \
${_PKG_DEBUG_SCRIPT} ${INSTALL_FILE} ${PKGNAME} POST-INSTALL
post-build: generate-install-scripts
generate-install-scripts: # do nothing
.if !empty(DEINSTALL_SRC)
generate-install-scripts: ${DEINSTALL_FILE}
${DEINSTALL_FILE}: ${DEINSTALL_SRC}
${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} | \
${SED} ${FILES_SUBST_SED} > ${.TARGET}
${_PKG_SILENT}${_PKG_DEBUG}${CHMOD} +x ${.TARGET}
.endif
.if !empty(INSTALL_SRC)
generate-install-scripts: ${INSTALL_FILE}
${INSTALL_FILE}: ${INSTALL_SRC}
${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} | \
${SED} ${FILES_SUBST_SED} > ${.TARGET}
${_PKG_SILENT}${_PKG_DEBUG}${CHMOD} +x ${.TARGET}
.endif
# rc.d scripts are automatically generated and installed into the rc.d
# scripts example directory at the post-install step. The following
# variables are relevent to this process:
#
# RCD_SCRIPTS lists the basenames of the rc.d scripts
#
# RCD_SCRIPT_SRC.<script> the source file for <script>; this will
# be run through FILES_SUBST to generate
# the rc.d script
#
# RCD_SCRIPTS_EXAMPLEDIR the directory in which to install the
# example rc.d scripts
#
# If the source rc.d script is not present, then the automatic handling
# doesn't occur.
post-build: generate-rcd-scripts
generate-rcd-scripts: # do nothing
install-rcd-scripts: # do nothing
.for _script_ in ${RCD_SCRIPTS}
RCD_SCRIPT_SRC.${_script_}?= ${FILESDIR}/${_script_}.sh
. if !empty(RCD_SCRIPT_SRC.${_script_})
. if exists(${RCD_SCRIPT_SRC.${_script_}})
generate-rcd-scripts: ${WRKDIR}/${_script_}
${WRKDIR}/${_script_}: ${RCD_SCRIPT_SRC.${_script_}}
${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} | \
${SED} ${FILES_SUBST_SED} > ${.TARGET}
${_PKG_SILENT}${_PKG_DEBUG}${CHMOD} +x ${.TARGET}
install-rcd-scripts: install-rcd-${_script_}
install-rcd-${_script_}: ${WRKDIR}/${_script_}
${_PKG_SILENT}${_PKG_DEBUG} \
if [ ! -d ${RCD_SCRIPTS_EXAMPLEDIR} ]; then \
${INSTALL} -d -o ${SHAREOWN} -g ${SHAREGRP} -m 0755 \
${RCD_SCRIPTS_EXAMPLEDIR}; \
fi
${_PKG_SILENT}${_PKG_DEBUG} \
if [ -f ${WRKDIR}/${_script_} ]; then \
${INSTALL_SCRIPT} ${WRKDIR}/${_script_} \
${RCD_SCRIPTS_EXAMPLEDIR}; \
fi
. endif
. endif
.endfor
.endif # BSD_PKG_INSTALL_MK
|