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 | e5eb2c56afcaf66f9ed3c7848573a343132b82b0 (patch) | |
tree | bfe84ef2dbbdd59b31ae6e0df262c47f9ad1b342 /mk/package | |
parent | 318cea5cbda9aa49ead151bb7ecfa2b8c8d51632 (diff) | |
download | pkgsrc-e5eb2c56afcaf66f9ed3c7848573a343132b82b0.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/package')
-rw-r--r-- | mk/package/bsd.package.mk | 45 | ||||
-rw-r--r-- | mk/package/package.mk | 109 |
2 files changed, 154 insertions, 0 deletions
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 |