blob: 7a978bcc23dda0ad1cda4251bf910303bc3d2d74 (
plain)
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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
|
# start of install
#
# $NetBSD: install,v 1.11 2002/07/24 20:30:07 jlam Exp $
case ${STAGE} in
PRE-INSTALL)
_pkg_exit=0
_print_line=1
_print_group=1
if [ -n "${PKG_GROUPS}" ]; then
eval set -- ${PKG_GROUPS}
for groupset; do
save_IFS="${IFS}"; IFS=":"
set -- ${groupset}
group="$1"; groupid="$2"
IFS="${save_IFS}"
# We need to check that ${PKG_GROUP} exists before
# adding the user. Do it with chgrp to be able to
# use NIS.
#
${TOUCH} /tmp/grouptest.$$
if ${CHGRP} ${group} /tmp/grouptest.$$ >/dev/null 2>&1; then
${ECHO} "Group '${group}' already exists."
elif [ "${_PKG_CREATE_USERGROUP}" = "NO" ]; then
if [ ${_print_line} -gt 0 ]; then
_print_line=0
${CAT} << EOF
===========================================================================
EOF
if [ ${_print_group} -gt 0 ]; then
_print_group=0
${CAT} << EOF
The following groups need to be created for ${PKGNAME}:
EOF
fi
fi
if [ -z "${groupid}" ]; then
groupid_str=
else
groupid_str=" (${groupid})"
fi
${ECHO} " ${group}${groupid_str}"
_pkg_exit=1
else
groupid_option=
if [ -n "${groupid}" ]; then
groupid_option="-g"
fi
${ECHO} "Creating group: ${group}"
${GROUPADD} ${groupid_option} ${groupid} "${group}"
fi
${RM} -f /tmp/grouptest.$$
done
fi
_print_user=1
if [ -n "${PKG_USERS}" ]; then
eval set -- ${PKG_USERS}
for userset; do
save_IFS="${IFS}"; IFS=":"
set -- ${userset}
user="$1"; group="$2"; userid="$3"
descr="${4:-${PKGBASE} ${user} user}"
home="${5:-@PKG_USER_HOME@}"
shell="${6:-@PKG_USER_SHELL@}"
IFS="${save_IFS}"
# Use `id' to be able to use NIS.
if ${ID} "${user}" >/dev/null 2>&1; then
${ECHO} "User '${user}' already exists."
elif [ "${_PKG_CREATE_USERGROUP}" = "NO" ]; then
if [ ${_print_line} -gt 0 ]; then
_print_line=0
${CAT} << EOF
===========================================================================
EOF
elif [ ${_print_group} -eq 0 ]; then
_print_group=1
${ECHO} "";
fi
if [ ${_print_user} -gt 0 ]; then
_print_user=0
${CAT} << EOF
The following users need to be created for ${PKGNAME}:
EOF
fi
if [ -z "${userid}" ]; then
userid_str=
else
userid_str=" (${userid})"
fi
${ECHO} " ${user}${userid_str}: ${group}, ${home}, ${shell}"
_pkg_exit=1
else
userid_option=
if [ -n "${userid}" ]; then
userid_option="-u"
fi
${ECHO} "Creating user: ${user}"
${USERADD} -c "${descr}" \
${userid_option} ${userid} \
-g "${group}" \
-d "${home}" \
-s "${shell}" \
"${user}"
fi
done
fi
if [ ${_print_line} -eq 0 ]; then
${CAT} << EOF
===========================================================================
EOF
fi
if [ ${_pkg_exit} -gt 0 ]; then
exit ${_pkg_exit}
fi
;;
POST-INSTALL)
# Create package directories.
_print_line=1
_print_dirs=1
if [ -n "${MAKE_DIRS}" -o -n "${OWN_DIRS}" -o \
-n "${MAKE_DIRS_PERMS}" -o -n "${OWN_DIRS_PERMS}" ]; then
eval set -- ${MAKE_DIRS} ${OWN_DIRS}
for dir; do
if [ -d "${dir}" ]; then
continue
fi
if [ "${_PKG_CONFIG}" = "NO" ]; then
if [ ${_print_line} -gt 0 ]; then
_print_line=0
${CAT} << EOF
===========================================================================
EOF
if [ ${_print_dirs} -gt 0 ]; then
_print_dirs=0
${CAT} << EOF
The following directories should be created for ${PKGNAME}:
EOF
fi
fi
${ECHO} " ${dir}"
else
${MKDIR} "${dir}"
fi
done
eval set -- ${MAKE_DIRS_PERMS} ${OWN_DIRS_PERMS}
while [ $# -gt 0 ]; do
dir="$1"; owner="$2"; group="$3"; mode="$4"
shift; shift; shift; shift
if [ "${_PKG_CONFIG}" = "NO" ]; then
if [ ${_print_line} -gt 0 ]; then
_print_line=0
${CAT} << EOF
===========================================================================
EOF
if [ ${_print_dirs} -gt 0 ]; then
_print_dirs=0
${CAT} << EOF
The following directories should be created for ${PKGNAME}:
EOF
fi
fi
${ECHO} " ${dir} (o=${owner}, g=${group}, m=${mode})"
else
${MKDIR} "${dir}"
${CHOWN} "${owner}" "${dir}"
${CHGRP} "${group}" "${dir}"
${CHMOD} "${mode}" "${dir}"
fi
done
fi
_print_files=1
if [ "${_PKG_CONFIG}" = "YES" ]; then
if [ -n "${CONF_FILES}" -o \
-n "${CONF_FILES_PERMS}" -o \
-n "${SUPPORT_FILES}" -o \
-n "${SUPPORT_FILES_PERMS}" -o \
-n "${RCD_SCRIPTS}" ]; then
${CAT} << EOF
Installing configuration files for ${PKGNAME}:
EOF
fi
fi
eval set -- ${CONF_FILES}
while [ $# -gt 0 ]; do
samplefile="$1"; file="$2"
shift; shift
if [ "${_PKG_CONFIG}" = "NO" ]; then
if [ ${_print_line} -gt 0 ]; then
_print_line=0
${CAT} << EOF
===========================================================================
EOF
elif [ ${_print_dirs} -eq 0 ]; then
_print_dirs=1
${ECHO} "";
fi
if [ ${_print_files} -gt 0 ]; then
_print_files=0
${CAT} << EOF
The following files should be created for ${PKGNAME}:
EOF
fi
${ECHO} " ${file} (m=@CONF_FILES_MODE@)"
elif [ -e "${file}" ]; then
${ECHO} " ${file} already exists, example file is"
${ECHO} " ${samplefile}"
else
if [ -e "${samplefile}" ]; then
${ECHO} " ${file}"
${CP} "${samplefile}" "${file}"
${CHMOD} @CONF_FILES_MODE@ "${file}"
fi
fi
done
eval set -- ${SUPPORT_FILES}
while [ $# -gt 0 ]; do
samplefile="$1"; file="$2"
shift; shift
if [ "${_PKG_CONFIG}" = "NO" ]; then
if [ ${_print_line} -gt 0 ]; then
_print_line=0
${CAT} << EOF
===========================================================================
EOF
elif [ ${_print_dirs} -eq 0 ]; then
_print_dirs=1
${ECHO} "";
fi
if [ ${_print_files} -gt 0 ]; then
_print_files=0
${CAT} << EOF
The following files should be created for ${PKGNAME}:
EOF
fi
${ECHO} " ${file} (m=@SUPPORT_FILES_MODE@)"
elif [ -e "${file}" ]; then
${ECHO} " ${file} already exists, example file is"
${ECHO} " ${samplefile}"
else
if [ -e "${samplefile}" ]; then
${ECHO} " ${file}"
${CP} "${samplefile}" "${file}"
${CHMOD} @SUPPORT_FILES_MODE@ "${file}"
fi
fi
done
eval set -- ${CONF_FILES_PERMS} ${SUPPORT_FILES_PERMS}
while [ $# -gt 0 ]; do
samplefile="$1"; file="$2"
owner="$3"; group="$4"; mode="$5"
shift; shift; shift; shift; shift
if [ "${_PKG_CONFIG}" = "NO" ]; then
if [ ${_print_line} -gt 0 ]; then
_print_line=0
${CAT} << EOF
===========================================================================
EOF
elif [ ${_print_dirs} -eq 0 ]; then
_print_dirs=1
${ECHO} "";
fi
if [ ${_print_files} -gt 0 ]; then
_print_files=0
${CAT} << EOF
The following files should be created for ${PKGNAME}:
EOF
fi
${ECHO} " ${file} (o=${owner}, g=${group}, m=${mode})"
elif [ -e ${file} ]; then
${ECHO} " ${file} already exists, example file is"
${ECHO} " ${samplefile}"
else
if [ -e "${samplefile}" ]; then
${ECHO} " ${file}"
${CP} "${samplefile}" "${file}"
${CHOWN} "${owner}" "${file}"
${CHGRP} "${group}" "${file}"
${CHMOD} ${mode} "${file}"
fi
fi
done
eval set -- ${RCD_SCRIPTS}
for script; do
samplefile="${RCD_SCRIPTS_EXAMPLEDIR}/${script}"
file="${RCD_SCRIPTS_DIR}/${script}"
if [ "${_PKG_CONFIG}" = "NO" ]; then
if [ ${_print_line} -gt 0 ]; then
_print_line=0
${CAT} << EOF
===========================================================================
EOF
elif [ ${_print_dirs} -eq 0 ]; then
_print_dirs=1
${ECHO} "";
fi
if [ ${_print_files} -gt 0 ]; then
_print_files=0
${CAT} << EOF
The following files should be created for ${PKGNAME}:
EOF
fi
${ECHO} " ${file} (m=@RCD_SCRIPTS_MODE@)"
elif [ -e "${file}" ]; then
${ECHO} " ${file} already exists, example file is"
${ECHO} " ${samplefile}"
else
if [ -e "${samplefile}" ]; then
${ECHO} " ${file}"
${CP} "${samplefile}" "${file}"
${CHMOD} @RCD_SCRIPTS_MODE@ "${file}"
fi
fi
done
if [ ${_print_line} -eq 0 ]; then
${CAT} << EOF
===========================================================================
EOF
fi
if [ "${_PKG_CONFIG}" = "YES" ]; then
if [ -n "${CONF_FILES}" -o -n "${CONF_FILES_PERMS}" ]; then
${CAT} << EOF
===========================================================================
You may wish to customize the following files for ${PKGNAME}:
EOF
eval set -- ${CONF_FILES}
while [ $# -gt 0 ]; do
samplefile="$1"; file="$2"
shift; shift
${ECHO} " ${file}"
done
eval set -- ${CONF_FILES_PERMS}
while [ $# -gt 0 ]; do
samplefile="$1"; file="$2"
owner="$3"; group="$4"; mode="$5"
shift; shift; shift; shift; shift
${ECHO} " ${file}"
done
${CAT} << EOF
===========================================================================
EOF
fi
fi
;;
*)
${ECHO} "Unexpected argument: ${STAGE}"
exit 1
;;
esac
# end of install
|