Index: bsd.pkg.mk =================================================================== RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.mk,v retrieving revision 1.1438 diff -u -r1.1438 bsd.pkg.mk --- bsd.pkg.mk 7 Apr 2004 14:26:50 -0000 1.1438 +++ bsd.pkg.mk 8 Apr 2004 15:05:41 -0000 @@ -137,10 +137,6 @@ PKG_FAIL_REASON+= "PLIST_TYPE must be \`\`dynamic'' or \`\`static''." .endif -.if (${PKG_INSTALLATION_TYPE} == "overwrite") && (${PLIST_TYPE} != "static") -PKG_FAIL_REASON+= "PLIST_TYPE must be \`\`static'' for \`\`overwrite'' packages." -.endif - .if empty(USE_BUILDLINK2:M[nN][oO]) && empty(USE_BUILDLINK3:M[nN][oO]) PKG_FAIL_REASON+= "Please undefine USE_BUILDLINK2 or USE_BUILDLINK3." .endif @@ -629,18 +625,64 @@ . endif . elif exists(${PKGDIR}/PLIST.${OPSYS}) PLIST_SRC= ${PKGDIR}/PLIST.${OPSYS} -. else +. elif exists(${PKGDIR}/PLIST) PLIST_SRC= ${PKGDIR}/PLIST +. else +# No PLISTs found, so we will generate it on the fly after installation. +# Enable the staged installation to achieve this. +PLIST_SRC= # empty +PLIST_TYPE= dynamic +STAGEDIR= ${WRKDIR}/.stage . endif . endif _PLIST_SRC= ${PLIST_SRC} .elif ${PLIST_TYPE} == "dynamic" _PLIST_SRC= # empty, since we're using a dynamic PLIST +STAGEDIR= # empty, as the depot dir is used instead .endif DLIST= ${WRKDIR}/.DLIST DDIR= ${WRKDIR}/.DDIR +.if defined(DYNAMIC_PLIST_ONLY) && (!defined(STAGEDIR) || empty(STAGEDIR)) +PKG_FAIL_REASON+= "Dynamic PLISTs requested but this package doesn't support them." +.endif + +.if !empty(STAGEDIR) +NO_MTREE= yes + +# If the package doesn't specify the type of staged installation it uses, +# we try to set a default value. When using GNU configure scripts, the +# package probably uses the 'prefix' variable, in lowercase, which can be +# overrided from the command line (they probably support DESTDIR too, but +# both should work). If not, we try with DESTDIR. +. if defined(GNU_CONFIGURE) && !empty(GNU_CONFIGURE:M[Yy][Ee][Ss]) +STAGED_TYPE?= prefix-lc +. else +STAGED_TYPE?= destdir-uc +. endif + +# Set up the environment according to the value of STAGED_TYPE. We only do +# this during the install phase to avoid problems during the build (which +# could pick up directories in the staging area otherwise). +. if ${PKG_PHASE} == "install" +. if ${STAGED_TYPE} == "prefix-lc" +MAKE_FLAGS+= prefix=${STAGEDIR}${PREFIX} +. elif ${STAGED_TYPE} == "prefix-uc" +MAKE_FLAGS+= PREFIX=${STAGEDIR}${PREFIX} +. elif ${STAGED_TYPE} == "destdir-uc" +MAKE_FLAGS+= DESTDIR=${STAGEDIR} +. else +PKG_FAIL_REASON+= "Unknown value for STAGED_TYPE." +. endif +. endif +.endif + +.if (${PKG_INSTALLATION_TYPE} == "overwrite") && (${PLIST_TYPE} != "static") && \ + empty(STAGEDIR) +PKG_FAIL_REASON+= "PLIST_TYPE must be \`\`static'' for \`\`overwrite'' packages." +.endif + # Set PLIST_SUBST to substitute "${variable}" to "value" in PLIST PLIST_SUBST+= OPSYS=${OPSYS} \ @@ -2299,6 +2341,15 @@ # post-configure. These targets typically edit the files generated by # the do-configure target that are used during the build phase. +#.if !empty(STAGEDIR) && (defined(STAGED_TYPE) && ${STAGED_TYPE} == "destdir-uc") +#_CONFIGURE_PREREQ+= subst-destdir +#SUBST_CLASSES+= destdir +#SUBST_MESSAGE.destdir= "Fixing destdir references." +#SUBST_FILES.destdir= `${FIND} . -name Makefile.in -print` +#SUBST_SED.destdir= \ +# -e 's|^DESTDIR[ ]*=.*|DESTDIR = ${STAGEDIR}|' +#.endif + .if defined(USE_PKGLOCALEDIR) _PKGLOCALEDIR= ${PREFIX}/${PKGLOCALEDIR}/locale REPLACE_LOCALEDIR_PATTERNS?= # empty @@ -2669,6 +2720,9 @@ ${ECHO_MSG} "If this is not desired, set it to an appropriate value (${DEF_UMASK})"; \ ${ECHO_MSG} "and install this package again by \`\`${MAKE} deinstall reinstall''."; \ fi +.if defined(STAGEDIR) + ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${STAGEDIR}${PREFIX} +.endif .if defined(INSTALLATION_DIRS) && !empty(INSTALLATION_DIRS) ${_PKG_SILENT}${_PKG_DEBUG}${ECHO_MSG} "${_PKGSRC_IN}> Creating installation directories" ${_PKG_SILENT}${_PKG_DEBUG} \ @@ -2676,11 +2730,11 @@ case $$dir in \ /*) ;; \ *bin|*bin/*|*libexec|*libexec/*) \ - ${INSTALL_PROGRAM_DIR} ${PREFIX}/$$dir ;; \ + ${INSTALL_PROGRAM_DIR} ${STAGEDIR}${PREFIX}/$$dir ;; \ *man/*) \ - ${INSTALL_MAN_DIR} ${PREFIX}/$$dir ;; \ + ${INSTALL_MAN_DIR} ${STAGEDIR}${PREFIX}/$$dir ;; \ *) \ - ${INSTALL_DATA_DIR} ${PREFIX}/$$dir ;; \ + ${INSTALL_DATA_DIR} ${STAGEDIR}${PREFIX}/$$dir ;; \ esac; \ done .endif # INSTALLATION_DIRS @@ -2703,9 +2757,9 @@ ${_PKG_SILENT}${_PKG_DEBUG}[ -d ${PREFIX} ] || ${MKDIR} ${PREFIX} .endif # !NO_MTREE ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} pre-install-script - ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} pre-install - ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} do-install - ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} post-install + ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} PREFIX=${STAGEDIR}${PREFIX} pre-install + ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} PREFIX=${STAGEDIR}${PREFIX} do-install + ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} PREFIX=${STAGEDIR}${PREFIX} post-install ${_PKG_SILENT}${DO_NADA} \ # \ # PLIST must be generated at this late point (instead of \ @@ -2717,7 +2771,18 @@ # that the real config files and rc.d scripts aren't \ # listed in the PLIST. \ # +.if !empty(STAGEDIR) + @${RM} -f ${PLIST} +.endif ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} ${PLIST} +.if !empty(STAGEDIR) +. if defined(PKG_DEVELOPER) && !empty(PKG_DEVELOPER:M[Yy][Ee][Ss]) + ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} verify-staged-install +. endif + @${ECHO_MSG} "=> Dumping staged files into ${PREFIX}" + @cd ${STAGEDIR}${PREFIX} && ${PAX} -rwpe . ${PREFIX} + @${RM} -rf ${STAGEDIR} +.endif ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} post-install-script ${_PKG_SILENT}${_PKG_DEBUG}newmanpages=`${EGREP} -h \ '^([^@/]*/)*man/([^/]*/)?(man[1-9ln]/.*\.[1-9ln]|cat[1-9ln]/.*\.0)(\.gz)?$$' \ @@ -2790,6 +2855,29 @@ ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} check-shlibs .endif +.PHONY: verify-staged-install +verify-staged-install: + ${_PKG_SILENT}${_PKG_DEBUG}${ECHO_MSG} "=> Verifying staged install" + ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} print-PLIST >${WRKDIR}/.unstaged_prefix + ${_PKG_SILENT}${_PKG_DEBUG} \ + if [ "$$(${WC} -l ${WRKDIR}/.unstaged_prefix | ${SED} -e 's| *||' | ${CUT} -d ' ' -f 1)" -gt 1 ]; then \ + ${ECHO_MSG} "*** FILES WERE INSTALLED DIRECTLY INTO ${PREFIX}"; \ + ${ECHO_MSG} " REVIEW ${WRKDIR}/.unstaged_prefix"; \ + fi; \ + ${FIND} ${PKG_SYSCONFBASE} -newer ${EXTRACT_COOKIE} -print >${WRKDIR}/.unstaged_sysconfdir 2>/dev/null || ${TRUE}; \ + if [ "$$(${WC} -l ${WRKDIR}/.unstaged_sysconfdir | ${SED} -e 's| *||' | ${CUT} -d ' ' -f 1)" -gt 0 ]; then \ + ${ECHO_MSG} "*** FILES WERE INSTALLED DIRECTLY INTO ${PKG_SYSCONFBASE}"; \ + ${ECHO_MSG} " REVIEW ${WRKDIR}/.unstaged_sysconfdir"; \ + fi; \ + if [ -d "${STAGEDIR}${PREFIX}/doc" ]; then \ + ${ECHO_MSG} "*** FILES WERE INSTALLED INTO ${PREFIX}/doc"; \ + ${ECHO_MSG} " THEY SHOULD GO INTO ${PREFIX}/share/doc INSTEAD"; \ + fi; \ + if [ -d "${STAGEDIR}${PREFIX}/etc" ]; then \ + ${ECHO_MSG} "*** FILES WERE INSTALLED INTO ${PREFIX}/etc"; \ + ${ECHO_MSG} " THE PACKAGE DOES NOT HONOUR PKG_SYSCONFDIR PROPERLY"; \ + fi; \ + exit 0 # Do handling of shared libs for two cases: @@ -5000,7 +5088,7 @@ # XXX When all info file entries will be removed from PLIST files # the non-BEGIN pattern-action statements generated below will be retired. _PLIST_AWK_INFO= -.if ${PLIST_TYPE} == "static" +.if ${PLIST_TYPE} == "static" && empty(STAGEDIR) . if !empty(INFO_FILES) . for _f_ in ${INFO_FILES} _PLIST_AWK_INFO+= \ @@ -5066,13 +5154,13 @@ [ "$$ignore" = "yes" ] || ${ECHO} "$$i"; \ done ) _GENERATE_PLIST= \ - ${FIND} ${PREFIX} \! -type d -print | ${SORT} | \ - ${SED} -e "s|^${PREFIX}/||" | \ + ${FIND} ${STAGEDIR}${PREFIX} \! -type d -print | ${SORT} | \ + ${SED} -e "s|^${STAGEDIR}${PREFIX}/||" | \ ${_PLIST_IGNORE_CMD}; \ - ${FIND} ${PREFIX} -type d -print | ${SORT} -r | \ - ${GREP} -v "^${PREFIX}$$" | \ + ${FIND} ${STAGEDIR}${PREFIX} -type d -print | ${SORT} -r | \ + ${GREP} -v "^${STAGEDIR}${PREFIX}$$" | \ ${_PLIST_IGNORE_CMD} | \ - ${SED} -e "s|^${PREFIX}/|@unexec ${RMDIR} -p %D/|" \ + ${SED} -e "s|^${STAGEDIR}${PREFIX}/|@unexec ${RMDIR} -p %D/|" \ -e "s,$$, 2>/dev/null || ${TRUE},"; .else _GENERATE_PLIST= ${CAT} ${_PLIST_SRC}; ${GENERATE_PLIST} Index: bsd.pkg.install.mk =================================================================== RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.install.mk,v retrieving revision 1.55 diff -u -r1.55 bsd.pkg.install.mk --- bsd.pkg.install.mk 12 Jan 2004 12:58:23 -0000 1.55 +++ bsd.pkg.install.mk 8 Apr 2004 15:05:41 -0000 @@ -277,6 +277,7 @@ FILES_SUBST_SED= ${FILES_SUBST:S/=/@!/:S/$/!g/:S/^/ -e s!@/} INSTALL_SCRIPTS_ENV= PKG_PREFIX=${PREFIX} +INSTALL_SCRIPTS_ENV+= PKG_STAGEDIR=${STAGEDIR} .PHONY: pre-install-script post-install-script Index: install/install =================================================================== RCS file: /cvsroot/pkgsrc/mk/install/install,v retrieving revision 1.30 diff -u -r1.30 install --- install/install 8 Jan 2004 14:19:29 -0000 1.30 +++ install/install 8 Apr 2004 15:05:41 -0000 @@ -126,12 +126,20 @@ -n "${MAKE_DIRS_PERMS}" -o -n "${OWN_DIRS_PERMS}" ]; then eval set -- ${MAKE_DIRS} ${OWN_DIRS} for dir; do + if [ -n "${PKG_STAGEDIR}" -a "${dir#${PKG_PREFIX}}" != "${dir}" ]; then + dir=${PKG_STAGEDIR}${dir} + create_dot=no + else + create_dot=yes + fi if [ -d "${dir}" ]; then continue fi if [ "${_PKG_CONFIG}" = "YES" ]; then ${MKDIR} "${dir}" - if [ "${PKG_INSTALLATION_TYPE}" = "pkgviews" ]; then + if [ ${create_dot} = no ]; then + : + elif [ "${PKG_INSTALLATION_TYPE}" = "pkgviews" ]; then case "${dir}" in ${PKG_PREFIX}|${PKG_PREFIX}/*) ;; *) ${ECHO} "${PKGBASE}" > "${dir}/.pkgsrc" ;; @@ -145,8 +153,16 @@ while [ $# -gt 0 ]; do dir="$1"; owner="$2"; group="$3"; mode="$4" shift; shift; shift; shift + if [ -n "${PKG_STAGEDIR}" -a "${dir#${PKG_PREFIX}}" != "${dir}" ]; then + dir=${PKG_STAGEDIR}${dir} + create_dot=no + else + create_dot=yes + fi if [ "${_PKG_CONFIG}" = "YES" ]; then - if [ ! -d "${dir}" ]; then + if [ ${create_dot} = no ]; then + : + elif [ ! -d "${dir}" ]; then ${MKDIR} "${dir}" if [ "${PKG_INSTALLATION_TYPE}" = "pkgviews" ]; then case "${dir}" in