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
|
#-*- tab-width: 4; -*-
# ex:ts=4
#
# $FreeBSD$
#
.if defined(_POSTMKINCLUDED)
PKGNG_Include_MAINTAINER= portmgr@FreeBSD.org
METADIR= ${WRKDIR}/.metadir
MANIFESTF= ${METADIR}/+MANIFEST
PKGPREINSTALL?= ${PKGDIR}/pkg-pre-install
PKGPOSTINSTALL?= ${PKGDIR}/pkg-post-install
PKGPREDEINSTALL?= ${PKGDIR}/pkg-pre-deinstall
PKGPOSTDEINSTALL?= ${PKGDIR}/pkg-post-deinstall
PKGPREUPGRADE?= ${PKGDIR}/pkg-pre-upgrade
PKGPOSTUPGRADE?= ${PKGDIR}/pkg-post-upgrade
PKGUPGRADE?= ${PKGDIR}/pkg-upgrade
_FORCE_POST_PATTERNS= rmdir kldxref mkfontscale mkfontdir fc-cache \
fonts.dir fonts.scale gtk-update-icon-cache \
gio-querymodules \
gtk-query-immodules \
ldconfig \
load-octave-pkg \
update-desktop-database update-mime-database \
gdk-pixbuf-query-loaders catalog.ports \
glib-compile-schemas
PLIST_REINPLACE:= ${PLIST_REINPLACE:Ndirrmtry}
PLIST_REINPLACE:= ${PLIST_REINPLACE:Nstopdaemon}
ACTUAL-PACKAGE-DEPENDS?= \
if [ "${_LIB_RUN_DEPENDS}" != " " ]; then \
${PKG_QUERY} "%n: {origin: %o, version: \"%v\"}" " " ${_LIB_RUN_DEPENDS:C,[^:]*:([^:]*):?.*,\1,:C,${PORTSDIR}/,,} 2>/dev/null || : ; \
${PKG_QUERY} "%dn: {origin: %do, version: \"%dv\"}" " " ${_LIB_RUN_DEPENDS:C,[^:]*:([^:]*):?.*,\1,:C,${PORTSDIR}/,,} 2>/dev/null || : ; \
fi
create-manifest:
@${MKDIR} ${METADIR}
@${ECHO_CMD} "name: ${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}" > ${MANIFESTF}
@${ECHO_CMD} "version: ${PKGVERSION}" >> ${MANIFESTF}
@${ECHO_CMD} "origin: ${PKGORIGIN}" >> ${MANIFESTF}
@${ECHO_CMD} "comment: |" >> ${MANIFESTF}
@${ECHO_CMD} " "${COMMENT:Q} >> ${MANIFESTF}
@${ECHO_CMD} "maintainer: ${MAINTAINER}" >> ${MANIFESTF}
@${ECHO_CMD} "prefix: ${PREFIX}" >> ${MANIFESTF}
#.if defined(NO_ARCH)
# @${ECHO_CMD} "arch: `${PKG_BIN} config abi | ${CUT} -d: -f1,2`:*" >> ${MANIFESTF}
#.endif
.if defined(WWW)
@${ECHO_CMD} "www: ${WWW}" >> ${MANIFESTF}
.endif
@${ECHO_CMD} "deps: " >> ${MANIFESTF}
@${ACTUAL-PACKAGE-DEPENDS} | ${GREP} -v -E ${PKG_IGNORE_DEPENDS} | ${SORT} -u | ${SED} 's/^/ /' >> ${MANIFESTF}
@${ECHO_CMD} -n "categories: [" >> ${MANIFESTF}
.for cat in ${CATEGORIES:u}
@${ECHO_CMD} -n "${cat}," >> ${MANIFESTF}
.endfor
@${ECHO_CMD} "]" >> ${MANIFESTF}
.if defined(LICENSE_COMB)
@${ECHO_CMD} "licenselogic: ${LICENSE_COMB}" >> ${MANIFESTF}
.else
@${ECHO_CMD} "licenselogic: single" >> ${MANIFESTF}
.endif
@${ECHO_CMD} -n "licenses: [" >> ${MANIFESTF}
.for lic in ${LICENSE:u}
@${ECHO_CMD} -n "${lic}," >> ${MANIFESTF}
.endfor
@${ECHO_CMD} "]" >> ${MANIFESTF}
@${ECHO_CMD} -n "users: [" >> ${MANIFESTF}
.for user in ${USERS:u}
@${ECHO_CMD} -n "${user}, " >> ${MANIFESTF}
.endfor
@${ECHO_CMD} "]" >> ${MANIFESTF}
@${ECHO_CMD} -n "groups: [" >> ${MANIFESTF}
.for group in ${GROUPS:u}
@${ECHO_CMD} -n "${group}, " >> ${MANIFESTF}
.endfor
@${ECHO_CMD} "]" >> ${MANIFESTF}
@${ECHO_CMD} -n "options: {" >> ${MANIFESTF}
.for opt in ${COMPLETE_OPTIONS_LIST}
@[ -z "${PORT_OPTIONS:M${opt}}" ] || match="on" ; ${ECHO_MSG} -n " ${opt}: $${match:-off}," >> ${MANIFESTF}
.endfor
.undef opt
@${ECHO_CMD} "}" >> ${MANIFESTF}
@[ -f ${PKGINSTALL} ] && ${CP} ${PKGINSTALL} ${METADIR}/+INSTALL; \
${RM} -f ${METADIR}/+PRE_INSTALL ; \
for a in ${PKGPREINSTALL}; do \
[ -f $$a ] && ${CAT} $$a >> ${METADIR}/+PRE_INSTALL ; \
done ; \
${RM} -f ${METADIR}/+POST_INSTALL ; \
for a in ${PKGPOSTINSTALL}; do \
[ -f $$a ] && ${CAT} $$a >> ${METADIR}/+POST_INSTALL ; \
done ; \
[ -f ${PKGDEINSTALL} ] && ${CP} ${PKGDEINSTALL} ${METADIR}/+DEINSTALL; \
${RM} -f ${METADIR}/+PRE_DEINSTALL ; \
for a in ${PKGPREDEINSTALL}; do \
[ -f $$a ] && ${CAT} $$a >> ${METADIR}/+PRE_DEINSTALL ; \
done ; \
${RM} -f ${METADIR}/+POST_DEINSTALL ; \
for a in ${PKGPOSTDEINSTALL}; do \
[ -f $$a ] && ${CAT} $$a >> ${METADIR}/+POST_DEINSTALL ; \
done ; \
[ -f ${PKGPOSTDEINSTALL} ] && ${CP} ${PKGPOSTDEINSTALL} ${METADIR}/+POST_DEINSTALL; \
[ -f ${PKGUPGRADE} ] && ${CP} ${PKGUPGRADE} ${METADIR}/+UPGRADE; \
[ -f ${PKGPREUPGRADE} ] && ${CP} ${PKGPREUPGRADE} ${METADIR}/+PRE_UPGRADE; \
[ -f ${PKGPOSTUPGRADE} ] && ${CP} ${PKGPOSTUPGRADE} ${METADIR}/+POST_UPGRADE; \
${CP} ${DESCR} ${METADIR}/+DESC; \
[ -f ${PKGMESSAGE} ] && ${CP} ${PKGMESSAGE} ${METADIR}/+DISPLAY || return 0
.if !defined(NO_MTREE)
@[ -f ${MTREE_FILE} ] && ${CP} ${MTREE_FILE} ${METADIR}/+MTREE_DIRS || return 0
.endif
.if !target(fake-pkg)
.if defined(NO_STAGE)
STAGE_ARGS= -l
.else
STAGE_ARGS= -i ${STAGEDIR}
.endif
fake-pkg: create-manifest
.if !defined(NO_PKG_REGISTER)
.if defined(INSTALLS_DEPENDS)
@${ECHO_MSG} "===> Registering installation for ${PKGNAME} as automatic"
.else
@${ECHO_MSG} "===> Registering installation for ${PKGNAME}"
.endif
.if defined(INSTALLS_DEPENDS)
@${SETENV} FORCE_POST="${_FORCE_POST_PATTERNS}" ${PKG_CMD} -d ${STAGE_ARGS} -m ${METADIR} -f ${TMPPLIST}
.else
@${SETENV} FORCE_POST="${_FORCE_POST_PATTERNS}" ${PKG_CMD} ${STAGE_ARGS} -m ${METADIR} -f ${TMPPLIST}
.endif
@${RM} -rf ${METADIR}
.else
@${DO_NADA}
.endif
.endif
.if defined(WITH_PKGNG)
.if !target(check-build-conflicts)
check-build-conflicts:
.if ( defined(CONFLICTS) || defined(CONFLICTS_BUILD) ) && !defined(DISABLE_CONFLICTS) && !defined(DEFER_CONFLICTS_CHECK)
@conflicts_with=$$( \
{ ${PKG_QUERY} -g "%n-%v %p %o" ${CONFLICTS:C/.+/'&'/} ${CONFLICTS_BUILD:C/.+/'&'/} 2>/dev/null || : ; } \
| while read pkgname prfx orgn; do \
if [ "/${PREFIX}" = "/$${prfx}" -a "/${PKGORIGIN}" != "/$${orgn}" ]; then \
${ECHO_CMD} -n " $${pkgname}"; \
fi; \
done); \
if [ -n "$${conflicts_with}" ]; then \
${ECHO_MSG}; \
${ECHO_MSG} "===> ${PKGNAME} conflicts with installed package(s): "; \
for entry in $${conflicts_with}; do \
${ECHO_MSG} " $${entry}"; \
done; \
${ECHO_MSG}; \
${ECHO_MSG} " They will not build together."; \
${ECHO_MSG} " Please remove them first with pkg delete."; \
exit 1;\
fi
.endif
.endif
.if !target(identify-install-conflicts)
identify-install-conflicts:
.if ( defined(CONFLICTS) || defined(CONFLICTS_INSTALL) ) && !defined(DISABLE_CONFLICTS)
@conflicts_with=$$( \
{ ${PKG_QUERY} -g "%n-%v %p %o" ${CONFLICTS:C/.+/'&'/} ${CONFLICTS_INSTALL:C/.+/'&'/} 2>/dev/null || : ; } \
| while read pkgname prfx orgn; do \
if [ "/${PREFIX}" = "/$${prfx}" -a "/${PKGORIGIN}" != "/$${orgn}" ]; then \
${ECHO_CMD} -n " $${pkgname}"; \
fi; \
done); \
if [ -n "$${conflicts_with}" ]; then \
${ECHO_MSG}; \
${ECHO_MSG} "===> ${PKGNAME} conflicts with installed package(s): "; \
for entry in $${conflicts_with}; do \
${ECHO_MSG} " $${entry}"; \
done; \
${ECHO_MSG}; \
${ECHO_MSG} " They install files into the same place."; \
${ECHO_MSG} " You may want to stop build with Ctrl + C."; \
sleep 10; \
fi
.endif
.endif
.if !target(check-install-conflicts)
check-install-conflicts:
.if ( defined(CONFLICTS) || defined(CONFLICTS_INSTALL) || ( defined(CONFLICTS_BUILD) && defined(DEFER_CONFLICTS_CHECK) ) ) && !defined(DISABLE_CONFLICTS)
.if defined(DEFER_CONFLICTS_CHECK)
@conflicts_with=$$( \
{ ${PKG_QUERY} -g "%n-%v %p %o" ${CONFLICTS:C/.+/'&'/} ${CONFLICTS_BUILD:C/.+/'&'/} ${CONFLICTS_INSTALL:C/.+/'&'/} 2>/dev/null || : ; } \
| while read pkgname prfx orgn; do \
if [ "/${PREFIX}" = "/$${prfx}" -a "/${PKGORIGIN}" != "/$${orgn}" ]; then \
${ECHO_CMD} -n " $${pkgname}"; \
fi; \
done); \
if [ -n "$${conflicts_with}" ]; then \
${ECHO_MSG}; \
${ECHO_MSG} "===> ${PKGNAME} conflicts with installed package(s): "; \
for entry in $${conflicts_with}; do \
${ECHO_MSG} " $${entry}"; \
done; \
${ECHO_MSG}; \
${ECHO_MSG} " Please remove them first with pkg delete."; \
exit 1; \
fi
.else
@conflicts_with=$$( \
{ ${PKG_QUERY} -g "%n-%v %p %o" ${CONFLICTS:C/.+/'&'/} ${CONFLICTS_INSTALL:C/.+/'&'/} 2>/dev/null || : ; } \
| while read pkgname prfx orgn; do \
if [ "/${PREFIX}" = "/$${prfx}" -a "/${PKGORIGIN}" != "/$${orgn}" ]; then \
${ECHO_CMD} -n " $${pkgname}"; \
fi; \
done); \
if [ -n "$${conflicts_with}" ]; then \
${ECHO_MSG}; \
${ECHO_MSG} "===> ${PKGNAME} conflicts with installed package(s): "; \
for entry in $${conflicts_with}; do \
${ECHO_MSG} " $${entry}"; \
done; \
${ECHO_MSG}; \
${ECHO_MSG} " They install files into the same place."; \
${ECHO_MSG} " Please remove them first with pkg delete."; \
exit 1; \
fi
.endif # defined(DEFER_CONFLICTS_CHECK)
.endif
.endif
.endif
.if !target(do-package)
.if !defined(NO_STAGE)
PKG_CREATE_ARGS= -r ${STAGEDIR} -m ${METADIR} -p ${TMPPLIST}
do-package: create-manifest
.endif
do-package: ${TMPPLIST}
@if [ -d ${PACKAGES} ]; then \
if [ ! -d ${PKGREPOSITORY} ]; then \
if ! ${MKDIR} ${PKGREPOSITORY}; then \
${ECHO_MSG} "=> Can't create directory ${PKGREPOSITORY}."; \
exit 1; \
fi; \
fi; \
fi
@for cat in ${CATEGORIES}; do \
${RM} -f ${PACKAGES}/$$cat/${PKGNAMEPREFIX}${PORTNAME}*${PKG_SUFX} ; \
done
@if ${PKG_CREATE} ${PKG_CREATE_ARGS} -o ${PKGREPOSITORY} ${PKGNAME}; then \
if [ -n "${WITH_PKGNG}" ]; then \
if [ "${PKGORIGIN}" = "ports-mgmt/pkg" -o "${PKGORIGIN}" = "ports-mgmt/pkg-devel" ]; then \
if [ ! -d ${PKGLATESTREPOSITORY} ]; then \
if ! ${MKDIR} ${PKGLATESTREPOSITORY}; then \
${ECHO_MSG} "=> Can't create directory ${PKGLATESTREPOSITORY}."; \
exit 1; \
fi; \
fi ; \
${LN} -sf ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PKGLATESTFILE} ; \
fi; \
else \
if [ -d ${PACKAGES} ]; then \
cd ${.CURDIR} && eval ${MAKE} package-links; \
fi; \
fi ; \
else \
cd ${.CURDIR} && eval ${MAKE} delete-package; \
exit 1; \
fi
.endif
.if defined(WITH_PKGNG)
.if !target(check-already-installed)
check-already-installed:
.if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER)
@${ECHO_MSG} "===> Checking if ${PKGORIGIN} already installed"; \
pkgname=`${PKG_INFO} -q -O ${PKGORIGIN}`; \
if [ -n "$${pkgname}" ]; then \
v=`${PKG_VERSION} -t $${pkgname} ${PKGNAME}`; \
if [ "$${v}" = "<" ]; then \
${ECHO_CMD} "===> An older version of ${PKGORIGIN} is already installed ($${pkgname})"; \
else \
${ECHO_CMD} "===> ${PKGNAME} is already installed"; \
fi; \
${ECHO_MSG} " You may wish to \`\`make deinstall'' and install this port again"; \
${ECHO_MSG} " by \`\`make reinstall'' to upgrade it properly."; \
${ECHO_MSG} " If you really wish to overwrite the old port of ${PKGORIGIN}"; \
${ECHO_MSG} " without deleting it first, set the variable \"FORCE_PKG_REGISTER\""; \
${ECHO_MSG} " in your environment or the \"make install\" command line."; \
exit 1; \
fi
.else
@${DO_NADA}
.endif
.endif
.if !target(deinstall)
deinstall:
.if defined(UID) && ${UID} != 0 && !defined(INSTALL_AS_USER)
@${ECHO_MSG} "===> Switching to root credentials for '${.TARGET}' target"
@cd ${.CURDIR} && \
${SU_CMD} "${MAKE} ${.TARGET}"
@${ECHO_MSG} "===> Returning to user credentials"
.else
@${ECHO_MSG} "===> Deinstalling for ${PKGORIGIN}"
@if ${PKG_INFO} -e ${PKGORIGIN}; then \
p=`${PKG_INFO} -q ${PKGORIGIN}`; \
${ECHO_MSG} "===> Deinstalling $${p}"; \
${PKG_DELETE} -f ${PKGORIGIN} ; \
else \
${ECHO_MSG} "===> ${PKGBASE} not installed, skipping"; \
fi
@${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
.endif
.endif
.endif
.endif # defined(_POSTMKINCLUDED)
|