Check-in [f81dd2951c]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix package building with stage and pkgng
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:f81dd2951c148352270f425bfc2355d7e7618fd3
User & Date: bapt 2013-09-19 18:15:30
Context
2013-09-19
18:45
Fix stagedir with pkg_install check-in: 492462dc2f user: bapt tags: trunk
18:15
Fix package building with stage and pkgng check-in: f81dd2951c user: bapt tags: trunk
12:34
Really out of the stagedir check-in: 599871a874 user: bapt tags: trunk
Changes

Changes to stage.patch.













1
2
3
4
5
6
7
..
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
...
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209




210
211
212
213
214
215
216
...
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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
...
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
...
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
...
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
...
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
...
551
552
553
554
555
556
557

















558
559
560
561
562
563
564












Index: bsd.licenses.mk
===================================================================
diff --git a/head/Mk/bsd.licenses.mk b/head/Mk/bsd.licenses.mk
--- a/head/Mk/bsd.licenses.mk	(revision 327600)
+++ b/head/Mk/bsd.licenses.mk	(working copy)
@@ -749,14 +749,14 @@
 .endif
................................................................................
 .else
 .	for lic in ${_LICENSE}
-	@${INSTALL_DATA} ${_LICENSE_FILE_${lic}} ${_LICENSE_DIR}/${lic}
+	@${INSTALL_DATA} ${_LICENSE_FILE_${lic}} ${STAGEDIR}${_LICENSE_DIR}/${lic}
 .	endfor
 .endif
 # XXX @dirrmtry entry must be here (no way to do with PLIST_* vars)














Index: bsd.pkgng.mk
===================================================================
diff --git a/head/Mk/bsd.pkgng.mk b/head/Mk/bsd.pkgng.mk
--- a/head/Mk/bsd.pkgng.mk	(revision 327600)
+++ b/head/Mk/bsd.pkgng.mk	(working copy)
@@ -37,6 +37,12 @@

 	fi
 
 .if !target(fake-pkg)


















+.if defined(NO_STAGE)
+STAGE_ARGS=		-l
+.else
+STAGE_ARGS=		-i ${STAGEDIR}
+.endif
+
 fake-pkg:
 .if !defined(NO_PKG_REGISTER)
 .if defined(INSTALLS_DEPENDS)
@@ -44,6 +50,7 @@

 .else

 	@${ECHO_MSG} "===>   Registering installation for ${PKGNAME}"
 .endif
+	@${FIND} ${STAGEDIR} -print
 	@${MKDIR} ${METADIR}
 	@${ECHO_CMD} "name: ${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}" > ${MANIFESTF} 
 	@${ECHO_CMD} "version: ${PKGVERSION}" >> ${MANIFESTF} 
@@ -103,9 +110,9 @@
 	@[ -f ${MTREE_FILE} ] && ${CP} ${MTREE_FILE} ${METADIR}/+MTREE_DIRS || return 0
 .endif
 .if defined(INSTALLS_DEPENDS)
-	@${SETENV} FORCE_POST="${_FORCE_POST_PATTERNS}" ${PKG_CMD} -d -l -m ${METADIR} -f ${TMPPLIST}
+	@${SETENV} FORCE_POST="${_FORCE_POST_PATTERNS}" ${PKG_CMD} -d ${STAGE_ARGS} -m ${METADIR} -f ${TMPPLIST}
 .else
-	@${SETENV} FORCE_POST="${_FORCE_POST_PATTERNS}" ${PKG_CMD} -l -m ${METADIR} -f ${TMPPLIST}
+	@${SETENV} FORCE_POST="${_FORCE_POST_PATTERNS}" ${PKG_CMD} ${STAGE_ARGS} -m ${METADIR} -f ${TMPPLIST}
 .endif
 	@${RM} -rf ${METADIR}
 .else

@@ -113,6 +120,7 @@
 .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)
@@ -204,9 +212,68 @@
 .endif # defined(DEFER_CONFLICTS_CHECK)
 .endif
 .endif
+.endif
 
 .if !target(do-package)
 do-package: ${TMPPLIST}
+	@${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(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; \
+	[ -f ${PKGPREINSTALL} ] && ${CP} ${PKGPREINSTALL} ${METADIR}/+PRE_INSTALL; \
+	[ -f ${PKGPOSTINSTALL} ] && ${CP} ${PKGPOSTINSTALL} ${METADIR}/+POST_INSTALL; \
+	[ -f ${PKGDEINSTALL} ] && ${CP} ${PKGDEINSTALL} ${METADIR}/+DEINSTALL; \
+	[ -f ${PKGPREDEINSTALL} ] && ${CP} ${PKGPREDEINSTALL} ${METADIR}/+PRE_DEINSTALL; \
+	[ -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 [ -d ${PACKAGES} ]; then \
 		if [ ! -d ${PKGREPOSITORY} ]; then \
 			if ! ${MKDIR} ${PKGREPOSITORY}; then \
@@ -219,15 +286,21 @@







 		${RM} -f ${PACKAGES}/$$cat/${PKGNAMEPREFIX}${PORTNAME}*${PKG_SUFX} ; \
 	done
 	@if ${PKG_CREATE} -o ${PKGREPOSITORY} ${PKGNAME}; 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; \





+		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 ; \
-			${LN} -sf ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PKGLATESTFILE} ; \
-		fi; \
+		fi ; \
 	else \
 		cd ${.CURDIR} && eval ${MAKE} delete-package; \
 		exit 1; \
@@ -234,6 +307,7 @@
 	fi
 .endif
 
+.if defined(WITH_PKGNG)
 .if !target(check-already-installed)
 check-already-installed:
 .if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER)
@@ -278,5 +352,6 @@
 	@${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
 .endif
 .endif
+.endif
 
 .endif # defined(_POSTMKINCLUDED)
Index: bsd.port.mk
................................................................................
+.if defined(FORCE_STAGE)
+.undef NO_STAGE
+.endif
+
 # make sure bmake treats -V as expected 
 .MAKE.EXPAND_VARIABLES= yes
 # tell bmake we use the old :L :U modifiers
@@ -1904,6 +1908,11 @@
 .if defined(WITH_PKGNG)
 .include "${PORTSDIR}/Mk/bsd.pkgng.mk"
 .endif
+
+.if !defined(NO_STAGE)
+.include "${PORTSDIR}/Mk/bsd.stage.mk"
+.endif




+
 .if defined(USE_LOCAL_MK)
 .include "${PORTSDIR}/Mk/bsd.local.mk"
 .endif
@@ -2082,6 +2091,7 @@
 BUILD_COOKIE?=		${WRKDIR}/.build_done.${PORTNAME}.${PREFIX:S/\//_/g}
 PATCH_COOKIE?=		${WRKDIR}/.patch_done.${PORTNAME}.${PREFIX:S/\//_/g}
................................................................................
 	@${ECHO_MSG} "===>   Installing 32-bit ldconfig configuration file"
 .if defined(NO_LDCONFIG_MTREE)
-	@${MKDIR} ${PREFIX}/${LDCONFIG_32DIR}
+	@${MKDIR} ${STAGEDIR}${PREFIX}/${LDCONFIG_32DIR}
 .endif
 	@${ECHO_CMD} ${USE_LDCONFIG32} | ${TR} ' ' '\n' \
 		> ${PREFIX}/${LDCONFIG32_DIR}/${UNIQUENAME}
@@ -4225,6 +4276,30 @@
 _BUILD_DEP=		configure
 _BUILD_SEQ=		build-message pre-build pre-build-script do-build \
 				post-build post-build-script
+.if !defined(NO_STAGE)
+
+_STAGE_DEP=		build
+_STAGE_SEQ=		stage-message stage-dir apply-slist pre-install generate-plist pre-su-install \
+				create-users-groups do-install post-install post-stage compress-man install-rc-script \
+				install-ldconfig-file install-license \
+				install-desktop-entries add-plist-info add-plist-docs add-plist-examples \
+				add-plist-data add-plist-post fix-plist-sequence
+.if defined(WITHT_PKGNG)
+_INSTALL_DEP=	stage
+_INSTALL_SEQ=	install-message run-depends lib-depends fake-pkg security-check
+
+_PACKAGE_DEP=	stage
+_PACKAGE_SEQ=	package-message pre-package pre-package-script do-package post-package-script

+.else # pkg_install

+_PACKAGE_DEP=	stage
+_PACKAGE_SEQ=	package-message pre-package pre-package-script do-package post-package-script
+
+_INSTALL_DEP=	package
+_INSTALL_SEQ=	install-message run-depends lib-depends install-package done-message
+.endif
+
+.else
+
 _INSTALL_DEP=	build
 _INSTALL_SEQ=	install-message check-install-conflicts run-depends lib-depends apply-slist pre-install \
 				pre-install-script generate-plist check-already-installed
@@ -4238,6 +4313,7 @@
 _PACKAGE_DEP=	install
 _PACKAGE_SEQ=	package-message pre-package pre-package-script \
 				do-package post-package-script
+.endif
 
 .if !target(post-chroot)
 post-chroot:
@@ -4260,7 +4336,7 @@
 # Main logic. The loop generates 6 main targets and using cookies
 # ensures that those already completed are skipped.
 
-.for target in extract patch configure build install package
+.for target in extract patch configure build stage install package
 
 .if !target(${target}) && defined(_OPTIONS_OK)
 ${target}: ${${target:U}_COOKIE}
@@ -4314,6 +4390,9 @@
 .ORDER: ${_PATCH_DEP} ${_PATCH_SEQ}
 .ORDER: ${_CONFIGURE_DEP} ${_CONFIGURE_SEQ}
 .ORDER: ${_BUILD_DEP} ${_BUILD_SEQ}
+.if !defined(NO_STAGE)
+.ORDER: ${_STAGE_DEP} ${_STAGE_SEQ}
+.endif
 .ORDER: ${_INSTALL_DEP} ${_INSTALL_SEQ}
 .ORDER: ${_PACKAGE_DEP} ${_PACKAGE_SEQ}
 
@@ -4325,6 +4404,8 @@
 	@${ECHO_MSG} "===>  Configuring for ${PKGNAME}"
 build-message:
 	@${ECHO_MSG} "===>  Building for ${PKGNAME}"
+stage-message:
+	@${ECHO_MSG} "===>  Staging for ${PKGNAME}"
 install-message:
 	@${ECHO_MSG} "===>  Installing for ${PKGNAME}"
 package-message:
@@ -4333,7 +4414,7 @@
 # Empty pre-* and post-* targets
 
 .for stage in pre post
-.for name in pkg check-sanity fetch extract patch configure build install package
+.for name in pkg check-sanity fetch extract patch configure build stage install package
 
 .if !target(${stage}-${name})
 ${stage}-${name}:
@@ -4396,6 +4477,12 @@
 	@cd ${.CURDIR} && DEPENDS_TARGET="${DEPENDS_TARGET}" ${MAKE} -DFORCE_PKG_REGISTER install
 .endif
 
+.if !target(restage)
+restage:
+	@${RM} -rf ${STAGE_DESTDIR} ${STAGE_COOKIE} ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
+	@cd ${.CURDIR} && ${MAKE} stage
+.endif
+
 # Deinstall
 #
 # Special target to remove installation
@@ -5612,6 +5699,7 @@
 	@for file in ${PLIST_FILES}; do \
 		${ECHO_CMD} $${file} | ${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} >> ${TMPPLIST}; \
 	done
+.if !defined(NO_STAGE)
 	@for man in ${__MANPAGES}; do \
 		${ECHO_CMD} $${man} >> ${TMPPLIST}; \
 	done
@@ -5629,6 +5717,7 @@
 	@${ECHO_CMD} '@cwd ${PREFIX}' >> ${TMPPLIST}
 .endif
 .endfor
+.endif
 	@if [ -f ${PLIST} ]; then \
 		${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} ${PLIST} >> ${TMPPLIST}; \
 	fi
@@ -5691,14 +5780,14 @@
 	fi
 .for x in ${PORTDOCS}
 	@if ${ECHO_CMD} "${x}"| ${AWK} '$$1 ~ /(\*|\||\[|\]|\?|\{|\}|\$$)/ { exit 1};'; then \
-		if [ ! -e ${DOCSDIR}/${x} ]; then \
+		if [ ! -e ${STAGEDIR}${DOCSDIR}/${x} ]; then \
 		${ECHO_CMD} ${DOCSDIR_REL}/${x} >> ${TMPPLIST}; \
 	fi;fi
................................................................................
+	@${FIND} -P ${STAGEDIR}${PORTDOCS:S/^/${STAGEDIR}${DOCSDIR}\//} ! -type d 2>/dev/null | \
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,,p' >> ${TMPPLIST}
+	@${FIND} -P -d ${STAGEDIR}${PORTDOCS:S/^/${STAGEDIR}${DOCSDIR}\//} -type d 2>/dev/null | \
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,@dirrm ,p' >> ${TMPPLIST}
 	@${ECHO_CMD} "@dirrm ${DOCSDIR_REL}" >> ${TMPPLIST}
 .else
 	@${DO_NADA}
@@ -5714,16 +5803,16 @@
 	fi
 .for x in ${PORTEXAMPLES}
 	@if ${ECHO_CMD} "${x}"| ${AWK} '$$1 ~ /(\*|\||\[|\]|\?|\{|\}|\$$)/ { exit 1};'; then \
-		if [ ! -e ${EXAMPLESDIR}/${x} ]; then \
+		if [ ! -e ${STAGEDIR}${EXAMPLESDIR}/${x} ]; then \
 		${ECHO_CMD} ${EXAMPLESDIR}/${x} | \
 			${SED} -e 's,^${PREFIX}/,,' >> ${TMPPLIST}; \
................................................................................
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,,p' >> ${TMPPLIST}
+	@${FIND} -P -d ${STAGEDIR}${PORTEXAMPLES:S/^/${STAGEDIR}${EXAMPLESDIR}\//} -type d 2>/dev/null | \
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,@dirrm ,p' >> ${TMPPLIST}
+	@${ECHO_CMD} "@dirrm ${EXAMPLESDIR:S,^${STAGEDIR}${PREFIX}/,,}" >> ${TMPPLIST}
 .else
 	@${DO_NADA}
 .endif
@@ -5738,16 +5827,16 @@
 	fi
 .for x in ${PORTDATA}
 	@if ${ECHO_CMD} "${x}"| ${AWK} '$$1 ~ /(\*|\||\[|\]|\?|\{|\}|\$$)/ { exit 1};'; then \
-		if [ ! -e ${DATADIR}/${x} ]; then \
+		if [ ! -e ${STAGEDIR}${DATADIR}/${x} ]; then \
 		${ECHO_CMD} ${DATADIR}/${x} | \
 			${SED} -e 's,^${PREFIX}/,,' >> ${TMPPLIST}; \
................................................................................
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,,p' >> ${TMPPLIST}
+	@${FIND} -P -d ${STAGEDIR}${PORTDATA:S/^/${STAGEDIR}${DATADIR}\//} -type d 2>/dev/null | \
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,@dirrm ,p' >> ${TMPPLIST}
+	@${ECHO_CMD} "@dirrm ${DATADIR:S,^${STAGEDIR}${PREFIX}/,,}" >> ${TMPPLIST}
 .else
 	@${DO_NADA}
 .endif
@@ -5803,19 +5892,19 @@
 install-rc-script:
 .if defined(USE_RCORDER) || defined(USE_RC_SUBR) && ${USE_RC_SUBR:U} != "YES"
 .if defined(USE_RCORDER)
-	@${ECHO_MSG} "===> Installing early rc.d startup script(s)"
+	@${ECHO_MSG} "===> Staging early rc.d startup script(s)"
 	@${ECHO_CMD} "@cwd /" >> ${TMPPLIST}
 	@for i in ${USE_RCORDER}; do \
................................................................................
 	@${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}
 	@for i in ${USE_RC_SUBR}; do \
-		${INSTALL_SCRIPT} ${WRKDIR}/$${i} ${PREFIX}/etc/rc.d/$${i%.sh}; \
+		${INSTALL_SCRIPT} ${WRKDIR}/$${i} ${STAGEDIR}${PREFIX}/etc/rc.d/$${i%.sh}; \
 		${ECHO_CMD} "etc/rc.d/$${i%.sh}" >> ${TMPPLIST}; \
 	done
 .endif
@@ -6436,7 +6525,7 @@
 .if !target(install-desktop-entries)
 install-desktop-entries:
 .if defined(DESKTOP_ENTRIES)
-	@(${MKDIR} "${DESKTOPDIR}" 2> /dev/null) || \
+	@(${MKDIR} "${STAGEDIR}${DESKTOPDIR}" 2> /dev/null) || \
 		(${ECHO_MSG} "===> Cannot create ${DESKTOPDIR}, check permissions"; exit 1)
 	@set -- ${DESKTOP_ENTRIES} XXX; \
................................................................................
 PYDISTUTILS_INSTALLARGS?=	-c -O1 --prefix=${PREFIX}
+.if !defined(NO_STAGE)
+PYDISTUTILS_INSTALLARGS+=	--root=${STAGEDIR}
+.endif
 PYDISTUTILS_PKGNAME?=	${PORTNAME}
 PYDISTUTILS_PKGVERSION?=${PORTVERSION}
 PYDISTUTILS_EGGINFO?=	${PYDISTUTILS_PKGNAME:C/[^A-Za-z0-9.]+/_/g}-${PYDISTUTILS_PKGVERSION:C/[^A-Za-z0-9.]+/_/g}-py${PYTHON_VER}.egg-info

















Index: bsd.stage.mk
===================================================================
diff --git a/head/Mk/bsd.stage.mk b/head/Mk/bsd.stage.mk
new file mode 10644
--- /dev/null	(revision 0)
+++ b/head/Mk/bsd.stage.mk	(working copy)
@@ -0,0 +1,82 @@
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>





|
>


|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






|
|

|
>

>
|

<
<
<
<
<
<
<
|
<
|
|
<
|
|


>
|







|






<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
>
>

>


<
<
>
>
>
>
>
>
>


|





>
>
>
>
>
|












<
<
<
|




|







|







 







|
|
<

|



>
>
>
>







 







|











|





>

>












|







|








|









|








|








|












|







|







|







 







|







 







|







 







|







 







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
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
...
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
...
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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
...
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
...
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
...
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
...
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
...
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
Index: bsd.default-versions.mk
===================================================================
diff --git a/head/Mk/bsd.default-versions.mk b/head/Mk/bsd.default-versions.mk
--- a/head/Mk/bsd.default-versions.mk	(revision 327602)
+++ b/head/Mk/bsd.default-versions.mk	(working copy)
@@ -19,5 +19,6 @@
 
 PERL5_DEFAULT?=		5.14
 RUBY_DEFAULT?=		1.9
+TCLTK_DEFAULT?=		8.6
 
 .endif
Index: bsd.licenses.mk
===================================================================
diff --git a/head/Mk/bsd.licenses.mk b/head/Mk/bsd.licenses.mk
--- a/head/Mk/bsd.licenses.mk	(revision 327600)
+++ b/head/Mk/bsd.licenses.mk	(working copy)
@@ -749,14 +749,14 @@
 .endif
................................................................................
 .else
 .	for lic in ${_LICENSE}
-	@${INSTALL_DATA} ${_LICENSE_FILE_${lic}} ${_LICENSE_DIR}/${lic}
+	@${INSTALL_DATA} ${_LICENSE_FILE_${lic}} ${STAGEDIR}${_LICENSE_DIR}/${lic}
 .	endfor
 .endif
 # XXX @dirrmtry entry must be here (no way to do with PLIST_* vars)
Index: bsd.ocaml.mk
===================================================================
diff --git a/head/Mk/bsd.ocaml.mk b/head/Mk/bsd.ocaml.mk
--- a/head/Mk/bsd.ocaml.mk	(revision 327600)
+++ b/head/Mk/bsd.ocaml.mk	(working copy)
@@ -1,7 +1,7 @@
 # ex:ts=4
 #
 # $MBSDlabs: portmk/bsd.ocaml.mk,v 1.18 2006/08/06 18:47:23 stas Exp $
-# $FreeBSD: /tmp/pcvs/ports/Mk/bsd.ocaml.mk,v 1.4 2011-12-15 19:47:53 tabthorpe Exp $
+# $FreeBSD: ports/Mk/bsd.ocaml.mk,v 1.5 2012/11/17 05:54:17 svnexp Exp $
 #
 # bsd.ocaml.mk - Support for the Objective Caml language packages
 #
Index: bsd.pkgng.mk
===================================================================
diff --git a/head/Mk/bsd.pkgng.mk b/head/Mk/bsd.pkgng.mk
--- a/head/Mk/bsd.pkgng.mk	(revision 327600)
+++ b/head/Mk/bsd.pkgng.mk	(working copy)
@@ -36,14 +36,7 @@
 		${PKG_QUERY} "%dn: {origin: %do, version: \"%dv\"}" " " ${_LIB_RUN_DEPENDS:C,[^:]*:([^:]*):?.*,\1,:C,${PORTSDIR}/,,} 2>/dev/null || : ; \
 	fi
 
-.if !target(fake-pkg)
-fake-pkg:
-.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
+create-manifest:
 	@${MKDIR} ${METADIR}
 	@${ECHO_CMD} "name: ${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}" > ${MANIFESTF} 
 	@${ECHO_CMD} "version: ${PKGVERSION}" >> ${MANIFESTF} 
@@ -102,11 +95,27 @@
 .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)
-	@${SETENV} FORCE_POST="${_FORCE_POST_PATTERNS}" ${PKG_CMD} -d -l -m ${METADIR} -f ${TMPPLIST}
+	@${ECHO_MSG} "===>   Registering installation for ${PKGNAME} as automatic"
 .else
-	@${SETENV} FORCE_POST="${_FORCE_POST_PATTERNS}" ${PKG_CMD} -l -m ${METADIR} -f ${TMPPLIST}
+	@${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}
@@ -113,6 +122,7 @@
 .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)
@@ -204,8 +214,13 @@
 .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 \


@@ -214,20 +229,26 @@
 				exit 1; \
 			fi; \
 		fi; \
-	fi;
+	fi
 	@for cat in ${CATEGORIES}; do \
 		${RM} -f ${PACKAGES}/$$cat/${PKGNAMEPREFIX}${PORTNAME}*${PKG_SUFX} ; \
 	done
-	@if ${PKG_CREATE} -o ${PKGREPOSITORY} ${PKGNAME}; 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; \
+	@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; \
@@ -234,6 +255,7 @@
 	fi
 .endif
 
+.if defined(WITH_PKGNG)
 .if !target(check-already-installed)
 check-already-installed:
 .if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER)
@@ -278,5 +300,6 @@
 	@${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
 .endif
 .endif
+.endif
 
 .endif # defined(_POSTMKINCLUDED)
Index: bsd.port.mk
................................................................................
+.if defined(FORCE_STAGE)
+.undef NO_STAGE
+.endif
+
 # make sure bmake treats -V as expected 
 .MAKE.EXPAND_VARIABLES= yes
 # tell bmake we use the old :L :U modifiers
@@ -1901,9 +1905,14 @@
 . endfor

 .endif
 
+.if !defined(NO_STAGE)
+.include "${PORTSDIR}/Mk/bsd.stage.mk"
+.endif
+
 .if defined(WITH_PKGNG)
 .include "${PORTSDIR}/Mk/bsd.pkgng.mk"
 .endif
+
 .if defined(USE_LOCAL_MK)
 .include "${PORTSDIR}/Mk/bsd.local.mk"
 .endif
@@ -2082,6 +2091,7 @@
 BUILD_COOKIE?=		${WRKDIR}/.build_done.${PORTNAME}.${PREFIX:S/\//_/g}
 PATCH_COOKIE?=		${WRKDIR}/.patch_done.${PORTNAME}.${PREFIX:S/\//_/g}
................................................................................
 	@${ECHO_MSG} "===>   Installing 32-bit ldconfig configuration file"
 .if defined(NO_LDCONFIG_MTREE)
-	@${MKDIR} ${PREFIX}/${LDCONFIG_32DIR}
+	@${MKDIR} ${STAGEDIR}${PREFIX}/${LDCONFIG_32DIR}
 .endif
 	@${ECHO_CMD} ${USE_LDCONFIG32} | ${TR} ' ' '\n' \
 		> ${PREFIX}/${LDCONFIG32_DIR}/${UNIQUENAME}
@@ -4225,6 +4276,32 @@
 _BUILD_DEP=		configure
 _BUILD_SEQ=		build-message pre-build pre-build-script do-build \
 				post-build post-build-script
+.if !defined(NO_STAGE)
+
+_STAGE_DEP=		build
+_STAGE_SEQ=		stage-message stage-dir apply-slist pre-install generate-plist pre-su-install \
+				create-users-groups do-install post-install post-stage compress-man install-rc-script \
+				install-ldconfig-file install-license \
+				install-desktop-entries add-plist-info add-plist-docs add-plist-examples \
+				add-plist-data add-plist-post fix-plist-sequence
+.if defined(WITH_PKGNG)
+_INSTALL_DEP=	stage
+_INSTALL_SEQ=	install-message run-depends lib-depends fake-pkg security-check
+
+_PACKAGE_DEP=	stage
+_PACKAGE_SEQ=	package-message pre-package pre-package-script do-package post-package-script
+
+.else # pkg_install
+
+_PACKAGE_DEP=	stage
+_PACKAGE_SEQ=	package-message pre-package pre-package-script do-package post-package-script
+
+_INSTALL_DEP=	package
+_INSTALL_SEQ=	install-message run-depends lib-depends install-package done-message
+.endif
+
+.else
+
 _INSTALL_DEP=	build
 _INSTALL_SEQ=	install-message check-install-conflicts run-depends lib-depends apply-slist pre-install \
 				pre-install-script generate-plist check-already-installed
@@ -4238,6 +4315,7 @@
 _PACKAGE_DEP=	install
 _PACKAGE_SEQ=	package-message pre-package pre-package-script \
 				do-package post-package-script
+.endif
 
 .if !target(post-chroot)
 post-chroot:
@@ -4260,7 +4338,7 @@
 # Main logic. The loop generates 6 main targets and using cookies
 # ensures that those already completed are skipped.
 
-.for target in extract patch configure build install package
+.for target in extract patch configure build stage install package
 
 .if !target(${target}) && defined(_OPTIONS_OK)
 ${target}: ${${target:U}_COOKIE}
@@ -4314,6 +4392,9 @@
 .ORDER: ${_PATCH_DEP} ${_PATCH_SEQ}
 .ORDER: ${_CONFIGURE_DEP} ${_CONFIGURE_SEQ}
 .ORDER: ${_BUILD_DEP} ${_BUILD_SEQ}
+.if !defined(NO_STAGE)
+.ORDER: ${_STAGE_DEP} ${_STAGE_SEQ}
+.endif
 .ORDER: ${_INSTALL_DEP} ${_INSTALL_SEQ}
 .ORDER: ${_PACKAGE_DEP} ${_PACKAGE_SEQ}
 
@@ -4325,6 +4406,8 @@
 	@${ECHO_MSG} "===>  Configuring for ${PKGNAME}"
 build-message:
 	@${ECHO_MSG} "===>  Building for ${PKGNAME}"
+stage-message:
+	@${ECHO_MSG} "===>  Staging for ${PKGNAME}"
 install-message:
 	@${ECHO_MSG} "===>  Installing for ${PKGNAME}"
 package-message:
@@ -4333,7 +4416,7 @@
 # Empty pre-* and post-* targets
 
 .for stage in pre post
-.for name in pkg check-sanity fetch extract patch configure build install package
+.for name in pkg check-sanity fetch extract patch configure build stage install package
 
 .if !target(${stage}-${name})
 ${stage}-${name}:
@@ -4396,6 +4479,12 @@
 	@cd ${.CURDIR} && DEPENDS_TARGET="${DEPENDS_TARGET}" ${MAKE} -DFORCE_PKG_REGISTER install
 .endif
 
+.if !target(restage)
+restage:
+	@${RM} -rf ${STAGE_DESTDIR} ${STAGE_COOKIE} ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
+	@cd ${.CURDIR} && ${MAKE} stage
+.endif
+
 # Deinstall
 #
 # Special target to remove installation
@@ -5612,6 +5701,7 @@
 	@for file in ${PLIST_FILES}; do \
 		${ECHO_CMD} $${file} | ${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} >> ${TMPPLIST}; \
 	done
+.if !defined(NO_STAGE)
 	@for man in ${__MANPAGES}; do \
 		${ECHO_CMD} $${man} >> ${TMPPLIST}; \
 	done
@@ -5629,6 +5719,7 @@
 	@${ECHO_CMD} '@cwd ${PREFIX}' >> ${TMPPLIST}
 .endif
 .endfor
+.endif
 	@if [ -f ${PLIST} ]; then \
 		${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} ${PLIST} >> ${TMPPLIST}; \
 	fi
@@ -5691,14 +5782,14 @@
 	fi
 .for x in ${PORTDOCS}
 	@if ${ECHO_CMD} "${x}"| ${AWK} '$$1 ~ /(\*|\||\[|\]|\?|\{|\}|\$$)/ { exit 1};'; then \
-		if [ ! -e ${DOCSDIR}/${x} ]; then \
+		if [ ! -e ${STAGEDIR}${DOCSDIR}/${x} ]; then \
 		${ECHO_CMD} ${DOCSDIR_REL}/${x} >> ${TMPPLIST}; \
 	fi;fi
................................................................................
+	@${FIND} -P ${STAGEDIR}${PORTDOCS:S/^/${STAGEDIR}${DOCSDIR}\//} ! -type d 2>/dev/null | \
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,,p' >> ${TMPPLIST}
+	@${FIND} -P -d ${STAGEDIR}${PORTDOCS:S/^/${STAGEDIR}${DOCSDIR}\//} -type d 2>/dev/null | \
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,@dirrm ,p' >> ${TMPPLIST}
 	@${ECHO_CMD} "@dirrm ${DOCSDIR_REL}" >> ${TMPPLIST}
 .else
 	@${DO_NADA}
@@ -5714,16 +5805,16 @@
 	fi
 .for x in ${PORTEXAMPLES}
 	@if ${ECHO_CMD} "${x}"| ${AWK} '$$1 ~ /(\*|\||\[|\]|\?|\{|\}|\$$)/ { exit 1};'; then \
-		if [ ! -e ${EXAMPLESDIR}/${x} ]; then \
+		if [ ! -e ${STAGEDIR}${EXAMPLESDIR}/${x} ]; then \
 		${ECHO_CMD} ${EXAMPLESDIR}/${x} | \
 			${SED} -e 's,^${PREFIX}/,,' >> ${TMPPLIST}; \
................................................................................
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,,p' >> ${TMPPLIST}
+	@${FIND} -P -d ${STAGEDIR}${PORTEXAMPLES:S/^/${STAGEDIR}${EXAMPLESDIR}\//} -type d 2>/dev/null | \
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,@dirrm ,p' >> ${TMPPLIST}
+	@${ECHO_CMD} "@dirrm ${EXAMPLESDIR:S,^${STAGEDIR}${PREFIX}/,,}" >> ${TMPPLIST}
 .else
 	@${DO_NADA}
 .endif
@@ -5738,16 +5829,16 @@
 	fi
 .for x in ${PORTDATA}
 	@if ${ECHO_CMD} "${x}"| ${AWK} '$$1 ~ /(\*|\||\[|\]|\?|\{|\}|\$$)/ { exit 1};'; then \
-		if [ ! -e ${DATADIR}/${x} ]; then \
+		if [ ! -e ${STAGEDIR}${DATADIR}/${x} ]; then \
 		${ECHO_CMD} ${DATADIR}/${x} | \
 			${SED} -e 's,^${PREFIX}/,,' >> ${TMPPLIST}; \
................................................................................
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,,p' >> ${TMPPLIST}
+	@${FIND} -P -d ${STAGEDIR}${PORTDATA:S/^/${STAGEDIR}${DATADIR}\//} -type d 2>/dev/null | \
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,@dirrm ,p' >> ${TMPPLIST}
+	@${ECHO_CMD} "@dirrm ${DATADIR:S,^${STAGEDIR}${PREFIX}/,,}" >> ${TMPPLIST}
 .else
 	@${DO_NADA}
 .endif
@@ -5803,19 +5894,19 @@
 install-rc-script:
 .if defined(USE_RCORDER) || defined(USE_RC_SUBR) && ${USE_RC_SUBR:U} != "YES"
 .if defined(USE_RCORDER)
-	@${ECHO_MSG} "===> Installing early rc.d startup script(s)"
+	@${ECHO_MSG} "===> Staging early rc.d startup script(s)"
 	@${ECHO_CMD} "@cwd /" >> ${TMPPLIST}
 	@for i in ${USE_RCORDER}; do \
................................................................................
 	@${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}
 	@for i in ${USE_RC_SUBR}; do \
-		${INSTALL_SCRIPT} ${WRKDIR}/$${i} ${PREFIX}/etc/rc.d/$${i%.sh}; \
+		${INSTALL_SCRIPT} ${WRKDIR}/$${i} ${STAGEDIR}${PREFIX}/etc/rc.d/$${i%.sh}; \
 		${ECHO_CMD} "etc/rc.d/$${i%.sh}" >> ${TMPPLIST}; \
 	done
 .endif
@@ -6436,7 +6527,7 @@
 .if !target(install-desktop-entries)
 install-desktop-entries:
 .if defined(DESKTOP_ENTRIES)
-	@(${MKDIR} "${DESKTOPDIR}" 2> /dev/null) || \
+	@(${MKDIR} "${STAGEDIR}${DESKTOPDIR}" 2> /dev/null) || \
 		(${ECHO_MSG} "===> Cannot create ${DESKTOPDIR}, check permissions"; exit 1)
 	@set -- ${DESKTOP_ENTRIES} XXX; \
................................................................................
 PYDISTUTILS_INSTALLARGS?=	-c -O1 --prefix=${PREFIX}
+.if !defined(NO_STAGE)
+PYDISTUTILS_INSTALLARGS+=	--root=${STAGEDIR}
+.endif
 PYDISTUTILS_PKGNAME?=	${PORTNAME}
 PYDISTUTILS_PKGVERSION?=${PORTVERSION}
 PYDISTUTILS_EGGINFO?=	${PYDISTUTILS_PKGNAME:C/[^A-Za-z0-9.]+/_/g}-${PYDISTUTILS_PKGVERSION:C/[^A-Za-z0-9.]+/_/g}-py${PYTHON_VER}.egg-info
Index: bsd.sanity.mk
===================================================================
diff --git a/head/Mk/bsd.sanity.mk b/head/Mk/bsd.sanity.mk
--- a/head/Mk/bsd.sanity.mk	(revision 327606)
+++ b/head/Mk/bsd.sanity.mk	(working copy)
@@ -91,6 +91,11 @@
 DEV_WARNING+=	"Please use the new format for LIB_DEPENDS, see handbook for details"
 .endif
 
+.if defined(USE_TCL) || defined(USE_TCL_BUILD) || defined(USE_TCL_RUN) || defined(USE_TCL_WRAPPER) || \
+   defined(USE_TK)  || defined(USE_TK_BUILD)  || defined(USE_TK_RUN)  || defined(USE_TK_WRAPPER)
+DEV_WARNING+=	"USE_TCL and USE_TK are deprecated, please use USES=tcl or USES=tk"
+.endif
+
 .if defined(_PREMKINCLUDED)
 DEV_ERROR+=	"you cannot include bsd.port[.pre].mk twice"
 .endif
Index: bsd.stage.mk
===================================================================
diff --git a/head/Mk/bsd.stage.mk b/head/Mk/bsd.stage.mk
new file mode 10644
--- /dev/null	(revision 0)
+++ b/head/Mk/bsd.stage.mk	(working copy)
@@ -0,0 +1,82 @@