Check-in [915fcdbebd]

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

Overview
Comment:Create package out of the STAGEDIR
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:915fcdbebd81e5e89b86ea834da4cd841d0b1999
User & Date: bapt 2013-09-19 12:33:36
Context
2013-09-19
12:34
Really out of the stagedir check-in: 599871a874 user: bapt tags: trunk
12:33
Create package out of the STAGEDIR check-in: 915fcdbebd user: bapt tags: trunk
10:23
Do not use pkgng for pkg_install packages check-in: 5c52d72b16 user: bapt tags: trunk
Changes

Changes to stage.patch.

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
...
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
...
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
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
...
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
...
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
...
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
...
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
+.else
+_TARGETS=	check-sanity fetch checksum extract patch configure all build install reinstall package
+.endif
+.for target in ${_TARGETS}
 .if !target(${target})
 ${target}:
 	@${IGNORECMD}







































@@ -3889,6 +3904,12 @@
 	@${ECHO_CMD} "[ -f ${PKGFILE} ] && (${ECHO_CMD} deleting ${PKGFILE}; ${RM} -f ${PKGFILE})"
 .endif
 
+.if !target(install-package)
+install-package:
+	@${PKG_ADD} ${PKGFILE}
+.endif
+
+
 # Utility targets follow
 
 .if !target(check-already-installed)
@@ -3978,9 +3999,12 @@
 .if defined(USE_LDCONFIG) || defined(USE_LDCONFIG32)
 .if defined(USE_LDCONFIG)
 .if defined(USE_LINUX_PREFIX)
+.if defined(NO_STAGE}
 	@${ECHO_MSG} "===>   Running linux ldconfig"
 	${LDCONFIG_CMD}
+.endif
 .else
+.if defined(NO_STAGE)
 .if !defined(INSTALL_AS_USER)
 	@${ECHO_MSG} "===>   Running ldconfig"
 	${LDCONFIG} -m ${USE_LDCONFIG}
@@ -3988,13 +4012,14 @@
 	@${ECHO_MSG} "===>   Running ldconfig (errors are ignored)"
 	-${LDCONFIG} -m ${USE_LDCONFIG}
 .endif
+.endif
 .if ${USE_LDCONFIG} != "${PREFIX}/lib" && !defined(INSTALL_AS_USER)
 	@${ECHO_MSG} "===>   Installing ldconfig configuration file"
 .if defined(NO_LDCONFIG_MTREE)
................................................................................
 .endif
 	@${ECHO_CMD} ${USE_LDCONFIG} | ${TR} ' ' '\n' \
-		> ${PREFIX}/${LDCONFIG_DIR}/${UNIQUENAME}
+		> ${STAGEDIR}${PREFIX}/${LDCONFIG_DIR}/${UNIQUENAME}
 	@${ECHO_CMD} "@cwd" >> ${TMPPLIST}
 	@${ECHO_CMD} ${LDCONFIG_DIR}/${UNIQUENAME} >> ${TMPPLIST}
 .if defined(NO_LDCONFIG_MTREE)
@@ -4004,6 +4029,7 @@
 .endif
 .endif
 .if defined(USE_LDCONFIG32)
+.if defined(NO_STAGE)
 .if !defined(INSTALL_AS_USER)
 	@${ECHO_MSG} "===>   Running ldconfig"
 	${LDCONFIG} -32 -m ${USE_LDCONFIG32}
@@ -4011,10 +4037,11 @@
 	@${ECHO_MSG} "===>   Running ldconfig (errors are ignored)"
 	-${LDCONFIG} -32 -m ${USE_LDCONFIG32}
 .endif
+.endif
 .if !defined(INSTALL_AS_USER)
 	@${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 +4252,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 \
................................................................................
+.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 +4289,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 +4312,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 +4366,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 +4380,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 +4390,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 +4453,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 +5675,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 +5693,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 +5756,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 +5779,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 +5803,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 +5868,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 +6501,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; \







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












|












|







 







|







|












|







 







|







|








|









|








|








|












|







|







|







 







|







 







|







 







|







 







|







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
...
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
...
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
+.else
+_TARGETS=	check-sanity fetch checksum extract patch configure all build install reinstall package
+.endif
+.for target in ${_TARGETS}
 .if !target(${target})
 ${target}:
 	@${IGNORECMD}
@@ -3825,6 +3840,7 @@
 			fi; \
 		fi; \
 	fi
+.if defined(NO_STAGE)
 	@if ${PKG_CMD} -b ${PKGNAME} ${PKGFILE}; then \
 		if [ -d ${PACKAGES} ]; then \
 			cd ${.CURDIR} && eval ${MAKE} package-links; \
@@ -3833,7 +3849,30 @@
 		cd ${.CURDIR} && eval ${MAKE} delete-package; \
 		exit 1; \
 	fi
+.else
+	@_LATE_PKG_ARGS=""; \
+	if [ -f ${PKGINSTALL} ]; then \
+		_LATE_PKG_ARGS="$${_LATE_PKG_ARGS} -i ${PKGINSTALL}"; \
+	fi; \
+	if [ -f ${PKGDEINSTALL} ]; then \
+		_LATE_PKG_ARGS="$${_LATE_PKG_ARGS} -k ${PKGDEINSTALL}"; \
+	fi; \
+	if [ -f ${PKGREQ} ]; then \
+		_LATE_PKG_ARGS="$${_LATE_PKG_ARGS} -r ${PKGREQ}"; \
+	fi; \
+	if [ -f ${PKGMESSAGE} ]; then \
+		_LATE_PKG_ARGS="$${_LATE_PKG_ARGS} -D ${PKGMESSAGE}"; \
+	fi; \
+	if ${PKG_CMD} ${PKG_ARGS} ${PKGFILE}; then \
+		if [ -d ${PACKAGES} ]; then \
+			cd ${.CURDIR} && eval ${MAKE} package-links; \
+		fi; \
+	else \
+		cd ${.CURDIR} && eval ${MAKE} delete-package; \
+		exit 1; \
+	fi
 .endif
+.endif
 
 # Some support rules for do-package
 
@@ -3889,6 +3928,12 @@
 	@${ECHO_CMD} "[ -f ${PKGFILE} ] && (${ECHO_CMD} deleting ${PKGFILE}; ${RM} -f ${PKGFILE})"
 .endif
 
+.if !target(install-package)
+install-package:
+	@${PKG_ADD} ${PKGFILE}
+.endif
+
+
 # Utility targets follow
 
 .if !target(check-already-installed)
@@ -3978,9 +4023,12 @@
 .if defined(USE_LDCONFIG) || defined(USE_LDCONFIG32)
 .if defined(USE_LDCONFIG)
 .if defined(USE_LINUX_PREFIX)
+.if defined(NO_STAGE}
 	@${ECHO_MSG} "===>   Running linux ldconfig"
 	${LDCONFIG_CMD}
+.endif
 .else
+.if defined(NO_STAGE)
 .if !defined(INSTALL_AS_USER)
 	@${ECHO_MSG} "===>   Running ldconfig"
 	${LDCONFIG} -m ${USE_LDCONFIG}
@@ -3988,13 +4036,14 @@
 	@${ECHO_MSG} "===>   Running ldconfig (errors are ignored)"
 	-${LDCONFIG} -m ${USE_LDCONFIG}
 .endif
+.endif
 .if ${USE_LDCONFIG} != "${PREFIX}/lib" && !defined(INSTALL_AS_USER)
 	@${ECHO_MSG} "===>   Installing ldconfig configuration file"
 .if defined(NO_LDCONFIG_MTREE)
................................................................................
 .endif
 	@${ECHO_CMD} ${USE_LDCONFIG} | ${TR} ' ' '\n' \
-		> ${PREFIX}/${LDCONFIG_DIR}/${UNIQUENAME}
+		> ${STAGEDIR}${PREFIX}/${LDCONFIG_DIR}/${UNIQUENAME}
 	@${ECHO_CMD} "@cwd" >> ${TMPPLIST}
 	@${ECHO_CMD} ${LDCONFIG_DIR}/${UNIQUENAME} >> ${TMPPLIST}
 .if defined(NO_LDCONFIG_MTREE)
@@ -4004,6 +4053,7 @@
 .endif
 .endif
 .if defined(USE_LDCONFIG32)
+.if defined(NO_STAGE)
 .if !defined(INSTALL_AS_USER)
 	@${ECHO_MSG} "===>   Running ldconfig"
 	${LDCONFIG} -32 -m ${USE_LDCONFIG32}
@@ -4011,10 +4061,11 @@
 	@${ECHO_MSG} "===>   Running ldconfig (errors are ignored)"
 	-${LDCONFIG} -32 -m ${USE_LDCONFIG32}
 .endif
+.endif
 .if !defined(INSTALL_AS_USER)
 	@${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 \
................................................................................
+.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; \