summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/CHANGES-20065
-rw-r--r--mk/bsd.options.mk4
-rw-r--r--mk/bsd.pkg.extract.mk5
-rw-r--r--mk/bsd.pkg.mk1373
-rw-r--r--mk/bsd.pkg.update.mk127
-rw-r--r--mk/bsd.pkg.use.mk5
-rw-r--r--mk/bsd.prefs.mk64
-rw-r--r--mk/check/bsd.check-vars.mk10
-rw-r--r--mk/check/bsd.check.mk16
-rw-r--r--mk/check/check-files.mk (renamed from mk/bsd.pkg.check.mk)243
-rw-r--r--mk/check/check-interpreter.mk47
-rw-r--r--mk/check/check-shlibs.mk43
-rw-r--r--mk/check/check-vulnerable.mk11
-rw-r--r--mk/check/check-wrkref.mk70
-rw-r--r--mk/depends/bsd.depends-vars.mk8
-rw-r--r--mk/depends/bsd.depends.mk60
-rw-r--r--mk/depends/depends.mk50
-rw-r--r--mk/flavor/bsd.flavor-vars.mk11
-rw-r--r--mk/flavor/bsd.flavor.mk7
-rw-r--r--mk/flavor/pkg/check.mk27
-rw-r--r--mk/flavor/pkg/deinstall.mk50
-rw-r--r--mk/flavor/pkg/depends.mk109
-rw-r--r--mk/flavor/pkg/flavor-vars.mk78
-rw-r--r--mk/flavor/pkg/flavor.mk21
-rw-r--r--mk/flavor/pkg/install.mk77
-rw-r--r--mk/flavor/pkg/metadata.mk404
-rw-r--r--mk/flavor/pkg/package.mk110
-rwxr-xr-xmk/flavor/pkg/reduce-depends.awk141
-rwxr-xr-xmk/flavor/pkg/register-dependencies54
-rw-r--r--mk/flavor/pkg/replace.mk173
-rw-r--r--mk/flavor/pkg/utility.mk75
-rw-r--r--mk/flavor/pkg/views.mk91
-rw-r--r--mk/install/bsd.install-vars.mk65
-rw-r--r--mk/install/bsd.install.mk40
-rw-r--r--mk/install/deinstall.mk44
-rw-r--r--mk/install/install.mk302
-rw-r--r--mk/install/replace.mk59
-rw-r--r--mk/package/bsd.package.mk45
-rw-r--r--mk/package/package.mk109
-rw-r--r--mk/pkginstall/bsd.pkginstall.mk7
-rw-r--r--mk/plist/plist.mk3
-rw-r--r--mk/reduce-depends.mk128
42 files changed, 2613 insertions, 1758 deletions
diff --git a/doc/CHANGES-2006 b/doc/CHANGES-2006
index dda2ba05017..0f886a8c8c2 100644
--- a/doc/CHANGES-2006
+++ b/doc/CHANGES-2006
@@ -1,4 +1,4 @@
-$NetBSD: CHANGES-2006,v 1.406 2006/06/03 22:26:04 adrianp Exp $
+$NetBSD: CHANGES-2006,v 1.407 2006/06/03 23:11:42 jlam Exp $
Changes to the packages collection and infrastructure in 2006:
@@ -2890,3 +2890,6 @@ Changes to the packages collection and infrastructure in 2006:
Updated databases/mysql5-client to 5.0.22 [tron 2006-06-03]
Updated databases/mysql5-server to 5.0.22 [tron 2006-06-03]
Updated www/drupal to 4.7.2 [adrianp 2006-06-03]
+ mk/bsd.pkg.mk: refactored depends, install, and package phases to
+ support additional package system flavors via PKG_FLAVOR
+ [jlam 2006-06-03]
diff --git a/mk/bsd.options.mk b/mk/bsd.options.mk
index 2aa59cb1a5b..22092b09db6 100644
--- a/mk/bsd.options.mk
+++ b/mk/bsd.options.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.options.mk,v 1.54 2006/06/03 08:44:46 seb Exp $
+# $NetBSD: bsd.options.mk,v 1.55 2006/06/03 23:11:42 jlam Exp $
#
# This Makefile fragment provides boilerplate code for standard naming
# conventions for handling per-package build options.
@@ -393,7 +393,7 @@ show-options:
.if defined(PKG_SUPPORTED_OPTIONS)
.PHONY: supported-options-message
-pre-install-depends: supported-options-message
+pre-depends-hook: supported-options-message
supported-options-message:
. if !empty(PKG_SUPPORTED_OPTIONS)
@${ECHO} "=========================================================================="
diff --git a/mk/bsd.pkg.extract.mk b/mk/bsd.pkg.extract.mk
index 4ae799c43e1..fc301d52258 100644
--- a/mk/bsd.pkg.extract.mk
+++ b/mk/bsd.pkg.extract.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.extract.mk,v 1.22 2006/05/30 23:51:38 wiz Exp $
+# $NetBSD: bsd.pkg.extract.mk,v 1.23 2006/06/03 23:11:42 jlam Exp $
#
# This Makefile fragment is included to bsd.pkg.mk and defines the
# relevant variables and targets for the "extract" phase.
@@ -165,7 +165,7 @@ _EXTRACT_COOKIE= ${WRKDIR}/.extract_done
_EXTRACT_TARGETS+= checksum
_EXTRACT_TARGETS+= ${WRKDIR}
-_EXTRACT_TARGETS+= ${PKG_DB_TMPDIR}
+_EXTRACT_TARGETS+= depends
_EXTRACT_TARGETS+= acquire-extract-lock
_EXTRACT_TARGETS+= ${_EXTRACT_COOKIE}
_EXTRACT_TARGETS+= release-extract-lock
@@ -193,7 +193,6 @@ ${_EXTRACT_COOKIE}:
_REAL_EXTRACT_TARGETS+= extract-message
_REAL_EXTRACT_TARGETS+= extract-vars
-_REAL_EXTRACT_TARGETS+= install-depends
_REAL_EXTRACT_TARGETS+= pre-extract
_REAL_EXTRACT_TARGETS+= do-extract
_REAL_EXTRACT_TARGETS+= post-extract
diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk
index 9f40fc64f3b..a5115cc8565 100644
--- a/mk/bsd.pkg.mk
+++ b/mk/bsd.pkg.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.mk,v 1.1826 2006/05/23 07:39:22 rillig Exp $
+# $NetBSD: bsd.pkg.mk,v 1.1827 2006/06/03 23:11:42 jlam Exp $
#
# This file is in the public domain.
#
@@ -23,8 +23,8 @@
# This has to come first to avoid showing all BUILD_DEFS added by this
# Makefile, which are usually not customizable.
-.PHONY: pre-install-depends build-defs-message
-pre-install-depends: build-defs-message
+.PHONY: build-defs-message
+pre-depends-hook: build-defs-message
.if empty(PKGSRC_SHOW_BUILD_DEFS:M[yY][eE][sS])
build-defs-message:
.elif !target(build-defs-message)
@@ -58,7 +58,6 @@ build-defs-message: ${WRKDIR}
# Transform package Makefile variables and set defaults
############################################################################
-DEINSTALLDEPENDS?= NO # add -R to pkg_delete
MKCRYPTO?= YES # build crypto packages by default
NOCLEAN?= NO # don't clean up after update
REINSTALL?= NO # reinstall upon update
@@ -103,31 +102,16 @@ DESCR_SRC?= ${PKGDIR}/DESCR
DIGEST_ALGORITHMS?= SHA1 RMD160
DISTFILES?= ${DISTNAME}${EXTRACT_SUFX}
DISTINFO_FILE?= ${PKGDIR}/distinfo
-INSTALL_DIRS?= ${BUILD_DIRS}
-INSTALL_MAKE_FLAGS?= ${MAKE_FLAGS}
-INSTALL_TARGET?= install
INTERACTIVE_STAGE?= none
MAINTAINER?= pkgsrc-users@NetBSD.org
MAKE_FLAGS?= # empty
MAKEFILE?= Makefile
PATCH_DIGEST_ALGORITHM?=SHA1
-PKG_SUFX?= .tgz
-PKGFILE?= ${PKGREPOSITORY}/${PKGNAME}${PKG_SUFX}
-PKGREPOSITORY?= ${PACKAGES}/${PKGREPOSITORYSUBDIR}
-PKGREPOSITORYSUBDIR?= All
PKGWILDCARD?= ${PKGBASE}-[0-9]*
SVR4_PKGNAME?= ${PKGNAME}
USE_DIGEST?= YES
WRKSRC?= ${WRKDIR}/${DISTNAME}
-# If a package sets INSTALLATION_DIRS, then it's known to pre-create all
-# of the directories that it needs at install-time, so we don't need
-# mtree to do it for us.
-#
-.if defined(INSTALLATION_DIRS) && !empty(INSTALLATION_DIRS)
-NO_MTREE= yes
-.endif
-
.if (defined(INSTALL_UNSTRIPPED) && !empty(INSTALL_UNSTRIPPED:M[yY][eE][sS])) || defined(DEBUG_FLAGS)
_INSTALL_UNSTRIPPED= # set (flag used by platform/*.mk)
.endif
@@ -138,22 +122,6 @@ _INSTALL_UNSTRIPPED= # set (flag used by platform/*.mk)
DIGEST_REQD= 20010302
PKGTOOLS_REQD= ${_OPSYS_PKGTOOLS_REQD:U20051103}
-PKG_DB_TMPDIR= ${WRKDIR}/.pkgdb
-DDIR= ${WRKDIR}/.DDIR
-DESCR= ${PKG_DB_TMPDIR}/+DESC
-DLIST= ${WRKDIR}/.DLIST
-
-# Files to create for versioning and build information
-BUILD_VERSION_FILE= ${PKG_DB_TMPDIR}/+BUILD_VERSION
-BUILD_INFO_FILE= ${PKG_DB_TMPDIR}/+BUILD_INFO
-
-# Files containing size of pkg w/o and w/ all required pkgs
-SIZE_PKG_FILE= ${PKG_DB_TMPDIR}/+SIZE_PKG
-SIZE_ALL_FILE= ${PKG_DB_TMPDIR}/+SIZE_ALL
-
-# File to denote "no deletion of a package"
-PRESERVE_FILE= ${PKG_DB_TMPDIR}/+PRESERVE
-
##### Transform USE_* into dependencies
.include "../../mk/bsd.pkg.use.mk"
@@ -331,8 +299,6 @@ _WRAPPER_COOKIE= ${WRKDIR}/.wrapper_done
_CONFIGURE_COOKIE= ${WRKDIR}/.configure_done
_BUILD_COOKIE= ${WRKDIR}/.build_done
_TEST_COOKIE= ${WRKDIR}/.test_done
-_INSTALL_COOKIE= ${WRKDIR}/.install_done
-_PACKAGE_COOKIE= ${WRKDIR}/.package_done
_INTERACTIVE_COOKIE= .interactive_stage
_NULL_COOKIE= ${WRKDIR}/.null
@@ -343,10 +309,6 @@ LIBABISUFFIX?=
TOUCH_FLAGS?= -f
-# Figure out where the local mtree file is
-MTREE_FILE?= ${PKGSRCDIR}/mk/platform/${OPSYS}.pkg.dist
-MTREE_ARGS?= -U -f ${MTREE_FILE} -d -e -p
-
# Debugging levels for this file, dependent on PKG_DEBUG_LEVEL definition
# 0 == normal, default, quiet operation
# 1 == all shell commands echoed before invocation
@@ -421,10 +383,6 @@ _PKGSRC_BUILD_TARGETS= build test
_PKGSRC_BUILD_TARGETS= build
.endif
-.if !defined(_BUILD_DATE)
-_BUILD_DATE!= ${DATE} "+%Y-%m-%d %H:%M:%S %z"
-.endif
-
# The user can override the NO_PACKAGE by specifying this from
# the make command line
.if defined(FORCE_PACKAGE)
@@ -438,46 +396,6 @@ _BUILD_DATE!= ${DATE} "+%Y-%m-%d %H:%M:%S %z"
# INSTALL/DEINSTALL script framework
.include "../../mk/pkginstall/bsd.pkginstall.mk"
-# If MESSAGE hasn't been defined, then set MESSAGE_SRC to be a space-separated
-# list of files to be concatenated together to generate the MESSAGE file.
-#
-.if !defined(MESSAGE_SRC) && !defined(MESSAGE)
-. if exists(${PKGDIR}/MESSAGE)
-MESSAGE_SRC= ${PKGDIR}/MESSAGE
-. else
-. if exists(${PKGDIR}/MESSAGE.common)
-MESSAGE_SRC= ${PKGDIR}/MESSAGE.common
-. endif
-. if exists(${PKGDIR}/MESSAGE.${OPSYS})
-MESSAGE_SRC+= ${PKGDIR}/MESSAGE.${OPSYS}
-. endif
-. if exists(${PKGDIR}/MESSAGE.${MACHINE_ARCH:C/i[3-6]86/i386/g})
-MESSAGE_SRC+= ${PKGDIR}/MESSAGE.${MACHINE_ARCH:C/i[3-6]86/i386/g}
-. endif
-. if exists(${PKGDIR}/MESSAGE.${OPSYS}-${MACHINE_ARCH:C/i[3-6]86/i386/g})
-MESSAGE_SRC+= ${PKGDIR}/MESSAGE.${OPSYS}-${MACHINE_ARCH:C/i[3-6]86/i386/g}
-. endif
-. endif
-.endif
-
-.if defined(MESSAGE_SRC)
-MESSAGE= ${PKG_DB_TMPDIR}/+DISPLAY
-
-# Set MESSAGE_SUBST to substitute "${variable}" to "value" in MESSAGE
-MESSAGE_SUBST+= PKGNAME=${PKGNAME} \
- PKGBASE=${PKGBASE} \
- PREFIX=${PREFIX} \
- LOCALBASE=${LOCALBASE} \
- VIEWBASE=${VIEWBASE} \
- X11PREFIX=${X11PREFIX} \
- X11BASE=${X11BASE} \
- PKG_SYSCONFDIR=${PKG_SYSCONFDIR} \
- ROOT_GROUP=${ROOT_GROUP} \
- ROOT_USER=${ROOT_USER}
-
-MESSAGE_SUBST_SED= ${MESSAGE_SUBST:S/=/}!/:S/$/!g/:S/^/ -e s!\\\${/}
-.endif
-
.PHONY: uptodate-digest
uptodate-digest:
.if !empty(USE_DIGEST:M[yY][eE][sS])
@@ -499,33 +417,6 @@ uptodate-digest:
@${DO_NADA}
.endif
-.if !defined(PKG_ARGS_COMMON)
-PKG_ARGS_COMMON= -v -c -${COMMENT:Q}" " -d ${DESCR} -f ${PLIST}
-PKG_ARGS_COMMON+= -l -b ${BUILD_VERSION_FILE} -B ${BUILD_INFO_FILE}
-PKG_ARGS_COMMON+= -s ${SIZE_PKG_FILE} -S ${SIZE_ALL_FILE}
-PKG_ARGS_COMMON+= -P "`${MAKE} ${MAKEFLAGS} run-depends-list | ${SORT} -u`"
-. if defined(CONFLICTS) && (${PKG_INSTALLATION_TYPE} == "overwrite")
-PKG_ARGS_COMMON+= -C "${CONFLICTS}"
-. endif
-. if defined(INSTALL_FILE) && exists(${INSTALL_FILE})
-PKG_ARGS_COMMON+= -i ${INSTALL_FILE}
-. endif
-. if defined(DEINSTALL_FILE) && exists(${DEINSTALL_FILE})
-PKG_ARGS_COMMON+= -k ${DEINSTALL_FILE}
-. endif
-PKG_ARGS_COMMON+= ${MESSAGE:D-D ${MESSAGE}}
-PKG_ARGS_COMMON+= ${NO_MTREE:D:U-m ${MTREE_FILE}}
-PKG_ARGS_COMMON+= ${PKG_PRESERVE:D-n ${PRESERVE_FILE}}
-
-PKG_ARGS_INSTALL= -p ${PREFIX} ${PKG_ARGS_COMMON}
-PKG_ARGS_BINPKG= -p ${PREFIX:S/^${DESTDIR}//} -L ${PREFIX} ${PKG_ARGS_COMMON}
-.endif # !PKG_ARGS_COMMON
-
-.if ${PKG_INSTALLATION_TYPE} == "pkgviews"
-PKG_ARGS_INSTALL+= -U # don't update the pkgdb.byfile.db
-PKG_ARGS_BINPKG+= -E # create an empty views file in the binpkg
-.endif
-
# Define SMART_MESSAGES in /etc/mk.conf for messages giving the tree
# of dependencies for building, and the current target.
_PKGSRC_IN?= ===${SMART_MESSAGES:D> ${.TARGET} [${PKGNAME}${_PKGSRC_DEPS}] ===}
@@ -676,19 +567,6 @@ USE_TOOLS+= expr
USE_TOOLS+= tee tsort
.endif
-.if !defined(NO_MTREE)
-USE_TOOLS+= mtree
-.endif
-
-.if defined(PKG_PRESERVE)
-USE_TOOLS+= date
-.endif
-
-# We need a mail command to send mail to ${PKGSRC_MESSAGE_RECIPIENTS}.
-.if !empty(PKGSRC_MESSAGE_RECIPIENTS)
-USE_TOOLS+= mail
-.endif
-
# We need shlock and sleep if we're using locking to synchronize multiple
# builds over the same pkgsrc tree.
#
@@ -696,58 +574,12 @@ USE_TOOLS+= mail
USE_TOOLS+= shlock sleep
.endif
-# If MANZ is defined, then we want the final man pages to be compressed.
-# If MANZ is not defined, then we want the final man pages to be
-# uncompressed.
-#
-# We need to figure out if during installation, we need either gunzip or
-# gzip to decompress or compress the installed man pages. If a package
-# sets MANCOMPRESSED to "yes" or "no", then it's an indication to the
-# install code that the package itself installed the man pages either
-# compressed or uncompressed. If a package sets MANCOMPRESSED_IF_MANZ,
-# then the package uses BSD-style makefiles, so we need to determine if
-# the BSD-style makefile causes the man pages to be compressed or not.
-#
-.if !defined(_MANCOMPRESSED)
-. if defined(MANCOMPRESSED) && !empty(MANCOMPRESSED:M[yY][eE][sS])
-_MANCOMPRESSED= yes
-. else
-_MANCOMPRESSED= no
-. endif
-. if defined(MANCOMPRESSED_IF_MANZ) && defined(PKGMAKECONF)
-_MANCOMPRESSED!= \
- { ${ECHO} ".include \""${PKGMAKECONF:Q}"\""; \
- ${ECHO} "all:"; \
- ${ECHO} ".if defined(MANZ)"; \
- ${ECHO} " @${ECHO} yes"; \
- ${ECHO} ".else"; \
- ${ECHO} " @${ECHO} no"; \
- ${ECHO} ".endif"; \
- } | ${MAKE} -f - all
-. endif
-.endif
-_MANZ= ${MANZ:Dyes:Uno}
-MAKEVARS+= _MANCOMPRESSED _MANZ
-
-.if !empty(_MANCOMPRESSED:M[yY][eE][sS]) && empty(_MANZ:M[yY][eE][sS])
-USE_TOOLS+= gunzip
-.endif
-.if empty(_MANCOMPRESSED:M[yY][eE][sS]) && !empty(_MANZ:M[yY][eE][sS])
-USE_TOOLS+= gzip
-.endif
-
# Extract
.include "../../mk/bsd.pkg.extract.mk"
# Patch
.include "../../mk/bsd.pkg.patch.mk"
-# Check
-.include "../../mk/bsd.pkg.check.mk"
-
-# Clean
-.include "../../mk/bsd.pkg.clean.mk"
-
# Tools
.include "../../mk/tools/bsd.tools.mk"
@@ -775,10 +607,6 @@ BUILD_DEFS+= USE_ABI_DEPENDS
. endif
.endif
-# Remove some redundant dependencies from the DEPENDS list.
-.include "../../mk/reduce-depends.mk"
-DEPENDS:= ${REDUCED_DEPENDS}
-
# Find out the PREFIX of dependencies where the PREFIX is needed at build time.
.if defined(EVAL_PREFIX)
FIND_PREFIX:= ${EVAL_PREFIX}
@@ -892,7 +720,7 @@ PKG_SKIP_REASON+= "${PKGNAME} is not available for ${MACHINE_PLATFORM}"
. if defined(PKG_FAIL_REASON) || defined(PKG_SKIP_REASON)
.PHONY: do-check-pkg-fail-or-skip-reason
fetch checksum extract patch configure all build install package \
-update install-depends do-check-pkg-fail-or-skip-reason:
+update depends do-check-pkg-fail-or-skip-reason:
. if defined(SKIP_SILENT)
@${DO_NADA}
. else
@@ -1002,24 +830,6 @@ _build: configure
${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_FLAGS} ${_BUILD_COOKIE}
.endif
-# Disable install
-.PHONY: install
-.if defined(NO_INSTALL) && !target(install)
-install: build
- ${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_FLAGS} ${_INSTALL_COOKIE}
-.endif
-
-# Disable package
-.PHONY: package
-.if defined(NO_PACKAGE) && !target(package)
-package:
-. if defined(SKIP_SILENT)
- @${DO_NADA}
-. else
- @${ECHO_MSG} "${_PKGSRC_IN}> ${PKGNAME} may not be packaged: "${NO_PACKAGE:Q}"."
-. endif
-.endif
-
################################################################
# More standard targets start here.
#
@@ -1245,24 +1055,6 @@ batch-check-distfiles:
${FALSE} ;; \
esac
-# check for any vulnerabilities in the package
-# Please do not modify the leading "@" here
-.PHONY: check-vulnerable
-check-vulnerable:
- @if [ ! -z "${PKG_SYSCONFDIR.audit-packages}" -a -f ${PKG_SYSCONFDIR.audit-packages}/audit-packages.conf ]; then \
- . ${PKG_SYSCONFDIR.audit-packages}/audit-packages.conf; \
- elif [ ! -z "${PKG_SYSCONFDIR}" -a -f ${PKG_SYSCONFDIR}/audit-packages.conf ]; then \
- . ${PKG_SYSCONFDIR}/audit-packages.conf; \
- fi; \
- if [ -f ${PKGVULNDIR}/pkg-vulnerabilities ]; then \
- ${SETENV} PKGNAME=${PKGNAME:Q} \
- PKGBASE=${PKGBASE:Q} \
- ${AWK} '/^$$/ { next } \
- /^#.*/ { next } \
- $$1 !~ ENVIRON["PKGBASE"] && $$1 !~ /\{/ { next } \
- { s = sprintf("${PKG_ADMIN} pmatch \"%s\" %s && ${ECHO} \"*** WARNING - %s vulnerability in %s - see %s for more information ***\"", $$1, ENVIRON["PKGNAME"], $$2, ENVIRON["PKGNAME"], $$3); system(s); }' < ${PKGVULNDIR}/pkg-vulnerabilities || ${FALSE}; \
- fi
-
.PHONY: do-fetch
.if !target(do-fetch)
do-fetch:
@@ -1340,73 +1132,17 @@ show-distfiles:
. endif
.endif
-.PHONY: show-downlevel
-.if !target(show-downlevel)
-show-downlevel:
-. if defined(PKG_FAIL_REASON)
- ${_PKG_SILENT}${_PKG_DEBUG}${DO_NADA}
-. else
- ${_PKG_SILENT}${_PKG_DEBUG} \
- found="`${PKG_BEST_EXISTS} \"${PKGWILDCARD}\" || ${TRUE}`"; \
- if [ "X$$found" != "X" -a "X$$found" != "X${PKGNAME}" ]; then \
- ${ECHO} "${PKGBASE} package: $$found installed, pkgsrc version ${PKGNAME}"; \
- if [ "X$$STOP_DOWNLEVEL_AFTER_FIRST" != "X" ]; then \
- ${ECHO} "stopping after first downlevel pkg found"; \
- exit 1; \
- fi; \
- fi
-. endif
-.endif
-
-.PHONY: show-installed-depends
-.if !target(show-installed-depends)
-show-installed-depends:
-. if !empty(DEPENDS)
- ${_PKG_SILENT}${_PKG_DEBUG} \
- for i in ${DEPENDS:C/:.*$//:Q:S/\ / /g} ; do \
- echo "$$i =>" `${PKG_BEST_EXISTS} "$$i"` ; \
- done
-. endif
-.endif
-
-.PHONY: show-needs-update
-.if !target(show-needs-update)
-show-needs-update:
-. if !empty(DEPENDS)
- ${_PKG_SILENT}${_PKG_DEBUG} \
- for i in `${MAKE} show-all-depends-dirs`; do \
- cd ${PKGSRCDIR}/$$i; \
- eval `${MAKE} show-vars-eval VARS='PKGNAME:want PKGWILDCARD:wild'`; \
- have=`${PKG_BEST_EXISTS} "$$wild" || ${TRUE}`; \
- if [ -z "$$have" ]; then \
- ${ECHO} "$$i => (none) => needs install of $$want"; \
- elif [ "$$have" != "$$want" ]; then \
- ${ECHO} "$$i => $$have => needs update to $$want"; \
- fi; \
- done
-. endif
-.endif
-
-.PHONY: show-pkgsrc-dir
-.if !target(show-pkgsrc-dir)
-show-pkgsrc-dir:
-. if defined(PKG_FAIL_REASON)
- ${_PKG_SILENT}${_PKG_DEBUG}${DO_NADA}
-. else
- ${_PKG_SILENT}${_PKG_DEBUG} \
- found="`${PKG_BEST_EXISTS} \"${PKGWILDCARD}\" || ${TRUE}`"; \
- if [ "X$$found" != "X" ]; then \
- ${ECHO} ${PKGPATH}; \
- fi
-. endif
-.endif
-
# Extract
# pkgsrc coarse-grained locking definitions and targets
+acquire-lock: .USE
+ ${_ACQUIRE_LOCK}
+release-lock: .USE
+ ${_RELEASE_LOCK}
+
.if ${PKGSRC_LOCKTYPE} == "none"
-_ACQUIRE_LOCK= ${_PKG_SILENT}${_PKG_DEBUG}${DO_NADA}
-_RELEASE_LOCK= ${_PKG_SILENT}${_PKG_DEBUG}${DO_NADA}
+_ACQUIRE_LOCK= @${DO_NADA}
+_RELEASE_LOCK= @${DO_NADA}
.else
LOCKFILE= ${WRKDIR}/.lockfile
@@ -1480,9 +1216,6 @@ ${WRKDIR}:
. endif
.endif # WRKOBJDIR
-${PKG_DB_TMPDIR}: ${WRKDIR}
- ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${PKG_DB_TMPDIR}
-
# Configure
# _CONFIGURE_PREREQ is a list of targets to run after pre-configure but before
@@ -1773,266 +1506,25 @@ do-test:
. endif
.endif
-# Install
+.include "${PKGSRCDIR}/mk/flavor/bsd.flavor.mk"
-.PHONY: do-install
-.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 ${MAKEFILE} ${INSTALL_TARGET}
-. endfor
-.endif
+# Dependencies
+.include "${PKGSRCDIR}/mk/depends/bsd.depends.mk"
-# Package
+# Check
+.include "${PKGSRCDIR}/mk/check/bsd.check.mk"
-.PHONY: real-su-package
-.if !target(real-su-package)
-real-su-package: ${PLIST} ${DESCR}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${ECHO_MSG} "${_PKGSRC_IN}> Building binary package for ${PKGNAME}"; \
- if ${PKG_INFO} -qe ${PKGNAME}; then \
- : The package is installed. ; \
- else \
- ${ECHO_MSG} "=> ${PKGNAME} is not installed."; \
- exit 1; \
- fi; \
- if [ ! -d ${PKGREPOSITORY} ]; then \
- ${MKDIR} ${PKGREPOSITORY}; \
- if [ $$? -ne 0 ]; then \
- ${ECHO_MSG} "=> Can't create directory ${PKGREPOSITORY}."; \
- exit 1; \
- fi; \
- fi; \
- if ${PKG_CREATE} ${PKG_ARGS_BINPKG} ${PKGFILE}; then \
- ${MAKE} ${MAKEFLAGS} package-links; \
- else \
- ${ECHO} "(pkg_create: exitcode $$?)"; \
- ${MAKE} ${MAKEFLAGS} delete-package; \
- exit 1; \
- fi
- ${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_FLAGS} ${_PACKAGE_COOKIE}
-. if defined(NO_BIN_ON_CDROM)
- @${ECHO_MSG} "${_PKGSRC_IN}> Warning: ${PKGNAME} may not be put on a CD-ROM:"
- @${ECHO_MSG} "${_PKGSRC_IN}> " ${NO_BIN_ON_CDROM:Q}
-. endif
-. if defined(NO_BIN_ON_FTP)
- @${ECHO_MSG} "${_PKGSRC_IN}> Warning: ${PKGNAME} may not be made available through FTP:"
- @${ECHO_MSG} "${_PKGSRC_IN}> " ${NO_BIN_ON_FTP:Q}
-. endif
-. if defined(ABI_DEPENDS) && !empty(USE_ABI_DEPENDS:M[Nn][Oo])
- @${ECHO_MSG} "${_PKGSRC_IN}> Warning: ABI dependency recommendations are being ignored!"
- @${ECHO_MSG} "${_PKGSRC_IN}> ${PKGNAME} should not be uploaded nor"
- @${ECHO_MSG} "${_PKGSRC_IN}> otherwise be used as a binary package!"
-. endif
-.endif
+# Clean
+.include "../../mk/bsd.pkg.clean.mk"
-# Some support rules for real-su-package
+# Install
+.include "${PKGSRCDIR}/mk/install/bsd.install.mk"
-.PHONY: package-links
-.if !target(package-links)
-package-links:
- ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} delete-package-links
- ${_PKG_SILENT}${_PKG_DEBUG}for cat in ${CATEGORIES}; do \
- if [ ! -d ${PACKAGES}/$$cat ]; then \
- ${MKDIR} ${PACKAGES}/$$cat; \
- if [ $$? -ne 0 ]; then \
- ${ECHO_MSG} "=> Can't create directory ${PACKAGES}/$$cat."; \
- exit 1; \
- fi; \
- fi; \
- ${RM} -f ${PACKAGES}/$$cat/${PKGNAME}${PKG_SUFX}; \
- ${LN} -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PACKAGES}/$$cat; \
- done;
-.endif
-
-.PHONY: delete-package-links
-.if !target(delete-package-links)
-delete-package-links:
- ${_PKG_SILENT}${_PKG_DEBUG}\
- ${FIND} ${PACKAGES} -type l -name ${PKGNAME}${PKG_SUFX} -print | ${XARGS} ${RM} -f
-.endif
-
-.PHONY: delete-package
-.if !target(delete-package)
-delete-package:
- ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} delete-package-links
- ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${PKGFILE}
-.endif
-
-_PLIST_REGEXP.info= \
- ^([^\/]*\/)*${PKGINFODIR}/[^/]*(\.info)?(-[0-9]+)?(\.gz)?$$
-_PLIST_REGEXP.man= \
- ^([^/]*/)+(man[1-9ln]/[^/]*\.[1-9ln]|cat[1-9ln]/[^/]*\.[0-9])(\.gz)?$$
-
-_DOC_COMPRESS= \
- ${SETENV} ECHO=${TOOLS_ECHO:Q} \
- EXPR=${TOOLS_EXPR:Q} \
- GZIP_CMD=${TOOLS_GZIP_CMD:Q} \
- GUNZIP_CMD=${TOOLS_GUNZIP_CMD:Q} \
- LN=${TOOLS_LN:Q} \
- LS=${TOOLS_LS:Q} \
- MANZ=${_MANZ:Q} \
- PKG_VERBOSE=${PKG_VERBOSE:Q} \
- RM=${TOOLS_RM:Q} \
- TEST=${TOOLS_TEST:Q} \
- ${SH} ${.CURDIR}/../../mk/plist/doc-compress ${PREFIX:Q}
-
-.PHONY: real-su-install
-real-su-install: ${MESSAGE}
-.if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER) && \
- (${PKG_INSTALLATION_TYPE} == "overwrite")
-. if defined(CONFLICTS)
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${RM} -f ${WRKDIR}/.CONFLICTS
-. for conflict in ${CONFLICTS}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- found="`${PKG_BEST_EXISTS} \"${conflict}\" || ${TRUE}`"; \
- if [ X"$$found" != X"" ]; then \
- ${ECHO} "$$found" >> ${WRKDIR}/.CONFLICTS; \
- fi
-. endfor
- ${_PKG_SILENT}${_PKG_DEBUG} \
- if [ -s ${WRKDIR}/.CONFLICTS ]; then \
- found=`${SED} -e s'|${_PKG_DBDIR}/||g' ${WRKDIR}/.CONFLICTS | tr '\012' ' '`; \
- ${ECHO_MSG} "${_PKGSRC_IN}> ${PKGNAME} conflicts with installed package(s): $$found found."; \
- ${ECHO_MSG} "*** They install the same files into the same place."; \
- ${ECHO_MSG} "*** Please remove $$found first with pkg_delete(1)."; \
- ${RM} -f ${WRKDIR}/.CONFLICTS; \
- exit 1; \
- fi
-. endif # CONFLICTS
- ${_PKG_SILENT}${_PKG_DEBUG} \
- found="`${PKG_BEST_EXISTS} \"${PKGWILDCARD}\" || ${TRUE}`"; \
- if [ "$$found" != "" ]; then \
- ${ECHO_MSG} "${_PKGSRC_IN}> $$found is already installed - perhaps an older version?"; \
- ${ECHO_MSG} "*** If so, you may use either of:"; \
- ${ECHO_MSG} "*** - \"pkg_delete $$found\" and \"${MAKE} reinstall\" to upgrade properly"; \
- ${ECHO_MSG} "*** - \"${MAKE} update\" to rebuild the package and all of its dependencies"; \
- ${ECHO_MSG} "*** - \"${MAKE} replace\" to replace only the package without re-linking"; \
- ${ECHO_MSG} "*** dependencies, risking various problems."; \
- exit 1; \
- fi
-.endif # !NO_PKG_REGISTER && !NO_FORCE_REGISTER && overwrite
-.if ${PKG_INSTALLATION_TYPE} == "pkgviews"
- ${_PKG_SILENT}${_PKG_DEBUG} \
- found="`${PKG_INFO} -e ${PKGNAME} || ${TRUE}`"; \
- if [ "$$found" != "" ]; then \
- ${ECHO_MSG} "${_PKGSRC_IN}> $$found is already installed."; \
- exit 1; \
- fi
-.endif
- ${_PKG_SILENT}${_PKG_DEBUG}if [ `${SH} -c umask` -ne ${DEF_UMASK} ]; then \
- ${ECHO_MSG} "${_PKGSRC_IN}> Warning: your umask is \"`${SH} -c umask`"\".; \
- ${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 empty(CHECK_FILES:M[nN][oO])
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} check-files-pre
-.endif
-.if defined(INSTALLATION_DIRS) && !empty(INSTALLATION_DIRS)
- ${_PKG_SILENT}${_PKG_DEBUG}${ECHO_MSG} "${_PKGSRC_IN}> Creating installation directories"
- ${_PKG_SILENT}${_PKG_DEBUG} \
- for dir in ${INSTALLATION_DIRS}; do \
- case $$dir in \
- ${PREFIX}/*) \
- dir=`${ECHO} $$dir | ${SED} "s|^${PREFIX}/||"` ;; \
- /*) continue ;; \
- esac; \
- case $$dir in \
- *bin|*bin/*|*libexec|*libexec/*) \
- ${INSTALL_PROGRAM_DIR} ${PREFIX}/$$dir ;; \
- ${PKGMANDIR}/*) \
- ${INSTALL_MAN_DIR} ${PREFIX}/$$dir ;; \
- *) \
- ${INSTALL_DATA_DIR} ${PREFIX}/$$dir ;; \
- esac; \
- done
-.endif # INSTALLATION_DIRS
-.if !defined(NO_MTREE)
- ${_PKG_SILENT}${_PKG_DEBUG}if [ `${ID} -u` = `${ID} -u ${ROOT_USER}` ]; then \
- if [ ! -f ${MTREE_FILE} ]; then \
- ${ECHO_MSG} "Error: mtree file \"${MTREE_FILE}\" is missing."; \
- exit 1; \
- else \
- if [ ! -d ${PREFIX} ]; then \
- ${MKDIR} ${PREFIX}; \
- fi; \
- ${MTREE} ${MTREE_ARGS} ${PREFIX}/; \
- fi; \
- else \
- ${ECHO_MSG} "Warning: not superuser, can't run mtree."; \
- ${ECHO_MSG} "Become ${ROOT_USER} and try again to ensure correct permissions."; \
- fi
-.else
- ${_PKG_SILENT}${_PKG_DEBUG}[ -d ${PREFIX} ] || ${MKDIR} ${PREFIX}
-.endif # !NO_MTREE
-.if !defined(NO_PKG_REGISTER)
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} pre-install-fake-pkg
-.endif # !NO_PKG_REGISTER
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} pre-install-script
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} pre-install PKG_PHASE=install
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} do-install PKG_PHASE=install
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} post-install PKG_PHASE=install
- ${_PKG_SILENT}${DO_NADA} \
- # \
- # PLIST must be generated at this late point (instead of \
- # depending on it somewhere earlier), because it needs \
- # to be created _after_ the {pre,do,post}-install \
- # targets are run. \
- # \
- # We generate _before_ post-install-script is run so \
- # that the real config files and rc.d scripts aren't \
- # listed in the PLIST. \
- #
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} ${PLIST}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${ECHO_MSG} "${_PKGSRC_IN}> [Automatic manual page handling]"; \
- ${CAT} ${PLIST} | ${GREP} -v "^@" | \
- ${EGREP} ${_PLIST_REGEXP.man:Q} | ${_DOC_COMPRESS}
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} install-script-data
-.if empty(CHECK_FILES:M[nN][oO])
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} check-files-post
-.endif
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} post-install-script
-.if defined(MESSAGE)
- @${ECHO_MSG} "${_PKGSRC_IN}> Please note the following:"
- @${ECHO_MSG} ""
- @${CAT} ${MESSAGE}
- @${ECHO_MSG} ""
-. if !empty(PKGSRC_MESSAGE_RECIPIENTS)
- ${_PKG_SILENT}${_PKG_DEBUG} \
- (${ECHO} "The ${PKGNAME} package was installed on `${HOSTNAME_CMD}` at `date`"; \
- ${ECHO} ""; \
- ${ECHO} "Please note the following:"; \
- ${ECHO} ""; \
- ${CAT} ${MESSAGE}; \
- ${ECHO} "") | \
- ${MAIL_CMD} -s"Package ${PKGNAME} installed on `${HOSTNAME_CMD}`" ${PKGSRC_MESSAGE_RECIPIENTS}
-. endif
-.endif
-.if !defined(NO_PKG_REGISTER)
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} register-pkg
-.endif # !NO_PKG_REGISTER
- ${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_FLAGS} ${_INSTALL_COOKIE}
-.if empty(CHECK_SHLIBS:M[nN][oO])
- ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} check-shlibs
-.endif
-.if empty(CHECK_WRKREF:M[nN][oO])
- ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} check-wrkref
-.endif
-.if empty(CHECK_FILES:M[nN][oO])
- ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} check-files
-.endif
-.if empty(CHECK_INTERPRETER:M[nN][oO])
- ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} check-interpreter
-.endif
+# Package
+.include "${PKGSRCDIR}/mk/package/bsd.package.mk"
.PHONY: acquire-tools-lock
.PHONY: acquire-wrapper-lock acquire-configure-lock acquire-build-lock
-.PHONY: acquire-install-lock acquire-package-lock
acquire-tools-lock:
${_ACQUIRE_LOCK}
acquire-wrapper-lock:
@@ -2041,14 +1533,9 @@ acquire-configure-lock:
${_ACQUIRE_LOCK}
acquire-build-lock:
${_ACQUIRE_LOCK}
-acquire-install-lock:
- ${_ACQUIRE_LOCK}
-acquire-package-lock:
- ${_ACQUIRE_LOCK}
.PHONY: release-tools-lock
.PHONY: release-wrapper-lock release-configure-lock release-build-lock
-.PHONY: release-install-lock release-package-lock
release-tools-lock:
${_RELEASE_LOCK}
release-wrapper-lock:
@@ -2057,10 +1544,6 @@ release-configure-lock:
${_RELEASE_LOCK}
release-build-lock:
${_RELEASE_LOCK}
-release-install-lock:
- ${_RELEASE_LOCK}
-release-package-lock:
- ${_RELEASE_LOCK}
################################################################
# Skeleton targets start here
@@ -2105,26 +1588,6 @@ build: pkginstall
test: build ${_TEST_COOKIE}
.endif
-.PHONY: install
-.if !target(install)
-install: ${_PKGSRC_BUILD_TARGETS} ${PKG_DB_TMPDIR} acquire-install-lock ${_INSTALL_COOKIE} release-install-lock
-.endif
-
-.PHONY: package
-.if !target(package)
-package: install acquire-package-lock ${_PACKAGE_COOKIE} release-package-lock
-.endif
-
-.PHONY: replace
-.if !target(replace)
-replace: ${_PKGSRC_BUILD_TARGETS} real-replace
-.endif
-
-.PHONY: undo-replace
-.if !target(undo-replace)
-undo-replace: real-undo-replace
-.endif
-
${_TOOLS_COOKIE}:
${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} real-tools PKG_PHASE=tools
@@ -2188,19 +1651,6 @@ ${_BUILD_COOKIE}:
${_TEST_COOKIE}:
${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${BUILD_ENV} ${MAKE} ${MAKEFLAGS} real-test PKG_PHASE=test
-${_INSTALL_COOKIE}:
-.if !empty(INTERACTIVE_STAGE:Minstall) && defined(BATCH)
- @${ECHO} "*** The installation stage of this package requires user interaction"
- @${ECHO} "*** Please install manually with \"cd ${PKGDIR} && ${MAKE} install\""
- @${TOUCH} ${_INTERACTIVE_COOKIE}
- @${FALSE}
-.else
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${BUILD_ENV} ${MAKE} ${MAKEFLAGS} real-install PKG_PHASE=install
-.endif
-
-${_PACKAGE_COOKIE}:
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${BUILD_ENV} ${MAKE} ${MAKEFLAGS} real-package PKG_PHASE=package
-
.PHONY: tools-message wrapper-message
.PHONY: configure-message build-message test-message
tools-message:
@@ -2239,18 +1689,13 @@ test-cookie:
# make i.e. without -j n)
.PHONY: real-fetch
.PHONY: real-tools real-wrapper
-.PHONY: real-configure real-build real-test real-install real-package
-.PHONY: real-replace real-undo-replace
+.PHONY: real-configure real-build real-test
real-fetch: pre-fetch do-fetch post-fetch
real-tools: tools-message tools-vars pre-tools do-tools post-tools tools-cookie
real-wrapper: wrapper-message wrapper-vars pre-wrapper do-wrapper post-wrapper wrapper-cookie
real-configure: configure-message configure-vars pre-configure pre-configure-override do-configure post-configure configure-cookie
real-build: build-message build-vars pre-build do-build post-build build-cookie
real-test: test-message pre-test do-test post-test test-cookie
-real-install: install-vars do-su-install
-real-package: package-vars do-su-package
-real-replace: do-su-replace
-real-undo-replace: do-su-undo-replace
_SU_TARGET= \
if [ `${ID} -u` = `${ID} -u ${ROOT_USER}` ]; then \
@@ -2275,51 +1720,28 @@ _SU_TARGET= \
${SU_CMD} "cd ${.CURDIR}; ${SETENV} PATH='$${PATH}:${SU_CMD_PATH_APPEND}' ${MAKE} $$args ${MAKEFLAGS} $$realtarget $$realflags"; \
fi
-.PHONY: do-su-install
-do-su-install:
- ${_PKG_SILENT}${_PKG_DEBUG} \
- extractname=`${CAT} ${_EXTRACT_COOKIE}`; \
- case "$$extractname" in \
- "") ${ECHO_MSG} "*** Warning: ${WRKDIR} may contain an older version of ${PKGBASE}" ;; \
- "${PKGNAME}") ;; \
- *) ${ECHO_MSG} "*** Warning: Package version $$extractname in ${WRKDIR}"; \
- ${ECHO_MSG} "*** Current version ${PKGNAME} in pkgsrc directory"; \
- ${ECHO_MSG} "*** Cleaning and rebuilding the newer version of the package..."; \
- ${MAKE} clean && ${MAKE} build ;; \
- esac
- @${ECHO_MSG} "${_PKGSRC_IN}> Installing for ${PKGNAME}"
- ${_PKG_SILENT}${_PKG_DEBUG} \
- realtarget="real-su-install"; \
- action="install"; \
- ${_SU_TARGET}
-
-.PHONY: do-su-package
-do-su-package:
- @${ECHO_MSG} "${_PKGSRC_IN}> Packaging ${PKGNAME}"
- ${_PKG_SILENT}${_PKG_DEBUG} \
- realtarget="real-su-package"; \
- action="package"; \
- ${_SU_TARGET}
-
-.PHONY: do-su-replace
-do-su-replace:
- @${ECHO_MSG} "${_PKGSRC_IN}> Replacing ${PKGNAME}"
- ${_PKG_SILENT}${_PKG_DEBUG} \
- realtarget="real-su-replace"; \
- action="replace"; \
- ${_SU_TARGET}
-
-.PHONY: do-su-undo-replace
-do-su-undo-replace:
- @${ECHO_MSG} "${_PKGSRC_IN}> Undoing Replacement of ${PKGNAME}"
+# su-target is a macro target that does just-in-time su-to-root before
+# reinvoking the make process as root.
+#
+.PHONY: su-target
+su-target: .USE
${_PKG_SILENT}${_PKG_DEBUG} \
- realtarget="real-su-undo-replace"; \
- action="undo-replace"; \
- ${_SU_TARGET}
+ if ${TEST} `${ID} -u` = `${ID} -u ${ROOT_USER}`; then \
+ ${MAKE} ${MAKEFLAGS} PKG_DEBUG_LEVEL=${PKG_DEBUG_LEVEL:Q} su-${.TARGET} ${MAKEFLAGS.${.TARGET}}; \
+ else \
+ case ${PRE_ROOT_CMD:Q}"" in \
+ ${TRUE:Q}"") ;; \
+ *) ${ECHO} "*** WARNING *** Running: "${PRE_ROOT_CMD:Q} ;; \
+ esac; \
+ ${PRE_ROOT_CMD}; \
+ ${ECHO_MSG} "${_PKGSRC_IN}> Becoming \`\`${ROOT_USER}'' to make su-${.TARGET} (`${ECHO} ${SU_CMD} | ${AWK} '{ print $$1 }'`)"; \
+ ${SU_CMD} "cd ${.CURDIR}; ${SETENV} PATH='$${PATH}:${SU_CMD_PATH_APPEND}' ${MAKE} ${MAKEFLAGS} PKG_DEBUG_LEVEL=${PKG_DEBUG_LEVEL} su-${.TARGET} ${MAKEFLAGS.su-${.TARGET}}"; \
+ ${ECHO_MSG} "${_PKGSRC_IN}> Dropping \`\`${ROOT_USER}'' privileges."; \
+ fi
# Empty pre-* and post-* targets
-.for name in fetch tools wrapper configure build test install package
+.for name in fetch tools wrapper configure build test
. if !target(pre-${name})
pre-${name}:
@@ -2333,289 +1755,15 @@ post-${name}:
.endfor
-# Reinstall
-#
-# Special target to re-run install
-
-.PHONY: reinstall
-.if !target(reinstall)
-reinstall:
- ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${_INSTALL_COOKIE} ${_PACKAGE_COOKIE} ${PLIST}
- ${_PKG_SILENT}${_PKG_DEBUG}DEPENDS_TARGET=${DEPENDS_TARGET:Q} ${MAKE} ${MAKEFLAGS} install
-.endif
-
-# Deinstall
-#
-# Special target to remove installation
-
-.PHONY: deinstall do-su-deinstall
-.if !target(deinstall)
-deinstall: do-su-deinstall
-
-.if !target(do-su-deinstall)
-do-su-deinstall:
- @${ECHO_MSG} "${_PKGSRC_IN}> Deinstalling for ${PKGBASE}"
- ${_PKG_SILENT}${_PKG_DEBUG} \
- realtarget="real-su-deinstall"; \
- realflags="DEINSTALLDEPENDS=${DEINSTALLDEPENDS}"; \
- action="deinstall"; \
- ${_SU_TARGET}
-.endif
-
-. if (${DEINSTALLDEPENDS} != "NO")
-. if (${DEINSTALLDEPENDS} != "ALL")
-# used for removing stuff in bulk builds
-real-su-deinstall-flags+= -r -R
-# used for "update" target
-. else
-real-su-deinstall-flags+= -r
-. endif
-. endif
-. if defined(PKG_VERBOSE)
-real-su-deinstall-flags+= -v
-. endif
-. if defined(PKG_PRESERVE)
-. if (${UPDATE_RUNNING} == "YES")
-# used to update w/o removing any files
-real-su-deinstall-flags+= -N -f
-. endif
-. endif
-
-.PHONY: real-su-deinstall
-real-su-deinstall:
- ${_PKG_SILENT}${_PKG_DEBUG} \
- found="`${PKG_INFO} -e \"${PKGNAME}\" || ${TRUE}`"; \
- case "$$found" in \
- "") found="`${PKG_BEST_EXISTS} \"${PKGWILDCARD}\" || ${TRUE}`" ;; \
- esac; \
- if [ "$$found" != "" ]; then \
- ${ECHO} Running ${PKG_DELETE} ${real-su-deinstall-flags} $$found ; \
- ${PKG_DELETE} ${real-su-deinstall-flags} $$found || ${TRUE} ; \
- fi
-. if (${DEINSTALLDEPENDS} != "NO") && (${DEINSTALLDEPENDS} != "ALL")
- @${SHCOMMENT} Also remove BUILD_DEPENDS:
-. for pkg in ${BUILD_DEPENDS:C/:.*$//}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- found="`${PKG_BEST_EXISTS} \"${pkg}\" || ${TRUE}`"; \
- if [ "$$found" != "" ]; then \
- ${ECHO} Running ${PKG_DELETE} $$found; \
- ${PKG_DELETE} ${real-su-deinstall-flags} $$found || ${TRUE}; \
- fi
-. endfor
-. endif # DEINSTALLDEPENDS
- @${RM} -f ${_INSTALL_COOKIE} ${_PACKAGE_COOKIE} \
- ${_CHECK_FILES_COOKIES} \
- ${_CHECK_FILES_PRE} ${_CHECK_FILES_POST}
-.endif # target(deinstall)
-
-
################################################################
# Some more targets supplied for users' convenience
################################################################
-# The 'update' target can be used to update a package and all
-# currently installed packages that depend upon this package.
-
-.PHONY: update
-.if !target(update)
-.if exists(${DDIR})
-RESUMEUPDATE?= YES
-CLEAR_DIRLIST?= NO
-
-update:
- ${_PKG_SILENT}${_PKG_DEBUG}${ECHO_MSG} \
- "${_PKGSRC_IN}> Resuming update for ${PKGNAME}"
-. if ${REINSTALL} != "NO" && ${UPDATE_TARGET} != "replace"
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${MAKE} ${MAKEFLAGS} deinstall UPDATE_RUNNING=YES DEINSTALLDEPENDS=ALL
-. endif
-.else
-RESUMEUPDATE?= NO
-CLEAR_DIRLIST?= YES
-
-update:
- ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} ${DDIR}
-. if ${UPDATE_TARGET} != "replace"
- ${_PKG_SILENT}${_PKG_DEBUG}if ${PKG_INFO} -qe ${PKGBASE}; then \
- ${MAKE} ${MAKEFLAGS} deinstall UPDATE_RUNNING=YES DEINSTALLDEPENDS=ALL \
- || (${RM} ${DDIR} && ${FALSE}); \
- fi
-. endif
-.endif
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${MAKE} ${MAKEFLAGS} ${UPDATE_TARGET} KEEP_WRKDIR=YES \
- DEPENDS_TARGET=${DEPENDS_TARGET:Q}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- [ ! -s ${DDIR} ] || for dep in `${CAT} ${DDIR}` ; do \
- (if cd ../.. && cd "$${dep}" ; then \
- ${ECHO_MSG} "${_PKGSRC_IN}> Installing in $${dep}" && \
- if [ "(" "${RESUMEUPDATE}" = "NO" -o \
- "${REINSTALL}" != "NO" ")" -a \
- "${UPDATE_TARGET}" != "replace" ] ; then \
- ${MAKE} ${MAKEFLAGS} deinstall UPDATE_RUNNING=YES; \
- fi && \
- ${MAKE} ${MAKEFLAGS} ${UPDATE_TARGET} \
- DEPENDS_TARGET=${DEPENDS_TARGET:Q} ; \
- else \
- ${ECHO_MSG} "${_PKGSRC_IN}> Skipping removed directory $${dep}"; \
- fi) ; \
- done
-.if ${NOCLEAN} == "NO"
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${MAKE} ${MAKEFLAGS} clean-update CLEAR_DIRLIST=YES
-.endif
-
-
-.PHONY: clean-update
-clean-update:
- ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} ${DDIR}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- if [ -s ${DDIR} ] ; then \
- for dep in `${CAT} ${DDIR}` ; do \
- (if cd ../.. && cd "$${dep}" ; then \
- ${MAKE} ${MAKEFLAGS} clean ; \
- else \
- ${ECHO_MSG} "${_PKGSRC_IN}> Skipping removed directory $${dep}";\
- fi) ; \
- done ; \
- fi
-.if ${CLEAR_DIRLIST} != "NO"
- ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} clean
-.else
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${MAKE} ${MAKEFLAGS} clean update-dirlist \
- DIRLIST="`${CAT} ${DDIR}`" PKGLIST="`${CAT} ${DLIST}`"
- ${_PKG_SILENT}${_PKG_DEBUG}${ECHO_MSG} \
- "${_PKGSRC_IN}> Warning: preserved leftover directory list. Your next";\
- ${ECHO_MSG} "${_PKGSRC_IN}> \`\`${MAKE} update'' may fail. It is advised to use";\
- ${ECHO_MSG} "${_PKGSRC_IN}> \`\`${MAKE} update REINSTALL=YES'' instead!"
-.endif
-
-.endif # !target(update)
-
-
-.PHONY: update-dirlist
-update-dirlist:
- ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} -p ${WRKDIR}
-.if defined(PKGLIST)
-. for __tmp__ in ${PKGLIST}
- ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} >>${DLIST} "${__tmp__}"
-. endfor
-.endif
-.if defined(DIRLIST)
-. for __tmp__ in ${DIRLIST}
- ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} >>${DDIR} "${__tmp__}"
-. endfor
-.endif
-
-
-${DDIR}: ${DLIST}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ddir=`${SED} 's:-[^-]*$$::' ${DLIST}`; \
- ${ECHO} >${DDIR}; \
- for pkg in $${ddir} ; do \
- if ${PKG_INFO} -b "$${pkg}" >/dev/null 2>&1 ; then \
- ${PKG_INFO} -b "$${pkg}" | ${SED} -ne \
- 's,\([^/]*/[^/]*\)/Makefile:.*,\1,p' | \
- ${HEAD} -1 >>${DDIR}; \
- fi ; \
- done
-
-${DLIST}: ${WRKDIR}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- { ${PKG_DELETE} -n "${PKGWILDCARD}" 2>&1 | \
- ${GREP} '^ ' | \
- ${AWK} '{ l[NR]=$$0 } END { for (i=NR;i>0;--i) print l[i] }' \
- || ${TRUE}; } > ${DLIST}
-
-# The 'info' target can be used to display information about a package.
-.PHONY: info
-info:
- ${_PKG_SILENT}${_PKG_DEBUG}${PKG_INFO} "${PKGWILDCARD}"
-
-# The 'check' target can be used to check an installed package.
-.PHONY: check
-check:
- ${_PKG_SILENT}${_PKG_DEBUG}${PKG_ADMIN} check "${PKGWILDCARD}"
-
-# The 'list' target can be used to list the files installed by a package.
-.PHONY: list
-list:
- ${_PKG_SILENT}${_PKG_DEBUG}${PKG_INFO} -L "${PKGWILDCARD}"
-
# Run pkglint:
.PHONY: lint
lint:
${_PKG_SILENT}${_PKG_DEBUG}${LOCALBASE}/bin/pkglint
-# Create a binary package from an install package using "pkg_tarup"
-.PHONY: tarup
-tarup:
-.if ${PKG_INSTALLATION_TYPE} == "overwrite"
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${RM} -f ${PACKAGES}/All/${PKGNAME}${PKG_SUFX}; \
- ${SETENV} PKG_DBDIR=${_PKG_DBDIR} PKG_SUFX=${PKG_SUFX} \
- PKGREPOSITORY=${PACKAGES}/All \
- ${LOCALBASE}/bin/pkg_tarup ${PKGNAME}; \
- for CATEGORY in ${CATEGORIES}; do \
- ${MKDIR} ${PACKAGES}/$$CATEGORY; \
- cd ${PACKAGES}/$$CATEGORY; \
- ${RM} -f ${PKGNAME}${PKG_SUFX}; \
- ${LN} -s ../All/${PKGNAME}${PKG_SUFX}; \
- done
-.endif
-
-# shared code for replace and undo-replace
-_REPLACE= \
- if [ -f ${_PKG_DBDIR}/$$oldpkgname/+REQUIRED_BY ]; then \
- ${MV} ${_PKG_DBDIR}/$$oldpkgname/+REQUIRED_BY ${WRKDIR}/.req; \
- fi; \
- ${MAKE} deinstall UPDATE_RUNNING=YES; \
- $$replace_action; \
- if [ -f ${WRKDIR}/.req ]; then \
- ${MV} ${WRKDIR}/.req ${_PKG_DBDIR}/$$newpkgname/+REQUIRED_BY; \
- for pkg in `${CAT} ${_PKG_DBDIR}/$$newpkgname/+REQUIRED_BY`; do \
- ${SETENV} NEWPKGNAME=$$newpkgname \
- ${AWK} '/^@pkgdep '$$oldpkgname'/ { print "@pkgdep " ENVIRON["NEWPKGNAME"]; next } { print }' \
- < ${_PKG_DBDIR}/$$pkg/+CONTENTS > ${_PKG_DBDIR}/$$pkg/+CONTENTS.$$$$ && \
- ${MV} ${_PKG_DBDIR}/$$pkg/+CONTENTS.$$$$ ${_PKG_DBDIR}/$$pkg/+CONTENTS; \
- done; \
- fi
-
-# replace a package in place - not for the faint-hearted
-.PHONY: real-su-replace
-real-su-replace:
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${ECHO_MSG} "*** WARNING - experimental target - data loss may occur ***"; \
- if [ -x ${LOCALBASE}/bin/pkg_tarup ]; then \
- ${SETENV} PKGREPOSITORY=${WRKDIR} ${LOCALBASE}/bin/pkg_tarup ${PKGBASE}; \
- else \
- ${ECHO} "No ${LOCALBASE}/bin/pkg_tarup binary - can't pkg_tarup ${PKGBASE}"; \
- exit 1; \
- fi
- ${_PKG_SILENT}${_PKG_DEBUG} \
- oldpkgname=`${PKG_BEST_EXISTS} "${PKGWILDCARD}"`; \
- newpkgname=${PKGNAME}; \
- ${ECHO} "$$oldpkgname" > ${WRKDIR}/.replace; \
- replace_action="${MAKE} install"; \
- ${_REPLACE}
-
-# undo the replacement of a package - not for the faint-hearted either
-.PHONY: real-su-undo-replace
-real-su-undo-replace:
- ${_PKG_SILENT}${_PKG_DEBUG} \
- if [ ! -f ${WRKDIR}/.replace ]; then \
- ${ECHO_MSG} "No replacement to undo"; \
- exit 1; \
- fi
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${ECHO_MSG} "*** WARNING - experimental target - data loss may occur ***"; \
- oldpkgname=${PKGNAME}; \
- newpkgname=`${CAT} ${WRKDIR}/.replace`; \
- replace_action="${SETENV} ${PKG_ADD} ${WRKDIR}/$$newpkgname${PKG_SUFX}"; \
- ${_REPLACE}; \
- ${RM} ${WRKDIR}/.replace
-
# This is for the use of sites which store distfiles which others may
# fetch - only fetch the distfile if it is allowed to be
# re-distributed freely
@@ -3010,88 +2158,6 @@ run-depends-list:
. endfor
.endif # target(run-depends-list)
-# Build a package but don't check the package cookie
-
-.PHONY: repackage
-.if !target(repackage)
-repackage: pre-repackage package
-
-.PHONY: pre-repackage
-pre-repackage:
- ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${_PACKAGE_COOKIE}
-.endif
-
-# Build a package but don't check the cookie for installation, also don't
-# install package cookie
-
-.PHONY: package-noinstall
-.if !target(package-noinstall)
-package-noinstall:
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} PACKAGE_NOINSTALL=yes real-package
-.endif
-
-################################################################
-# Dependency checking
-################################################################
-
-.PHONY: install-depends pre-install-depends
-pre-install-depends:
-.if !target(install-depends)
-# Tells whether to halt execution if the object formats differ
-FATAL_OBJECT_FMT_SKEW?= yes
-WARN_NO_OBJECT_FMT?= yes
-
-install-depends: pre-install-depends
-. if !empty(DEPENDS) || !empty(BUILD_DEPENDS)
-. if defined(NO_DEPENDS)
- @${DO_NADA}
-. else # !DEPENDS
-. for dep in ${DEPENDS} ${BUILD_DEPENDS}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- pkg=${dep:C/:.*//:Q}; \
- dir=${dep:C/[^:]*://:C/:.*$//:Q}; \
- found=`${PKG_BEST_EXISTS} "$$pkg" || ${TRUE}`; \
- if [ "X$$REBUILD_DOWNLEVEL_DEPENDS" != "X" ]; then \
- pkgname=`cd $$dir ; ${MAKE} ${MAKEFLAGS} show-var VARNAME=PKGNAME`; \
- if [ "X$$found" != "X" -a "X$$found" != "X$${pkgname}" ]; then \
- ${ECHO_MSG} "ignoring old installed package \"$$found\""; \
- found=""; \
- fi; \
- fi; \
- if [ "$$found" != "" ]; then \
- instobjfmt=`${PKG_INFO} -B "$$found" | ${AWK} -F'=[ \t]*' '/^OBJECT_FMT/ {print $$2; exit}'`; \
- if [ "$$instobjfmt" = "" ]; then \
- if [ "X${WARN_NO_OBJECT_FMT}" != "Xno" ]; then \
- ${ECHO} "WARNING: Unknown object format for installed package $$found - continuing"; \
- fi; \
- elif [ "$$instobjfmt" != "${OBJECT_FMT}" ]; then \
- ${ECHO} "Installed package $$found is an $$instobjfmt package."; \
- ${ECHO} "You are building an ${OBJECT_FMT} package, which will not inter-operate."; \
- ${ECHO} "Please update the $$found package to ${OBJECT_FMT}"; \
- if [ "X${FATAL_OBJECT_FMT_SKEW}" != "Xno" ]; then \
- exit 1; \
- fi; \
- fi; \
- ${ECHO_MSG} "${_PKGSRC_IN}> Required installed package $${pkg}: $${found} found"; \
- else \
- ${ECHO_MSG} "${_PKGSRC_IN}> Required package $${pkg}: NOT found"; \
- target=${DEPENDS_TARGET:Q}; \
- ${ECHO_MSG} "${_PKGSRC_IN}> Verifying $$target for $$dir"; \
- if [ ! -d $$dir ]; then \
- ${ECHO_MSG} "=> [bsd.pkg.mk] error: The directory $$dir does not exist."; \
- exit 1; \
- else \
- cd $$dir ; \
- ${SETENV} _PKGSRC_DEPS=", ${PKGNAME}${_PKGSRC_DEPS}" PKGNAME_REQD="$$pkg" ${MAKE} ${MAKEFLAGS} _AUTOMATIC=YES $$target || exit 1; \
- ${ECHO_MSG} "${_PKGSRC_IN}> Returning to build of ${PKGNAME}"; \
- fi; \
- fi
-. endfor # DEPENDS
-. endif # !NO_DEPENDS
-. endif # DEPENDS
-
-.endif
-
.PHONY: build-depends-list
.if !target(build-depends-list)
build-depends-list:
@@ -3406,331 +2472,6 @@ show-options:
@${ECHO} This package does not use the options framework.
.endif
-# Stat all the files of one pkg and sum the sizes up.
-#
-# XXX This is intended to be run before pkg_create is called, so the
-# existence of ${PLIST} can be assumed.
-.PHONY: print-pkg-size-this
-print-pkg-size-this:
- @${SHCOMMENT} "This pkg's files" ; \
- ${AWK} 'BEGIN { base = "${PREFIX}/" } \
- /^@cwd/ { base = $$2 "/" } \
- /^@/ { next } \
- { print base $$0 }' \
- <${PLIST} \
- | ${SORT} -u \
- | ${SED} -e "s/'/'\\\\''/g" -e "s/.*/'&'/" \
- | ${XARGS} -n 256 ${LS} -ld \
- | ${AWK} 'BEGIN { s = 0; } { s += $$5; } END { print s; }'
-
-# Sizes of required pkgs (only)
-#
-# XXX This is intended to be run before pkg_create is called, so the
-# dependencies are all installed.
-.PHONY: print-pkg-size-depends
-print-pkg-size-depends:
- @pkglist=`${MAKE} ${MAKEFLAGS} run-depends-list`; \
- if [ "X$${pkglist}" != "X" ]; then \
- ${ECHO} $${pkglist} \
- | ${XARGS} -n 1 ${SETENV} ${PKG_BEST_EXISTS} \
- | ${SORT} -u \
- | ${XARGS} -n 256 ${SETENV} ${PKG_INFO} -qs \
- | ${AWK} '/^[0-9]+$$/ { s += $$1; } END { print s; }'; \
- else \
- ${ECHO} "0"; \
- fi
-
-# By default, all packages attempt to link into the views.
-.if ${PKG_INSTALLATION_TYPE} == "pkgviews"
-BUILD_VIEWS?= yes
-.endif
-
-# DEFAULT_VIEW.${PKGBASE} default view for ${PKGBASE}
-# VIEWBASE base location of files at run-time
-#
-DEFAULT_VIEW.${PKGBASE}?= ${DEFAULT_VIEW}
-.if ${PKG_INSTALLATION_TYPE} == "pkgviews"
-. if empty(DEFAULT_VIEW.${PKGBASE}:M"")
-VIEWBASE= ${LOCALBASE}/${DEFAULT_VIEW.${PKGBASE}}
-. else
-VIEWBASE= ${LOCALBASE}
-. endif
-.elif ${PKG_INSTALLATION_TYPE} == "overwrite"
-VIEWBASE= ${PREFIX}
-.endif
-MAKE_ENV+= VIEWBASE=${VIEWBASE:Q}
-
-PKGVIEWS+= ${DEFAULT_VIEW.${PKGBASE}}
-
-.PHONY: pre-install-fake-pkg
-.if !target(pre-install-fake-pkg)
-pre-install-fake-pkg:
- ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${PRESERVE_FILE}
-. if defined(PKG_PRESERVE)
- ${_PKG_SILENT}${_PKG_DEBUG}${DATE} > ${PRESERVE_FILE}
-. endif
- ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${BUILD_VERSION_FILE}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- files=""; \
- for f in ${.CURDIR}/Makefile ${FILESDIR}/* ${PKGDIR}/*; do \
- if [ -f "$$f" ]; then \
- files="$$files \"$$f\""; \
- fi; \
- done; \
- if [ -f ${DISTINFO_FILE} ]; then \
- for f in `${AWK} 'NF == 4 && $$3 == "=" { gsub("[()]", "", $$2); print $$2 }' < ${DISTINFO_FILE}`; do \
- if [ -f ${PATCHDIR}/$$f ]; then \
- files="$$files \"${PATCHDIR}/$$f\""; \
- fi; \
- done; \
- fi; \
- if [ -d ${PATCHDIR} ]; then \
- for f in ${PATCHDIR}/patch-*; do \
- case $$f in \
- *.orig|*.rej|*~) ;; \
- ${PATCHDIR}/patch-local-*) \
- files="$$files \"$$f\"" ;; \
- esac; \
- done; \
- fi; \
- eval ${GREP} '\$$NetBSD' $$files | ${SED} -e 's|^${PKGSRCDIR}/||' > ${BUILD_VERSION_FILE}
- ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${BUILD_INFO_FILE}
-. for def in ${BUILD_DEFS}
- @${ECHO} ${def}=${${def}:Q} | ${SED} -e 's|^PATH=[^ ]*|PATH=...|' >> ${BUILD_INFO_FILE}
-. endfor
-. if !empty(USE_LANGUAGES)
- @${ECHO} "CC_VERSION=${CC_VERSION}" >> ${BUILD_INFO_FILE}
-. endif
-. if !empty(USE_TOOLS:Mperl\:run)
- @${ECHO} "PERL=`${PERL5} --version 2>/dev/null | ${GREP} 'This is perl'`" >> ${BUILD_INFO_FILE}
-. endif
-. if defined(_USE_GMAKE) || !empty(USE_TOOLS:Mgmake)
- @${ECHO} "GMAKE=`${GMAKE} --version | ${GREP} Make`" >> ${BUILD_INFO_FILE}
-. endif
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${ECHO} "PKGTOOLS_VERSION=${PKGTOOLS_VERSION}" >> ${BUILD_INFO_FILE}
-.endif
-
-.PHONY: post-install-fake-pkg
-.if !target(post-install-fake-pkg)
-post-install-fake-pkg: ${PLIST} ${DESCR} ${MESSAGE}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- if [ ! -f ${PLIST} -o ! -f ${DESCR} ]; then \
- ${ECHO} "** Missing package files for ${PKGNAME} - installation not recorded."; \
- exit 1; \
- fi
- ${_PKG_SILENT}${_PKG_DEBUG} \
- if [ ! -d ${_PKG_DBDIR} ]; then \
- ${RM} -f ${_PKG_DBDIR}; \
- ${MKDIR} ${_PKG_DBDIR}; \
- fi
-. if defined(FORCE_PKG_REGISTER)
- ${_PKG_SILENT}${_PKG_DEBUG}${PKG_ADMIN} delete ${PKGNAME}
-. endif
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${ECHO} ${COMMENT:Q} > ${PKG_DB_TMPDIR}/+COMMENT
- ${_PKG_SILENT}${_PKG_DEBUG} \
- case "${DESCR}" in \
- ${PKG_DB_TMPDIR}/*|"") ;; \
- *) if ${TEST} -f ${DESCR}; then \
- ${CP} ${DESCR} ${PKG_DB_TMPDIR}/+DESC; \
- fi ;; \
- esac
- ${_PKG_SILENT}${_PKG_DEBUG} \
- case "${MESSAGE}" in \
- ${PKG_DB_TMPDIR}/*|"") ;; \
- *) if ${TEST} -f ${MESSAGE}; then \
- ${CP} ${MESSAGE} ${PKG_DB_TMPDIR}/+DISPLAY; \
- fi ;; \
- esac
- ${_PKG_SILENT}${_PKG_DEBUG} \
- case ${PKG_INSTALLATION_TYPE} in \
- pkgview) ${TOUCH} ${PKG_DB_TMPDIR}/+VIEWS ;; \
- esac
- ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${SIZE_PKG_FILE} ${SIZE_ALL_FILE}
-. if !empty(CHECK_SHLIBS_SUPPORTED:M[yY][eE][sS])
- ${_PKG_SILENT}${_PKG_DEBUG} \
- case "${LDD}" in \
- "") ldd=`${TYPE} ldd 2>/dev/null | ${AWK} '{ print $$NF }'`;; \
- *) ldd="${LDD}"; \
- esac; \
- case "${OBJECT_FMT}" in \
- ELF) bins=`${SETENV} PREFIX=${PREFIX} ${AWK} '/^(bin|sbin|libexec)\// { print ENVIRON["PREFIX"] "/" $$0 }' ${PLIST} || ${TRUE}`; \
- libs=`${SETENV} PREFIX=${PREFIX} ${AWK} '/^lib\/lib.*\.so\.[0-9]+$$/ { print ENVIRON["PREFIX"] "/" $$0 }' ${PLIST} || ${TRUE}`; \
- if ${TEST} "$$bins" != "" -o "$$libs" != ""; then \
- requires=`($$ldd $$bins $$libs 2>/dev/null || ${TRUE}) | ${AWK} '$$2 == "=>" && $$3 ~ "/" { print $$3 }' | ${SORT} -u`; \
- fi; \
- linklibs=`${SETENV} PREFIX=${PREFIX} ${AWK} '/^[^@].*\.so\.[0-9\.]+$$/ { print ENVIRON["PREFIX"] "/" $$0 }' ${PLIST} || ${TRUE}`; \
- for i in $${linklibs}; do \
- if ${TEST} -r $$i -a ! -x $$i -a ! -h $$i; then \
- ${TEST} "${PKG_DEVELOPER:Uno}" = "no" || \
- ${ECHO} "$$i: installed without execute permission; fixing (should use [BSD_]INSTALL_LIB)"; \
- ${CHMOD} +x $$i; \
- fi; \
- done; \
- ;; \
- Mach-O) bins=`${SETENV} PREFIX=${PREFIX} ${AWK} '/^(bin|sbin|libexec)\// { print ENVIRON["PREFIX"] "/" $$0 }' ${PLIST} || ${TRUE}`; \
- libs=`${SETENV} PREFIX=${PREFIX} ${AWK} '/^lib\/lib.*\.dylib/ { print ENVIRON["PREFIX"] "/" $$0 }' ${PLIST} || ${TRUE}`; \
- if ${TEST} "$$bins" != "" -o "$$libs" != ""; then \
- requires=`($$ldd $$bins $$libs 2>/dev/null || ${TRUE}) | ${AWK} '/compatibility version/ { print $$1 }' | ${SORT} -u`; \
- fi; \
- ;; \
- esac; \
- for i in "" $$libs; do \
- ${TEST} "$$i" = "" && continue; \
- ${ECHO} "PROVIDES=$$i" >> ${BUILD_INFO_FILE}; \
- done; \
- for req in "" $$requires; do \
- ${TEST} "$$req" = "" && continue; \
- ${ECHO} "REQUIRES=$$req" >> ${BUILD_INFO_FILE}; \
- done
-. endif
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${ECHO} "HOMEPAGE=${HOMEPAGE}" >> ${BUILD_INFO_FILE}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${ECHO} "CATEGORIES=${CATEGORIES}" >> ${BUILD_INFO_FILE}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${ECHO} "MAINTAINER=${MAINTAINER}" >> ${BUILD_INFO_FILE}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${ECHO} "BUILD_DATE=${_BUILD_DATE}" >> ${BUILD_INFO_FILE}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- size_this=`${MAKE} ${MAKEFLAGS} print-pkg-size-this`; \
- size_depends=`${MAKE} ${MAKEFLAGS} print-pkg-size-depends`; \
- ${ECHO} $$size_this >${SIZE_PKG_FILE}; \
- ${ECHO} $$size_this $$size_depends \
- | ${AWK} '{ print $$1 + $$2; }' >${SIZE_ALL_FILE}
-.endif
-
-# Fake installation of package so that user can pkg_delete it later.
-# Also, make sure that an installed package is recognized correctly in
-# accordance to the @pkgdep directive in the packing lists.
-#
-.PHONY: register-pkg
-.if !target(register-pkg)
-register-pkg: post-install-fake-pkg
- ${_PKG_SILENT}${_PKG_DEBUG} \
- doit=yes; \
- case ${PKG_INSTALLATION_TYPE} in \
- overwrite) if [ -d ${_PKG_DBDIR}/${PKGNAME} ]; then \
- doit=no; \
- fi ;; \
- esac; \
- case $$doit in \
- yes) \
- ${ECHO_MSG} "${_PKGSRC_IN}> Registering installation for ${PKGNAME}"; \
- ${PKG_CREATE} ${PKG_ARGS_INSTALL} -O ${PKGFILE} > ${PKG_DB_TMPDIR}/+CONTENTS; \
- list="`${MAKE} ${MAKEFLAGS} run-depends-list ECHO_MSG=${TRUE} | ${SORT} -u`" ; \
- for realdep in `${ECHO} $$list | ${XARGS} -n 1 ${SETENV} ${PKG_BEST_EXISTS} | ${SORT} -u`; do \
- if ${TEST} -z "$$realdep"; then \
- ${ECHO} "$$dep not installed - dependency NOT registered" ; \
- elif [ -d ${_PKG_DBDIR}/$$realdep ]; then \
- if ${TEST} ! -f ${_PKG_DBDIR}/$$realdep/+REQUIRED_BY; then \
- ${TOUCH} ${_PKG_DBDIR}/$$realdep/+REQUIRED_BY; \
- fi; \
- ${AWK} 'BEGIN { found = 0; } \
- $$0 == "${PKGNAME}" { found = 1; } \
- { print $$0; } \
- END { if (!found) { printf("%s\n", "${PKGNAME}"); }}' \
- < ${_PKG_DBDIR}/$$realdep/+REQUIRED_BY > ${_PKG_DBDIR}/$$realdep/reqby.$$$$; \
- ${MV} ${_PKG_DBDIR}/$$realdep/reqby.$$$$ ${_PKG_DBDIR}/$$realdep/+REQUIRED_BY; \
- ${ECHO} "${PKGNAME} requires installed package $$realdep"; \
- fi; \
- done; \
- case ${PKG_INSTALLATION_TYPE} in \
- overwrite) ${RM} -rf ${_PKG_DBDIR}/${PKGNAME} ;; \
- esac; \
- ${MKDIR} ${_PKG_DBDIR}/${PKGNAME}; \
- ${CP} ${PKG_DB_TMPDIR}/+* ${_PKG_DBDIR}/${PKGNAME}; \
- if [ "${_AUTOMATIC}" = "YES" ]; then \
- ${PKG_ADMIN} set automatic=yes ${PKGNAME}; \
- fi; \
- ;; \
- esac
-. if (${PKG_INSTALLATION_TYPE} == "pkgviews") && \
- !empty(BUILD_VIEWS:M[yY][eE][sS])
- ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} build-views
-. endif # pkgviews
-.endif
-
-.PHONY: build-views
-build-views: do-su-build-views
-
-.PHONY: do-su-build-views
-do-su-build-views:
- @${ECHO_MSG} "${_PKGSRC_IN}> Building views for ${PKGNAME}"
- ${_PKG_SILENT}${_PKG_DEBUG} \
- realtarget="real-su-build-views"; \
- action="build-views"; \
- ${_SU_TARGET}
-
-.PHONY: real-su-build-views
-.if !target(real-su-build-views)
-real-su-build-views:
-. if (${PKG_INSTALLATION_TYPE} == "pkgviews") && defined(PKGVIEWS)
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${MKDIR} ${LOCALBASE}; \
- for v in ${PKGVIEWS}; do \
- case "$$v" in \
- "") dbdir=${PKG_DBDIR}; viewname=standard ;; \
- *) dbdir=${LOCALBASE}/$$v/.dbdir; viewname=$$v ;; \
- esac; \
- ${ECHO} "=> Performing package view clash check for ${PKGNAME} in $$viewname view"; \
- pkg=`${PKG_INFO_CMD} -K $$dbdir -e ${PKGBASE} || ${TRUE}`; \
- case "$$pkg" in \
- "") ;; \
- *) ${ECHO} "*** ${PKGBASE} exists in $$viewname view - package $$pkg ***"; \
- ${ECHO} "*** Not hoisting ${PKGNAME} into $$viewname view"; \
- continue ;; \
- esac; \
- ${ECHO} "=> Performing package view overwrite check for ${PKGNAME} in $$viewname view"; \
- dups=`${SETENV} PLIST_IGNORE_FILES=${_PLIST_IGNORE_FILES:Q} ${PKG_VIEW} --view=$$v check ${PKGNAME} || ${TRUE}`; \
- case "$$dups" in \
- "") ;; \
- *) ${ECHO} "***********************************************************"; \
- ${ECHO} "**** The following symbolic links will be overwritten *****"; \
- for f in $$dups; do \
- ${LS} -l ${LOCALBASE}/$$v/$$f; \
- done; \
- ${ECHO} "***********************************************************"; \
- ;; \
- esac; \
- ${ECHO} "=> Linking package into $$viewname view"; \
- ${SETENV} PLIST_IGNORE_FILES=${_PLIST_IGNORE_FILES:Q} ${PKG_VIEW} --view=$$v add ${PKGNAME}; \
- done
-. else
- ${_PKG_SILENT}${_PKG_DEBUG}${DO_NADA}
-. endif
-.endif
-
-.PHONY: remove-views
-remove-views: do-su-remove-views
-
-.PHONY: do-su-remove-views
-do-su-remove-views:
- @${ECHO_MSG} "${_PKGSRC_IN}> Removing ${PKGNAME} from views"
- ${_PKG_SILENT}${_PKG_DEBUG} \
- realtarget="real-su-remove-views"; \
- action="remove-views"; \
- ${_SU_TARGET}
-
-.PHONY: real-su-remove-views
-.if !target(real-su-remove-views)
-real-su-remove-views:
-. if (${PKG_INSTALLATION_TYPE} == "pkgviews") && defined(PKGVIEWS)
- ${_PKG_SILENT}${_PKG_DEBUG} \
- for v in ${PKGVIEWS}; do \
- case "$$v" in \
- "") dbdir=${PKG_DBDIR}; viewname=standard ;; \
- *) dbdir=${LOCALBASE}/$$v/.dbdir; viewname=$$v ;; \
- esac; \
- ${ECHO} "=> Removing package from $$viewname view"; \
- ${SETENV} PLIST_IGNORE_FILES=${_PLIST_IGNORE_FILES:Q} ${PKG_VIEW} --view=$$v delete ${PKGNAME}; \
- done
-.else
- ${_PKG_SILENT}${_PKG_DEBUG}${DO_NADA}
-. endif
-.endif
-
# Depend is generally meaningless for arbitrary packages, but if someone wants
# one they can override this. This is just to catch people who've gotten into
# the habit of typing `${MAKE} depend all install' as a matter of course.
@@ -3746,38 +2487,6 @@ depend:
tags:
.endif
-# generate ${MESSAGE} from ${MESSAGE_SRC} by substituting
-# for MESSAGE_SUBST entries
-
-.PHONY: message
-message: ${MESSAGE}
-.if defined(MESSAGE)
-${MESSAGE}: ${MESSAGE_SRC}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- if [ -z "${MESSAGE_SRC}" ]; then \
- ${ECHO} "${MESSAGE_SRC} not found."; \
- ${ECHO} "Please set MESSAGE_SRC correctly."; \
- else \
- ${CAT} ${MESSAGE_SRC} | \
- ${SED} ${MESSAGE_SUBST_SED} \
- > ${MESSAGE}; \
- fi
-.endif
-
-# generate ${DESCR} from ${DESCR_SRC} by:
-# - Appending the homepage URL, if any
-
-.PHONY: descr
-descr: ${DESCR}
-${DESCR}: ${DESCR_SRC}
- @${CAT} ${DESCR_SRC} >${DESCR}
-.if defined(HOMEPAGE)
- @\
- ${ECHO} >>${DESCR} ; \
- ${ECHO} "Homepage:" >>${DESCR} ; \
- ${ECHO} '${HOMEPAGE}' >>${DESCR}
-.endif
-
.include "../../mk/plist/bsd.plist.mk"
.include "../../mk/bsd.utils.mk"
diff --git a/mk/bsd.pkg.update.mk b/mk/bsd.pkg.update.mk
new file mode 100644
index 00000000000..4971da75eb9
--- /dev/null
+++ b/mk/bsd.pkg.update.mk
@@ -0,0 +1,127 @@
+# $NetBSD: bsd.pkg.update.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+#
+# This Makefile fragment is included by bsd.pkg.mk and contains the targets
+# and variables for "make update".
+#
+# There is no documentation on what "update" actually does. This is merely
+# an attempt to separate the magic into a separate module that can be
+# reimplemented later.
+#
+
+# The 'update' target can be used to update a package and all
+# currently installed packages that depend upon this package.
+
+_DDIR= ${WRKDIR}/.DDIR
+_DLIST= ${WRKDIR}/.DLIST
+
+.PHONY: update
+.if !target(update)
+.if exists(${_DDIR})
+RESUMEUPDATE?= YES
+CLEAR_DIRLIST?= NO
+
+update:
+ ${_PKG_SILENT}${_PKG_DEBUG}${ECHO_MSG} \
+ "${_PKGSRC_IN}> Resuming update for ${PKGNAME}"
+. if ${REINSTALL} != "NO" && ${UPDATE_TARGET} != "replace"
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${MAKE} ${MAKEFLAGS} deinstall UPDATE_RUNNING=YES DEINSTALLDEPENDS=ALL
+. endif
+.else
+RESUMEUPDATE?= NO
+CLEAR_DIRLIST?= YES
+
+update:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} ${_DDIR}
+. if ${UPDATE_TARGET} != "replace"
+ ${_PKG_SILENT}${_PKG_DEBUG}if ${PKG_INFO} -qe ${PKGBASE}; then \
+ ${MAKE} ${MAKEFLAGS} deinstall UPDATE_RUNNING=YES DEINSTALLDEPENDS=ALL \
+ || (${RM} ${_DDIR} && ${FALSE}); \
+ fi
+. endif
+.endif
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${MAKE} ${MAKEFLAGS} ${UPDATE_TARGET} KEEP_WRKDIR=YES \
+ DEPENDS_TARGET=${DEPENDS_TARGET:Q}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ [ ! -s ${_DDIR} ] || for dep in `${CAT} ${_DDIR}` ; do \
+ (if cd ../.. && cd "$${dep}" ; then \
+ ${ECHO_MSG} "${_PKGSRC_IN}> Installing in $${dep}" && \
+ if [ "(" "${RESUMEUPDATE}" = "NO" -o \
+ "${REINSTALL}" != "NO" ")" -a \
+ "${UPDATE_TARGET}" != "replace" ] ; then \
+ ${MAKE} ${MAKEFLAGS} deinstall UPDATE_RUNNING=YES; \
+ fi && \
+ ${MAKE} ${MAKEFLAGS} ${UPDATE_TARGET} \
+ DEPENDS_TARGET=${DEPENDS_TARGET:Q} ; \
+ else \
+ ${ECHO_MSG} "${_PKGSRC_IN}> Skipping removed directory $${dep}"; \
+ fi) ; \
+ done
+.if ${NOCLEAN} == "NO"
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${MAKE} ${MAKEFLAGS} clean-update CLEAR_DIRLIST=YES
+.endif
+
+
+.PHONY: clean-update
+clean-update:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} ${_DDIR}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ if [ -s ${_DDIR} ] ; then \
+ for dep in `${CAT} ${_DDIR}` ; do \
+ (if cd ../.. && cd "$${dep}" ; then \
+ ${MAKE} ${MAKEFLAGS} clean ; \
+ else \
+ ${ECHO_MSG} "${_PKGSRC_IN}> Skipping removed directory $${dep}";\
+ fi) ; \
+ done ; \
+ fi
+.if ${CLEAR_DIRLIST} != "NO"
+ ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} clean
+.else
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${MAKE} ${MAKEFLAGS} clean update-dirlist \
+ DIRLIST="`${CAT} ${_DDIR}`" PKGLIST="`${CAT} ${_DLIST}`"
+ ${_PKG_SILENT}${_PKG_DEBUG}${ECHO_MSG} \
+ "${_PKGSRC_IN}> Warning: preserved leftover directory list. Your next";\
+ ${ECHO_MSG} "${_PKGSRC_IN}> \`\`${MAKE} update'' may fail. It is advised to use";\
+ ${ECHO_MSG} "${_PKGSRC_IN}> \`\`${MAKE} update REINSTALL=YES'' instead!"
+.endif
+
+.endif # !target(update)
+
+
+.PHONY: update-dirlist
+update-dirlist:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} -p ${WRKDIR}
+.if defined(PKGLIST)
+. for __tmp__ in ${PKGLIST}
+ ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} >>${_DLIST} "${__tmp__}"
+. endfor
+.endif
+.if defined(DIRLIST)
+. for __tmp__ in ${DIRLIST}
+ ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} >>${_DDIR} "${__tmp__}"
+. endfor
+.endif
+
+
+${_DDIR}: ${_DLIST}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ddir=`${SED} 's:-[^-]*$$::' ${_DLIST}`; \
+ ${ECHO} >${_DDIR}; \
+ for pkg in $${ddir} ; do \
+ if ${PKG_INFO} -b "$${pkg}" >/dev/null 2>&1 ; then \
+ ${PKG_INFO} -b "$${pkg}" | ${SED} -ne \
+ 's,\([^/]*/[^/]*\)/Makefile:.*,\1,p' | \
+ ${HEAD} -1 >>${_DDIR}; \
+ fi ; \
+ done
+
+${_DLIST}: ${WRKDIR}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ { ${PKG_DELETE} -n "${PKGWILDCARD}" 2>&1 | \
+ ${GREP} '^ ' | \
+ ${AWK} '{ l[NR]=$$0 } END { for (i=NR;i>0;--i) print l[i] }' \
+ || ${TRUE}; } > ${_DLIST}
diff --git a/mk/bsd.pkg.use.mk b/mk/bsd.pkg.use.mk
index 08a2ce4e860..787471604b5 100644
--- a/mk/bsd.pkg.use.mk
+++ b/mk/bsd.pkg.use.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.use.mk,v 1.33 2006/05/25 11:00:39 wiz Exp $
+# $NetBSD: bsd.pkg.use.mk,v 1.34 2006/06/03 23:11:42 jlam Exp $
#
# Turn USE_* macros into proper depedency logic. Included near the top of
# bsd.pkg.mk, after bsd.prefs.mk.
@@ -26,7 +26,6 @@ PLIST_SUBST+= IMAKE_MANNEWSUFFIX=${IMAKE_MANNEWSUFFIX:Q}
.if defined(USE_IMAKE)
USE_X11BASE?= implied
-INSTALL_TARGET+= ${NO_INSTALL_MANPAGES:D:Uinstall.man}
MAKE_FLAGS+= CC=${CC:Q} CXX=${CXX:Q}
.endif
@@ -37,7 +36,6 @@ MTREE_FILE?= ${PKGSRCDIR}/mk/platform/${OPSYS}.x11.dist
.if ${PKG_INSTALLATION_TYPE} == "pkgviews"
PREFIX= ${DEPOTBASE}/${PKGNAME}
-NO_MTREE= yes
.elif ${PKG_INSTALLATION_TYPE} == "overwrite"
. if defined(INSTALLATION_PREFIX)
PREFIX= ${INSTALLATION_PREFIX}
@@ -45,7 +43,6 @@ PREFIX= ${INSTALLATION_PREFIX}
PREFIX= ${X11PREFIX}
. elif defined(USE_CROSSBASE)
PREFIX= ${CROSSBASE}
-NO_MTREE= yes
. else
PREFIX= ${LOCALBASE}
. endif
diff --git a/mk/bsd.prefs.mk b/mk/bsd.prefs.mk
index 8ba57d28614..112c663759e 100644
--- a/mk/bsd.prefs.mk
+++ b/mk/bsd.prefs.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.prefs.mk,v 1.220 2006/03/08 01:56:46 minskim Exp $
+# $NetBSD: bsd.prefs.mk,v 1.221 2006/06/03 23:11:42 jlam Exp $
#
# Make file, included to get the site preferences, if any. Should
# only be included by package Makefiles before any .if defined()
@@ -486,63 +486,6 @@ DIGEST_VERSION!= ${DIGEST} -V 2>/dev/null
MAKEFLAGS+= DIGEST_VERSION=${DIGEST_VERSION:Q}
.endif
-# This is the package database directory for the default view.
-PKG_DBDIR?= ${DESTDIR}/var/db/pkg
-
-# _PKG_DBDIR is the actual packages database directory where we register
-# packages.
-#
-.if ${PKG_INSTALLATION_TYPE} == "overwrite"
-_PKG_DBDIR= ${PKG_DBDIR}
-.elif ${PKG_INSTALLATION_TYPE} == "pkgviews"
-_PKG_DBDIR= ${DEPOTBASE}
-.endif
-
-PKG_ADD_CMD?= ${PKG_TOOLS_BIN}/pkg_add
-PKG_ADMIN_CMD?= ${PKG_TOOLS_BIN}/pkg_admin
-PKG_CREATE_CMD?= ${PKG_TOOLS_BIN}/pkg_create
-PKG_DELETE_CMD?= ${PKG_TOOLS_BIN}/pkg_delete
-PKG_INFO_CMD?= ${PKG_TOOLS_BIN}/pkg_info
-PKG_VIEW_CMD?= ${PKG_TOOLS_BIN}/pkg_view
-LINKFARM_CMD?= ${PKG_TOOLS_BIN}/linkfarm
-
-.if !defined(PKGTOOLS_VERSION)
-PKGTOOLS_VERSION!= ${PKG_INFO_CMD} -V 2>/dev/null || echo 20010302
-MAKEFLAGS+= PKGTOOLS_VERSION=${PKGTOOLS_VERSION:Q}
-.endif
-
-# The binary pkg_install tools all need to consistently to refer to the
-# correct package database directory.
-#
-.if ${PKGTOOLS_VERSION} < 20030823
-PKGTOOLS_ENV?= PKG_DBDIR=${_PKG_DBDIR:Q}
-PKGTOOLS_ARGS?= # empty
-.else
-PKGTOOLS_ENV?= # empty
-PKGTOOLS_ARGS?= -K ${_PKG_DBDIR:Q}
-.endif
-
-# Views are rooted in ${LOCALBASE}, all packages are depoted in
-# ${DEPOTBASE}, and the package database directory for the default view
-# is in ${PKG_DBDIR}.
-#
-PKG_VIEW_ARGS?= -W ${LOCALBASE} -d ${DEPOTBASE} -k ${PKG_DBDIR}
-
-PKG_ADD?= ${SETENV} ${PKGTOOLS_ENV} ${PKG_ADD_CMD} ${PKGTOOLS_ARGS}
-PKG_ADMIN?= ${SETENV} ${PKGTOOLS_ENV} ${PKG_ADMIN_CMD} ${PKGTOOLS_ARGS}
-PKG_CREATE?= ${SETENV} ${PKGTOOLS_ENV} ${PKG_CREATE_CMD} ${PKGTOOLS_ARGS}
-PKG_DELETE?= ${SETENV} ${PKGTOOLS_ENV} ${PKG_DELETE_CMD} ${PKGTOOLS_ARGS}
-PKG_INFO?= ${SETENV} ${PKGTOOLS_ENV} ${PKG_INFO_CMD} ${PKGTOOLS_ARGS}
-PKG_VIEW?= ${SETENV} ${PKGTOOLS_ENV} ${PKG_VIEW_CMD} ${PKG_VIEW_ARGS}
-LINKFARM?= ${LINKFARM_CMD}
-
-# "${PKG_BEST_EXISTS} pkgpattern" prints out the name of the installed
-# package that best matches pkgpattern. Use this instead of
-# "${PKG_INFO} -e pkgpattern" if the latter would return more than one
-# package name.
-#
-PKG_BEST_EXISTS?= ${PKG_ADMIN} -b -d ${_PKG_DBDIR} -S lsbest
-
.if exists(${LOCALBASE}/bsd/share/mk/zoularis.mk)
PKG_FAIL_REASON+= 'You appear to have a deprecated Zoularis installation.'
PKG_FAIL_REASON+= 'Please update your system to bootstrap-pkgsrc and remove the'
@@ -612,6 +555,11 @@ PREPEND_PATH+= ${USE_X11:D${X11BASE}/bin} ${LOCALBASE}/bin
# Make variable definitions cache
.include "${PKGSRCDIR}/mk/bsd.makevars.mk"
+.include "${PKGSRCDIR}/mk/flavor/bsd.flavor-vars.mk"
+.include "${PKGSRCDIR}/mk/check/bsd.check-vars.mk"
+.include "${PKGSRCDIR}/mk/depends/bsd.depends-vars.mk"
+.include "${PKGSRCDIR}/mk/install/bsd.install-vars.mk"
+
USE_TOOLS+= awk:pkgsrc cut:pkgsrc echo:pkgsrc pwd:pkgsrc \
sed:pkgsrc tr:pkgsrc uname:pkgsrc
diff --git a/mk/check/bsd.check-vars.mk b/mk/check/bsd.check-vars.mk
new file mode 100644
index 00000000000..2d804076f3a
--- /dev/null
+++ b/mk/check/bsd.check-vars.mk
@@ -0,0 +1,10 @@
+# $NetBSD: bsd.check-vars.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+#
+# This Makefile fragment is included by bsd.prefs.mk and defines some
+# variables which must be defined earlier than where bsd.check.mk
+# is included.
+#
+
+CHECK_SHLIBS_SUPPORTED?= yes
+
+USE_TOOLS+= awk cat cmp diff echo find grep rm sed test touch true
diff --git a/mk/check/bsd.check.mk b/mk/check/bsd.check.mk
new file mode 100644
index 00000000000..37bca2bed74
--- /dev/null
+++ b/mk/check/bsd.check.mk
@@ -0,0 +1,16 @@
+# $NetBSD: bsd.check.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+#
+# This Makefile fragment is included by bsd.pkg.mk and provides all
+# variables and targets related to build and install checks.
+#
+# The following are the "public" targets provided this module:
+#
+# check-files-pre, check-files-post, check-files
+# check-interpreter, check-shlibs, check-vulnerable, check-wrkref
+#
+
+.include "${PKGSRCDIR}/mk/check/check-files.mk"
+.include "${PKGSRCDIR}/mk/check/check-interpreter.mk"
+.include "${PKGSRCDIR}/mk/check/check-shlibs.mk"
+.include "${PKGSRCDIR}/mk/check/check-vulnerable.mk"
+.include "${PKGSRCDIR}/mk/check/check-wrkref.mk"
diff --git a/mk/bsd.pkg.check.mk b/mk/check/check-files.mk
index 19fb74708ac..7d11838c4b3 100644
--- a/mk/bsd.pkg.check.mk
+++ b/mk/check/check-files.mk
@@ -1,72 +1,11 @@
-# $NetBSD: bsd.pkg.check.mk,v 1.35 2006/05/22 22:22:02 jlam Exp $
-#
-# This Makefile fragment is included by bsd.pkg.mk and defines the
-# relevant variables and targets for the various install-time "check"
-# targets.
-#
-# The following variables may be set by the user and control which
-# checks are run:
-#
-# CHECK_FILES causes the extra or missing file checks to be run if
-# it is any value other than "no". Defaults to "no".
-#
-# CHECK_FILES_STRICT makes the file checks very strict on errors if
-# it is any value other than "no". Defaults to "no".
-#
-# CHECK_SHLIBS checks that all shared libraries that are used by
-# binaries and shared libraries within the package can be found
-# at run-time. Defaults to "no".
-#
-# CHECK_WRKREF is a list of options that trigger the checks for
-# ${WRKDIR} or ${TOOLS_DIR} in the package's installed files.
-# Valid values are "work", which checks for ${WRKDIR}, and
-# "tools", which checks for ${TOOLS_DIR}. Defaults to "no".
-#
-# CHECK_INTERPRETER can be set to "yes" to check that installed
-# #!-scripts will find their interpreter.
-#
-# The following variables may be set by a package and control which
-# checks can be run:
-#
-# CHECK_SHLIBS_SUPPORTED notes whether the package supports running
-# the check-shlibs target. Defaults to "yes", but is often set
-# to "no" for syscall-emulation packages.
-#
-# The following targets are defined by bsd.pkg.check.mk:
-#
-# check-files-pre & check-files-post generate the list of files on the
-# filesystem just before and just after the package's files are
-# installed.
-#
-# check-files compares the "pre" and "post" file lists to determine
-# if there are any extra or missing files installed by the
-# package.
-#
-# check-wrkref checks whether a package's installed files contain
-# references to ${WRKDIR}.
-#
-# check-interpreter checks whether a script's interpreter exists.
-#
+# $NetBSD: check-files.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
-# For PKG_DEVELOPERs, cause some checks to be run automatically by default.
.if defined(PKG_DEVELOPER)
CHECK_FILES?= yes
-CHECK_WRKREF?= tools
-CHECK_SHLIBS?= yes
.endif
CHECK_FILES?= no
CHECK_FILES_STRICT?= no
-CHECK_WRKREF?= no
-CHECK_SHLIBS?= no
-CHECK_INTERPRETER?= no
-
-USE_TOOLS+= awk cat cmp diff echo find grep rm sed test \
- touch true
-
-###########################################################################
-### check-files ###########################################################
-###########################################################################
###########################################################################
# CHECK_FILES_SKIP is a list of file names that will be skipped when
@@ -184,9 +123,6 @@ _CHECK_FILES_POST+= ${_CHECK_FILES_POST.varbase}
###########################################################################
# check-files-pre and check-files-post targets and subtargets
#
-.ORDER: ${_CHECK_FILES_PRE}
-.ORDER: ${_CHECK_FILES_POST}
-
.PHONY: check-files-pre check-files-post
check-files-pre: ${_CHECK_FILES_PRE}
check-files-post: ${_CHECK_FILES_POST}
@@ -229,8 +165,6 @@ check-files-prefix: ${_CHECK_FILES_COOKIE.prefix}
check-files-sysconfdir: ${_CHECK_FILES_COOKIE.sysconfdir}
check-files-varbase: ${_CHECK_FILES_COOKIE.varbase}
-.ORDER: ${_CHECK_FILES_COOKIES}
-
# The check-files target looks at the cookie files generated by the
# check-files-* subtargets, and if they are non-empty, then they
# contain the error messages collected during the build of each
@@ -257,13 +191,13 @@ ${_CHECK_FILES_COOKIE.prefix}:
then \
{ exit 0; }; \
fi; \
- f_added=${WRKDIR:Q}/.files.added; \
- f_deleted=${WRKDIR:Q}/.files.deleted; \
- f_expected=${WRKDIR:Q}/.files.expected; \
- f_missing=${WRKDIR:Q}/.files.missing; \
- f_missing_real=${WRKDIR:Q}/.files.missing.real; \
- f_missing_skip=${WRKDIR:Q}/.files.missing.skip; \
- f_extra=${WRKDIR:Q}/.files.extra; \
+ f_added=${WRKDIR}/.files.added; \
+ f_deleted=${WRKDIR}/.files.deleted; \
+ f_expected=${WRKDIR}/.files.expected; \
+ f_missing=${WRKDIR}/.files.missing; \
+ f_missing_real=${WRKDIR}/.files.missing.real; \
+ f_missing_skip=${WRKDIR}/.files.missing.skip; \
+ f_extra=${WRKDIR}/.files.extra; \
${DIFF} -u ${_CHECK_FILES_PRE.prefix} ${_CHECK_FILES_POST.prefix} \
> ${WRKDIR}/.files.diff || ${TRUE}; \
${GREP} '^+/' ${WRKDIR}/.files.diff | ${SED} "s|^+||" | ${SORT} \
@@ -368,159 +302,12 @@ ${_CHECK_FILES_COOKIE.varbase}:
${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_FLAGS} ${.TARGET}
###########################################################################
-### check-wrkref ##########################################################
-###########################################################################
-
-###########################################################################
-# CHECK_WRKREF_SKIP is a list of shell globs. Installed files that
-# match these globs are skipped when running the check-wrkref target.
+# check-files-clean removes the state files related to the "check-files"
+# target so that the check-files-{pre,post} targets may be re-run.
#
-.if make(check-wrkref)
-. if !defined(_CHECK_WRKREF_SKIP_FILTER)
-_CHECK_WRKREF_SKIP_FILTER= ${TRUE}
-. if defined(CHECK_WRKREF_SKIP) && !empty(CHECK_WRKREF_SKIP)
-_CHECK_WRKREF_SKIP_FILTER= case "$$file" in
-. for _pattern_ in ${CHECK_WRKREF_SKIP}
-_CHECK_WRKREF_SKIP_FILTER+= ${_pattern_}) continue ;;
-. endfor
-_CHECK_WRKREF_SKIP_FILTER+= *) ;;
-_CHECK_WRKREF_SKIP_FILTER+= esac
-. endif
-. endif
-MAKEVARS+= _CHECK_WRKREF_SKIP_FILTER
-.else
-_CHECK_WRKREF_SKIP_FILTER= ${TRUE}
-.endif
-
-_CHECK_WRKREF:= ${CHECK_WRKREF}
-.if !empty(_CHECK_WRKREF:Mwork)
-_CHECK_WRKREF:= work # "work" is the "max" option
-.endif
-
-###########################################################################
-# check-wrkref target
-#
-.PHONY: check-wrkref
-check-wrkref:
-.if !defined(NO_PKG_REGISTER)
- ${_PKG_SILENT}${_PKG_DEBUG}${STEP_MSG} \
- "Checking for work-directory references in ${PKGNAME}"
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${PKG_INFO} -qL ${PKGNAME:Q} | ${SORT} | \
- { while read file; do \
- ${_CHECK_WRKREF_SKIP_FILTER}; \
- ${SHCOMMENT} [$$file]; \
- case ${_CHECK_WRKREF:Mwork:Q}"" in \
- work) \
- if ${GREP} -H ${WRKDIR:Q} "$$file" 2>/dev/null; then \
- found=1; \
- fi; \
- ;; \
- esac; \
- case ${_CHECK_WRKREF:Mtools:Q}"" in \
- tools) \
- if ${GREP} -H ${TOOLS_DIR:Q} "$$file" 2>/dev/null; then \
- found=1; \
- fi; \
- ;; \
- esac; \
- done; \
- if ${TEST} "$$found" = 1; then \
- ${ECHO} "***"; \
- ${ECHO} "*** The above files still have references to the build directory."; \
- ${ECHO} "*** This is possibly an error that should be fixed by unwrapping"; \
- ${ECHO} "*** the files or adding missing tools to the package makefile!"; \
- ${ECHO} "***"; \
- exit 1; \
- fi; }
-.endif
-
-###########################################################################
-### check-interpreter #####################################################
-###########################################################################
-
-###########################################################################
-# CHECK_INTERPRETER_SKIP is a list of shell globs. Installed files that
-# match these globs are skipped when running the check-interpreter target.
-#
-CHECK_INTERPRETER_SKIP?= # empty
-
-_CHECK_INTERP_SKIP_FILTER= case $$file in
-.for _pattern_ in ${CHECK_INTERPRETER_SKIP}
-_CHECK_INTERP_SKIP_FILTER+= ${PREFIX:Q}/${_pattern_}|${_pattern_}) continue ;;
-.endfor
-_CHECK_INTERP_SKIP_FILTER+= *) ;;
-_CHECK_INTERP_SKIP_FILTER+= esac
-
-###########################################################################
-# check-interpreter target
-#
-.PHONY: check-interpreter
-check-interpreter:
- ${_PKG_SILENT}${_PKG_DEBUG}${STEP_MSG} \
- "Checking for non-existent script interpreters in ${PKGNAME}"
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${PKG_INFO} -qL ${PKGNAME:Q} | ${SORT} | ${SED} 's,\\,\\\\,g' | \
- { exitcode=0; \
- while read file; do \
- ${_CHECK_INTERP_SKIP_FILTER}; \
- ${SHCOMMENT} "[$$file]"; \
- interp=`${SED} -n -e '1s/^#! *\([^ ]*\).*/\1/p' -e '2q' < "$$file"` \
- || { ${ECHO} "[bsd.pkg.check.mk] WARNING: sed(1) failed for \"$$file\"." 1>&2; \
- continue; \
- }; \
- case $$interp in \
- "") continue; \
- esac; \
- if ${TEST} ! -f "$$interp"; then \
- if ${TEST} -x "$$file"; then \
- ${ECHO} "[bsd.pkg.check.mk] ERROR: The interpreter \"$$interp\" of \"$$file\" does not exist." 1>&2; \
- exitcode=1; \
- else \
- ${ECHO} "[bsd.pkg.check.mk] WARNING: The interpreter \"$$interp\" of \"$$file\" does not exist." 1>&2; \
- fi; \
- fi; \
- done; \
- exit $$exitcode; }
-
-###########################################################################
-### check-shlibs ##########################################################
-###########################################################################
-
-# All binaries and shared libraries.
-_CHECK_SHLIBS_ERE= /(bin/|sbin/|libexec/|lib/lib.*\.so|lib/lib.*\.dylib)
-
-CHECK_SHLIBS_SUPPORTED?= yes
-
-###########################################################################
-# check-shlibs target
-#
-.PHONY: check-shlibs
-check-shlibs:
-.if !empty(CHECK_SHLIBS_SUPPORTED:M[yY][eE][sS]) && !defined(NO_PKG_REGISTER)
- ${_PKG_SILENT}${_PKG_DEBUG}${STEP_MSG} \
- "Checking for missing run-time search paths in ${PKGNAME}"
+.PHONY: check-files-clean
+check-clean: check-files-clean
+check-files-clean:
${_PKG_SILENT}${_PKG_DEBUG} \
- case ${LDD:Q}"" in \
- "") ldd=`${TYPE} ldd 2>/dev/null | ${AWK} '{ print $$NF }'` ;; \
- *) ldd=${LDD:Q} ;; \
- esac; \
- ${TEST} -x "$$ldd" || exit 0; \
- ${PKG_INFO} -qL ${PKGNAME} | \
- { ${EGREP} -h ${_CHECK_SHLIBS_ERE:Q} || ${TRUE}; } | \
- { while read file; do \
- ${TEST} -z ${PKG_VERBOSE:Q}"" || ${ECHO} "$$ldd $$file"; \
- err=`{ $$ldd $$file 2>&1 || ${TRUE}; } | { ${GREP} "not found" || ${TRUE}; }`; \
- if ${TEST} -n "$$err"; then \
- ${ECHO} "$$file: $$err"; \
- error=1; \
- fi; \
- done; \
- if ${TEST} "$$error" = 1; then \
- ${ECHO} "*** The above programs/libs will not find the listed shared libraries"; \
- ${ECHO} " at runtime. Please fix the package (add -Wl,-R.../lib in the right"; \
- ${ECHO} " places)!"; \
- ${SHCOMMENT} Might not error-out for non-pkg-developers; \
- exit 1; \
- fi; }
-.endif
+ ${RM} -f ${_CHECK_FILES_COOKIES} \
+ ${_CHECK_FILES_PRE} ${_CHECK_FILES_POST}
diff --git a/mk/check/check-interpreter.mk b/mk/check/check-interpreter.mk
new file mode 100644
index 00000000000..6c8bf28a2fc
--- /dev/null
+++ b/mk/check/check-interpreter.mk
@@ -0,0 +1,47 @@
+# $NetBSD: check-interpreter.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+
+CHECK_INTERPRETER?= no
+
+###########################################################################
+# CHECK_INTERPRETER_SKIP is a list of shell globs. Installed files that
+# match these globs are skipped when running the check-interpreter target.
+#
+CHECK_INTERPRETER_SKIP?= # empty
+
+_CHECK_INTERP_SKIP_FILTER= case $$file in
+.for _pattern_ in ${CHECK_INTERPRETER_SKIP}
+_CHECK_INTERP_SKIP_FILTER+= ${PREFIX}/${_pattern_}|${_pattern_}) continue ;;
+.endfor
+_CHECK_INTERP_SKIP_FILTER+= *) ;;
+_CHECK_INTERP_SKIP_FILTER+= esac
+
+###########################################################################
+# check-interpreter target
+#
+.PHONY: check-interpreter
+check-interpreter:
+ ${_PKG_SILENT}${_PKG_DEBUG}${STEP_MSG} \
+ "Checking for non-existent script interpreters in ${PKGNAME}"
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${PKG_FILELIST_CMD} | ${SORT} | ${SED} 's,\\,\\\\,g' | \
+ { exitcode=0; \
+ while read file; do \
+ ${_CHECK_INTERP_SKIP_FILTER}; \
+ ${SHCOMMENT} "[$$file]"; \
+ interp=`${SED} -n -e '1s/^#! *\([^ ]*\).*/\1/p' -e '2q' < "$$file"` \
+ || { ${ECHO} "[check-interpreter.mk] WARNING: sed(1) failed for \"$$file\"." 1>&2; \
+ continue; \
+ }; \
+ case $$interp in \
+ "") continue; \
+ esac; \
+ if ${TEST} ! -f "$$interp"; then \
+ if ${TEST} -x "$$file"; then \
+ ${ECHO} "[check-interpreter.mk] ERROR: The interpreter \"$$interp\" of \"$$file\" does not exist." 1>&2; \
+ exitcode=1; \
+ else \
+ ${ECHO} "[check-interpreter.mk] WARNING: The interpreter \"$$interp\" of \"$$file\" does not exist." 1>&2; \
+ fi; \
+ fi; \
+ done; \
+ exit $$exitcode; }
diff --git a/mk/check/check-shlibs.mk b/mk/check/check-shlibs.mk
new file mode 100644
index 00000000000..bbeb6d4119f
--- /dev/null
+++ b/mk/check/check-shlibs.mk
@@ -0,0 +1,43 @@
+# $NetBSD: check-shlibs.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+
+# For PKG_DEVELOPERs, cause some checks to be run automatically by default.
+.if defined(PKG_DEVELOPER)
+CHECK_SHLIBS?= yes
+.endif
+CHECK_SHLIBS?= no
+
+# All binaries and shared libraries.
+_CHECK_SHLIBS_ERE= /(bin/|sbin/|libexec/|lib/lib.*\.so|lib/lib.*\.dylib)
+
+###########################################################################
+# check-shlibs target
+#
+.PHONY: check-shlibs
+check-shlibs:
+.if !empty(CHECK_SHLIBS_SUPPORTED:M[yY][eE][sS]) && !defined(NO_PKG_REGISTER)
+ ${_PKG_SILENT}${_PKG_DEBUG}${STEP_MSG} \
+ "Checking for missing run-time search paths in ${PKGNAME}"
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ case ${LDD:Q}"" in \
+ "") ldd=`${TYPE} ldd 2>/dev/null | ${AWK} '{ print $$NF }'` ;; \
+ *) ldd=${LDD:Q} ;; \
+ esac; \
+ ${TEST} -x "$$ldd" || exit 0; \
+ ${PKG_FILELIST_CMD} | \
+ { ${EGREP} -h ${_CHECK_SHLIBS_ERE:Q} || ${TRUE}; } | \
+ { while read file; do \
+ ${TEST} -z ${PKG_VERBOSE:Q}"" || ${ECHO} "$$ldd $$file"; \
+ err=`{ $$ldd $$file 2>&1 || ${TRUE}; } | { ${GREP} "not found" || ${TRUE}; }`; \
+ if ${TEST} -n "$$err"; then \
+ ${ECHO} "$$file: $$err"; \
+ error=1; \
+ fi; \
+ done; \
+ if ${TEST} "$$error" = 1; then \
+ ${ECHO} "*** The above programs/libs will not find the listed shared libraries"; \
+ ${ECHO} " at runtime. Please fix the package (add -Wl,-R.../lib in the right"; \
+ ${ECHO} " places)!"; \
+ ${SHCOMMENT} Might not error-out for non-pkg-developers; \
+ exit 1; \
+ fi; }
+.endif
diff --git a/mk/check/check-vulnerable.mk b/mk/check/check-vulnerable.mk
new file mode 100644
index 00000000000..ca4425d5250
--- /dev/null
+++ b/mk/check/check-vulnerable.mk
@@ -0,0 +1,11 @@
+# $NetBSD: check-vulnerable.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+
+###########################################################################
+# check-vulnerable checks for vulnerabilities in the package. This should
+# be overridden per package system flavor.
+#
+.PHONY: check-vulnerable
+.if !target(check-vulnerable)
+check-vulnerable:
+ @${ECHO_MSG} "${_PKGSRC_IN} *** Skipping vulnerability checks."
+.endif
diff --git a/mk/check/check-wrkref.mk b/mk/check/check-wrkref.mk
new file mode 100644
index 00000000000..51d93e43148
--- /dev/null
+++ b/mk/check/check-wrkref.mk
@@ -0,0 +1,70 @@
+# $NetBSD: check-wrkref.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+
+.if defined(PKG_DEVELOPER)
+CHECK_WRKREF?= tools
+.endif
+CHECK_WRKREF?= no
+
+###########################################################################
+# CHECK_WRKREF_SKIP is a list of shell globs. Installed files that
+# match these globs are skipped when running the check-wrkref target.
+#
+.if make(check-wrkref)
+. if !defined(_CHECK_WRKREF_SKIP_FILTER)
+_CHECK_WRKREF_SKIP_FILTER= ${TRUE}
+. if defined(CHECK_WRKREF_SKIP) && !empty(CHECK_WRKREF_SKIP)
+_CHECK_WRKREF_SKIP_FILTER= case "$$file" in
+. for _pattern_ in ${CHECK_WRKREF_SKIP}
+_CHECK_WRKREF_SKIP_FILTER+= ${_pattern_}) continue ;;
+. endfor
+_CHECK_WRKREF_SKIP_FILTER+= *) ;;
+_CHECK_WRKREF_SKIP_FILTER+= esac
+. endif
+. endif
+MAKEVARS+= _CHECK_WRKREF_SKIP_FILTER
+.else
+_CHECK_WRKREF_SKIP_FILTER= ${TRUE}
+.endif
+
+_CHECK_WRKREF:= ${CHECK_WRKREF}
+.if !empty(_CHECK_WRKREF:Mwork)
+_CHECK_WRKREF:= work # "work" is the "max" option
+.endif
+
+###########################################################################
+# check-wrkref target
+#
+.PHONY: check-wrkref
+check-wrkref:
+.if !defined(NO_PKG_REGISTER)
+ ${_PKG_SILENT}${_PKG_DEBUG}${STEP_MSG} \
+ "Checking for work-directory references in ${PKGNAME}"
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${PKG_FILELIST_CMD} | ${SORT} | \
+ { while read file; do \
+ ${_CHECK_WRKREF_SKIP_FILTER}; \
+ ${SHCOMMENT} [$$file]; \
+ case ${_CHECK_WRKREF:Mwork:Q}"" in \
+ work) \
+ if ${GREP} -H ${WRKDIR} "$$file" 2>/dev/null; then \
+ found=1; \
+ fi; \
+ ;; \
+ esac; \
+ case ${_CHECK_WRKREF:Mtools:Q}"" in \
+ tools) \
+ if ${GREP} -H ${TOOLS_DIR} "$$file" 2>/dev/null; then \
+ found=1; \
+ fi; \
+ ;; \
+ esac; \
+ done; \
+ if ${TEST} "$$found" = 1; then \
+ ${ECHO} "***"; \
+ ${ECHO} "*** The above files still have references to the build directory."; \
+ ${ECHO} "*** This is possibly an error that should be fixed by unwrapping"; \
+ ${ECHO} "*** the files or adding missing tools to the package makefile!"; \
+ ${ECHO} "***"; \
+ exit 1; \
+ fi; }
+.endif
diff --git a/mk/depends/bsd.depends-vars.mk b/mk/depends/bsd.depends-vars.mk
new file mode 100644
index 00000000000..0807b387eb8
--- /dev/null
+++ b/mk/depends/bsd.depends-vars.mk
@@ -0,0 +1,8 @@
+# $NetBSD: bsd.depends-vars.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+#
+# This Makefile fragment is included by bsd.prefs.mk and defines some
+# variables which must be defined earlier than where bsd.depends.mk
+# is included.
+#
+
+_DEPENDS_COOKIE= ${WRKDIR}/.depends_done
diff --git a/mk/depends/bsd.depends.mk b/mk/depends/bsd.depends.mk
new file mode 100644
index 00000000000..a660d161527
--- /dev/null
+++ b/mk/depends/bsd.depends.mk
@@ -0,0 +1,60 @@
+# $NetBSD: bsd.depends.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+#
+# This Makefile fragment is included by bsd.pkg.mk and provides all
+# variables and targets related to dependencies.
+#
+# The following are the "public" targets provided by this module:
+#
+# depends, install-depends
+#
+
+_DEPENDS_COOKIE= ${WRKDIR}/.depends_done
+
+######################################################################
+### depends (PUBLIC)
+######################################################################
+### depends is a public target to install missing dependencies for
+### the package.
+###
+.PHONY: depends
+.if defined(NO_DEPENDS)
+depends: depends-cookie
+.else
+. include "${PKGSRCDIR}/mk/depends/depends.mk"
+.endif
+
+######################################################################
+### install-depends (PUBLIC)
+######################################################################
+### install-depends is a convenience target that installs all dependencies
+### and removes the cookie file afterwards, so that the state of the
+### filesystem remains unchanged.
+###
+### XXX This target is probably not needed and might be removed.
+###
+.PHONY: install-depends
+install-depends: depends depends-clean
+
+######################################################################
+### depends-clean (PRIVATE)
+######################################################################
+### depends-clean removes the state files associated with the "depends"
+### target so that "depends" may be re-invoked.
+###
+depends-clean:
+ ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${_DEPENDS_COOKIE}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${RMDIR} -p ${_DEPENDS_COOKIE:H} 2>/dev/null || ${TRUE}
+
+######################################################################
+### depends-cookie (PRIVATE, override)
+######################################################################
+### depends-cookie creates the depends "cookie" state file. This should
+### be overridden per package system flavor.
+###
+.if !target(depends-cookie)
+.PHONY: depends-cookie
+depends-cookie:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${_DEPENDS_COOKIE:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_ARGS} ${_DEPENDS_COOKIE}
+.endif
diff --git a/mk/depends/depends.mk b/mk/depends/depends.mk
new file mode 100644
index 00000000000..04253d493d3
--- /dev/null
+++ b/mk/depends/depends.mk
@@ -0,0 +1,50 @@
+# $NetBSD: depends.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+
+######################################################################
+### depends (PUBLIC)
+######################################################################
+### depends is a public target to install missing dependencies for
+### the package.
+###
+_DEPENDS_TARGETS+= acquire-depends-lock
+_DEPENDS_TARGETS+= ${_DEPENDS_COOKIE}
+_DEPENDS_TARGETS+= release-depends-lock
+
+.PHONY: depends
+depends: ${_DEPENDS_TARGETS}
+
+.PHONY: acquire-depends-lock release-depends-lock
+acquire-depends-lock: acquire-lock
+release-depends-lock: release-lock
+
+.if !exists(${_DEPENDS_COOKIE})
+${_DEPENDS_COOKIE}: pre-depends-hook depends-install depends-cookie
+.else
+${_DEPENDS_COOKIE}:
+ @${DO_NADA}
+.endif
+
+######################################################################
+### depends-install (PRIVATE, override)
+######################################################################
+### depends-install checks that all dependencies are installed, and will
+### install any missing dependencies. This should be overridden per
+### package system flavor.
+###
+.if !target(depends-install)
+.PHONY: depends-install
+depends-install:
+ @${DO_NADA}
+.endif
+
+######################################################################
+### pre-depends-hook (PRIVATE, override, hook)
+######################################################################
+### pre-depends-hook is a generic hook target that is run just before
+### dependencies are installed for depends-install.
+###
+.PHONY: pre-depends-hook
+.if !target(pre-depends-hook)
+pre-depends-hook:
+ @${DO_NADA}
+.endif
diff --git a/mk/flavor/bsd.flavor-vars.mk b/mk/flavor/bsd.flavor-vars.mk
new file mode 100644
index 00000000000..9e0cf2eb8cb
--- /dev/null
+++ b/mk/flavor/bsd.flavor-vars.mk
@@ -0,0 +1,11 @@
+# $NetBSD: bsd.flavor-vars.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+#
+# This Makefile fragment is included by bsd.prefs.mk and defines some
+# variables which must be defined earlier than where bsd.flavor.mk
+# is included.
+#
+
+# Default to the pkgsrc-package flavor.
+PKG_FLAVOR?= pkg
+
+.sinclude "${PKGSRCDIR}/mk/flavor/${PKG_FLAVOR}/flavor-vars.mk"
diff --git a/mk/flavor/bsd.flavor.mk b/mk/flavor/bsd.flavor.mk
new file mode 100644
index 00000000000..385d3a77d53
--- /dev/null
+++ b/mk/flavor/bsd.flavor.mk
@@ -0,0 +1,7 @@
+# $NetBSD: bsd.flavor.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+#
+# This Makefile fragment is included by bsd.pkg.mk and pulls in the correct
+# target and variable overrides for the selected package system flavor.
+#
+
+.include "${PKGSRCDIR}/mk/flavor/${PKG_FLAVOR}/flavor.mk"
diff --git a/mk/flavor/pkg/check.mk b/mk/flavor/pkg/check.mk
new file mode 100644
index 00000000000..537599df581
--- /dev/null
+++ b/mk/flavor/pkg/check.mk
@@ -0,0 +1,27 @@
+# $NetBSD: check.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+
+######################################################################
+### check-vulnerable (PUBLIC, pkgsrc/mk/check/check.mk)
+######################################################################
+### check-vulnerable checks for any vulnerabilities in the package
+### without needing audit-packages to be installed.
+###
+### XXX This should really be invoking audit-packages directly. Having
+### XXX a separately maintained piece of code that inspects the
+### XXX vulnerabilities database is poor.
+###
+.PHONY: check-vulnerable
+check-vulnerable:
+ @if [ ! -z "${PKG_SYSCONFDIR.audit-packages}" -a -f ${PKG_SYSCONFDIR.audit-packages}/audit-packages.conf ]; then \
+ . ${PKG_SYSCONFDIR.audit-packages}/audit-packages.conf; \
+ elif [ ! -z "${PKG_SYSCONFDIR}" -a -f ${PKG_SYSCONFDIR}/audit-packages.conf ]; then \
+ . ${PKG_SYSCONFDIR}/audit-packages.conf; \
+ fi; \
+ if [ -f ${PKGVULNDIR}/pkg-vulnerabilities ]; then \
+ ${SETENV} PKGNAME=${PKGNAME} \
+ PKGBASE=${PKGBASE} \
+ ${AWK} '/^$$/ { next } \
+ /^#.*/ { next } \
+ $$1 !~ ENVIRON["PKGBASE"] && $$1 !~ /\{/ { next } \
+ { s = sprintf("${PKG_ADMIN} pmatch \"%s\" %s && ${ECHO} \"*** WARNING - %s vulnerability in %s - see %s for more information ***\"", $$1, ENVIRON["PKGNAME"], $$2, ENVIRON["PKGNAME"], $$3); system(s); }' < ${PKGVULNDIR}/pkg-vulnerabilities || ${FALSE}; \
+ fi
diff --git a/mk/flavor/pkg/deinstall.mk b/mk/flavor/pkg/deinstall.mk
new file mode 100644
index 00000000000..f092c57a84f
--- /dev/null
+++ b/mk/flavor/pkg/deinstall.mk
@@ -0,0 +1,50 @@
+# $NetBSD: deinstall.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+
+# Set the appropriate flags to pass to pkg_delete(1) based on the value
+# of DEINSTALLDEPENDS (see pkgsrc/mk/install/deinstall.mk).
+#
+.if defined(DEINSTALLDEPENDS)
+. if empty(DEINSTALLDEPENDS:M[nN][oO])
+. if !empty(DEINSTALLDEPENDS:M[aA][lL][lL)
+_PKG_ARGS_DEINSTALL+= -r # for "update" target
+. else
+_PKG_ARGS_DEINSTALL+= -r -R # for removing stuff in bulk builds
+. endif
+. endif
+.endif
+
+.if defined(PKG_VERBOSE)
+_PKG_ARGS_DEINSTALL+= -v
+.endif
+
+.if defined(PKG_PRESERVE)
+. if !empty(UPDATE_RUNNING:M[yY][eE][sS])
+_PKG_ARGS_DEINSTALL+= -N -f # update w/o removing any files
+. endif
+.endif
+
+######################################################################
+### deinstall-pkg (PRIVATE, pkgsrc/mk/install/deinstall.mk)
+######################################################################
+### deinstall-pkg removes the package from the system.
+###
+deinstall-pkg:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ found="`${PKG_INFO} -e \"${PKGNAME}\" || ${TRUE}`"; \
+ case "$$found" in \
+ "") found="`${_PKG_BEST_EXISTS} ${PKGWILDCARD:Q} || ${TRUE}`" ;; \
+ esac; \
+ if ${TEST} -n "$$found"; then \
+ ${ECHO} "Running ${PKG_DELETE} ${_PKG_ARGS_DEINSTALL} $$found"; \
+ ${PKG_DELETE} ${_PKG_ARGS_DEINSTALL} "$$found" || ${TRUE} ; \
+ fi
+.if defined(DEINSTALLDEPENDS) && !empty(DEINSTALLDEPENDS:M[yY][eE][sS])
+. for _pkg_ in ${BUILD_DEPENDS:C/:.*$//}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ found="`${_PKG_BEST_EXISTS} ${_pkg_:Q} || ${TRUE}`"; \
+ if ${TEST} -n "$$found"; then \
+ ${ECHO} "Running ${PKG_DELETE} ${_PKG_ARGS_DEINSTALL} $$found"; \
+ ${PKG_DELETE} ${_PKG_ARGS_DEINSTALL} "$$found" || ${TRUE}; \
+ fi
+. endfor
+.endif
diff --git a/mk/flavor/pkg/depends.mk b/mk/flavor/pkg/depends.mk
new file mode 100644
index 00000000000..788f616db7e
--- /dev/null
+++ b/mk/flavor/pkg/depends.mk
@@ -0,0 +1,109 @@
+# $NetBSD: depends.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+
+_DEPENDS_FILE= ${WRKDIR}/.depends
+_REDUCE_DEPENDS_CMD= ${AWK} -f ${PKGSRCDIR}/mk/flavor/pkg/reduce-depends.awk
+
+# This command prints out the dependency patterns for all full (run-time)
+# dependencies of the package.
+#
+_DEPENDS_PATTERNS_CMD= \
+ if ${TEST} -f ${_DEPENDS_COOKIE}; then \
+ ${CAT} ${_DEPENDS_COOKIE} | \
+ ${AWK} '/^full/ { print $$2 } { next }'; \
+ fi
+
+.PHONY: show-depends
+show-depends:
+ @case ${VARNAME:Q}"" in \
+ BUILD_DEPENDS) ${_REDUCE_DEPENDS_CMD} ${BUILD_DEPENDS:Q} ;; \
+ DEPENDS|*) ${_REDUCE_DEPENDS_CMD} ${DEPENDS:Q} ;; \
+ esac
+
+######################################################################
+### depends-cookie (PRIVATE, pkgsrc/mk/depends/bsd.depends.mk)
+######################################################################
+### depends-cookie creates the "depends" cookie file.
+###
+### The "depends" cookie file contains all of the dependency information
+### for the package. The format of each line of the cookie file is:
+###
+### <depends_type> <pattern> <directory>
+###
+### Valid dependency types are "build" and "full".
+###
+.PHONY: depends-cookie
+depends-cookie: ${_DEPENDS_FILE}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MV} -f ${_DEPENDS_FILE} ${_DEPENDS_COOKIE}
+
+${_DEPENDS_FILE}:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_ARGS} ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${_REDUCE_DEPENDS_CMD} ${BUILD_DEPENDS:Q} | \
+ while read dep; do \
+ pattern=`${ECHO} $$dep | ${SED} -e "s,:.*,,"`; \
+ dir=`${ECHO} $$dep | ${SED} -e "s,.*:,,"`; \
+ ${TEST} -n "$$pattern" || exit 1; \
+ ${TEST} -n "$$dir" || exit 1; \
+ ${ECHO} "build $$pattern $$dir" \
+ >> ${.TARGET}.tmp; \
+ done
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${_REDUCE_DEPENDS_CMD} ${DEPENDS:Q} | \
+ while read dep; do \
+ pattern=`${ECHO} $$dep | ${SED} -e "s,:.*,,"`; \
+ dir=`${ECHO} $$dep | ${SED} -e "s,.*:,,"`; \
+ ${TEST} -n "$$pattern" || exit 1; \
+ ${TEST} -n "$$dir" || exit 1; \
+ ${ECHO} "full $$pattern $$dir" \
+ >> ${.TARGET}.tmp; \
+ done
+ ${_PKG_SILENT}${_PKG_DEBUG}${MV} -f ${.TARGET}.tmp ${.TARGET}
+
+######################################################################
+### depends-install (PRIVATE, pkgsrc/mk/depends/depends.mk)
+######################################################################
+### depends-install installs any missing dependencies.
+###
+.PHONY: depends-install
+depends-install: ${_DEPENDS_FILE}
+ ${_PKG_SILENT}${_PKG_DEBUG}set -e; \
+ ${CAT} ${_DEPENDS_FILE} | \
+ while read type pattern dir; do \
+ pkg=`${_PKG_BEST_EXISTS} "$$pattern" || ${TRUE}`; \
+ case "$$pkg" in \
+ "") \
+ ${ECHO_MSG} "${_PKGSRC_IN}> Required installed package $$pattern: NOT found"; \
+ target=${DEPENDS_TARGET}; \
+ ${ECHO_MSG} "${_PKGSRC_IN}> Verifying $$target for $$dir"; \
+ if ${TEST} ! -d "$$dir"; then \
+ ${ERROR_MSG} "=> [depends.mk] The directory \`\`$$dir'' does not exist."; \
+ exit 1; \
+ fi; \
+ cd $$dir; \
+ ${SETENV} _PKGSRC_DEPS=", ${PKGNAME}${_PKGSRC_DEPS}" PKGNAME_REQD="$$pattern" ${MAKE} ${MAKEFLAGS} _AUTOMATIC=yes $$target; \
+ pkg=`${_PKG_BEST_EXISTS} "$$pattern" || ${TRUE}`; \
+ case "$$pkg" in \
+ "") ${ERROR_MSG} "[depends.mk] A package matching \`\`$$pattern'' should"; \
+ ${ERROR_MSG} " be installed, but one cannot be found. Perhaps there is a"; \
+ ${ERROR_MSG} " stale work directory for $$dir?"; \
+ exit 1; \
+ esac; \
+ ${ECHO_MSG} "${_PKGSRC_IN}> Returning to build of ${PKGNAME}"; \
+ ;; \
+ *) \
+ objfmt=`${PKG_INFO} -Q OBJECT_FMT "$$pkg"`; \
+ case "$$objfmt" in \
+ "") ${WARNING_MSG} "[depends.mk] Unknown object format for installed package $$pkg" ;; \
+ ${OBJECT_FMT}) ;; \
+ *) ${ERROR_MSG} "[depends.mk] Installed package $$pkg has an"; \
+ ${ERROR_MSG} " object format \`\`$$objfmt'' which differs from \`\`${OBJECT_FMT}''. Please"; \
+ ${ERROR_MSG} " update the $$pkg package to ${OBJECT_FMT}."; \
+ exit 1; \
+ ;; \
+ esac; \
+ ${ECHO_MSG} "${_PKGSRC_IN}> Required installed package $$pattern: $$pkg found"; \
+ ;; \
+ esac; \
+ done
diff --git a/mk/flavor/pkg/flavor-vars.mk b/mk/flavor/pkg/flavor-vars.mk
new file mode 100644
index 00000000000..95e2a22e405
--- /dev/null
+++ b/mk/flavor/pkg/flavor-vars.mk
@@ -0,0 +1,78 @@
+# $NetBSD: flavor-vars.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+#
+# This Makefile fragment is included indirectly by bsd.prefs.mk and
+# defines some variables which must be defined earlier than where
+# flavor.mk is included.
+#
+
+PKGSRC_MESSAGE_RECIPIENTS?= # empty
+
+.if !empty(PKGSRC_MESSAGE_RECIPIENTS)
+USE_TOOLS+= mail
+.endif
+
+.if defined(PKG_PRESERVE)
+USE_TOOLS+= date
+.endif
+
+# This is the package database directory for the default view.
+PKG_DBDIR?= ${DESTDIR}/var/db/pkg
+
+# _PKG_DBDIR is the actual packages database directory where we register
+# packages.
+#
+.if ${PKG_INSTALLATION_TYPE} == "overwrite"
+_PKG_DBDIR= ${PKG_DBDIR}
+.elif ${PKG_INSTALLATION_TYPE} == "pkgviews"
+_PKG_DBDIR= ${DEPOTBASE}
+.endif
+
+PKG_ADD_CMD?= ${PKG_TOOLS_BIN}/pkg_add
+PKG_ADMIN_CMD?= ${PKG_TOOLS_BIN}/pkg_admin
+PKG_CREATE_CMD?= ${PKG_TOOLS_BIN}/pkg_create
+PKG_DELETE_CMD?= ${PKG_TOOLS_BIN}/pkg_delete
+PKG_INFO_CMD?= ${PKG_TOOLS_BIN}/pkg_info
+PKG_VIEW_CMD?= ${PKG_TOOLS_BIN}/pkg_view
+LINKFARM_CMD?= ${PKG_TOOLS_BIN}/linkfarm
+
+.if !defined(PKGTOOLS_VERSION)
+PKGTOOLS_VERSION!= ${PKG_INFO_CMD} -V 2>/dev/null || echo 20010302
+MAKEFLAGS+= PKGTOOLS_VERSION=${PKGTOOLS_VERSION}
+.endif
+
+# The binary pkg_install tools all need to consistently to refer to the
+# correct package database directory.
+#
+.if ${PKGTOOLS_VERSION} < 20030823
+PKGTOOLS_ENV?= PKG_DBDIR=${_PKG_DBDIR}
+PKGTOOLS_ARGS?= # empty
+.else
+PKGTOOLS_ENV?= # empty
+PKGTOOLS_ARGS?= -K ${_PKG_DBDIR}
+.endif
+
+# Views are rooted in ${LOCALBASE}, all packages are depoted in
+# ${DEPOTBASE}, and the package database directory for the default view
+# is in ${PKG_DBDIR}.
+#
+PKG_VIEW_ARGS?= -W ${LOCALBASE} -d ${DEPOTBASE} -k ${PKG_DBDIR}
+
+PKG_ADD?= ${SETENV} ${PKGTOOLS_ENV} ${PKG_ADD_CMD} ${PKGTOOLS_ARGS}
+PKG_ADMIN?= ${SETENV} ${PKGTOOLS_ENV} ${PKG_ADMIN_CMD} ${PKGTOOLS_ARGS}
+PKG_CREATE?= ${SETENV} ${PKGTOOLS_ENV} ${PKG_CREATE_CMD} ${PKGTOOLS_ARGS}
+PKG_DELETE?= ${SETENV} ${PKGTOOLS_ENV} ${PKG_DELETE_CMD} ${PKGTOOLS_ARGS}
+PKG_INFO?= ${SETENV} ${PKGTOOLS_ENV} ${PKG_INFO_CMD} ${PKGTOOLS_ARGS}
+PKG_VIEW?= ${SETENV} ${PKGTOOLS_ENV} ${PKG_VIEW_CMD} ${PKG_VIEW_ARGS}
+LINKFARM?= ${LINKFARM_CMD}
+
+# "${_PKG_BEST_EXISTS} pkgpattern" prints out the name of the installed
+# package that best matches pkgpattern. Use this instead of
+# "${PKG_INFO} -e pkgpattern" if the latter would return more than one
+# package name.
+#
+_PKG_BEST_EXISTS?= ${PKG_ADMIN} -b -d ${_PKG_DBDIR} -S lsbest
+
+# XXX Leave this here until all uses of this have been purged from the
+# XXX public parts of pkgsrc.
+# XXX
+PKG_BEST_EXISTS= ${_PKG_BEST_EXISTS}
diff --git a/mk/flavor/pkg/flavor.mk b/mk/flavor/pkg/flavor.mk
new file mode 100644
index 00000000000..120f20b78a4
--- /dev/null
+++ b/mk/flavor/pkg/flavor.mk
@@ -0,0 +1,21 @@
+# $NetBSD: flavor.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+#
+# This Makefile fragment provides variable and target overrides that are
+# specific to the pkgsrc native package format.
+#
+
+# PKG_FILELIST_CMD outputs the list of files owned by ${PKGNAME} as
+# registered on the system.
+#
+PKG_FILELIST_CMD= ${PKG_INFO} -qL ${PKGNAME:Q}
+
+.include "${PKGSRCDIR}/mk/flavor/pkg/depends.mk"
+.include "${PKGSRCDIR}/mk/flavor/pkg/check.mk"
+.include "${PKGSRCDIR}/mk/flavor/pkg/metadata.mk"
+.include "${PKGSRCDIR}/mk/flavor/pkg/install.mk"
+.include "${PKGSRCDIR}/mk/flavor/pkg/deinstall.mk"
+.include "${PKGSRCDIR}/mk/flavor/pkg/replace.mk"
+.include "${PKGSRCDIR}/mk/flavor/pkg/package.mk"
+.include "${PKGSRCDIR}/mk/flavor/pkg/views.mk"
+
+.include "${PKGSRCDIR}/mk/flavor/pkg/utility.mk"
diff --git a/mk/flavor/pkg/install.mk b/mk/flavor/pkg/install.mk
new file mode 100644
index 00000000000..d8bec5aa489
--- /dev/null
+++ b/mk/flavor/pkg/install.mk
@@ -0,0 +1,77 @@
+# $NetBSD: install.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+
+######################################################################
+### install-check-conflicts (PRIVATE, pkgsrc/mk/install/install.mk)
+######################################################################
+### install-check-conflicts checks for conflicts between the package
+### and and installed packages.
+###
+.PHONY: install-check-conflicts
+install-check-conflicts:
+ ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${WRKDIR}/.CONFLICTS
+.for _conflict_ in ${CONFLICTS}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ found="`${_PKG_BEST_EXISTS} ${_conflict_:Q} || ${TRUE}`"; \
+ case "$$found" in \
+ "") ;; \
+ *) ${ECHO} "$$found" >> ${WRKDIR}/.CONFLICTS ;; \
+ esac
+.endfor
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${TEST} -f ${WRKDIR}/.CONFLICTS || exit 0; \
+ ${ERROR_MSG} "${PKGNAME} conflicts with installed package(s):"; \
+ while read line; do ${ERROR_MSG} " $line"; done \
+ < ${WRKDIR}/.CONFLICTS; \
+ ${ERROR_MSG} "They install the same files into the same place."; \
+ ${ERROR_MSG} "Please remove conflicts first with pkg_delete(1)."; \
+ ${RM} -f ${WRKDIR}/.CONFLICTS; \
+ exit 1
+
+######################################################################
+### install-check-installed (PRIVATE, pkgsrc/mk/install/install.mk)
+######################################################################
+### install-check-installed checks if the package (perhaps an older
+### version) is already installed on the system.
+###
+.PHONY: install-check-installed
+install-check-installed:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ found="`${_PKG_BEST_EXISTS} ${PKGWILDCARD:Q} || ${TRUE}`"; \
+ case "$$found" in \
+ "") ;; \
+ *) ${ERROR_MSG} "$$found is already installed - perhaps an older version?"; \
+ ${ERROR_MSG} "If so, you may use either of:"; \
+ ${ERROR_MSG} " - \"pkg_delete $$found\" and \"${MAKE} reinstall\""; \
+ ${ERROR_MSG} " to upgrade properly"; \
+ ${ERROR_MSG} " - \"${MAKE} update\" to rebuild the package and all"; \
+ ${ERROR_MSG} " of its dependencies"; \
+ ${ERROR_MSG} " - \"${MAKE} replace\" to replace only the package without"; \
+ ${ERROR_MSG} " re-linking dependencies, risking various problems."; \
+ exit 1; \
+ ;; \
+ esac
+
+######################################################################
+### register-pkg (PRIVATE, pkgsrc/mk/install/install.mk)
+######################################################################
+### register-pkg populates the package database with the appropriate
+### entries to register the package as being installed on the system.
+###
+_REGISTER_DEPENDENCIES= \
+ ${SETENV} PKG_DBDIR=${_PKG_DBDIR:Q} \
+ AWK=${TOOLS_AWK:Q} \
+ PKG_ADMIN=${PKG_ADMIN_CMD:Q} \
+ ${SH} ${PKGSRCDIR}/mk/flavor/pkg/register-dependencies
+
+.PHONY: register-pkg
+register-pkg: generate-metadata ${_DEPENDS_COOKIE}
+ @${ECHO_MSG} "${_PKGSRC_IN}> Registering installation for ${PKGNAME}"
+ ${_PKG_SILENT}${_PKG_DEBUG}${RM} -fr ${_PKG_DBDIR}/${PKGNAME}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CP} -R ${PKG_DB_TMPDIR} ${_PKG_DBDIR}
+ ${_PKG_SILENT}${_PKG_DEBUG}${PKG_ADMIN} add ${PKGNAME}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ case ${_AUTOMATIC:Q}"" in \
+ [yY][eE][sS]) ${PKG_ADMIN} set automatic=yes ${PKGNAME} ;; \
+ esac
+ ${_PKG_SILENT}${_PKG_DEBUG}${_DEPENDS_PATTERNS_CMD} | \
+ ${SORT} -u | ${_REGISTER_DEPENDENCIES} ${PKGNAME}
diff --git a/mk/flavor/pkg/metadata.mk b/mk/flavor/pkg/metadata.mk
new file mode 100644
index 00000000000..086926dcd09
--- /dev/null
+++ b/mk/flavor/pkg/metadata.mk
@@ -0,0 +1,404 @@
+# $NetBSD: metadata.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+
+######################################################################
+### The targets below are all PRIVATE.
+######################################################################
+
+######################################################################
+###
+### Temporary package meta-data directory. The contents of this directory
+### are copied directly into the real package meta-data directory.
+###
+PKG_DB_TMPDIR= ${WRKDIR}/.pkgdb/${PKGNAME}
+
+unprivileged-install-hook: ${PKG_DB_TMPDIR}
+${PKG_DB_TMPDIR}:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET}
+
+######################################################################
+###
+### +BUILD_INFO - Package build environment and settings information
+###
+_BUILD_INFO_FILE= ${PKG_DB_TMPDIR}/+BUILD_INFO
+_BUILD_DATE_cmd= ${DATE} "+%Y-%m-%d %H:%M:%S %z"
+_METADATA_TARGETS+= ${_BUILD_INFO_FILE}
+
+${_BUILD_INFO_FILE}: plist
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${.TARGET}.tmp
+.for _def_ in ${BUILD_DEFS}
+ ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} ${_def_}=${${_def_}:Q} | \
+ ${SED} -e 's|^PATH=[^ ]*|PATH=...|' \
+ >> ${.TARGET}.tmp
+.endfor
+.if !empty(USE_LANGUAGES)
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${ECHO} "CC_VERSION=${CC_VERSION}" >> ${.TARGET}.tmp
+.endif
+.if !empty(USE_TOOLS:Mperl\:run)
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${ECHO} "PERL=`${PERL5} --version 2>/dev/null | ${GREP} 'This is perl'`" >> ${.TARGET}.tmp
+.endif
+.if !empty(USE_TOOLS:Mgmake)
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${ECHO} "GMAKE=`${GMAKE} --version | ${GREP} Make`" >> ${.TARGET}.tmp
+.endif
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${ECHO} "PKGTOOLS_VERSION=${PKGTOOLS_VERSION}" >> ${.TARGET}.tmp
+.if defined(HOMEPAGE)
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${ECHO} "HOMEPAGE=${HOMEPAGE}" >> ${.TARGET}.tmp
+.endif
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${ECHO} "CATEGORIES=${CATEGORIES}" >> ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${ECHO} "MAINTAINER=${MAINTAINER}" >> ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${ECHO} "BUILD_DATE=${_BUILD_DATE_cmd:sh}" >> ${.TARGET}.tmp
+.if !empty(CHECK_SHLIBS_SUPPORTED:M[yY][eE][sS])
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ case ${LDD:Q}"" in \
+ "") 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}`; \
+ case ${OBJECT_FMT:Q}"" in \
+ ELF) \
+ libs=`${AWK} '/^lib\/lib.*\.so\.[0-9]+$$/ { print "${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}`; \
+ for i in $$linklibs; do \
+ if ${TEST} -r $$i -a ! -x $$i -a ! -h $$i; then \
+ ${TEST} ${PKG_DEVELOPER:Uno:Q} = "no" || \
+ ${ECHO} "$$i: installed without execute permission; fixing (should use [BSD_]INSTALL_LIB)"; \
+ ${CHMOD} +x $$i; \
+ fi; \
+ done; \
+ ;; \
+ Mach-O) \
+ libs=`${AWK} '/^lib\/lib.*\.dylib/ { print "${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; \
+ ;; \
+ esac; \
+ for i in "" $$libs; do \
+ ${TEST} "$$i" != "" || continue; \
+ ${ECHO} "PROVIDES=$$i" >> ${.TARGET}.tmp; \
+ done; \
+ for req in "" $$requires; do \
+ ${TEST} "$$req" != "" || continue; \
+ ${ECHO} "REQUIRES=$$req" >> ${.TARGET}.tmp; \
+ done
+.endif
+ ${_PKG_SILENT}${_PKG_DEBUG}${SORT} ${.TARGET}.tmp > ${.TARGET}.tmp2
+ ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${MV} -f ${.TARGET}.tmp2 ${.TARGET}
+
+######################################################################
+###
+### +BUILD_VERSION - Package build files versioning information
+###
+### We extract the ident strings from all of the important pkgsrc files
+### involved in building the package, i.e. Makefile and patches.
+###
+_BUILD_VERSION_FILE= ${PKG_DB_TMPDIR}/+BUILD_VERSION
+_METADATA_TARGETS+= ${_BUILD_VERSION_FILE}
+
+${_BUILD_VERSION_FILE}:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}exec 1>>${.TARGET}.tmp; \
+ for f in ${.CURDIR}/Makefile ${FILESDIR}/* ${PKGDIR}/*; do \
+ ${TEST} ! -f "$$f" || ${ECHO} "$$f"; \
+ done
+ ${_PKG_SILENT}${_PKG_DEBUG}exec 1>>${.TARGET}.tmp; \
+ ${TEST} -f ${DISTINFO_FILE:Q} || exit 0; \
+ ${CAT} ${DISTINFO_FILE} | \
+ ${AWK} 'NF == 4 && $$3 == "=" { gsub("[()]", "", $$2); print $$2 }' | \
+ while read file; do \
+ ${TEST} ! -f "${PATCHDIR}/$$file" || \
+ ${ECHO} "${PATCHDIR}/$$file"; \
+ done
+ ${_PKG_SILENT}${_PKG_DEBUG}exec 1>>${.TARGET}.tmp; \
+ ${TEST} -d ${PATCHDIR} || exit 0; \
+ cd ${PATCHDIR}; for f in *; do \
+ case "$$f" in \
+ "*"|*.orig|*.rej|*~) ;; \
+ patch-*) ${ECHO} "${PATCHDIR}/$$f" ;; \
+ esac; \
+ done
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${CAT} ${.TARGET}.tmp | ${XARGS} ${GREP} -H '\$$NetBSD' | \
+ ${AWK} '{ sub("^${PKGSRCDIR}/", ""); \
+ sub(":.*[$$]NetBSD", ": $$NetBSD"); \
+ sub("[$$][^$$]*$$", "$$"); \
+ print; }' | ${SORT} -u > ${.TARGET}.tmp1 && \
+ ${RM} -f ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${MV} -f ${.TARGET}.tmp1 ${.TARGET}
+
+######################################################################
+###
+### +COMMENT - Package comment file
+###
+### This file contains the one-line description of the package.
+###
+_COMMENT_FILE= ${PKG_DB_TMPDIR}/+COMMENT
+_METADATA_TARGETS+= ${_COMMENT_FILE}
+
+${_COMMENT_FILE}:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} ${COMMENT:Q} > ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${MV} -f ${.TARGET}.tmp ${.TARGET}
+
+######################################################################
+###
+### +DESC - Package description file
+###
+### This file contains the paragraph description of the package.
+###
+_DESCR_FILE= ${PKG_DB_TMPDIR}/+DESC
+_METADATA_TARGETS+= ${_DESCR_FILE}
+
+${_DESCR_FILE}: ${DESCR_SRC}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} > ${.TARGET}.tmp
+.if defined(HOMEPAGE)
+ ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} >> ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} "Homepage:" >> ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} ""${HOMEPAGE:Q} >> ${.TARGET}.tmp
+.endif
+ ${_PKG_SILENT}${_PKG_DEBUG}${MV} -f ${.TARGET}.tmp ${.TARGET}
+
+######################################################################
+###
+### +DISPLAY - Package message file
+###
+### This file contains important messages which apply to this package,
+### and are shown during installation.
+###
+.if !defined(MESSAGE_SRC)
+. if exists(${PKGDIR}/MESSAGE)
+MESSAGE_SRC= ${PKGDIR}/MESSAGE
+. else
+. if exists(${PKGDIR}/MESSAGE.common)
+MESSAGE_SRC= ${PKGDIR}/MESSAGE.common
+. endif
+. if exists(${PKGDIR}/MESSAGE.${OPSYS})
+MESSAGE_SRC+= ${PKGDIR}/MESSAGE.${OPSYS}
+. endif
+. if exists(${PKGDIR}/MESSAGE.${MACHINE_ARCH:C/i[3-6]86/i386/g})
+MESSAGE_SRC+= ${PKGDIR}/MESSAGE.${MACHINE_ARCH:C/i[3-6]86/i386/g}
+. endif
+. if exists(${PKGDIR}/MESSAGE.${OPSYS}-${MACHINE_ARCH:C/i[3-6]86/i386/g})
+MESSAGE_SRC+= ${PKGDIR}/MESSAGE.${OPSYS}-${MACHINE_ARCH:C/i[3-6]86/i386/g}
+. endif
+. endif
+.endif
+
+.if defined(MESSAGE_SRC)
+_MESSAGE_FILE= ${PKG_DB_TMPDIR}/+DISPLAY
+_METADATA_TARGETS+= ${_MESSAGE_FILE}
+
+# Set MESSAGE_SUBST to substitute "${variable}" to "value" in MESSAGE
+MESSAGE_SUBST+= PKGNAME=${PKGNAME} \
+ PKGBASE=${PKGBASE} \
+ PREFIX=${PREFIX} \
+ LOCALBASE=${LOCALBASE} \
+ X11PREFIX=${X11PREFIX} \
+ X11BASE=${X11BASE} \
+ PKG_SYSCONFDIR=${PKG_SYSCONFDIR} \
+ ROOT_GROUP=${ROOT_GROUP} \
+ ROOT_USER=${ROOT_USER}
+
+_MESSAGE_SUBST_SED= ${MESSAGE_SUBST:S/=/}!/:S/$/!g/:S/^/ -e s!\\\${/}
+
+${_MESSAGE_FILE}: ${MESSAGE_SRC}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} | \
+ ${SED} ${_MESSAGE_SUBST_SED} > ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${MV} -f ${.TARGET}.tmp ${.TARGET}
+
+
+# Display MESSAGE file and optionally mail the contents to
+# PKGSRC_MESSAGE_RECIPIENTS.
+#
+.PHONY: install-display-message
+register-pkg: install-display-message
+install-display-message: ${_MESSAGE_FILE}
+ @${ECHO_MSG} "${_PKGSRC_IN}> Please note the following:"
+ @${ECHO_MSG} ""
+ @${CAT} ${_MESSAGE_FILE}
+ @${ECHO_MSG} ""
+. if !empty(PKGSRC_MESSAGE_RECIPIENTS)
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ (${ECHO} "The ${PKGNAME} package was installed on `${HOSTNAME_CMD}` at `date`"; \
+ ${ECHO} ""; \
+ ${ECHO} "Please note the following:"; \
+ ${ECHO} ""; \
+ ${CAT} ${_MESSAGE_FILE}; \
+ ${ECHO} "") | \
+ ${MAIL_CMD} -s"Package ${PKGNAME} installed on `${HOSTNAME_CMD}`" ${PKGSRC_MESSAGE_RECIPIENTS}
+. endif
+.endif # MESSAGE_SRC
+
+######################################################################
+###
+### +PRESERVE - Package preserve file
+###
+### The existence of this file prevents pkg_delete from removing this
+### package unless one "force-deletes" the package.
+###
+.if defined(PKG_PRESERVE)
+_PRESERVE_FILE= ${PKG_DB_TMPDIR}/+PRESERVE
+_METADATA_TARGETS+= ${_PRESERVE_FILE}
+
+${_PRESERVE_FILE}:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${DATE} > ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${MV} -f ${.TARGET}.tmp ${.TARGET}
+.endif
+
+######################################################################
+###
+### +SIZE_ALL - Package size-of-dependencies file
+###
+### This is the total size of the dependencies that this package was
+### built against.
+###
+_SIZE_ALL_FILE= ${PKG_DB_TMPDIR}/+SIZE_ALL
+_METADATA_TARGETS+= ${_SIZE_ALL_FILE}
+
+${_SIZE_ALL_FILE}: ${_DEPENDS_COOKIE}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${_DEPENDS_PATTERNS_CMD} | \
+ ${XARGS} -n 1 ${_PKG_BEST_EXISTS} | ${SORT} -u | \
+ ${XARGS} -n 256 ${PKG_INFO} -qs | \
+ ${AWK} 'BEGIN { s = 0 } /^[0-9]+$$/ { s += $$1 } END { print s }' \
+ > ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${MV} -f ${.TARGET}.tmp ${.TARGET}
+
+######################################################################
+###
+### +SIZE_PKG - Package size file
+###
+### This is the total size of the files contained in the package.
+###
+_SIZE_PKG_FILE= ${PKG_DB_TMPDIR}/+SIZE_PKG
+_METADATA_TARGETS+= ${_SIZE_PKG_FILE}
+
+${_SIZE_PKG_FILE}: plist
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${CAT} ${PLIST} | \
+ ${AWK} 'BEGIN { base = "${PREFIX}/" } \
+ /^@cwd/ { base = $$2 "/" } \
+ /^@/ { next } \
+ { print base $$0 }' | \
+ ${SORT} -u | \
+ ${SED} -e "s/'/'\\\\''/g" -e "s/.*/'&'/" | \
+ ${XARGS} -n 256 ${LS} -ld 2>/dev/null | \
+ ${AWK} 'BEGIN { s = 0 } { s += $$5 } END { print s }' \
+ > ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${MV} -f ${.TARGET}.tmp ${.TARGET}
+
+######################################################################
+###
+### +CONTENTS - Package manifest file
+###
+### This file contains the list of files and checksums, along with
+### any special "@" commands, e.g. @dirrm.
+###
+_CONTENTS_FILE= ${PKG_DB_TMPDIR}/+CONTENTS
+_METADATA_TARGETS+= ${_CONTENTS_FILE}
+
+_PKG_CREATE_ARGS+= -v -l -U
+_PKG_CREATE_ARGS+= -B ${_BUILD_INFO_FILE}
+_PKG_CREATE_ARGS+= -b ${_BUILD_VERSION_FILE}
+_PKG_CREATE_ARGS+= -c ${_COMMENT_FILE}
+_PKG_CREATE_ARGS+= ${_MESSAGE_FILE:D -D ${_MESSAGE_FILE}}
+_PKG_CREATE_ARGS+= -d ${_DESCR_FILE}
+_PKG_CREATE_ARGS+= -f ${PLIST}
+_PKG_CREATE_ARGS+= ${NO_MTREE:D:U -m ${MTREE_FILE}}
+_PKG_CREATE_ARGS+= ${PKG_PRESERVE:D -n ${_PRESERVE_FILE}}
+_PKG_CREATE_ARGS+= -S ${_SIZE_ALL_FILE}
+_PKG_CREATE_ARGS+= -s ${_SIZE_PKG_FILE}
+_PKG_CREATE_ARGS+= ${_DEPENDS_ARG_cmd:sh}
+_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}
+_PKG_ARGS_INSTALL+= -p ${PREFIX}
+
+_DEPENDS_ARG_cmd= depends=`${_DEPENDS_PATTERNS_CMD}`; \
+ if ${TEST} -n "$$depends"; then \
+ ${ECHO} "-P \"$$depends\""; \
+ else \
+ ${ECHO}; \
+ fi
+
+_DEINSTALL_ARG_cmd= if ${TEST} -f ${DEINSTALL_FILE}; then \
+ ${ECHO} "-k "${DEINSTALL_FILE:Q}; \
+ else \
+ ${ECHO}; \
+ fi
+_INSTALL_ARG_cmd= if ${TEST} -f ${INSTALL_FILE}; then \
+ ${ECHO} "-i "${INSTALL_FILE:Q}; \
+ else \
+ ${ECHO}; \
+ fi
+
+_CONTENTS_TARGETS+= ${_BUILD_INFO_FILE}
+_CONTENTS_TARGETS+= ${_BUILD_VERSION_FILE}
+_CONTENTS_TARGETS+= ${_COMMENT_FILE}
+_CONTENTS_TARGETS+= ${_DEPENDS_COOKIE}
+_CONTENTS_TARGETS+= ${_DESCR_FILE}
+_CONTENTS_TARGETS+= ${_MESSAGE_FILE}
+_CONTENTS_TARGETS+= plist
+_CONTENTS_TARGETS+= ${_PRESERVE_FILE}
+_CONTENTS_TARGETS+= ${_SIZE_ALL_FILE}
+_CONTENTS_TARGETS+= ${_SIZE_PKG_FILE}
+_CONTENTS_TARGETS+= ${NO_MTREE:D:U${MTREE_FILE}}
+
+${_CONTENTS_FILE}: ${_CONTENTS_TARGETS}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${PKG_CREATE} ${_PKG_ARGS_INSTALL} -O ${PKGFILE:T} > ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${MV} -f ${.TARGET}.tmp ${.TARGET}
+
+######################################################################
+### generate-metadata (PRIVATE)
+######################################################################
+### generate-metadata is a convenience target for generating all of
+### the pkgsrc binary package meta-data files. It populates
+### ${PKG_DB_TMPDIR} with the following files:
+###
+### +BUILD_INFO
+### +BUILD_VERSION
+### +COMMENT
+### +CONTENTS
+### +DESC
+### +DISPLAY
+### +PRESERVE
+### +SIZE_ALL
+### +SIZE_PKG
+###
+### See the targets above for descriptions of each of those files.
+###
+.PHONY: generate-metadata
+generate-metadata: ${_METADATA_TARGETS}
+
+######################################################################
+### clean-metadata (PRIVATE)
+######################################################################
+### clean-metadata is a convenience target for removing the meta-data
+### directory.
+###
+.PHONY: clean-metadata
+clean-metadata:
+ ${_PKG_SILENT}${_PKG_DEBUG}${RM} -fr ${PKG_DB_TMPDIR}
diff --git a/mk/flavor/pkg/package.mk b/mk/flavor/pkg/package.mk
new file mode 100644
index 00000000000..097dc71d195
--- /dev/null
+++ b/mk/flavor/pkg/package.mk
@@ -0,0 +1,110 @@
+# $NetBSD: package.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+
+PKG_SUFX?= .tgz
+PKGFILE?= ${PKGREPOSITORY}/${PKGNAME}${PKG_SUFX}
+PKGREPOSITORY?= ${PACKAGES}/${PKGREPOSITORYSUBDIR}
+PKGREPOSITORYSUBDIR?= All
+
+######################################################################
+### package-check-installed (PRIVATE, pkgsrc/mk/package/package.mk)
+######################################################################
+### package-check-installed verifies that the package is installed on
+### the system.
+###
+.PHONY: package-check-installed
+package-check-installed:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${PKG_INFO} -qe ${PKGNAME}; \
+ if ${TEST} $$? -ne 0; then \
+ ${ECHO_MSG} "=> ${PKGNAME} is not installed."; \
+ exit 1; \
+ fi
+
+######################################################################
+### package-create (PRIVATE, pkgsrc/mk/package/package.mk)
+######################################################################
+### package-create creates the binary package.
+###
+.PHONY: package-create
+package-create: package-remove ${PKGFILE} package-links
+
+_PKG_ARGS_PACKAGE+= ${_PKG_CREATE_ARGS}
+_PKG_ARGS_PACKAGE+= -p ${PREFIX:S/^${DESTDIR}//}
+_PKG_ARGS_PACKAGE+= -L ${PREFIX} # @src ...
+.if ${PKG_INSTALLATION_TYPE} == "pkgviews"
+_PKG_ARGS_PACKAGE+= -E
+.endif
+
+${PKGFILE}: ${_CONTENTS_TARGETS}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${PKG_CREATE} ${_PKG_ARGS_PACKAGE} ${.TARGET}; \
+ exitcode=$$?; \
+ if ${TEST} $$exitcode -ne 0; then \
+ ${ECHO} "(${PKG_CREATE:T}: exitcode $$exitcode)"; \
+ ${RM} -f ${.TARGET}; \
+ exit 1; \
+ fi
+
+######################################################################
+### package-remove (PRIVATE)
+######################################################################
+### package-remove removes the binary package from the package
+### repository.
+###
+.PHONY: package-remove
+package-remove:
+ ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${PKGFILE}
+
+######################################################################
+### package-links (PRIVATE)
+######################################################################
+### package-links creates symlinks to the binary package from the
+### non-primary categories to which the package belongs.
+###
+package-links: delete-package-links
+.for _dir_ in ${CATEGORIES:S/^/${PACKAGES}\//}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${_dir_:Q}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ if ${TEST} ! -d ${_dir_:Q}; then \
+ ${ECHO_MSG} "=> Can't create directory "${_dir_:Q}"."; \
+ exit 1; \
+ fi
+ ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${_dir_:Q}/${PKGFILE:T}
+ ${_PKG_SILENT}${_PKG_DEBUG}${LN} -s ../${PKGREPOSITORYSUBDIR}/${PKGFILE:T} ${_dir_:Q}
+.endfor
+
+######################################################################
+### delete-package-links (PRIVATE)
+######################################################################
+### delete-package-links removes the symlinks to the binary package from
+### the non-primary categories to which the package belongs.
+###
+delete-package-links:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${FIND} ${PACKAGES} -type l -name ${PKGFILE:T} -print | \
+ ${XARGS} ${RM} -f
+
+######################################################################
+### tarup (PUBLIC)
+######################################################################
+### tarup is a public target to generate a binary package from an
+### installed package instance.
+###
+_PKG_TARUP_CMD= ${LOCALBASE}/bin/pkg_tarup
+
+.PHONY: tarup
+tarup: package-remove tarup-pkg package-links
+
+######################################################################
+### tarup-pkg (PRIVATE)
+######################################################################
+### tarup-pkg creates a binary package from an installed package instance
+### using "pkg_tarup".
+###
+tarup-pkg:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${TEST} -x ${_PKG_TARUP_CMD} || exit 1; \
+ ${SETENV} PKG_DBDIR=${_PKG_DBDIR} PKG_SUFX=${PKG_SUFX} \
+ PKGREPOSITORY=${PKGREPOSITORY} \
+ ${_PKG_TARUP_CMD} ${PKGNAME}
diff --git a/mk/flavor/pkg/reduce-depends.awk b/mk/flavor/pkg/reduce-depends.awk
new file mode 100755
index 00000000000..d7c416fb22f
--- /dev/null
+++ b/mk/flavor/pkg/reduce-depends.awk
@@ -0,0 +1,141 @@
+#!/usr/bin/awk -f
+#
+# $NetBSD: reduce-depends.awk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+#
+# Copyright (c) 2006 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the NetBSD
+# Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+######################################################################
+#
+# NAME
+# reduce-depends.awk -- reduce a list of dependencies
+#
+# SYNOPSIS
+# reduce-depends.awk "depends_list"
+#
+# DESCRIPTION
+# reduce-depends.awk removes some extraneous dependencies from the
+# dependency list. The dependency list should be passed as a single
+# argument, and the output will be a list of the reduced dependencies,
+# echo one on a new line.
+#
+######################################################################
+
+BEGIN {
+ CAT = ENVIRON["CAT"] ? ENVIRON["CAT"] : "cat"
+ PKG_ADMIN = ENVIRON["PKG_ADMIN"] ? ENVIRON["PKG_ADMIN"] : "pkg_admin"
+ PWD_CMD = ENVIRON["PWD_CMD"] ? ENVIRON["PWD_CMD"] : "pwd -P"
+ TEST = ENVIRON["TEST"] ? ENVIRON["TEST"] : "test"
+
+ PROGNAME = "reduce-depends.awk"
+ ERRCAT = CAT " 1>&2"
+
+ # Gather all dependencies into the depends array. Index 0 of the
+ # depends[pkgpath] array is the number of patterns associated with
+ # that pkgpath.
+ #
+ args = ARGV[1]
+ ARGC = split(args, ARGV); ARGC++
+ for (i = 1; i < ARGC; i++) {
+ pattern = ARGV[i]; sub(":.*", "", pattern)
+ dir = ARGV[i]; sub(".*:", "", dir)
+ cmd = TEST " -d " dir
+ if (system(cmd) == 0) {
+ cmd = "cd " dir " && " PWD_CMD
+ while (cmd | getline pkgpath)
+ if (!(pkgpath in pkgsrcdirs)) {
+ pkgpaths[P++] = pkgpath
+ pkgsrcdirs[pkgpath] = dir
+ }
+ depends[pkgpath, 0]++;
+ depends[pkgpath, depends[pkgpath, 0]] = pattern
+ close(cmd)
+ } else {
+ print "ERROR: [" PROGNAME "] " dir " does not exist." | ERRCAT
+ exit 1
+ }
+ }
+
+ # Reduce dependencies to the strictest set of dependencies it
+ # can derive from all of depends[...]. It only understands
+ # dependencies of the form foo>=1.0, and leaves the other
+ # dependencies undisturbed.
+ #
+ # The algorithm takes dependencies of the form foo>=1.0 and
+ # converts them to foo-1.0. It then compares this pkg name against
+ # each dependency to see if it satisfies them all. The key fact
+ # is the the strictest dependency, when converted to a pkg name,
+ # will satisfy every dependency.
+ #
+ for (p = 0; p < P; p++) {
+ pkgpath = pkgpaths[p]
+ D = depends[pkgpath, 0];
+ for (d = 1; d <= D; d++) {
+ dep = depends[pkgpath, d]
+ if (dep ~ /[{]/ || \
+ dep ~ />=[0-9]+<[0-9]+/ || \
+ dep !~ />=[0-9]+/)
+ {
+ reduced[N++] = dep ":" pkgsrcdirs[pkgpath]
+ continue
+ }
+ ge_depends[dep] = dep
+ }
+ for (dep in ge_depends) {
+ dep2pkg = dep; sub(">=", "-", dep2pkg)
+ match_all = 1
+ for (pattern in ge_depends) {
+ cmd = PKG_ADMIN " pmatch \"" pattern "\" " dep2pkg
+ if (system(cmd) != 0) {
+ match_all = 0
+ break
+ }
+ }
+ if (match_all == 0) continue
+ reduced[N++] = dep ":" pkgsrcdirs[pkgpath]
+ }
+ # This should theoretically never happen.
+ if (match_all == "no") {
+ print "ERROR: [" PROGNAME "] conflicting dependencies" | ERRCAT
+ exit 1
+ }
+ for (dep in ge_depends)
+ delete ge_depends[dep]
+ }
+
+ # Output reduced dependencies.
+ for (n = 0; n < N; n++)
+ print reduced[n];
+}
diff --git a/mk/flavor/pkg/register-dependencies b/mk/flavor/pkg/register-dependencies
new file mode 100755
index 00000000000..0ede219fd85
--- /dev/null
+++ b/mk/flavor/pkg/register-dependencies
@@ -0,0 +1,54 @@
+#!/bin/sh
+#
+# $NetBSD: register-dependencies,v 1.1 2006/06/03 23:11:42 jlam Exp $
+#
+######################################################################
+#
+# NAME
+# register-dependencies -- register package dependencies
+#
+# SYNOPSIS
+# register-dependencies pkgname
+#
+# DESCRIPTION
+# register-dependencies registers a dependency relationship from
+# the named package pkgname and the dependencies passed in via
+# standard input. The dependencies may be wildcard patterns.
+#
+# ENVIRONMENT
+# PKG_ADMIN
+# This is the path to the pkg_admin command.
+#
+# PKG_DBDIR
+# This is the package meta-data directory in which the
+# packages are registered. By default, this is /var/db/pkg.
+#
+######################################################################
+
+: ${AWK:=awk}
+: ${ECHO:=echo}
+: ${PKG_ADMIN:=pkg_admin}
+: ${PKG_DBDIR:=/var/db/pkg}
+: ${TEST:=test}
+: ${TOUCH:=touch}
+: ${TRUE:=true}
+
+PKGNAME="$1"
+
+while read dependency; do
+ pkg=`${PKG_ADMIN} -b -d ${PKG_DBDIR} -S lsbest "$dependency" || ${TRUE}`
+ pkgdir="${PKG_DBDIR}/$pkg"
+ if ${TEST} -z "$pkg" -o ! -d "$pkgdir"; then
+ ${ECHO} 1>&2 "$dependency not found - dependency NOT registered"
+ continue
+ fi
+ req="$pkgdir/+REQUIRED_BY"
+ tmpreq="$pkgdir/+REQUIRED_BY.$$"
+ ${TOUCH} $req
+ ${AWK} -v PKGNAME="${PKGNAME}" \
+ 'BEGIN { found = 0 }
+ $0 == PKGNAME { found = 1 } { print }
+ END { if (!found) print PKGNAME }' $req > $tmpreq
+ ${CP} -f $tmpreq $req; ${RM} -f $tmpreq
+ ${ECHO} "${PKGNAME} requires installed package $pkg"
+done
diff --git a/mk/flavor/pkg/replace.mk b/mk/flavor/pkg/replace.mk
new file mode 100644
index 00000000000..8892d090ed6
--- /dev/null
+++ b/mk/flavor/pkg/replace.mk
@@ -0,0 +1,173 @@
+# $NetBSD: replace.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+
+######################################################################
+### replace-pkg (PRIVATE, pkgsrc/mk/install/replace.mk)
+######################################################################
+### replace-pkg updates a package in-place on the system.
+###
+_REPLACE_PKG_TARGETS+= replace-tarup
+_REPLACE_PKG_TARGETS+= replace-names
+_REPLACE_PKG_TARGETS+= replace-preserve-required-by
+_REPLACE_PKG_TARGETS+= deinstall
+_REPLACE_PKG_TARGETS+= install-clean
+_REPLACE_PKG_TARGETS+= install
+_REPLACE_PKG_TARGETS+= replace-fixup-required-by
+
+replace-pkg: ${_REPLACE_PKG_TARGETS}
+
+######################################################################
+### undo-replace-pkg (PRIVATE, pkgsrc/mk/install/replace.mk)
+######################################################################
+### undo-replace-pkg undoes a "make replace".
+###
+_UNDO_REPLACE_PKG_TARGETS+= undo-replace-check
+_UNDO_REPLACE_PKG_TARGETS+= undo-replace-names
+_UNDO_REPLACE_PKG_TARGETS+= replace-preserve-required-by
+_UNDO_REPLACE_PKG_TARGETS+= deinstall
+_UNDO_REPLACE_PKG_TARGETS+= undo-replace-install
+_UNDO_REPLACE_PKG_TARGETS+= replace-fixup-required-by
+_UNDO_REPLACE_PKG_TARGETS+= replace-clean
+
+undo-replace-pkg: ${_UNDO_REPLACE_PKG_TARGETS}
+
+_REQUIRED_BY_FILE= ${PKG_DB_TMPDIR}/+REQUIRED_BY
+
+_REPLACE_COOKIE= ${WRKDIR}/.replace_done
+_REPLACE_OLDNAME_FILE= ${WRKDIR}/.replace_oldname
+_REPLACE_NEWNAME_FILE= ${WRKDIR}/.replace_newname
+
+######################################################################
+### undo-replace-check (PRIVATE)
+######################################################################
+### undo-replace-check verifies that there was a previous "replace"
+### action performed that can be undone.
+###
+.PHONY: undo-replace-check
+undo-replace-check:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${TEST} ! -f ${_REPLACE_COOKIE} || exit 0; \
+ ${ERROR_MSG} "No replacment to undo!"; \
+ exit 1
+
+######################################################################
+### replace-tarup (PRIVATE)
+######################################################################
+### replace-tarup generates a binary package for the (older) installed
+### package using pkg_tarup.
+###
+.PHONY: replace-tarup
+replace-tarup:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ if ${TEST} ! -x ${_PKG_TARUP_CMD:Q}; then \
+ ${ERROR_MSG} ${_PKG_TARUP_CMD:Q}" was not found."; \
+ exit 1; \
+ fi; \
+ ${SETENV} PKG_DBDIR=${_PKG_DBDIR} PKG_SUFX=${PKG_SUFX} \
+ PKGREPOSITORY=${WRKDIR} \
+ ${_PKG_TARUP_CMD} ${PKGBASE}
+
+######################################################################
+### undo-replace-install (PRIVATE)
+######################################################################
+### undo-replace-install re-installs the old package from the binary
+### package saved from replace-tarup.
+###
+.PHONY: undo-replace-install
+undo-replace-install:
+ @${ECHO_MSG} "${_PKGSRC_IN}> Re-adding ${PKGNAME} from saved tar-up package."
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${TEST} -f ${_REPLACE_NEWNAME_FILE} || exit 0; \
+ newname=`${CAT} ${_REPLACE_NEWNAME_FILE}`; \
+ ${ECHO} "Running "${PKG_ADD} ${WRKDIR}/$$newname${PKG_SUFX}"; \
+ ${PKG_ADD} ${WRKDIR}/$$newname${PKG_SUFX}
+
+######################################################################
+### replace-names, undo-replace-names (PRIVATE)
+######################################################################
+### replace-names and undo-replace-names save the correct names of the
+### installed and replacement packages into files queried by other
+### targets.
+###
+.PHONY: replace-names
+replace-names:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${_PKG_BEST_EXISTS} ${PKGWILDCARD:Q} > ${_REPLACE_OLDNAME_FILE}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${ECHO} ${PKGNAME} > ${_REPLACE_NEWNAME_FILE}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${CP} -f ${_REPLACE_NEWNAME_FILE} ${_REPLACE_COOKIE}
+
+.PHONY: undo-replace-names
+undo-replace-names:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${ECHO} ${PKGNAME} > ${_REPLACE_OLDNAME_FILE}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${CP} -f ${_REPLACE_COOKIE} ${_REPLACE_NEWNAME_FILE}
+
+######################################################################
+### replace-preserve-required-by (PRIVATE)
+######################################################################
+### replace-preserve-required-by saves and removes the +REQUIRED_BY
+### file from the installed package.
+###
+.PHONY: replace-preserve-required-by
+replace-preserve-required-by:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${TEST} -f ${_REPLACE_OLDNAME_FILE} || exit 0; \
+ ${STEP_MSG} "Preserving existing +REQUIRED_BY file.";
+ oldname=`${CAT} ${_REPLACE_OLDNAME_FILE}`; \
+ required_by="${_PKG_DBDIR}/$$oldname/+REQUIRED_BY"; \
+ ${TEST} ! -f "$$required_by" || \
+ ${MV} $$required_by ${_REQUIRED_BY_FILE}
+
+######################################################################
+### replace-fixup-required-by (PRIVATE)
+######################################################################
+### replace-fixup-required-by fixes the +CONTENTS files of dependent
+### packages to refer to the replacement package.
+###
+.PHONY: replace-fixup-required-by
+replace-fixup-required-by:
+ @${STEP_MSG} "Fixing @pkgdep entries in dependent packages."
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ set -e; \
+ ${TEST} -f ${_REPLACE_OLDNAME_FILE} || exit 0; \
+ ${TEST} -f ${_REPLACE_NEWNAME_FILE} || exit 0; \
+ ${TEST} -f ${_REQUIRED_BY_FILE} || exit 0; \
+ oldname=`${CAT} ${_REPLACE_OLDNAME_FILE}`; \
+ newname=`${CAT} ${_REPLACE_NEWNAME_FILE}`; \
+ ${CAT} ${_REQUIRED_BY_FILE} | \
+ while read pkg; do \
+ case $$pkg in \
+ /*) pkgdir="$$pkg" ;; \
+ *) pkgdir="${_PKG_DBDIR}/$$pkg" ;; \
+ esac; \
+ contents="$$pkgdir/+CONTENTS"; \
+ newcontents="$$contents.$$$$"; \
+ ${SETENV} OLDNAME="$$oldname" NEWNAME="$$newname" \
+ ${AWK} '($$0 ~ "^@pkgdep " ENVIRON["OLDNAME"]) \
+ { print "@pkgdep " ENVIRON["NEWNAME"]; next } \
+ { print }' \
+ $$contents > $$newcontents; \
+ ${MV} -f $$newcontents $$contents; \
+ done
+
+######################################################################
+### replace-clean (PRIVATE)
+######################################################################
+### replace-clean removes the state files for the "replace" target so
+### that it may be re-invoked.
+###
+.PHONY: replace-clean
+replace-clean:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${TEST} -f ${_REPLACE_OLDNAME_FILE} || exit 0; \
+ oldname=`${CAT} ${_REPLACE_OLDNAME_FILE}`; \
+ ${RM} -f ${WRKDIR}/$$oldname${PKG_SUFX}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${TEST} -f ${_REPLACE_NEWNAME_FILE} || exit 0; \
+ newname=`${CAT} ${_REPLACE_NEWNAME_FILE}`; \
+ ${RM} -f ${WRKDIR}/$$newname${PKG_SUFX}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${RM} -f ${_REPLACE_OLDNAME_FILE} ${_REPLACE_NEWNAME_FILE} \
+ ${_REPLACE_COOKIE}
diff --git a/mk/flavor/pkg/utility.mk b/mk/flavor/pkg/utility.mk
new file mode 100644
index 00000000000..35131b91c6a
--- /dev/null
+++ b/mk/flavor/pkg/utility.mk
@@ -0,0 +1,75 @@
+# $NetBSD: utility.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+
+######################################################################
+###
+### The targets below should probably be removed from pkgsrc.
+###
+######################################################################
+
+# The 'info' target can be used to display information about a package.
+.PHONY: info
+info:
+ ${_PKG_SILENT}${_PKG_DEBUG}${PKG_INFO} "${PKGWILDCARD}"
+
+# The 'check' target can be used to check an installed package.
+.PHONY: check
+check:
+ ${_PKG_SILENT}${_PKG_DEBUG}${PKG_ADMIN} check "${PKGWILDCARD}"
+
+# The 'list' target can be used to list the files installed by a package.
+.PHONY: list
+list:
+ ${_PKG_SILENT}${_PKG_DEBUG}${PKG_INFO} -L "${PKGWILDCARD}"
+
+.PHONY: show-downlevel
+show-downlevel:
+.if defined(PKG_FAIL_REASON)
+ ${_PKG_SILENT}${_PKG_DEBUG}${DO_NADA}
+.else
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ found="`${_PKG_BEST_EXISTS} \"${PKGWILDCARD}\" || ${TRUE}`"; \
+ if [ "X$$found" != "X" -a "X$$found" != "X${PKGNAME}" ]; then \
+ ${ECHO} "${PKGBASE} package: $$found installed, pkgsrc version ${PKGNAME}"; \
+ if [ "X$$STOP_DOWNLEVEL_AFTER_FIRST" != "X" ]; then \
+ ${ECHO} "stopping after first downlevel pkg found"; \
+ exit 1; \
+ fi; \
+ fi
+.endif
+
+.PHONY: show-installed-depends
+show-installed-depends:
+.if !empty(DEPENDS)
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ for i in ${DEPENDS:C/:.*$//:Q:S/\ / /g} ; do \
+ echo "$$i =>" `${_PKG_BEST_EXISTS} "$$i"`; \
+ done
+.endif
+
+.PHONY: show-needs-update
+show-needs-update:
+.if !empty(DEPENDS)
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ for i in `${MAKE} show-all-depends-dirs`; do \
+ cd ${PKGSRCDIR}/$$i; \
+ eval `${MAKE} show-vars-eval VARS='PKGNAME:want PKGWILDCARD:wild'`; \
+ have=`${_PKG_BEST_EXISTS} "$$wild" || ${TRUE}`; \
+ if [ -z "$$have" ]; then \
+ ${ECHO} "$$i => (none) => needs install of $$want"; \
+ elif [ "$$have" != "$$want" ]; then \
+ ${ECHO} "$$i => $$have => needs update to $$want"; \
+ fi; \
+ done
+.endif
+
+.PHONY: show-pkgsrc-dir
+show-pkgsrc-dir:
+.if defined(PKG_FAIL_REASON)
+ ${_PKG_SILENT}${_PKG_DEBUG}${DO_NADA}
+.else
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ found="`${_PKG_BEST_EXISTS} \"${PKGWILDCARD}\" || ${TRUE}`"; \
+ if [ "X$$found" != "X" ]; then \
+ ${ECHO} ${PKGPATH}; \
+ fi
+.endif
diff --git a/mk/flavor/pkg/views.mk b/mk/flavor/pkg/views.mk
new file mode 100644
index 00000000000..638b803dc40
--- /dev/null
+++ b/mk/flavor/pkg/views.mk
@@ -0,0 +1,91 @@
+# $NetBSD: views.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+
+# By default, all packages attempt to link into the views.
+.if ${PKG_INSTALLATION_TYPE} == "pkgviews"
+BUILD_VIEWS?= yes
+.endif
+
+# DEFAULT_VIEW.${PKGBASE} default view for ${PKGBASE}
+# VIEWBASE base location of files at run-time
+#
+DEFAULT_VIEW.${PKGBASE}?= ${DEFAULT_VIEW}
+.if ${PKG_INSTALLATION_TYPE} == "pkgviews"
+. if empty(DEFAULT_VIEW.${PKGBASE}:M"")
+VIEWBASE= ${LOCALBASE}/${DEFAULT_VIEW.${PKGBASE}}
+. else
+VIEWBASE= ${LOCALBASE}
+. endif
+.elif ${PKG_INSTALLATION_TYPE} == "overwrite"
+VIEWBASE= ${PREFIX}
+.endif
+MAKE_ENV+= VIEWBASE=${VIEWBASE}
+
+PKGVIEWS+= ${DEFAULT_VIEW.${PKGBASE}}
+
+.if ${PKG_INSTALLATION_TYPE} == "pkgviews"
+privileged-install-hook: build-views
+.endif
+
+######################################################################
+### build-views, su-build-views (PRIVATE)
+######################################################################
+### build-views adds the package to each view in PKGVIEWS.
+###
+.PHONY: build-views su-build-views
+build-views: su-target
+ @${ECHO_MSG} "${_PKGSRC_IN}> Building views for ${PKGNAME}"
+
+su-build-views:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${MKDIR} ${LOCALBASE}; \
+ for v in "" ${PKGVIEWS}; do \
+ ${TEST} -n "$$v" || continue; \
+ case "$$v" in \
+ "") dbdir=${PKG_DBDIR}; viewname=standard ;; \
+ *) dbdir=${LOCALBASE}/$$v/.dbdir; viewname=$$v ;; \
+ esac; \
+ ${ECHO} "=> Performing package view clash check for ${PKGNAME} in $$viewname view"; \
+ pkg=`${PKG_INFO_CMD} -K $$dbdir -e ${PKGBASE} || ${TRUE}`; \
+ case "$$pkg" in \
+ "") ;; \
+ *) ${ECHO} "*** ${PKGBASE} exists in $$viewname view - package $$pkg ***"; \
+ ${ECHO} "*** Not hoisting ${PKGNAME} into $$viewname view"; \
+ continue; \
+ ;; \
+ esac; \
+ ${ECHO} "=> Performing package view overwrite check for ${PKGNAME} in $$viewname view"; \
+ dups=`${SETENV} PLIST_IGNORE_FILES=${_PLIST_IGNORE_FILES:Q} ${PKG_VIEW} --view=$$v check ${PKGNAME} || ${TRUE}`; \
+ case "$$dups" in \
+ "") ;; \
+ *) ${ECHO} "***********************************************************"; \
+ ${ECHO} "**** The following symbolic links will be overwritten *****"; \
+ for f in $$dups; do \
+ ${LS} -l ${LOCALBASE}/$$v/$$f; \
+ done; \
+ ${ECHO} "***********************************************************"; \
+ ;; \
+ esac; \
+ ${ECHO} "=> Linking package into $$viewname view"; \
+ ${SETENV} PLIST_IGNORE_FILES=${_PLIST_IGNORE_FILES:Q} ${PKG_VIEW} --view=$$v add ${PKGNAME}; \
+ done
+
+######################################################################
+### remove-views, su-remove-views (PRIVATE)
+######################################################################
+### remove-views removes the package from each view in PKGVIEWS.
+###
+.PHONY: remove-views su-remove-views
+remove-views: su-target
+ @${ECHO_MSG} "${_PKGSRC_IN}> Removing ${PKGNAME} from views"
+
+su-remove-views:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ for v in "" ${PKGVIEWS}; do \
+ ${TEST} -n "$$v" || continue; \
+ case "$$v" in \
+ "") dbdir=${PKG_DBDIR}; viewname=standard ;; \
+ *) dbdir=${LOCALBASE}/$$v/.dbdir; viewname=$$v ;; \
+ esac; \
+ ${ECHO} "=> Removing package from $$viewname view"; \
+ ${SETENV} PLIST_IGNORE_FILES=${_PLIST_IGNORE_FILES:Q} ${PKG_VIEW} --view=$$v delete ${PKGNAME}; \
+ done
diff --git a/mk/install/bsd.install-vars.mk b/mk/install/bsd.install-vars.mk
new file mode 100644
index 00000000000..ec6c429021e
--- /dev/null
+++ b/mk/install/bsd.install-vars.mk
@@ -0,0 +1,65 @@
+# $NetBSD: bsd.install-vars.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+#
+# This Makefile fragment is included by bsd.prefs.mk and defines some
+# variables which must be defined earlier than where bsd.install.mk
+# is included.
+#
+
+# If a package sets INSTALLATION_DIRS, then it's known to pre-create
+# all of the directories that it needs at install-time, so we don't need
+# mtree to do it for us.
+#
+.if defined(INSTALLATION_DIRS) && !empty(INSTALLATION_DIRS)
+NO_MTREE= yes
+.endif
+#
+# Certain classes of packages never need to run mtree during installation
+# because they manage the creation of their own directories.
+#
+.if (${PKG_INSTALLATION_TYPE} == "pkgviews") && defined(CROSSBASE)
+NO_MTREE= yes
+.endif
+.if !defined(NO_MTREE)
+USE_TOOLS+= mtree
+.endif
+
+# If MANZ is defined, then we want the final man pages to be compressed.
+# If MANZ is not defined, then we want the final man pages to be
+# uncompressed.
+#
+# We need to figure out if during installation, we need either gunzip
+# or gzip to decompress or compress the installed man pages. If a
+# package sets MANCOMPRESSED to "yes" or "no", then it's an indication
+# to the install code that the package itself installed the man pages
+# either compressed or uncompressed. If a package sets
+# MANCOMPRESSED_IF_MANZ, then the package uses BSD-style makefiles,
+# so we need to determine if the BSD-style makefile causes the man
+# pages to be compressed or not.
+#
+.if !defined(_MANCOMPRESSED)
+. if defined(MANCOMPRESSED) && !empty(MANCOMPRESSED:M[yY][eE][sS])
+_MANCOMPRESSED= yes
+. else
+_MANCOMPRESSED= no
+. endif
+. if defined(MANCOMPRESSED_IF_MANZ) && defined(PKGMAKECONF)
+_MANCOMPRESSED!= \
+ { ${ECHO} ".include \""${PKGMAKECONF:Q}"\""; \
+ ${ECHO} "all:"; \
+ ${ECHO} ".if defined(MANZ)"; \
+ ${ECHO} " @${ECHO} yes"; \
+ ${ECHO} ".else"; \
+ ${ECHO} " @${ECHO} no"; \
+ ${ECHO} ".endif"; \
+ } | ${MAKE} -f - all
+. endif
+.endif
+_MANZ= ${MANZ:Dyes:Uno}
+MAKEVARS+= _MANCOMPRESSED _MANZ
+
+.if !empty(_MANCOMPRESSED:M[yY][eE][sS]) && empty(_MANZ:M[yY][eE][sS])
+USE_TOOLS+= gunzip
+.endif
+.if empty(_MANCOMPRESSED:M[yY][eE][sS]) && !empty(_MANZ:M[yY][eE][sS])
+USE_TOOLS+= gzip
+.endif
diff --git a/mk/install/bsd.install.mk b/mk/install/bsd.install.mk
new file mode 100644
index 00000000000..2cfcb186e04
--- /dev/null
+++ b/mk/install/bsd.install.mk
@@ -0,0 +1,40 @@
+# $NetBSD: bsd.install.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+#
+# This Makefile fragment is included by bsd.pkg.mk and provides all
+# variables and targets related to installing packages.
+#
+# The following are the "public" targets provided this module:
+#
+# install, deinstall, reinstall, replace, undo-replace
+#
+# The following targets may be overridden in a package Makefile:
+#
+# pre-install, do-install, post-install
+#
+
+_INSTALL_COOKIE= ${WRKDIR}/.install_done
+
+######################################################################
+### install (PUBLIC)
+######################################################################
+### install is a public target to install the package.
+###
+.if defined(NO_INSTALL)
+.PHONY: install
+install: ${_PKGSRC_BUILD_TARGETS} install-cookie
+.else
+. include "${PKGSRCDIR}/mk/install/install.mk"
+.endif
+
+.include "${PKGSRCDIR}/mk/install/deinstall.mk"
+.include "${PKGSRCDIR}/mk/install/replace.mk"
+
+######################################################################
+### install-cookie (PRIVATE)
+######################################################################
+### install-cookie creates the "install" cookie file.
+###
+.PHONY: install-cookie
+install-cookie:
+ ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} ${PKGNAME} >> ${_INSTALL_COOKIE}
+
diff --git a/mk/install/deinstall.mk b/mk/install/deinstall.mk
new file mode 100644
index 00000000000..eccbd639911
--- /dev/null
+++ b/mk/install/deinstall.mk
@@ -0,0 +1,44 @@
+# $NetBSD: deinstall.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+
+# DEINSTALLDEPENDS controls whether dependencies and dependents are also
+# removed when a package is de-installed. The valid values are:
+#
+# no only the package is removed (if dependencies allow it)
+# yes dependent packages are also removed
+# all dependent packages and unused dependencies are also removed
+#
+DEINSTALLDEPENDS?= no
+
+######################################################################
+### deinstall, su-deinstall (PUBLIC)
+######################################################################
+### deinstall is a public target to remove an installed package.
+### It will acquire elevated privileges just-in-time.
+###
+.PHONY: deinstall su-deinstall
+deinstall: su-target
+ @${ECHO_MSG} "${_PKGSRC_IN}> Deinstalling for ${PKGNAME}"
+
+su-deinstall: deinstall-pkg install-clean
+
+MAKEFLAGS.su-deinstall= DEINSTALLDEPENDS=${DEINSTALLDEPENDS}
+
+######################################################################
+### reinstall (PUBLIC)
+######################################################################
+### reinstall is a special target to re-run the install target.
+### It will acquire elevated privileges just-in-time.
+###
+.PHONY: reinstall
+reinstall: install-clean install
+
+######################################################################
+### deinstall-pkg (PRIVATE, override)
+######################################################################
+### deinstall-pkg removes the package from the system. This should
+### be overridden per package system flavor.
+###
+.if !target(deinstall-pkg)
+deinstall-pkg:
+ @${DO_NADA}
+.endif
diff --git a/mk/install/install.mk b/mk/install/install.mk
new file mode 100644
index 00000000000..3ccfc610702
--- /dev/null
+++ b/mk/install/install.mk
@@ -0,0 +1,302 @@
+# $NetBSD: install.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+
+######################################################################
+### install (PUBLIC)
+######################################################################
+### install is a public target to install the package. It will
+### acquire elevated privileges just-in-time.
+###
+_INSTALL_TARGETS+= ${_PKGSRC_BUILD_TARGETS}
+_INSTALL_TARGETS+= acquire-install-lock
+_INSTALL_TARGETS+= ${_INSTALL_COOKIE}
+_INSTALL_TARGETS+= release-install-lock
+
+.PHONY: install
+install: ${_INSTALL_TARGETS}
+
+.PHONY: acquire-install-lock release-install-lock
+acquire-install-lock: acquire-lock
+release-install-lock: release-lock
+
+${_INSTALL_COOKIE}:
+.if !empty(INTERACTIVE_STAGE:Minstall) && defined(BATCH)
+ @${ECHO} "*** The installation stage of this package requires user interaction"
+ @${ECHO} "*** Please install manually with \"cd ${.CURDIR} && ${MAKE} install\""
+ @${TOUCH} ${_INTERACTIVE_COOKIE}
+ @${FALSE}
+.else
+ ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} real-install PKG_PHASE=install
+.endif
+
+######################################################################
+### real-install (PRIVATE)
+######################################################################
+### real-install is a helper target to set the PKG_PHASE explicitly to
+### "install" before running the remainder of the install targets.
+###
+_REAL_INSTALL_TARGETS+= install-check-version
+_REAL_INSTALL_TARGETS+= install-message
+_REAL_INSTALL_TARGETS+= install-vars
+_REAL_INSTALL_TARGETS+= unprivileged-install-hook
+_REAL_INSTALL_TARGETS+= install-all
+_REAL_INSTALL_TARGETS+= install-cookie
+
+.PHONY: real-install
+real-install: ${_REAL_INSTALL_TARGETS}
+
+.PHONY: install-message
+install-message:
+ @${ECHO_MSG} "${_PKGSRC_IN}> Installing for ${PKGNAME}"
+
+######################################################################
+### unprivileged-install-hook (PRIVATE, override, hook)
+######################################################################
+### unprivileged-install-hook is a generic hook target that is run just
+### before pkgsrc elevates privileges for install-all.
+###
+.PHONY: unprivileged-install-hook
+.if !target(unprivileged-install-hook)
+unprivileged-install-hook:
+ @${DO_NADA}
+.endif
+
+######################################################################
+### install-check-version (PRIVATE)
+######################################################################
+### install-check-version will verify that the built package located in
+### ${WRKDIR} matches the version specified in the package Makefile.
+### This is a check against stale work directories.
+###
+.PHONY: install-check-version
+install-check-version: ${_EXTRACT_COOKIE}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ extractname=`${CAT} ${_EXTRACT_COOKIE}`; \
+ pkgname=${PKGNAME}; \
+ case "$$extractname" in \
+ "") ${ECHO_MSG} "*** Warning: ${WRKDIR} may contain an older version of ${PKGBASE}" ;; \
+ "$$pkgname") ;; \
+ *) ${ECHO_MSG} "*** Warning: Package version $$extractname in ${WRKDIR}"; \
+ ${ECHO_MSG} "*** Current version $$pkgname in ${PKG_PATH}"; \
+ ${ECHO_MSG} "*** Cleaning and rebuilding $$pkgname..."; \
+ ${MAKE} clean && ${MAKE} build ;; \
+ esac
+
+######################################################################
+### The targets below are run with elevated privileges.
+######################################################################
+
+######################################################################
+### install-all, su-install-all (PRIVATE)
+######################################################################
+### install-all is a helper target to run the install target of
+### the built software, register the software installation, and run
+### some sanity checks.
+###
+.if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER)
+_INSTALL_ALL_TARGETS+= install-check-conflicts
+_INSTALL_ALL_TARGETS+= install-check-installed
+.endif
+_INSTALL_ALL_TARGETS+= install-check-umask
+.if empty(CHECK_FILES:M[nN][oO])
+_INSTALL_ALL_TARGETS+= check-files-pre
+.endif
+_INSTALL_ALL_TARGETS+= install-makedirs
+_INSTALL_ALL_TARGETS+= pre-install-script
+_INSTALL_ALL_TARGETS+= pre-install
+_INSTALL_ALL_TARGETS+= do-install
+_INSTALL_ALL_TARGETS+= post-install
+_INSTALL_ALL_TARGETS+= plist
+_INSTALL_ALL_TARGETS+= install-doc-handling
+_INSTALL_ALL_TARGETS+= install-script-data
+.if empty(CHECK_FILES:M[nN][oO])
+_INSTALL_ALL_TARGETS+= check-files-post
+.endif
+_INSTALL_ALL_TARGETS+= post-install-script
+.if !defined(NO_PKG_REGISTER)
+_INSTALL_ALL_TARGETS+= register-pkg
+.endif
+_INSTALL_ALL_TARGETS+= privileged-install-hook
+
+.if empty(CHECK_SHLIBS:M[nN][oO])
+privileged-install-hook: check-shlibs
+.endif
+.if empty(CHECK_WRKREF:M[nN][oO])
+privileged-install-hook: check-wrkref
+.endif
+.if empty(CHECK_FILES:M[nN][oO])
+privileged-install-hook: check-files
+.endif
+.if empty(CHECK_INTERPRETER:M[nN][oO])
+privileged-install-hook: check-interpreter
+.endif
+
+.PHONY: install-all su-install-all
+install-all: su-target
+su-install-all: ${_INSTALL_ALL_TARGETS}
+
+######################################################################
+### install-check-conflicts (PRIVATE, override)
+######################################################################
+### install-check-conflicts check for conflicts between the package and
+### any installed packages. This should be overridden per package
+### system flavor.
+###
+.PHONY: install-check-conflicts
+.if !target(install-check-conflicts)
+install-check-conflicts:
+ @${DO_NADA}
+.endif
+
+######################################################################
+### install-check-installed (PRIVATE, override)
+######################################################################
+### install-check-installed checks if the package (perhaps an older
+### version) is already installed on the system. This should be
+### overridden per package system flavor.
+###
+.PHONY: install-check-installed
+.if !target(install-check-installed)
+install-check-installed:
+ @${DO_NADA}
+.endif
+
+######################################################################
+### install-check-umask (PRIVATE)
+######################################################################
+### install-check-umask tests whether the umask is properly set and
+### emits a non-fatal warning otherwise.
+###
+.PHONY: install-check-umask
+install-check-umask:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ umask=`${SH} -c umask`; \
+ if ${TEST} "$$umask" -ne ${DEF_UMASK}; then \
+ ${ECHO_MSG} "${_PKGSRC_IN}> Warning: your umask is \`\`$$umask''."; \
+ ${ECHO_MSG} "If this is not desired, set it to an appropriate value (${DEF_UMASK}) and install"; \
+ ${ECHO_MSG} "this package again by \`\`${MAKE} deinstall reinstall''."; \
+ fi
+
+######################################################################
+### install-makedirs (PRIVATE)
+######################################################################
+### install-makedirs is a target to create directories expected to
+### exist prior to installation. If a package sets INSTALLATION_DIRS,
+### then it's known to pre-create all of the directories that it needs
+### at install-time, so we don't need mtree to do it for us.
+###
+MTREE_FILE?= ${PKGSRCDIR}/mk/platform/${OPSYS}.pkg.dist
+MTREE_ARGS?= -U -f ${MTREE_FILE} -d -e -p
+
+.PHONY: install-makedirs
+install-makedirs:
+ ${_PKG_SILENT}${_PKG_DEBUG}${TEST} -d ${PREFIX} || ${MKDIR} ${PREFIX}
+.if !defined(NO_MTREE)
+ ${_PKG_SILENT}${_PKG_DEBUG}${TEST} ! -f ${MTREE_FILE} || \
+ ${MTREE} ${MTREE_ARGS} ${PREFIX}/
+.endif
+.if defined(INSTALLATION_DIRS) && !empty(INSTALLATION_DIRS)
+ @${ECHO_MSG} "${_PKGSRC_IN}> Creating installation directories"
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ for dir in ${INSTALLATION_DIRS}; do \
+ case "$$dir" in \
+ ${PREFIX}/*) \
+ dir=`${ECHO} $$dir | ${SED} "s|^${PREFIX}/||"` ;; \
+ /*) continue ;; \
+ esac; \
+ case "$$dir" in \
+ *bin|*bin/*|*libexec|*libexec/*) \
+ ${INSTALL_PROGRAM_DIR} ${PREFIX}/$$dir ;; \
+ ${PKGMANDIR}/*) \
+ ${INSTALL_MAN_DIR} ${PREFIX}/$$dir ;; \
+ *) \
+ ${INSTALL_DATA_DIR} ${PREFIX}/$$dir ;; \
+ esac; \
+ done
+.endif # INSTALLATION_DIRS
+
+######################################################################
+### pre-install, do-install, post-install (PUBLIC, override)
+######################################################################
+### {pre,do,post}-install are the heart of the package-customizable
+### install targets, and may be overridden within a package Makefile.
+###
+.PHONY: pre-install do-install post-install
+
+INSTALL_DIRS?= ${BUILD_DIRS}
+INSTALL_MAKE_FLAGS?= ${MAKE_FLAGS}
+INSTALL_TARGET?= install ${USE_IMAKE:D${NO_INSTALL_MANPAGES:D:Uinstall.man}}
+
+.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 ${MAKEFILE} ${INSTALL_TARGET}
+. endfor
+.endif
+
+.if !target(pre-install)
+pre-install:
+ @${DO_NADA}
+.endif
+.if !target(post-install)
+post-install:
+ @${DO_NADA}
+.endif
+
+######################################################################
+### install-doc-handling (PRIVATE)
+######################################################################
+### install-doc-handling does automatic document (de)compression based
+### on the contents of the PLIST.
+###
+_PLIST_REGEXP.info= \
+ ^([^\/]*\/)*${PKGINFODIR}/[^/]*(\.info)?(-[0-9]+)?(\.gz)?$$
+_PLIST_REGEXP.man= \
+ ^([^/]*/)+(man[1-9ln]/[^/]*\.[1-9ln]|cat[1-9ln]/[^/]*\.[0-9])(\.gz)?$$
+
+_DOC_COMPRESS= \
+ ${SETENV} PATH=${PATH:Q} \
+ MANZ=${_MANZ} \
+ PKG_VERBOSE=${PKG_VERBOSE} \
+ TEST=${TOOLS_TEST:Q} \
+ ${SH} ${PKGSRCDIR}/mk/plist/doc-compress ${PREFIX}
+
+.PHONY: install-doc-handling
+install-doc-handling: plist
+ @${ECHO_MSG} "${_PKGSRC_IN}> [Automatic manual page handling]"
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${PLIST} | ${GREP} -v "^@" | \
+ ${EGREP} ${_PLIST_REGEXP.man:Q} | ${_DOC_COMPRESS}
+
+######################################################################
+### register-pkg (PRIVATE, override)
+######################################################################
+### register-pkg registers the package as being installed on the system.
+###
+.PHONY: register-pkg
+.if !target(register-pkg)
+register-pkg:
+ @${DO_NADA}
+.endif
+
+######################################################################
+### privileged-install-hook (PRIVATE, override, hook)
+######################################################################
+### privileged-install-hook is a generic hook target that is run just
+### before pkgsrc drops elevated privileges.
+###
+.PHONY: privileged-install-hook
+.if !target(privileged-install-hook)
+privileged-install-hook:
+ @${DO_NADA}
+.endif
+
+######################################################################
+### install-clean (PRIVATE)
+######################################################################
+### install-clean removes the state files for the "install" and
+### later phases so that the "install" target may be re-invoked.
+###
+install-clean: package-clean check-clean
+ ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${PLIST} ${_INSTALL_COOKIE}
diff --git a/mk/install/replace.mk b/mk/install/replace.mk
new file mode 100644
index 00000000000..18623adf950
--- /dev/null
+++ b/mk/install/replace.mk
@@ -0,0 +1,59 @@
+# $NetBSD: replace.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+
+######################################################################
+### replace (PUBLIC)
+######################################################################
+### replace is a public target to update a package in-place on the
+### system. It will acquire elevated privileges just-in-time.
+###
+_REPLACE_TARGETS+= ${_PKGSRC_BUILD_TARGETS}
+_REPLACE_TARGETS+= replace-message
+_REPLACE_TARGETS+= unprivileged-install-hook
+
+.PHONY: replace su-replace
+replace: ${_REPLACE_TARGETS} su-target
+
+replace-message:
+ @${ECHO_MSG} "${_PKGSRC_IN}> Replacing for ${PKGNAME}"
+ @${WARNING_MSG} "experimental target - DATA LOSS MAY OCCUR."
+
+su-replace: replace-pkg
+MAKEFLAGS.su-replace= UPDATE_RUNNING=yes
+
+######################################################################
+### undo-replace (PUBLIC)
+######################################################################
+### undo-replace is a public target to undo the effects of the
+### "replace" target. It will acquire elevated privileges just-in-time.
+###
+.PHONY: undo-replace su-undo-replace
+undo-replace: undo-replace-message su-target
+
+undo-replace-message:
+ @${ECHO_MSG} "${_PKGSRC_IN}> Undoing replacement for ${PKGNAME}"
+ @${WARNING_MSG} "experimental target - DATA LOSS MAY OCCUR."
+
+su-undo-replace: undo-replace-pkg
+MAKEFLAGS.su-undo-replace= UPDATE_RUNNING=yes
+
+######################################################################
+### replace-pkg (PRIVATE, override)
+######################################################################
+### replace-pkg updates a package in-place on the system. This should
+### be overridden per package system flavor.
+###
+.if !target(replace-pkg)
+replace-pkg:
+ @${DO_NADA}
+.endif
+
+######################################################################
+### undo-replace-pkg (PRIVATE, override)
+######################################################################
+### undo-replace-pkg undoes a "make replace". This should be overridden
+### per package system flavor.
+###
+.if !target(undo-replace-pkg)
+undo-replace-pkg:
+ @${DO_NADA}
+.endif
diff --git a/mk/package/bsd.package.mk b/mk/package/bsd.package.mk
new file mode 100644
index 00000000000..d37a9433dc8
--- /dev/null
+++ b/mk/package/bsd.package.mk
@@ -0,0 +1,45 @@
+# $NetBSD: bsd.package.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+#
+# This Makefile fragment is included by bsd.pkg.mk and provides all
+# variables and targets related to binary packages.
+#
+# The following are the "public" targets provided by this module:
+#
+# package, repackage
+#
+
+_PACKAGE_COOKIE= ${WRKDIR}/.package_done
+
+######################################################################
+### package (PUBLIC)
+######################################################################
+### package is a public target to generate a binary package.
+###
+.if defined(NO_PACKAGE)
+.PHONY: package
+package: install
+. if defined(SKIP_SILENT)
+ @${DO_NADA}
+. else
+ @${ECHO_MSG} "${_PKGSRC_IN}> ${PKGNAME} may not be packaged: "${NO_PACKAGE:Q}"."
+. endif
+.else
+. include "${PKGSRCDIR}/mk/package/package.mk"
+.endif
+
+######################################################################
+### repackage (PUBLIC)
+######################################################################
+### repackage is a special target to re-run the package target.
+###
+.PHONY: repackage
+repackage: package-clean package
+
+######################################################################
+### package-clean (PRIVATE)
+######################################################################
+### package-clean removes the state files associated with the "package"
+### phase so that the "package" target may be re-invoked.
+###
+package-clean:
+ ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${_PACKAGE_COOKIE}
diff --git a/mk/package/package.mk b/mk/package/package.mk
new file mode 100644
index 00000000000..58617b7eef8
--- /dev/null
+++ b/mk/package/package.mk
@@ -0,0 +1,109 @@
+# $NetBSD: package.mk,v 1.1 2006/06/03 23:11:42 jlam Exp $
+
+_PACKAGE_COOKIE= ${WRKDIR}/.package_done
+
+######################################################################
+### package (PUBLIC)
+######################################################################
+### package is a public target to generate a binary package. It will
+### acquire elevated privileges just-in-time.
+###
+_PACKAGE_TARGETS+= install
+_PACKAGE_TARGETS+= acquire-package-lock
+_PACKAGE_TARGETS+= ${_PACKAGE_COOKIE}
+_PACKAGE_TARGETS+= release-package-lock
+
+.PHONY: package
+package: ${_PACKAGE_TARGETS}
+
+.PHONY: acquire-package-lock release-package-lock
+acquire-package-lock: acquire-lock
+release-package-lock: release-lock
+
+${_PACKAGE_COOKIE}:
+ ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} real-package PKG_PHASE=package
+
+######################################################################
+### real-package (PRIVATE)
+######################################################################
+### real-package is a helper target to set the PKG_PHASE explicitly to
+### "package" before running the remainder of the package targets.
+###
+.PHONY: real-package
+real-package: package-message package-all package-cookie
+
+.PHONY: package-message
+package-message:
+ @${ECHO_MSG} "${_PKGSRC_IN}> Building binary package for ${PKGNAME}"
+
+######################################################################
+### package-cookie (PRIVATE)
+######################################################################
+### package-cookie creates the "package" cookie file
+###
+.PHONY: package-cookie
+package-cookie:
+ ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} ${PKGNAME} >> ${_PACKAGE_COOKIE}
+
+######################################################################
+### The targets below are run with elevated privileges.
+######################################################################
+
+######################################################################
+### package-all, su-package-all (PRIVATE)
+######################################################################
+### package-all is a helper target to create the binary package and
+### generate any necessary warnings.
+###
+_PACKAGE_ALL_TARGETS+= package-check-installed
+_PACKAGE_ALL_TARGETS+= package-create
+_PACKAGE_ALL_TARGETS+= package-warnings
+
+.PHONY: package-all su-package-all
+package-all: su-target
+su-package-all: ${_PACKAGE_ALL_TARGETS}
+
+######################################################################
+### package-check-installed (PRIVATE, override)
+######################################################################
+### package-check-installed verifies that the package is installed on
+### the system. This should be overridden per package system flavor.
+###
+.if !target(package-check-installed)
+.PHONY: package-check-installed
+package-check-installed:
+ @${DO_NADA}
+.endif
+
+######################################################################
+### package-create (PRIVATE, override)
+######################################################################
+### package-create creates the binary package. This should be overridden
+### per package system flavor.
+###
+.if !target(package-create)
+.PHONY: package-create
+package-create:
+ @${DO_NADA}
+.endif
+
+######################################################################
+### package-warnings (PRIVATE)
+######################################################################
+### package-warnings displays warnings about the binary package.
+###
+.PHONY: package-warnings
+package-warnings:
+.if defined(NO_BIN_ON_CDROM)
+ @${ECHO_MSG} "${_PKGSRC_IN}> Warning: ${PKGNAME} may not be put on a CD-ROM:"
+ @${ECHO_MSG} "${_PKGSRC_IN}> " ${NO_BIN_ON_CDROM:Q}
+.endif
+.if defined(NO_BIN_ON_FTP)
+ @${ECHO_MSG} "${_PKGSRC_IN}> Warning: ${PKGNAME} may not be made available through FTP:"
+ @${ECHO_MSG} "${_PKGSRC_IN}> " ${NO_BIN_ON_FTP:Q}
+.endif
+.if defined(ABI_DEPENDS) && !empty(USE_ABI_DEPENDS:M[Nn][Oo])
+ @${ECHO_MSG} "${_PKGSRC_IN}> Warning: ABI dependency recommendations are being ignored!"
+ @${ECHO_MSG} "${_PKGSRC_IN}> ${PKGNAME} should not be uploaded nor"
+ @${ECHO_MSG} "${_PKGSRC_IN}> otherwise be used as a binary package!"
+.endif
diff --git a/mk/pkginstall/bsd.pkginstall.mk b/mk/pkginstall/bsd.pkginstall.mk
index 22182d62087..613cf67a81f 100644
--- a/mk/pkginstall/bsd.pkginstall.mk
+++ b/mk/pkginstall/bsd.pkginstall.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkginstall.mk,v 1.1 2006/05/21 23:50:15 jlam Exp $
+# $NetBSD: bsd.pkginstall.mk,v 1.2 2006/06/03 23:11:43 jlam Exp $
#
# This Makefile fragment is included by bsd.pkg.mk and implements the
# common INSTALL/DEINSTALL scripts framework. To use the pkginstall
@@ -27,6 +27,11 @@ _ZERO_FILESIZE_P= ${AWK} 'END { exit NR ? 1 : 0; }'
_PKGINSTALL_DIR= ${WRKDIR}/.pkginstall
+# XXX This should not be duplicated from the install module, but we
+# XXX need this until pkginstall is refactored.
+# XXX
+PKG_DB_TMPDIR?= ${WRKDIR}/.pkgdb/${PKGNAME}
+
# These are the template scripts for the INSTALL/DEINSTALL scripts.
# Packages may do additional work in the INSTALL/DEINSTALL scripts by
# overriding the variables DEINSTALL_TEMPLATE and INSTALL_TEMPLATE to
diff --git a/mk/plist/plist.mk b/mk/plist/plist.mk
index c7c7b757da6..fa4b04e5314 100644
--- a/mk/plist/plist.mk
+++ b/mk/plist/plist.mk
@@ -1,4 +1,4 @@
-# $NetBSD: plist.mk,v 1.11 2006/04/17 06:30:48 jlam Exp $
+# $NetBSD: plist.mk,v 1.12 2006/06/03 23:11:43 jlam Exp $
#
# This Makefile fragment handles the creation of PLISTs for use by
# pkg_create(8).
@@ -226,6 +226,7 @@ plist: ${PLIST}
${PLIST}: ${PLIST_SRC}
.endif
${PLIST}:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
${_PKG_SILENT}${_PKG_DEBUG} \
{ ${_GENERATE_PLIST} } | \
${SETENV} ${_PLIST_AWK_ENV} ${AWK} ${_PLIST_AWK} | \
diff --git a/mk/reduce-depends.mk b/mk/reduce-depends.mk
deleted file mode 100644
index 28cd8d929c1..00000000000
--- a/mk/reduce-depends.mk
+++ /dev/null
@@ -1,128 +0,0 @@
-# $NetBSD: reduce-depends.mk,v 1.3 2005/10/09 08:48:44 rillig Exp $
-#
-# Copyright (c) 2004 The NetBSD Foundation, Inc.
-# All rights reserved.
-#
-# This code is derived from software contributed to The NetBSD Foundation
-# by Johnny C. Lam.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 3. All advertising materials mentioning features or use of this software
-# must display the following acknowledgement:
-# This product includes software developed by the NetBSD
-# Foundation, Inc. and its contributors.
-# 4. Neither the name of The NetBSD Foundation nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
-# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
-# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-
-# This Makefile fragment takes the dependencies listed in ${DEPENDS} and
-# creates a smaller set of dependencies in ${REDUCED_DEPENDS} that imply
-# the same dependency relationships as ${DEPENDS}.
-
-# We skip the dependency calculation for some phases since they never
-# use the dependency information. In these cases, ${REDUCED_DEPENDS}
-# is simply empty.
-#
-_PHASES_SKIP_DEPENDS= fetch patch tools wrapper configure build test
-.if !empty(_PHASES_SKIP_DEPENDS:M${PKG_PHASE})
-_DEPENDS= # empty
-.else
-_DEPENDS= ${DEPENDS}
-.endif
-
-# _DEPENDS_PKGPATHS contains the full physical paths to the pkgsrc
-# directories for dependencies.
-# _DEPENDS_PKGPATH.<relpkgpath> maps <relpkgpath> to the full physical path.
-# _DEPENDS.<physpkgpath> is a list of the wildcard dependencies associated
-# with <physpkgpath>.
-#
-_DEPENDS_PKGPATHS= # empty
-.for _dep_ in ${_DEPENDS}
-. for _depdir_ in ${_dep_:C/^[^:]*://:C/:.*$//}
-. if !defined(_DEPENDS_PKGPATH.${_depdir_})
-. if exists(${_depdir_})
-_DEPENDS_PKGPATH.${_depdir_}!= cd ${_depdir_:Q} && ${PWD_CMD}
-. else
-PKG_FAIL_REASON+= "[reduce-depends.mk] "${PKGPATH:Q}" depends on "${_depdir_:Q}", but the latter does not exist."
-. endif
-. endif
-_DEPENDS_PKGPATH.${_DEPENDS_PKGPATH.${_depdir_}}?= ${_depdir_}
-_DEPENDS.${_DEPENDS_PKGPATH.${_depdir_}}+= ${_dep_:C/:.*$//}
-. if empty(_DEPENDS_PKGPATHS:M${_DEPENDS_PKGPATH.${_depdir_}})
-_DEPENDS_PKGPATHS+= ${_DEPENDS_PKGPATH.${_depdir_}}
-. endif
-. endfor
-.endfor
-
-# This next block of code sets REDUCED_DEPENDS to the strictest set of
-# dependencies it can derive from all of ${_DEPENDS.<path>}. It only
-# understands dependencies of the form foo>=1.0, and leaves the other
-# dependencies undisturbed.
-#
-# The algorithm takes dependencies of the form foo>=1.0 and converts
-# them to foo-1.0. It then compares this pkg name against each
-# dependency to see if it satisfies them all. The key fact is the
-# the strictest dependency, when converted to a pkg name, will satisfy
-# every dependency.
-#
-REDUCED_DEPENDS= # empty
-.for _path_ in ${_DEPENDS_PKGPATHS}
-_GE_DEPENDS.${_path_}= ${_DEPENDS.${_path_}:N*\{*:M*>=[0-9]*}
-_STRICTEST_DEPENDS.${_path_}?= none
-. for _depend_ in ${_GE_DEPENDS.${_path_}}
-. for _dep2pkg_ in ${_depend_:S/>=/-/}
-. if ${_STRICTEST_DEPENDS.${_path_}} == "none"
-_SATISFIES_DEPENDS.${_path_}= YES
-. for _dep_ in ${_GE_DEPENDS.${_path_}}
-. if !empty(_SATISFIES_DEPENDS.${_path_}:M[yY][eE][sS])
-_SATISFIES_DEPENDS.${_path_}!= \
- if ${PKG_ADMIN} pmatch '${_dep_}' ${_dep2pkg_}; then \
- ${ECHO} "YES"; \
- else \
- ${ECHO} "NO"; \
- fi
-. endif
-. endfor
-. if !empty(_SATISFIES_DEPENDS.${_path_}:M[yY][eE][sS])
-_STRICTEST_DEPENDS.${_path_}= ${_depend_}
-. endif
-. endif
-. endfor
-. endfor
-. if ${_STRICTEST_DEPENDS.${_path_}} == "none"
-#
-# The dependencies simply conflict, so just pass them on through to the
-# normal dependency handling code.
-#
-. for _depend_ in ${_DEPENDS.${_path_}}
-REDUCED_DEPENDS+= ${_depend_}:${_DEPENDS_PKGPATH.${_path_}}
-. endfor
-. else
-. for _depend_ in ${_DEPENDS.${_path_}}
-. if empty(_GE_DEPENDS.${_path_}:M${_depend_})
-REDUCED_DEPENDS+= ${_depend_}:${_DEPENDS_PKGPATH.${_path_}}
-. endif
-. endfor
-REDUCED_DEPENDS+= ${_STRICTEST_DEPENDS.${_path_}}:${_DEPENDS_PKGPATH.${_path_}}
-. endif
-.endfor