summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorjoerg <joerg@pkgsrc.org>2006-10-09 12:25:44 +0000
committerjoerg <joerg@pkgsrc.org>2006-10-09 12:25:44 +0000
commit1309bbb4267377288c3d88aa567d126a963fceeb (patch)
tree9814d8b785561d4625d3535aa344ea9c5b84ef85 /mk
parentc4170bda15ee54fd5095d9f81bc37151f1d41440 (diff)
downloadpkgsrc-1309bbb4267377288c3d88aa567d126a963fceeb.tar.gz
Main infrastructure for DESTDIR support.
Packages may set PKG_DESTDIR_SUPPORT to either "destdir" or "user-destdir" to flag support for this, following the same rules as PKG_INSTALLATION_TYPES (e.g. define before first include of bsd.prefs.mk). The user activates it via USE_DESTDIR. When set to "yes", packages with "user-destdir" are handled as "destdir". The installation of the package will not go to ${LOCALBASE}, but a subdirectory of ${WRKDIR} instead. pre/post install scripts are not run and the package is not registered either. A binary package can be created instead to be installed normally with pkg_add. For "user-destdir" packages, everything is run as normal user and ownership is supposed to be correctled by pkg_create later. Since the current pkg_install code uses pax and it doesn't allow overwriting owners, this does not work yet. For "destdir" packages, installation, packaging and cleaning is run as root. This commit does not change the handling of DEPENDS_TARGET or bin-install to allow recursive usage.
Diffstat (limited to 'mk')
-rw-r--r--mk/bsd.prefs.mk38
-rw-r--r--mk/check/check-files.mk12
-rw-r--r--mk/check/check-interpreter.mk4
-rw-r--r--mk/check/check-shlibs.mk6
-rw-r--r--mk/check/check-wrkref.mk6
-rw-r--r--mk/flavor/pkg/metadata.mk16
-rw-r--r--mk/flavor/pkg/package.mk8
-rw-r--r--mk/install/install.mk39
-rw-r--r--mk/package/package.mk4
-rw-r--r--mk/plist/plist.mk12
-rw-r--r--mk/plist/print-plist.mk14
-rw-r--r--mk/unprivileged.mk10
12 files changed, 119 insertions, 50 deletions
diff --git a/mk/bsd.prefs.mk b/mk/bsd.prefs.mk
index 39077cb81eb..da3654789be 100644
--- a/mk/bsd.prefs.mk
+++ b/mk/bsd.prefs.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.prefs.mk,v 1.240 2006/10/09 11:59:08 joerg Exp $
+# $NetBSD: bsd.prefs.mk,v 1.241 2006/10/09 12:25:44 joerg Exp $
#
# Make file, included to get the site preferences, if any. Should
# only be included by package Makefiles before any .if defined()
@@ -326,6 +326,42 @@ PKG_FAIL_REASON+= "missing mk/platform/${OPSYS}.mk"
PKGDIRMODE?= 755
+# PKG_DESTDIR_SUPPORT can only be one of "destdir" or "user-destdir".
+USE_DESTDIR?= no
+PKG_DESTDIR_SUPPORT?= # empty
+
+.if empty(PKG_DESTDIR_SUPPORT) || (empty(USE_DESTDIR:M[Yy][Ee][Ss]) && empty(USE_DESTDIR:M[Ff][Uu][Ll][Ll]))
+_USE_DESTDIR= no
+.elif ${PKG_DESTDIR_SUPPORT} == "user-destdir"
+. if !empty(USE_DESTDIR:M[Ff][Uu][Ll][Ll])
+_USE_DESTDIR= user-destdir
+. else
+_USE_DESTDIR= destdir
+. endif
+.elif ${PKG_DESTDIR_SUPPORT} == "destdir"
+_USE_DESTDIR= destdir
+.else
+PKG_FAIL_REASON+= "PKG_DESTDIR_SUPPORT must be \`\`destdir'' or \`\`user-destdir''."
+.endif
+
+# When using staged installation, everything gets installed into
+# ${DESTDIR}${PREFIX} instead of ${PREFIX} directly.
+#
+.if ${_USE_DESTDIR} != "no"
+DESTDIR= ${WRKDIR}/.destdir
+. if ${_USE_DESTDIR} == "destdir"
+_MAKE_PACKAGE_AS_ROOT= yes
+_MAKE_CLEAN_AS_ROOT= yes
+_MAKE_INSTALL_AS_ROOT= yes
+. elif ${_USE_DESTDIR} == "user-destdir"
+_MAKE_PACKAGE_AS_ROOT= no
+_MAKE_CLEAN_AS_ROOT= no
+_MAKE_INSTALL_AS_ROOT= no
+. endif
+.else
+DESTDIR=
+.endif
+
_MAKE_CLEAN_AS_ROOT?= no
# Whether to run the clean target as root.
_MAKE_INSTALL_AS_ROOT?= yes
diff --git a/mk/check/check-files.mk b/mk/check/check-files.mk
index 9bf97b02382..7a2170b58a6 100644
--- a/mk/check/check-files.mk
+++ b/mk/check/check-files.mk
@@ -1,4 +1,4 @@
-# $NetBSD: check-files.mk,v 1.8 2006/09/22 21:53:58 joerg Exp $
+# $NetBSD: check-files.mk,v 1.9 2006/10/09 12:25:44 joerg Exp $
.if defined(PKG_DEVELOPER)
CHECK_FILES?= yes
@@ -65,7 +65,7 @@ CHECK_FILES_SKIP+= ${PREFIX}/.*/fonts.cache-1
# Mutable charset.alias file
CHECK_FILES_SKIP+= ${PREFIX}/lib/charset.alias
-_CHECK_FILES_SKIP_FILTER= ${GREP} -vx ${CHECK_FILES_SKIP:@f@-e ${f:Q}@}
+_CHECK_FILES_SKIP_FILTER= ${GREP} -vx ${CHECK_FILES_SKIP:@f@-e ${DESTDIR:Q}${f:Q}@}
###########################################################################
# These are the files generated and used by the check-files implementation
@@ -144,7 +144,7 @@ check-files-post-message:
${_CHECK_FILES_PRE.prefix} ${_CHECK_FILES_POST.prefix}:
${_PKG_SILENT}${_PKG_DEBUG} \
- ${FIND} ${PREFIX}/. \( -type f -o -type l \) -print 2>/dev/null \
+ ${FIND} ${DESTDIR}${PREFIX}/. \( -type f -o -type l \) -print 2>/dev/null \
| ${SED} -e 's,/\./,/,' \
| ${_CHECK_FILES_SKIP_FILTER} \
| ${SORT} > ${.TARGET} \
@@ -152,7 +152,7 @@ ${_CHECK_FILES_PRE.prefix} ${_CHECK_FILES_POST.prefix}:
${_CHECK_FILES_PRE.sysconfdir} ${_CHECK_FILES_POST.sysconfdir}:
${_PKG_SILENT}${_PKG_DEBUG} \
- ${FIND} ${PKG_SYSCONFDIR}/. -print 2>/dev/null \
+ ${FIND} ${DESTDIR}${PKG_SYSCONFDIR}/. -print 2>/dev/null \
| ${SED} -e 's,/\./,/,' \
| ${_CHECK_FILES_SKIP_FILTER} \
| ${SORT} > ${.TARGET} \
@@ -160,7 +160,7 @@ ${_CHECK_FILES_PRE.sysconfdir} ${_CHECK_FILES_POST.sysconfdir}:
${_CHECK_FILES_PRE.varbase} ${_CHECK_FILES_POST.varbase}:
${_PKG_SILENT}${_PKG_DEBUG} \
- ${FIND} ${VARBASE}/. -print 2>/dev/null \
+ ${FIND} ${DESTDIR}${VARBASE}/. -print 2>/dev/null \
| ${SED} -e 's,/\./,/,' \
| ${_CHECK_FILES_SKIP_FILTER} \
| ${SORT} > ${.TARGET} \
@@ -221,7 +221,7 @@ ${_CHECK_FILES_DELETED}: ${_CHECK_FILES_DIFF}
${_CHECK_FILES_EXPECTED}: plist
${_PKG_SILENT}${_PKG_DEBUG} \
- ${GREP} '^[^@]' ${PLIST} | ${SED} "s|^|${PREFIX}/|" | ${SORT} \
+ ${GREP} '^[^@]' ${PLIST} | ${SED} "s|^|${DESTDIR}${PREFIX}/|" | ${SORT} \
> ${.TARGET}
${_CHECK_FILES_MISSING}: ${_CHECK_FILES_EXPECTED} ${_CHECK_FILES_ADDED}
diff --git a/mk/check/check-interpreter.mk b/mk/check/check-interpreter.mk
index faa5af15574..729f9c8dc30 100644
--- a/mk/check/check-interpreter.mk
+++ b/mk/check/check-interpreter.mk
@@ -1,4 +1,4 @@
-# $NetBSD: check-interpreter.mk,v 1.11 2006/07/13 19:07:54 heinz Exp $
+# $NetBSD: check-interpreter.mk,v 1.12 2006/10/09 12:25:44 joerg Exp $
# This file checks that after installation, all files of the package
# that start with a "#!" line will find their interpreter. Files that
@@ -32,7 +32,7 @@ _CHECK_INTERP_SKIP_FILTER+= ${_CHECK_INTERP_SKIP:@.pattern.@${PREFIX}/${.pattern
_CHECK_INTERP_SKIP_FILTER+= *) ;;
_CHECK_INTERP_SKIP_FILTER+= esac
-_CHECK_INTERP_FILELIST_CMD?= ${PKG_FILELIST_CMD}
+_CHECK_INTERP_FILELIST_CMD?= ${SED} -e '/^@/d' ${PLIST}
######################################################################
### check-interpreter (PRIVATE)
diff --git a/mk/check/check-shlibs.mk b/mk/check/check-shlibs.mk
index 93a046dd397..e564f20e40f 100644
--- a/mk/check/check-shlibs.mk
+++ b/mk/check/check-shlibs.mk
@@ -1,4 +1,4 @@
-# $NetBSD: check-shlibs.mk,v 1.4 2006/09/14 22:00:49 rillig Exp $
+# $NetBSD: check-shlibs.mk,v 1.5 2006/10/09 12:25:44 joerg Exp $
# For PKG_DEVELOPERs, cause some checks to be run automatically by default.
.if defined(PKG_DEVELOPER)
@@ -9,6 +9,8 @@ CHECK_SHLIBS?= no
# All binaries and shared libraries.
_CHECK_SHLIBS_ERE= /(bin/|sbin/|libexec/|lib/lib.*\.so|lib/lib.*\.dylib)
+_CHECK_SHLIB_FILELIST_CMD?= ${SED} -e '/^@/d' ${PLIST}
+
######################################################################
### check-shlibs (PRIVATE)
######################################################################
@@ -31,7 +33,7 @@ check-shlibs: error-check
*) ldd=${LDD:Q} ;; \
esac; \
${TEST} -x "$$ldd" || exit 0; \
- ${PKG_FILELIST_CMD} | \
+ ${_CHECK_SHLIB_FILELIST_CMD} | \
${EGREP} -h ${_CHECK_SHLIBS_ERE:Q} | \
while read file; do \
err=`$$ldd $$file 2>&1 | ${GREP} "not found" || ${TRUE}`; \
diff --git a/mk/check/check-wrkref.mk b/mk/check/check-wrkref.mk
index c109bee6c9f..72d3636273b 100644
--- a/mk/check/check-wrkref.mk
+++ b/mk/check/check-wrkref.mk
@@ -1,4 +1,4 @@
-# $NetBSD: check-wrkref.mk,v 1.4 2006/06/09 13:59:08 jlam Exp $
+# $NetBSD: check-wrkref.mk,v 1.5 2006/10/09 12:25:44 joerg Exp $
.if defined(PKG_DEVELOPER)
CHECK_WRKREF?= tools
@@ -30,6 +30,8 @@ _CHECK_WRKREF:= ${CHECK_WRKREF}
_CHECK_WRKREF:= work # "work" is the "max" option
.endif
+_CHECK_WRKREF_FILELIST_CMD?= ${SED} -e '/^@/d' ${PLIST}
+
######################################################################
### check-wrkref (PRIVATE)
######################################################################
@@ -43,7 +45,7 @@ check-wrkref: error-check
${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${ERROR_DIR}/${.TARGET}
${_PKG_SILENT}${_PKG_DEBUG} \
exec 1>${ERROR_DIR}/${.TARGET}; \
- ${PKG_FILELIST_CMD} | ${SORT} | \
+ ${_CHECK_WRKREF_FILELIST_CMD} | ${SORT} | \
while read file; do \
${_CHECK_WRKREF_SKIP_FILTER}; \
${SHCOMMENT} [$$file]; \
diff --git a/mk/flavor/pkg/metadata.mk b/mk/flavor/pkg/metadata.mk
index 17576364edd..98c5f701f99 100644
--- a/mk/flavor/pkg/metadata.mk
+++ b/mk/flavor/pkg/metadata.mk
@@ -1,4 +1,4 @@
-# $NetBSD: metadata.mk,v 1.11 2006/10/08 20:25:43 rillig Exp $
+# $NetBSD: metadata.mk,v 1.12 2006/10/09 12:25:44 joerg Exp $
######################################################################
### The targets below are all PRIVATE.
@@ -61,14 +61,14 @@ ${_BUILD_INFO_FILE}: plist
"") ldd=`${TYPE} ldd 2>/dev/null | ${AWK} '{ print $$NF }'` ;; \
*) ldd=${LDD:Q} ;; \
esac; \
- bins=`${AWK} '/(^|\/)(bin|sbin|libexec)\// { print "${PREFIX}/" $$0 } END { exit 0 }' ${PLIST}`; \
+ bins=`${AWK} '/(^|\/)(bin|sbin|libexec)\// { print "${DESTDIR}${PREFIX}/" $$0 } END { exit 0 }' ${PLIST}`; \
case ${OBJECT_FMT:Q}"" in \
ELF) \
- libs=`${AWK} '/(^|\/)lib\/lib.*\.so\.[0-9]+$$/ { print "${PREFIX}/" $$0 } END { exit 0 }' ${PLIST}`; \
+ libs=`${AWK} '/(^|\/)lib\/lib.*\.so\.[0-9]+$$/ { print "${DESTDIR}${PREFIX}/" $$0 } END { exit 0 }' ${PLIST}`; \
if ${TEST} -n "$$bins" -o -n "$$libs"; then \
requires=`($$ldd $$bins $$libs 2>/dev/null || ${TRUE}) | ${AWK} '$$2 == "=>" && $$3 ~ "/" { print $$3 }' | ${SORT} -u`; \
fi; \
- linklibs=`${AWK} '/[^@].*\.so\.[0-9\.]+$$/ { print "${PREFIX}/" $$0 }' ${PLIST}`; \
+ linklibs=`${AWK} '/[^@].*\.so\.[0-9\.]+$$/ { print "${DESTDIR}${PREFIX}/" $$0 }' ${PLIST}`; \
for i in $$linklibs; do \
if ${TEST} -r $$i -a ! -x $$i -a ! -h $$i; then \
${TEST} ${PKG_DEVELOPER:Uno:Q} = "no" || \
@@ -78,7 +78,7 @@ ${_BUILD_INFO_FILE}: plist
done; \
;; \
Mach-O) \
- libs=`${AWK} '/(^|\/)lib\/lib.*\.dylib/ { print "${PREFIX}/" $$0 } END { exit 0 }' ${PLIST}`; \
+ libs=`${AWK} '/(^|\/)lib\/lib.*\.dylib/ { print "${DESTDIR}${PREFIX}/" $$0 } END { exit 0 }' ${PLIST}`; \
if ${TEST} "$$bins" != "" -o "$$libs" != ""; then \
requires=`($$ldd $$bins $$libs 2>/dev/null || ${TRUE}) | ${AWK} '/compatibility version/ { print $$1 }' | ${SORT} -u`; \
fi; \
@@ -301,7 +301,7 @@ ${_SIZE_PKG_FILE}: plist
/^@/ { next } \
{ print base $$0 }' | \
${SORT} -u | \
- ${SED} -e "s/'/'\\\\''/g" -e "s/.*/'&'/" | \
+ ${SED} -e "s,^/,${DESTDIR}/," -e "s/'/'\\\\''/g" -e "s/.*/'&'/" | \
${XARGS} -n 256 ${LS} -ld 2>/dev/null | \
${AWK} 'BEGIN { s = 0 } { s += $$5 } END { print s }' \
> ${.TARGET}
@@ -333,7 +333,11 @@ _PKG_CREATE_ARGS+= ${INSTALL_FILE:D ${_INSTALL_ARG_cmd:sh}}
_PKG_CREATE_ARGS+= ${DEINSTALL_FILE:D ${_DEINSTALL_ARG_cmd:sh}}
_PKG_ARGS_INSTALL+= ${_PKG_CREATE_ARGS}
+.if ${_USE_DESTDIR} == "no"
_PKG_ARGS_INSTALL+= -p ${PREFIX}
+.else
+_PKG_ARGS_INSTALL+= -I ${PREFIX} -p ${DESTDIR}${PREFIX}
+.endif
_DEPENDS_ARG_cmd= depends=`${_DEPENDS_PATTERNS_CMD}`; \
if ${TEST} -n "$$depends"; then \
diff --git a/mk/flavor/pkg/package.mk b/mk/flavor/pkg/package.mk
index d27e8b2a9cb..291cef480ca 100644
--- a/mk/flavor/pkg/package.mk
+++ b/mk/flavor/pkg/package.mk
@@ -1,4 +1,4 @@
-# $NetBSD: package.mk,v 1.4 2006/10/08 20:24:03 rillig Exp $
+# $NetBSD: package.mk,v 1.5 2006/10/09 12:25:44 joerg Exp $
PKG_SUFX?= .tgz
PKGFILE?= ${PKGREPOSITORY}/${PKGNAME}${PKG_SUFX}
@@ -29,8 +29,12 @@ package-check-installed:
package-create: package-remove ${PKGFILE} package-links
_PKG_ARGS_PACKAGE+= ${_PKG_CREATE_ARGS}
+.if ${_USE_DESTDIR} == "no"
_PKG_ARGS_PACKAGE+= -p ${PREFIX}
-_PKG_ARGS_PACKAGE+= -L ${PREFIX} # @src ...
+.else
+_PKG_ARGS_PACKAGE+= -I ${PREFIX} -p ${DESTDIR}${PREFIX}
+.endif
+_PKG_ARGS_PACKAGE+= -L ${DESTDIR}${PREFIX} # @src ...
.if ${PKG_INSTALLATION_TYPE} == "pkgviews"
_PKG_ARGS_PACKAGE+= -E
.endif
diff --git a/mk/install/install.mk b/mk/install/install.mk
index a09fde24288..99bed60bcf7 100644
--- a/mk/install/install.mk
+++ b/mk/install/install.mk
@@ -1,4 +1,4 @@
-# $NetBSD: install.mk,v 1.21 2006/10/09 11:59:08 joerg Exp $
+# $NetBSD: install.mk,v 1.22 2006/10/09 12:25:44 joerg Exp $
######################################################################
### install (PUBLIC)
@@ -121,8 +121,10 @@ release-install-localbase-lock: release-localbase-lock
### the built software, register the software installation, and run
### some sanity checks.
###
+.if ${_USE_DESTDIR} != "user-destdir"
_INSTALL_ALL_TARGETS+= acquire-install-localbase-lock
-.if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER)
+.endif
+.if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER) && ${_USE_DESTDIR} == "no"
_INSTALL_ALL_TARGETS+= install-check-conflicts
_INSTALL_ALL_TARGETS+= install-check-installed
.endif
@@ -131,7 +133,9 @@ _INSTALL_ALL_TARGETS+= install-check-umask
_INSTALL_ALL_TARGETS+= check-files-pre
.endif
_INSTALL_ALL_TARGETS+= install-makedirs
+.if ${_USE_DESTDIR} == "no"
_INSTALL_ALL_TARGETS+= pre-install-script
+.endif
_INSTALL_ALL_TARGETS+= pre-install
_INSTALL_ALL_TARGETS+= do-install
_INSTALL_ALL_TARGETS+= post-install
@@ -141,12 +145,16 @@ _INSTALL_ALL_TARGETS+= install-script-data
.if empty(CHECK_FILES:M[nN][oO]) && !empty(CHECK_FILES_SUPPORTED:M[Yy][Ee][Ss])
_INSTALL_ALL_TARGETS+= check-files-post
.endif
+.if ${_USE_DESTDIR} == "no"
_INSTALL_ALL_TARGETS+= post-install-script
-.if !defined(NO_PKG_REGISTER)
+.endif
+.if !defined(NO_PKG_REGISTER) && ${_USE_DESTDIR} == "no"
_INSTALL_ALL_TARGETS+= register-pkg
.endif
_INSTALL_ALL_TARGETS+= privileged-install-hook
+.if ${_USE_DESTDIR} != "user-destdir"
_INSTALL_ALL_TARGETS+= release-install-localbase-lock
+.endif
_INSTALL_ALL_TARGETS+= error-check
.if empty(CHECK_SHLIBS:M[nN][oO])
@@ -225,18 +233,18 @@ MTREE_ARGS?= -U -f ${MTREE_FILE} -d -e -p
.PHONY: install-makedirs
install-makedirs:
- ${_PKG_SILENT}${_PKG_DEBUG}${TEST} -d ${PREFIX} || ${MKDIR} ${PREFIX}
+ ${_PKG_SILENT}${_PKG_DEBUG}${TEST} -d ${DESTDIR}${PREFIX} || ${MKDIR} ${DESTDIR}${PREFIX}
.if !defined(NO_MTREE)
${_PKG_SILENT}${_PKG_DEBUG}${TEST} ! -f ${MTREE_FILE} || \
- ${MTREE} ${MTREE_ARGS} ${PREFIX}/
+ ${MTREE} ${MTREE_ARGS} ${DESTDIR}${PREFIX}/
.endif
.if defined(INSTALLATION_DIRS) && !empty(INSTALLATION_DIRS)
@${STEP_MSG} "Creating installation directories"
${_PKG_SILENT}${_PKG_DEBUG} \
for dir in ${INSTALLATION_DIRS}; do \
case "$$dir" in \
- ${PREFIX}/*) \
- dir=`${ECHO} $$dir | ${SED} "s|^${PREFIX}/||"` ;; \
+ ${DESTDIR}${PREFIX}/*) \
+ dir=`${ECHO} $$dir | ${SED} "s|^${DESTDIR}${PREFIX}/||"` ;; \
/*) continue ;; \
esac; \
if [ -f "${PREFIX}/$$dir" ]; then \
@@ -245,11 +253,11 @@ install-makedirs:
fi; \
case "$$dir" in \
*bin|*bin/*|*libexec|*libexec/*) \
- ${INSTALL_PROGRAM_DIR} ${PREFIX}/$$dir ;; \
+ ${INSTALL_PROGRAM_DIR} ${DESTDIR}${PREFIX}/$$dir ;; \
${PKGMANDIR}/*) \
- ${INSTALL_MAN_DIR} ${PREFIX}/$$dir ;; \
+ ${INSTALL_MAN_DIR} ${DESTDIR}${PREFIX}/$$dir ;; \
*) \
- ${INSTALL_DATA_DIR} ${PREFIX}/$$dir ;; \
+ ${INSTALL_DATA_DIR} ${DESTDIR}${PREFIX}/$$dir ;; \
esac; \
done
.endif # INSTALLATION_DIRS
@@ -265,14 +273,19 @@ install-makedirs:
INSTALL_DIRS?= ${BUILD_DIRS}
INSTALL_MAKE_FLAGS?= ${MAKE_FLAGS}
INSTALL_TARGET?= install ${USE_IMAKE:D${NO_INSTALL_MANPAGES:D:Uinstall.man}}
+.if ${_USE_DESTDIR} != "no"
+INSTALL_ENV+= DESTDIR=${DESTDIR:Q}
+INSTALL_MAKE_FLAGS+= DESTDIR=${DESTDIR:Q}
+.endif
.if !target(do-install)
do-install:
. for _dir_ in ${INSTALL_DIRS}
${_PKG_SILENT}${_PKG_DEBUG}${_ULIMIT_CMD} \
cd ${WRKSRC} && cd ${_dir_} && \
- ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
- -f ${MAKE_FILE} ${INSTALL_TARGET}
+ ${SETENV} ${INSTALL_ENV} ${MAKE_ENV} \
+ ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
+ -f ${MAKE_FILE} ${INSTALL_TARGET}
. endfor
.endif
@@ -301,7 +314,7 @@ _DOC_COMPRESS= \
MANZ=${_MANZ} \
PKG_VERBOSE=${PKG_VERBOSE} \
TEST=${TOOLS_TEST:Q} \
- ${SH} ${PKGSRCDIR}/mk/plist/doc-compress ${PREFIX}
+ ${SH} ${PKGSRCDIR}/mk/plist/doc-compress ${DESTDIR}${PREFIX}
.PHONY: install-doc-handling
install-doc-handling: plist
diff --git a/mk/package/package.mk b/mk/package/package.mk
index d3a9ca63530..b7fd8ada7c5 100644
--- a/mk/package/package.mk
+++ b/mk/package/package.mk
@@ -1,4 +1,4 @@
-# $NetBSD: package.mk,v 1.17 2006/10/09 11:44:07 joerg Exp $
+# $NetBSD: package.mk,v 1.18 2006/10/09 12:25:44 joerg Exp $
######################################################################
### package (PUBLIC)
@@ -77,7 +77,9 @@ package-cookie:
### package-all is a helper target to create the binary package and
### generate any necessary warnings.
###
+.if ${_USE_DESTDIR} == "no"
_PACKAGE_ALL_TARGETS+= package-check-installed
+.endif
_PACKAGE_ALL_TARGETS+= package-create
_PACKAGE_ALL_TARGETS+= package-warnings
_PACKAGE_ALL_TARGETS+= error-check
diff --git a/mk/plist/plist.mk b/mk/plist/plist.mk
index 3b0e3101140..ed9948c4b40 100644
--- a/mk/plist/plist.mk
+++ b/mk/plist/plist.mk
@@ -1,4 +1,4 @@
-# $NetBSD: plist.mk,v 1.15 2006/07/21 13:40:27 jlam Exp $
+# $NetBSD: plist.mk,v 1.16 2006/10/09 12:25:44 joerg Exp $
#
# This Makefile fragment handles the creation of PLISTs for use by
# pkg_create(8).
@@ -102,7 +102,7 @@ _PLIST_AWK_ENV+= LS=${TOOLS_LS:Q}
_PLIST_AWK_ENV+= MANINSTALL=${MANINSTALL:Q}
_PLIST_AWK_ENV+= MANZ=${_MANZ:Q}
_PLIST_AWK_ENV+= PKGMANDIR=${PKGMANDIR:Q}
-_PLIST_AWK_ENV+= PREFIX=${PREFIX:Q}
+_PLIST_AWK_ENV+= PREFIX=${DESTDIR:Q}${PREFIX:Q}
_PLIST_AWK_ENV+= TEST=${TOOLS_TEST:Q}
# PLIST_SUBST contains package-settable "${variable}" to "value"
@@ -205,13 +205,13 @@ _PLIST_IGNORE_CMD= \
[ "$$ignore" = "yes" ] || ${ECHO} "$$i"; \
done )
_GENERATE_PLIST= \
- ${FIND} ${PREFIX} \! -type d -print | ${SORT} | \
- ${SED} -e "s|^${PREFIX}/||" | \
+ ${FIND} ${DESTDIR}${PREFIX} \! -type d -print | ${SORT} | \
+ ${SED} -e "s|^${DESTDIR}${PREFIX}/||" | \
${_PLIST_IGNORE_CMD}; \
- ${FIND} ${PREFIX} -type d -print | ${SORT} -r | \
+ ${FIND} ${DESTDIR}${PREFIX} -type d -print | ${SORT} -r | \
${GREP} -v "^${PREFIX}$$" | \
${_PLIST_IGNORE_CMD} | \
- ${SED} -e "s|^${PREFIX}/|@unexec ${RMDIR} -p %D/|" \
+ ${SED} -e "s|^${DESTDIR}${PREFIX}/|@unexec ${RMDIR} -p %D/|" \
-e "s,$$, 2>/dev/null || ${TRUE},";
.else
_GENERATE_PLIST= ${CAT} ${PLIST_SRC}; \
diff --git a/mk/plist/print-plist.mk b/mk/plist/print-plist.mk
index 1fb2ae6d22e..332c3f170c5 100644
--- a/mk/plist/print-plist.mk
+++ b/mk/plist/print-plist.mk
@@ -1,4 +1,4 @@
-# $NetBSD: print-plist.mk,v 1.9 2006/07/07 21:24:29 jlam Exp $
+# $NetBSD: print-plist.mk,v 1.10 2006/10/09 12:25:44 joerg Exp $
###
### Automatic PLIST generation
@@ -76,9 +76,9 @@ _PRINT_PLIST_COMMON_DIRS!= ${AWK} 'BEGIN { \
# XXX should check $LOCALBASE and $X11BASE, and add @cwd statements
_PRINT_PLIST_FILES_CMD= \
- ${FIND} ${PREFIX}/. -xdev -newer ${_COOKIE.extract} \! -type d -print
+ ${FIND} ${DESTDIR}${PREFIX}/. -xdev -newer ${_COOKIE.extract} \! -type d -print
_PRINT_PLIST_DIRS_CMD= \
- ${FIND} ${PREFIX}/. -xdev -newer ${_COOKIE.extract} -type d -print
+ ${FIND} ${DESTDIR}${PREFIX}/. -xdev -newer ${_COOKIE.extract} -type d -print
.if !empty(LIBTOOLIZE_PLIST:M[yY][eE][sS])
_PRINT_PLIST_LIBTOOLIZE_FILTER?= \
@@ -124,7 +124,7 @@ print-PLIST:
| ${_PRINT_PLIST_LIBTOOLIZE_FILTER} \
| ${SORT} \
| ${AWK} ' \
- { sub("${PREFIX}/\\./", ""); } \
+ { sub("${DESTDIR}${PREFIX}/\\./", ""); } \
${_PRINT_PLIST_AWK_IGNORE} { next; } \
${PRINT_PLIST_AWK} \
${_PRINT_PLIST_AWK_SUBST} \
@@ -153,16 +153,16 @@ print-PLIST:
| ${SORT} -r \
| ${AWK} ' \
/emul\/linux\/proc/ { next; } \
- /${PREFIX:S|/|\\/|g}\/\.$$/ { next; } \
+ /${DESTDIR:S|/|\\/|g}${PREFIX:S|/|\\/|g}\/\.$$/ { next; } \
/${PKG_DBDIR:S|/|\\/|g}\// { next; } \
- { sub("${PREFIX}/\\\\./", ""); } \
+ { sub("${DESTDIR}${PREFIX}/\\\\./", ""); } \
{ sub("^${PKGINFODIR}/", "info/"); } \
{ sub("^${PKGMANDIR}/", "man/"); } \
/^${PKG_DBDIR:S|^${PREFIX}/||:S|/|\\/|g}(\/|$$)/ { next; } \
/^${PKGINFODIR:S|/|\\/|g}$$/ { next; } \
${_PRINT_PLIST_COMMON_DIRS}'` ; \
do \
- if [ `${LS} -la ${PREFIX}/$$i | ${WC} -l` = 3 ]; then \
+ if [ `${LS} -la ${DESTDIR}${PREFIX}/$$i | ${WC} -l` = 3 ]; then \
${ECHO} @exec \$${MKDIR} %D/$$i | ${AWK} ' \
${PRINT_PLIST_AWK} \
{ print $$0; }' ; \
diff --git a/mk/unprivileged.mk b/mk/unprivileged.mk
index f04f25f8f9d..b50a9373936 100644
--- a/mk/unprivileged.mk
+++ b/mk/unprivileged.mk
@@ -1,4 +1,4 @@
-# $NetBSD: unprivileged.mk,v 1.5 2006/08/31 16:21:20 rillig Exp $
+# $NetBSD: unprivileged.mk,v 1.6 2006/10/09 12:25:44 joerg Exp $
#
# This file collects definitions that are useful when using pkgsrc as an
# unprivileged (non-root) user. It is included automatically by the
@@ -17,7 +17,7 @@
# Specifies the user name (or uid) that will be used to install
# files.
-.if defined(UNPRIVILEGED) && !empty(UNPRIVILEGED:M[Yy][Ee][Ss])
+.if (defined(UNPRIVILEGED) && !empty(UNPRIVILEGED:M[Yy][Ee][Ss])) || ${_USE_DESTDIR} == "user-destdir"
# Guess which user/group has to be used.
. if !defined(UNPRIVILEGED_USER) || empty(UNPRIVILEGED_USER)
@@ -27,6 +27,10 @@ UNPRIVILEGED_USER!= ${ID} -n -u
UNPRIVILEGED_GROUP!= ${ID} -n -g
. endif
+.if ${_USE_DESTDIR} == "user-destdir" && (!defined(UNPRIVILEGED) || empty(UNPRIVILEGED:M[Yy][Ee][Ss]))
+_SU_ROOT_USER:= ${ROOT_USER}
+.endif
+
# Override super-user account.
ROOT_GROUP= ${UNPRIVILEGED_GROUP}
ROOT_USER= ${UNPRIVILEGED_USER}
@@ -49,7 +53,9 @@ NONBINMODE= 644
# mtree is useless as a regular user because it won't set directory
# ownerships correctly.
NO_MTREE= yes
+.endif
+.if (defined(UNPRIVILEGED) && !empty(UNPRIVILEGED:M[Yy][Ee][Ss]))
# As a regular user, creation of other users and groups won't work, so
# disable this step by default.
PKG_CREATE_USERGROUP= NO