summaryrefslogtreecommitdiff
path: root/mk/flavor/pkg/utility.mk
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2006-06-03 23:11:42 +0000
committerjlam <jlam@pkgsrc.org>2006-06-03 23:11:42 +0000
commitda00355ef9f0ccdb29bf7fc00bdd973c5a3e99ef (patch)
treebfe84ef2dbbdd59b31ae6e0df262c47f9ad1b342 /mk/flavor/pkg/utility.mk
parentfebe86b50d11bbb909b34c883a9e53ed72350e40 (diff)
downloadpkgsrc-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/pkg/utility.mk')
-rw-r--r--mk/flavor/pkg/utility.mk75
1 files changed, 75 insertions, 0 deletions
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