Add support for staging area in the ports tree

The ports tree is now staged by default. With pkgng the sequence hasn't
changed, the main difference is that creating package is now independent
from installing it. With pkg_install, the package is now created first
and make install, do install the package.

New macros:
- STAGEDIR: PATH to the directory where the port will be staged.
- NO_STAGE: Keep the old behaviour of the ports tree (aka no staging area)

Unsupported macro if NO_STAGE is not set:
- MAN* with staging man page compression and handling of hardlinks and
symlinks is automatically done in the stage. the manpages becomes then a
"normal" plist files and should be tracked in pkg-plist.
- MANCOMPRESSED the compress-man target is able to only compress when it
needed.

New target:
- stage: this installs everything into the stage directory
- makeplist: this will create a pkg-plist and print it to stdout. This is
a sample plist and it should always be _reviewed_ not directly used.

NOTE: with staging only what is in the plist will be installed, nothing more,
meaning a port staged cannot have leftovers exect directories left. It is
really important to double check the pkg-plist to make sure all the files
the maintainer want to package are in! make makeplist can help in that area.

The goal is to handle as quickly as possible a full removal of the NO_STAGE
support.

More features can be added once the full ports tree is converted to using the
staging area

Conversion notes:
- Remove NO_STAGE
- in {pre,do,post}-install
  * Before any usage of ${PREFIX}, ${ETCDIR}, ${PORTSDIR}, ${PORTEXAMPLES}
    prepend ${STAGEDIR}
  * Remove any thing that is done by @exec or +INSTALL script it will be
    done automatically when syncing packages
  * Remove any code to show PKG-MESSAGE it will be done automatically when
    syncing packages
  * Directory creation should remain in post-install (in particular because
    pkgng doesn't work like pkg_install in that area and pkgng ignores the
    @exec mkdir but directly pack the directory even if empty)
- PORTDOCS/PORTEXAMPELS
  To support PORTDOCS, PORTEXAMPLES most of the time there is no more need
  for hacks. just add the right %%PORTDOCS%% or %%PORTEXAMPLES%% in your
  plist then the given files from the stagedir will or will not sync
  according to NOPORTDOCS and NOPORTEXAMPLES.

With hat:	portmgr
Reviewed by:	bdrewery
This commit is contained in:
Baptiste Daroussin 2013-09-23 05:56:35 +00:00
parent 785d744f1f
commit cf099c77fa
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=327910
7 changed files with 321 additions and 55 deletions

29
CHANGES
View File

@ -10,6 +10,35 @@ in the release notes and/or placed into UPDATING.
All ports committers are allowed to commit to this file.
20130923:
AUTHOT: bapt@FreeBSD.org
The ports tree is now staged by default. With pkgng the sequence hasn't
changed, the main difference is that creating package is now independent
from installing it. With pkg_install, the package is now created first
and make install, do install the package.
New macros:
- STAGEDIR: PATH to the directory where the port will be staged.
- NO_STAGE: Keep the old behaviour of the ports tree (aka no staging area)
Unsupported macro if NO_STAGE is not set:
- MAN* with staging man page compression and handling of hardlinks and
symlinks is automatically done in the stage. the manpages becomes then a
"normal" plist files and should be tracked in pkg-plist.
- MANCOMPRESSED the compress-man target is able to only compress when it
needed.
New target:
- stage: this installs everything into the stage directory
- makeplist: this will create a pkg-plist and print it to stdout. This is
a sample plist and it should always be _reviewed_ not directly used.
NOTE: with staging only what is in the plist will be installed, nothing more,
meaning a port staged cannot have leftovers exect directories left. It is
really important to double check the pkg-plist to make sure all the files
the maintainer want to package are in! make makeplist can help in that area.
20130920:
AUTHOR: bdrewery@FreeBSD.org

View File

@ -749,14 +749,14 @@ PLIST_FILES+= ${_LICENSE_DIR_REL}/${lic}
.endif
install-license:
@${MKDIR} ${_LICENSE_DIR}
@${INSTALL_DATA} ${_LICENSE_CATALOG_TMP} ${_LICENSE_CATALOG}
@${INSTALL_DATA} ${_LICENSE_REPORT_TMP} ${_LICENSE_REPORT}
@${MKDIR} ${STAGEDIR}${_LICENSE_DIR}
@${INSTALL_DATA} ${_LICENSE_CATALOG_TMP} ${STAGEDIR}${_LICENSE_CATALOG}
@${INSTALL_DATA} ${_LICENSE_REPORT_TMP} ${STAGEDIR}${_LICENSE_REPORT}
.if ${_LICENSE_COMB} == "single"
@${INSTALL_DATA} ${_LICENSE_FILE} ${_LICENSE_DIR}/${_LICENSE}
@${INSTALL_DATA} ${_LICENSE_FILE} ${STAGEDIR}${_LICENSE_DIR}/${_LICENSE}
.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)

View File

@ -36,14 +36,7 @@ ACTUAL-PACKAGE-DEPENDS?= \
${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,10 +95,26 @@ fake-pkg:
.if !defined(NO_MTREE)
@[ -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}
.if !target(fake-pkg)
.if defined(NO_STAGE)
STAGE_ARGS= -l
.else
@${SETENV} FORCE_POST="${_FORCE_POST_PATTERNS}" ${PKG_CMD} -l -m ${METADIR} -f ${TMPPLIST}
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
@ -113,6 +122,7 @@ fake-pkg:
.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 @@ check-install-conflicts:
.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,26 +229,33 @@ do-package: ${TMPPLIST}
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; \
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 @@ deinstall:
@${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
.endif
.endif
.endif
.endif # defined(_POSTMKINCLUDED)

View File

@ -1122,6 +1122,10 @@ SRC_BASE?= /usr/src
USESDIR?= ${PORTSDIR}/Mk/Uses
LIB_DIRS?= /lib /usr/lib ${LOCALBASE}/lib
.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
@ -1913,9 +1917,14 @@ RUN_DEPENDS+= ${_GL_${_component}_RUN_DEPENDS}
. 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
@ -2094,6 +2103,7 @@ INSTALL_COOKIE?= ${WRKDIR}/.install_done.${PORTNAME}.${PREFIX:S/\//_/g}
BUILD_COOKIE?= ${WRKDIR}/.build_done.${PORTNAME}.${PREFIX:S/\//_/g}
PATCH_COOKIE?= ${WRKDIR}/.patch_done.${PORTNAME}.${PREFIX:S/\//_/g}
PACKAGE_COOKIE?= ${WRKDIR}/.package_done.${PORTNAME}.${PREFIX:S/\//_/g}
STAGE_COOKIE?= ${WRKDIR}/.stage_done.${PORTNAME}.${PREFIX:S/\//_/g}
# How to do nothing. Override if you, for some strange reason, would rather
# do something.
@ -3129,7 +3139,12 @@ IGNORECMD= ${DO_NADA}
IGNORECMD= ${ECHO_MSG} "===> ${PKGNAME} "${IGNORE:Q}.;exit 1
.endif
.for target in check-sanity fetch checksum extract patch configure all build install reinstall package
.if !defined(NO_STAGE)
_TARGETS= check-sanity fetch checksum extract patch configure all build stage restage install reinstall package
.else
_TARGETS= check-sanity fetch checksum extract patch configure all build install reinstall package
.endif
.for target in ${_TARGETS}
.if !target(${target})
${target}:
@${IGNORECMD}
@ -3834,6 +3849,7 @@ do-package: ${TMPPLIST}
fi; \
fi; \
fi
.if defined(NO_STAGE)
@if ${PKG_CMD} -b ${PKGNAME} ${PKGFILE}; then \
if [ -d ${PACKAGES} ]; then \
cd ${.CURDIR} && eval ${MAKE} package-links; \
@ -3842,6 +3858,29 @@ do-package: ${TMPPLIST}
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} -S ${STAGEDIR} ${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
@ -3898,6 +3937,12 @@ delete-package-list: delete-package-links-list
@${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)
@ -3987,9 +4032,12 @@ install-ldconfig-file:
.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}
@ -3997,13 +4045,14 @@ install-ldconfig-file:
@${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)
@${MKDIR} ${PREFIX}/${LDCONFIG_DIR}
@${MKDIR} ${STAGEDIR}${PREFIX}/${LDCONFIG_DIR}
.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)
@ -4013,6 +4062,7 @@ install-ldconfig-file:
.endif
.endif
.if defined(USE_LDCONFIG32)
.if defined(NO_STAGE)
.if !defined(INSTALL_AS_USER)
@${ECHO_MSG} "===> Running ldconfig"
${LDCONFIG} -32 -m ${USE_LDCONFIG32}
@ -4020,10 +4070,11 @@ install-ldconfig-file:
@${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}
@ -4234,6 +4285,35 @@ _CONFIGURE_SEQ= build-depends lib-depends configure-message run-autotools-fixup
_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 run-depends lib-depends apply-slist pre-install generate-plist \
pre-su-install
_STAGE_SUSEQ= 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
_INSTALL_SUSEQ= 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
_INSTALL_SUSEQ= install-package security-check
.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
@ -4247,6 +4327,7 @@ _INSTALL_SUSEQ= check-umask install-mtree pre-su-install \
_PACKAGE_DEP= install
_PACKAGE_SEQ= package-message pre-package pre-package-script \
do-package post-package-script
.endif
.if !target(post-chroot)
post-chroot:
@ -4269,7 +4350,7 @@ pkg: ${_PKG_DEP} ${_PKG_SEQ}
# 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}
@ -4323,6 +4404,9 @@ ${${target:U}_COOKIE}::
.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}
@ -4334,6 +4418,8 @@ configure-message:
@${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:
@ -4342,7 +4428,7 @@ package-message:
# 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}:
@ -4405,6 +4491,12 @@ reinstall:
@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
@ -4471,6 +4563,12 @@ deinstall-all:
.if !target(do-clean)
do-clean:
.if !defined(NO_STAGE) && ${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
@if [ -d ${WRKDIR} ]; then \
if [ -w ${WRKDIR} ]; then \
${RM} -rf ${WRKDIR}; \
@ -4479,6 +4577,7 @@ do-clean:
fi; \
fi
.endif
.endif
.if !target(clean)
clean:
@ -5621,6 +5720,7 @@ generate-plist:
@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
@ -5638,6 +5738,7 @@ generate-plist:
@${ECHO_CMD} '@cwd ${PREFIX}' >> ${TMPPLIST}
.endif
.endfor
.endif
@if [ -f ${PLIST} ]; then \
${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} ${PLIST} >> ${TMPPLIST}; \
fi
@ -5700,14 +5801,14 @@ add-plist-docs:
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
.endfor
@${FIND} -P ${PORTDOCS:S/^/${DOCSDIR}\//} ! -type d 2>/dev/null | \
${SED} -ne 's,^${PREFIX}/,,p' >> ${TMPPLIST}
@${FIND} -P -d ${PORTDOCS:S/^/${DOCSDIR}\//} -type d 2>/dev/null | \
${SED} -ne 's,^${PREFIX}/,@dirrm ,p' >> ${TMPPLIST}
@${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}
@ -5723,16 +5824,16 @@ add-plist-examples:
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}; \
fi;fi
.endfor
@${FIND} -P ${PORTEXAMPLES:S/^/${EXAMPLESDIR}\//} ! -type d 2>/dev/null | \
${SED} -ne 's,^${PREFIX}/,,p' >> ${TMPPLIST}
@${FIND} -P -d ${PORTEXAMPLES:S/^/${EXAMPLESDIR}\//} -type d 2>/dev/null | \
${SED} -ne 's,^${PREFIX}/,@dirrm ,p' >> ${TMPPLIST}
@${ECHO_CMD} "@dirrm ${EXAMPLESDIR:S,^${PREFIX}/,,}" >> ${TMPPLIST}
@${FIND} -P ${STAGEDIR}${PORTEXAMPLES:S/^/${STAGEDIR}${EXAMPLESDIR}\//} ! -type d 2>/dev/null | \
${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_REL}" >> ${TMPPLIST}
.else
@${DO_NADA}
.endif
@ -5747,16 +5848,16 @@ add-plist-data:
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}; \
fi;fi
.endfor
@${FIND} -P ${PORTDATA:S/^/${DATADIR}\//} ! -type d 2>/dev/null | \
${SED} -ne 's,^${PREFIX}/,,p' >> ${TMPPLIST}
@${FIND} -P -d ${PORTDATA:S/^/${DATADIR}\//} -type d 2>/dev/null | \
${SED} -ne 's,^${PREFIX}/,@dirrm ,p' >> ${TMPPLIST}
@${ECHO_CMD} "@dirrm ${DATADIR:S,^${PREFIX}/,,}" >> ${TMPPLIST}
@${FIND} -P ${STAGEDIR}${PORTDATA:S/^/${STAGEDIR}${DATADIR}\//} ! -type d 2>/dev/null | \
${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_REL}" >> ${TMPPLIST}
.else
@${DO_NADA}
.endif
@ -5778,6 +5879,8 @@ add-plist-info:
.if !defined(WITH_PKGNG)
@${ECHO_CMD} "@unexec install-info --quiet --delete %D/${INFO_PATH}/$i.info %D/${INFO_PATH}/dir" \
>> ${TMPPLIST}
@${ECHO_CMD} "@unexec [ \`info -d %D/${INFO_PATH} --output - 2>/dev/null | grep -c '^*'\` -eq 1 ] && rm -f %D/${INFO_PATH}/dir || :"\
>> ${TMPPLIST}
@${LS} ${PREFIX}/${INFO_PATH}/$i.info* | ${SED} -e s:${PREFIX}/::g >> ${TMPPLIST}
@${ECHO_CMD} "@exec install-info --quiet %D/${INFO_PATH}/$i.info %D/${INFO_PATH}/dir" \
>> ${TMPPLIST}
@ -5812,19 +5915,19 @@ add-plist-post:
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 \
${INSTALL_SCRIPT} ${WRKDIR}/$${i} /etc/rc.d/$${i%.sh}; \
${INSTALL_SCRIPT} ${WRKDIR}/$${i} ${STAGEDIR}/etc/rc.d/$${i%.sh}; \
${ECHO_CMD} "etc/rc.d/$${i%.sh}" >> ${TMPPLIST}; \
done
@${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}
.endif
.if defined(USE_RC_SUBR) && ${USE_RC_SUBR:U} != "YES"
@${ECHO_MSG} "===> Installing rc.d startup script(s)"
@${ECHO_MSG} "===> Staging rc.d startup script(s)"
@${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
@ -6445,7 +6548,7 @@ check-desktop-entries:
.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; \
if [ -z "${_DESKTOPDIR_REL}" ]; then \

View File

@ -534,6 +534,9 @@ PYSETUP?= setup.py
PYDISTUTILS_CONFIGUREARGS?=
PYDISTUTILS_BUILDARGS?=
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

View File

@ -96,6 +96,14 @@ DEV_WARNING+= "Please use the new format for LIB_DEPENDS, see handbook for detai
DEV_WARNING+= "USE_TCL and USE_TK are deprecated, please use USES=tcl or USES=tk"
.endif
.if !defined(NO_STAGE) && defined(_MANPAGES)
DEV_WARNING+= "MAN* macros are deprecated when using stage directory"
.endif
.if !defined(NO_STAGE) && defined(_MLINKS)
DEV_WARNING+= "MLINKS* macros are deprecated when using stage directory"
.endif
.if defined(_PREMKINCLUDED)
DEV_ERROR+= "you cannot include bsd.port[.pre].mk twice"
.endif

100
Mk/bsd.stage.mk Normal file
View File

@ -0,0 +1,100 @@
#
# $FreeBSD$
#
STAGEDIR?= ${WRKDIR}/stage
DESTDIRNAME?= DESTDIR
MAKE_ARGS+= ${DESTDIRNAME}=${STAGEDIR}
.if !target(stage-dir)
stage-dir:
@${MKDIR} ${STAGEDIR}${PREFIX}
.if !defined(NO_MTREE)
@${MTREE_CMD} ${MTREE_ARGS} ${STAGEDIR}${PREFIX} > /dev/null
.if defined(USE_LINUX) && ${PREFIX} != ${LINUXBASE_REL}
@${MKDIR} ${STAGEDIR}${LINUXBASE_REL}
@${MTREE_CMD} ${MTREE_LINUX_ARGS} ${STAGEDIR}${LINUXBASE_REL} > /dev/null
.endif
.endif
.endif
# Compress all manpage not already compressed which are not hardlinks
# Find all manpages which are not compressed and are hadlinks, and only get the list of inodes concerned, for each of them compress the first one found and recreate the hardlinks for the others
# Fixes all dead symlinks left by the previous round
.if !target(compress-man)
compress-man:
@${ECHO_CMD} "====> Compressing man pages" ; \
mdirs="${STAGEDIR}${MANPREFIX}/man"; \
for dir in `cat /usr/local/etc/man.d/*.conf ${STAGEDIR}/usr/local/etc/man.d/*.conf 2>/dev/null| awk -vstagedir=${STAGEDIR} '{ print stagedir$$2 }'` ; do \
[ -d $$dir ] && mdirs="$$mdirs $$dir" ;\
done ; \
for dir in $$mdirs; do \
${FIND} $$dir -type f \! -name "*.gz" -links 1 -exec ${GZIP_CMD} {} \; ; \
${FIND} $$dir -type f \! -name "*.gz" \! -links 1 -print -exec ${STAT} -f '%i' {} \; | \
${SORT} -u | while read inode ; do \
unset ref ; \
for f in $$(${FIND} -type f -inum $${inode} -print); do \
if [ -z $$ref ]; then \
ref=$${f}.gz ; \
${GZIP_CMD} $${f} ; \
continue ; \
fi ; \
${RM} -f $${f} ; \
(cd $${f%/*}; ${LN} -f $${ref##*/} $${f##*/}.gz) ; \
done ; \
done ; \
${FIND} $$dir -type l \! -name "*.gz" | while read link ; do \
dest=$$(readlink $$link) ; \
rm -f $$link ; \
(cd $${link%/*} ; ${LN} -sf $${dest##*/}.gz $${link##*/}.gz) ;\
done; \
done
.endif
.if !target(add-plist-info)
add-plist-info:
.for i in ${INFO}
.if !defined(WITH_PKGNG)
@${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}
@${ECHO_CMD} "@unexec install-info --quiet --delete %D/${INFO_PATH}/$i.info %D/${INFO_PATH}/dir" \
>> ${TMPPLIST}
@${ECHO_CMD} "@unexec [ \`info -d %D/${INFO_PATH} --output - 2>/dev/null | grep -c '^*'\` -eq 1 ] && rm -f %D/${INFO_PATH}/dir || :"\
>> ${TMPPLIST}
@${LS} ${STAGEDIR}${PREFIX}/${INFO_PATH}/$i.info* | ${SED} -e s:${STAGEDIR}${PREFIX}/::g >> ${TMPPLIST}
@${ECHO_CMD} "@exec install-info --quiet %D/${INFO_PATH}/$i.info %D/${INFO_PATH}/dir" \
>> ${TMPPLIST}
.else
@${LS} ${STAGEDIR}${PREFIX}/${INFO_PATH}/$i.info* | ${SED} -e s:${STAGEDIR}${PREFIX}/:@info\ :g >> ${TMPPLIST}
.endif
.endfor
.endif
.if !target(makeplist)
makeplist: stage
@{ ${ECHO_CMD} "#mtree"; ${CAT} ${MTREE_FILE}; } | ${TAR} tf - | \
awk '{ sub(/^\.$$/, "", $$1); \
if ($$1 == "") print "${PREFIX}"; else print "${PREFIX}/"$$1; }' \
> ${WRKDIR}/.mtree
@a=${PREFIX}; \
while :; do \
a=$${a%/*} ; \
[ -z "$${a}" ] && break ; \
${ECHO_CMD} $${a} >> ${WRKDIR}/.mtree ; \
done
@${FIND} ${STAGEDIR} -type f -o -type l | ${SED} -e "s,${STAGEDIR},,g" \
-e "s,${DOCSDIR},%%PORTDOCS%%%%DOCSDIR%%,g" \
-e "s,${EXAMPLESDIR},%%PORTEXAMPLES%%%%EXAMPLESDIR%%,g" \
-e "s,${DATADIR},%%DATADIR%%,g" \
-e "s,${PREFIX}/,,g" | sort | grep -v "^share/licenses" || ${TRUE}
@${FIND} ${STAGEDIR} -type d | sed -e "s,${STAGEDIR},,g" \
| while read line; do \
${GREP} -qw "^$${line}$$" ${WRKDIR}/.mtree || { \
[ -n "$${line}" ] && ${ECHO_CMD} "@dirrmtry $${line}"; \
}; \
done | ${SORT} -r | ${SED} \
-e "s,\(.*\)${DOCSDIR},%%PORTDOCS%%\1%%DOCSDIR%%,g" \
-e "s,\(.*\)${EXAMPLESDIR},%%PORTEXAMPLES%%\1%%EXAMPLESDIR%%,g" \
-e "s,${DATADIR},%%DATADIR%%,g" \
-e "s,${PREFIX}/,,g" | grep -v "^@dirrmtry share/licenses" || ${TRUE}
.endif