diff options
author | jlam <jlam@pkgsrc.org> | 2006-06-03 23:11:42 +0000 |
---|---|---|
committer | jlam <jlam@pkgsrc.org> | 2006-06-03 23:11:42 +0000 |
commit | da00355ef9f0ccdb29bf7fc00bdd973c5a3e99ef (patch) | |
tree | bfe84ef2dbbdd59b31ae6e0df262c47f9ad1b342 /mk/flavor | |
parent | febe86b50d11bbb909b34c883a9e53ed72350e40 (diff) | |
download | pkgsrc-da00355ef9f0ccdb29bf7fc00bdd973c5a3e99ef.tar.gz |
First pass at implementing support for package system flavors other
than pkgsrc's current one. This is an important lead-up to any project
that redesigns the pkg_* tools in that it doesn't tie us to past design
(mis)choices. This commit mostly deals with rearranging code, although
there was a considerable amount of rewriting done in cases where I
thought the code was somewhat messy and was difficult to understand.
The design I chose for supporting multiple package system flavors is
that the various depends, install, package, etc. modules would define
default targets and variables that may be overridden in files from
pkgsrc/mk/flavor/${PKG_FLAVOR}. The default targets would do the
sensible thing of doing nothing, and pkgsrc infrastructure would rely
on the appropriate things to be defined in pkgsrc/mk/flavor to do the
real work. The pkgsrc/mk/flavor directory contains subdirectories
corresponding to each package system flavor that we support. Currently,
I only have "pkg" which represents the current pkgsrc-native package
flavor. I've separated out most of the code where we make assumptions
about the package system flavor, mostly either because we directly
use the pkg_* tools, or we make assumptions about the package meta-data
directory, or we directly manipulate the package meta-data files, and
placed it into pkgsrc/mk/flavor/pkg.
There are several new modules that have been refactored out of bsd.pkg.mk
as part of these changes: check, depends, install, package, and update.
Each of these modules has been slimmed down by rewriting them to avoid
some recursive make calls. I've also religiously documented which
targets are "public" and which are "private" so that users won't rely
on reaching into pkgsrc innards to call a private target.
The "depends" module is a complete overhaul of the way that we handle
dependencies. There is now a separate "depends" phase that occurs
before the "extract" phase where dependencies are installed. This
differs from the old way where dependencies were installed just before
extraction occurred. The reduce-depends.mk file is now replaced by
a script that is invoked only once during the depends phase and is
used to generate a cookie file that holds the full set of reduced
dependencies. It is now possible to type "make depends" in a package
directory and all missing dependencies will be installed.
Future work on this project include:
* Resolve the workflow design in anticipation of future work on
staged installations where "package" conceptually happens before
"install".
* Rewrite the buildlink3 framework to not assume the use of the
pkgsrc pkg_* tools.
* Rewrite the pkginstall framework to provide a standard pkg_*
tool to perform the actions, and allowing a purely declarative
file per package to describe what actions need to be taken at
install or deinstall time.
* Implement support for the SVR4 package flavor. This will be
proof that the appropriate abstractions are in place to allow
using a completely different set of package management tools.
Diffstat (limited to 'mk/flavor')
-rw-r--r-- | mk/flavor/bsd.flavor-vars.mk | 11 | ||||
-rw-r--r-- | mk/flavor/bsd.flavor.mk | 7 | ||||
-rw-r--r-- | mk/flavor/pkg/check.mk | 27 | ||||
-rw-r--r-- | mk/flavor/pkg/deinstall.mk | 50 | ||||
-rw-r--r-- | mk/flavor/pkg/depends.mk | 109 | ||||
-rw-r--r-- | mk/flavor/pkg/flavor-vars.mk | 78 | ||||
-rw-r--r-- | mk/flavor/pkg/flavor.mk | 21 | ||||
-rw-r--r-- | mk/flavor/pkg/install.mk | 77 | ||||
-rw-r--r-- | mk/flavor/pkg/metadata.mk | 404 | ||||
-rw-r--r-- | mk/flavor/pkg/package.mk | 110 | ||||
-rwxr-xr-x | mk/flavor/pkg/reduce-depends.awk | 141 | ||||
-rwxr-xr-x | mk/flavor/pkg/register-dependencies | 54 | ||||
-rw-r--r-- | mk/flavor/pkg/replace.mk | 173 | ||||
-rw-r--r-- | mk/flavor/pkg/utility.mk | 75 | ||||
-rw-r--r-- | mk/flavor/pkg/views.mk | 91 |
15 files changed, 1428 insertions, 0 deletions
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 |