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/bsd.pkg.update.mk | |
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/bsd.pkg.update.mk')
-rw-r--r-- | mk/bsd.pkg.update.mk | 127 |
1 files changed, 127 insertions, 0 deletions
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} |