summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2006-03-14 01:14:26 +0000
committerjlam <jlam@pkgsrc.org>2006-03-14 01:14:26 +0000
commitdaad0f3d6ce8b344ce91e35e98ea05abf8e03f2d (patch)
tree2d76c0a00d07e0939789aa971b834f332c4820c3 /mk
parentb1472309671a67b16cab03410ae83bb9d6007baa (diff)
downloadpkgsrc-daad0f3d6ce8b344ce91e35e98ea05abf8e03f2d.tar.gz
Modify the pkginstall framework so that it manages all aspects of
INSTALL/DEINSTALL script creation within pkgsrc. If an INSTALL or DEINSTALL script is found in the package directory, it is automatically used as a template for the pkginstall-generated scripts. If instead, they should be used simply as the full scripts, then the package Makefile should set INSTALL_SRC or DEINSTALL_SRC explicitly, e.g.: INSTALL_SRC= ${PKGDIR}/INSTALL DEINSTALL_SRC= # emtpy As part of the restructuring of the pkginstall framework internals, we now *always* generate temporary INSTALL or DEINSTALL scripts. By comparing these temporary scripts with minimal INSTALL/DEINSTALL scripts formed from only the base templates, we determine whether or not the INSTALL/DEINSTALL scripts are actually needed by the package (see the generate-install-scripts target in bsd.pkginstall.mk). In addition, more variables in the framework have been made private. The *_EXTRA_TMPL variables have been renamed to *_TEMPLATE, which are more sensible names given the very few exported variables in this framework. The only public variables relating to the templates are: INSTALL_SRC INSTALL_TEMPLATE DEINSTALL_SRC DEINSTALL_TEMPLATE HEADER_TEMPLATE The packages in pkgsrc have been modified to reflect the changes in the pkginstall framework.
Diffstat (limited to 'mk')
-rw-r--r--mk/alternatives.mk6
-rw-r--r--mk/bsd.pkg.mk37
-rw-r--r--mk/install/bsd.pkginstall.mk216
3 files changed, 125 insertions, 134 deletions
diff --git a/mk/alternatives.mk b/mk/alternatives.mk
index c5293237fa1..aa1866ed359 100644
--- a/mk/alternatives.mk
+++ b/mk/alternatives.mk
@@ -1,4 +1,4 @@
-# $NetBSD: alternatives.mk,v 1.5 2005/12/29 06:22:26 jlam Exp $
+# $NetBSD: alternatives.mk,v 1.6 2006/03/14 01:14:35 jlam Exp $
#
# This Makefile fragment handles the alternatives system, registering a
# package in the database.
@@ -49,8 +49,8 @@ EVAL_PREFIX+= PREFIX.pkg_alternatives=pkg_alternatives
PREFIX.alternatives_DEFAULT= ${LOCALBASE}
PKG_ALTERNATIVES= ${PREFIX.pkg_alternatives}/sbin/pkg_alternatives
-INSTALL_EXTRA_TMPL+= ${WRKDIR}/.altinstall
-DEINSTALL_EXTRA_TMPL+= ${WRKDIR}/.altdeinstall
+INSTALL_TEMPLATE+= ${WRKDIR}/.altinstall
+DEINSTALL_TEMPLATE+= ${WRKDIR}/.altdeinstall
.endif
diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk
index 3a24e0a68ec..35deb3a15ee 100644
--- a/mk/bsd.pkg.mk
+++ b/mk/bsd.pkg.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.mk,v 1.1806 2006/03/12 14:55:18 rillig Exp $
+# $NetBSD: bsd.pkg.mk,v 1.1807 2006/03/14 01:14:35 jlam Exp $
#
# This file is in the public domain.
#
@@ -420,18 +420,9 @@ SCRIPTS_ENV+= ${INSTALL_MACROS}
#
.include "../../mk/alternatives.mk"
+# INSTALL/DEINSTALL script framework
.include "../../mk/install/bsd.pkginstall.mk"
-# Set INSTALL_FILE to be the name of any INSTALL file
-.if !defined(INSTALL_FILE) && exists(${PKGDIR}/INSTALL)
-INSTALL_FILE= ${PKGDIR}/INSTALL
-.endif
-
-# Set DEINSTALL_FILE to be the name of any DEINSTALL file
-.if !defined(DEINSTALL_FILE) && exists(${PKGDIR}/DEINSTALL)
-DEINSTALL_FILE= ${PKGDIR}/DEINSTALL
-.endif
-
# 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.
#
@@ -512,8 +503,12 @@ PKG_ARGS_COMMON+= -P "`${MAKE} ${MAKEFLAGS} run-depends-list | ${SORT} -u`"
. if defined(CONFLICTS) && (${PKG_INSTALLATION_TYPE} == "overwrite")
PKG_ARGS_COMMON+= -C "${CONFLICTS}"
. endif
-PKG_ARGS_COMMON+= ${INSTALL_FILE:D-i ${INSTALL_FILE}}
-PKG_ARGS_COMMON+= ${DEINSTALL_FILE:D-k ${DEINSTALL_FILE}}
+. 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}}
@@ -2334,7 +2329,7 @@ do-su-undo-replace:
# Empty pre-* and post-* targets
-.for name in fetch tools wrapper configure build test install-script install package
+.for name in fetch tools wrapper configure build test install package
. if !target(pre-${name})
pre-${name}:
@@ -3562,20 +3557,6 @@ post-install-fake-pkg: ${PLIST} ${DESCR} ${MESSAGE}
case ${PKG_INSTALLATION_TYPE} in \
pkgview) ${TOUCH} ${PKG_DB_TMPDIR}/+VIEWS ;; \
esac
- ${_PKG_SILENT}${_PKG_DEBUG} \
- case "${INSTALL_FILE}" in \
- ${PKG_DB_TMPDIR}/*|"") ;; \
- *) if ${TEST} -f ${INSTALL_FILE}; then \
- ${CP} ${INSTALL_FILE} ${PKG_DB_TMPDIR}/+INSTALL; \
- fi ;; \
- esac
- ${_PKG_SILENT}${_PKG_DEBUG} \
- case "${DEINSTALL_FILE}" in \
- ${PKG_DB_TMPDIR}/*|"") ;; \
- *) if ${TEST} -f ${DEINSTALL_FILE}; then \
- ${CP} ${DEINSTALL_FILE} ${PKG_DB_TMPDIR}/+DEINSTALL; \
- fi ;; \
- esac
${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${SIZE_PKG_FILE} ${SIZE_ALL_FILE}
. if ${SHLIB_HANDLING} == "YES" && ${CHECK_SHLIBS} == "YES"
${_PKG_SILENT}${_PKG_DEBUG} \
diff --git a/mk/install/bsd.pkginstall.mk b/mk/install/bsd.pkginstall.mk
index 2eeb3624c5b..8b73c9942a9 100644
--- a/mk/install/bsd.pkginstall.mk
+++ b/mk/install/bsd.pkginstall.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkginstall.mk,v 1.39 2006/03/10 23:36:08 jlam Exp $
+# $NetBSD: bsd.pkginstall.mk,v 1.40 2006/03/14 01:14:36 jlam Exp $
#
# This Makefile fragment is included by bsd.pkg.mk and implements the
# common INSTALL/DEINSTALL scripts framework. To use the pkginstall
@@ -6,51 +6,6 @@
# scripts to the package.
#
-# _PKGINSTALL_VARS is a list of the variables that, if non-empty, indicate
-# that the pkginstall framework should be used. These variables
-# should be extracted from bsd.pkginstall.mk and are typically the
-# variables named in the _INSTALL_<SCRIPT>_MEMBERS lists.
-#
-# USE_PKGINSTALL may be set to "yes" to force the pkginstall framework
-# to be used.
-#
-_PKGINSTALL_VARS+= HEADER_EXTRA_TMPL
-_PKGINSTALL_VARS+= DEINSTALL_EXTRA_TMPL
-_PKGINSTALL_VARS+= INSTALL_EXTRA_TMPL
-_PKGINSTALL_VARS+= DEINSTALL_SRC INSTALL_SRC
-
-_PKGINSTALL_VARS+= PKG_GROUPS PKG_USERS
-_PKGINSTALL_VARS+= SPECIAL_PERMS
-_PKGINSTALL_VARS+= CONF_FILES CONF_FILES_PERMS \
- REQD_FILES REQD_FILES_PERMS \
- RCD_SCRIPTS
-_PKGINSTALL_VARS+= INFO_FILES
-_PKGINSTALL_VARS+= MAKE_DIRS MAKE_DIRS_PERMS \
- REQD_DIRS REQD_DIRS_PERMS \
- OWN_DIRS OWN_DIRS_PERMS
-_PKGINSTALL_VARS+= PKG_SHELL
-_PKGINSTALL_VARS+= FONTS_DIRS.ttf FONTS_DIRS.type1 FONTS_DIRS.x11
-
-# CONF_DEPENDS notes a dependency where the config directory for the
-# package matches the dependency's config directory. CONF_DEPENDS is
-# only meaningful if PKG_INSTALLATION_TYPE is "pkgviews".
-#
-_PKGINSTALL_VARS+= CONF_DEPENDS
-
-.if defined(USE_PKGINSTALL) && !empty(USE_PKGINSTALL:M[yY][eE][sS])
-_USE_PKGINSTALL= yes
-.else
-_USE_PKGINSTALL= no
-.endif
-
-.if !empty(_USE_PKGINSTALL:M[nN][oO])
-. for _var_ in ${_PKGINSTALL_VARS}
-. if defined(${_var_}) && !empty(${_var_}:M*)
-_USE_PKGINSTALL= yes
-. endif
-. endfor
-.endif
-
# The Solaris /bin/sh does not know the ${foo#bar} shell substitution.
# This shell function serves a similar purpose, but is specialized on
# stripping ${PREFIX}/ from a pathname.
@@ -65,49 +20,68 @@ _FUNC_STRIP_PREFIX= \
}' s="$$1" prefix=${PREFIX:Q}/ /dev/null; \
}
-# 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_EXTRA_TMPL and INSTALL_EXTRA_TMPL to point to
-# additional script fragments. These bits are included after the main
-# install/deinstall script fragments.
+# 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
+# point to additional script fragments. These bits are included after
+# the main install/deinstall script fragments.
#
_HEADER_TMPL?= ${.CURDIR}/../../mk/install/header
-.if !defined(HEADER_EXTRA_TMPL) && exists(${.CURDIR}/HEADER)
-HEADER_EXTRA_TMPL?= ${.CURDIR}/HEADER
-.else
-HEADER_EXTRA_TMPL?= # empty
+HEADER_TEMPLATE?= # empty
+.if exists(${PKGDIR}/HEADER) && \
+ empty(HEADER_TEMPLATE:M${PKGDIR}/HEADER)
+HEADER_TEMPLATE+= ${PKGDIR}/HEADER
.endif
_DEINSTALL_PRE_TMPL?= ${.CURDIR}/../../mk/install/deinstall-pre
-DEINSTALL_EXTRA_TMPL?= # empty
+DEINSTALL_TEMPLATE?= # empty
+.if exists(${PKGDIR}/DEINSTALL) && \
+ empty(DEINSTALL_TEMPLATE:M${PKGDIR}/DEINSTALL)
+DEINSTALL_TEMPLATE+= ${PKGDIR}/DEINSTALL
+.endif
_DEINSTALL_TMPL?= ${.CURDIR}/../../mk/install/deinstall
_INSTALL_UNPACK_TMPL?= # empty
_INSTALL_TMPL?= ${.CURDIR}/../../mk/install/install
-INSTALL_EXTRA_TMPL?= # empty
+INSTALL_TEMPLATE?= # empty
+.if exists(${PKGDIR}/INSTALL) && \
+ empty(INSTALL_TEMPLATE:M${PKGDIR}/INSTALL)
+INSTALL_TEMPLATE+= ${PKGDIR}/INSTALL
+.endif
_INSTALL_POST_TMPL?= ${.CURDIR}/../../mk/install/install-post
_FOOTER_TMPL?= ${.CURDIR}/../../mk/install/footer
-# DEINSTALL_TEMPLATES and INSTALL_TEMPLATES are the default list of source
-# files that are concatenated to form the DEINSTALL/INSTALL scripts.
-#
-DEINSTALL_TEMPLATES= ${_HEADER_TMPL}
-DEINSTALL_TEMPLATES+= ${HEADER_EXTRA_TMPL}
-DEINSTALL_TEMPLATES+= ${_DEINSTALL_PRE_TMPL}
-DEINSTALL_TEMPLATES+= ${DEINSTALL_EXTRA_TMPL}
-DEINSTALL_TEMPLATES+= ${_DEINSTALL_TMPL}
-DEINSTALL_TEMPLATES+= ${_FOOTER_TMPL}
-INSTALL_TEMPLATES= ${_HEADER_TMPL}
-INSTALL_TEMPLATES+= ${HEADER_EXTRA_TMPL}
-INSTALL_TEMPLATES+= ${_INSTALL_UNPACK_TMPL}
-INSTALL_TEMPLATES+= ${_INSTALL_TMPL}
-INSTALL_TEMPLATES+= ${INSTALL_EXTRA_TMPL}
-INSTALL_TEMPLATES+= ${_INSTALL_POST_TMPL}
-INSTALL_TEMPLATES+= ${_FOOTER_TMPL}
+# _DEINSTALL_TEMPLATES and _INSTALL_TEMPLATES are the list of source
+# files that are concatenated to form the DEINSTALL/INSTALL
+# scripts.
+#
+# _DEINSTALL_TEMPLATES_DFLT and _INSTALL_TEMPLATES_DFLT are the list of
+# template files minus any user-supplied templates.
+#
+_DEINSTALL_TEMPLATES= ${_HEADER_TMPL} ${HEADER_TEMPLATE} \
+ ${_DEINSTALL_PRE_TMPL} \
+ ${DEINSTALL_TEMPLATE} \
+ ${_DEINSTALL_TMPL} \
+ ${_FOOTER_TMPL}
+_INSTALL_TEMPLATES= ${_HEADER_TMPL} ${HEADER_TEMPLATE} \
+ ${_INSTALL_UNPACK_TMPL} \
+ ${_INSTALL_TMPL} \
+ ${INSTALL_TEMPLATE} \
+ ${_INSTALL_POST_TMPL} \
+ ${_FOOTER_TMPL}
+
+_DEINSTALL_TEMPLATES_DFLT= ${_HEADER_TMPL} \
+ ${_DEINSTALL_PRE_TMPL} \
+ ${_DEINSTALL_TMPL} \
+ ${_FOOTER_TMPL}
+_INSTALL_TEMPLATES_DFLT= ${_HEADER_TMPL} \
+ ${_INSTALL_TMPL} \
+ ${_INSTALL_POST_TMPL} \
+ ${_FOOTER_TMPL}
# These are the list of source files that are concatenated to form the
# INSTALL/DEINSTALL scripts.
#
-DEINSTALL_SRC?= ${DEINSTALL_TEMPLATES}
-INSTALL_SRC?= ${INSTALL_TEMPLATES}
+DEINSTALL_SRC?= ${_DEINSTALL_TEMPLATES}
+INSTALL_SRC?= ${_INSTALL_TEMPLATES}
# FILES_SUBST lists what to substitute in DEINSTALL/INSTALL scripts and in
# rc.d scripts.
@@ -798,49 +772,85 @@ INSTALL_SCRIPTS_ENV+= PKG_REFCOUNT_DBDIR=${PKG_REFCOUNT_DBDIR}
.PHONY: pre-install-script post-install-script
-# This section is the only part that hooks into the INSTALL/DEINSTALL
-# script logic in bsd.pkg.mk
-#
-.if !empty(_USE_PKGINSTALL:M[yY][eE][sS])
-. if !empty(DEINSTALL_SRC)
DEINSTALL_FILE= ${PKG_DB_TMPDIR}/+DEINSTALL
-. endif
-. if !empty(INSTALL_SRC)
INSTALL_FILE= ${PKG_DB_TMPDIR}/+INSTALL
-. endif
-
-pre-install-script: generate-install-scripts
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${PKG_DB_TMPDIR} && \
- ${SETENV} ${INSTALL_SCRIPTS_ENV} \
- ${_PKG_DEBUG_SCRIPT} ${INSTALL_FILE} ${PKGNAME} PRE-INSTALL
-
-post-install-script:
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${PKG_DB_TMPDIR} && \
- ${SETENV} ${INSTALL_SCRIPTS_ENV} \
- ${_PKG_DEBUG_SCRIPT} ${INSTALL_FILE} ${PKGNAME} POST-INSTALL
-.endif
+_DEINSTALL_FILE= ${WRKDIR}/.DEINSTALL
+_INSTALL_FILE= ${WRKDIR}/.INSTALL
+_DEINSTALL_FILE_DFLT= ${WRKDIR}/.DEINSTALL_default
+_INSTALL_FILE_DFLT= ${WRKDIR}/.INSTALL_default
.PHONY: generate-install-scripts
post-build: generate-install-scripts
-generate-install-scripts: # do nothing
+generate-install-scripts: \
+ ${_DEINSTALL_FILE} ${_INSTALL_FILE} \
+ ${_DEINSTALL_FILE_DFLT} ${_INSTALL_FILE_DFLT}
+.if !exists(${DEINSTALL_FILE}) || !exists(${INSTALL_FILE})
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${INSTALL_FILE:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${DEINSTALL_FILE:H}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ if ${CMP} -s ${_INSTALL_FILE_DFLT:Q} ${_INSTALL_FILE:Q}; then \
+ ${TRUE}; \
+ else \
+ ${CP} -f ${_INSTALL_FILE} ${INSTALL_FILE}; \
+ ${CP} -f ${_DEINSTALL_FILE} ${DEINSTALL_FILE}; \
+ fi
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ if ${CMP} -s ${_DEINSTALL_FILE_DFLT:Q} ${_DEINSTALL_FILE:Q}; then \
+ ${TRUE}; \
+ else \
+ ${CP} -f ${_DEINSTALL_FILE} ${DEINSTALL_FILE}; \
+ fi
+.endif
-.if !empty(DEINSTALL_SRC)
-generate-install-scripts: ${DEINSTALL_FILE}
-${DEINSTALL_FILE}: ${DEINSTALL_SRC}
+${_DEINSTALL_FILE_DFLT}: ${_DEINSTALL_TEMPLATES_DFLT}
${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} | \
${SED} ${FILES_SUBST_SED} > ${.TARGET}
${_PKG_SILENT}${_PKG_DEBUG}${CHMOD} +x ${.TARGET}
-.endif
-.if !empty(INSTALL_SRC)
-generate-install-scripts: ${INSTALL_FILE}
-${INSTALL_FILE}: ${INSTALL_SRC}
+${_INSTALL_FILE_DFLT}: ${_INSTALL_TEMPLATES_DFLT}
${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} | \
${SED} ${FILES_SUBST_SED} > ${.TARGET}
${_PKG_SILENT}${_PKG_DEBUG}${CHMOD} +x ${.TARGET}
-.endif
+
+${_DEINSTALL_FILE}: ${DEINSTALL_SRC}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ case ${.ALLSRC:Q}"" in \
+ "") { ${ECHO} "#!${SH}"; \
+ ${ECHO} "exit 0"; } > ${.TARGET} ;; \
+ *) ${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} \
+ > ${.TARGET} ;; \
+ esac
+ ${_PKG_SILENT}${_PKG_DEBUG}${CHMOD} +x ${.TARGET}
+
+${_INSTALL_FILE}: ${INSTALL_SRC}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ case ${.ALLSRC:Q}"" in \
+ "") { ${ECHO} "#!${SH}"; \
+ ${ECHO} "exit 0"; } > ${.TARGET} ;; \
+ *) ${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} \
+ > ${.TARGET} ;; \
+ esac
+ ${_PKG_SILENT}${_PKG_DEBUG}${CHMOD} +x ${.TARGET}
+
+pre-install-script:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ if ${TEST} -x ${INSTALL_FILE}; then \
+ cd ${PKG_DB_TMPDIR} && ${SETENV} ${INSTALL_SCRIPTS_ENV} \
+ ${_PKG_DEBUG_SCRIPT} ${INSTALL_FILE} ${PKGNAME} \
+ PRE-INSTALL; \
+ fi
+
+post-install-script:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ if ${TEST} -x ${INSTALL_FILE}; then \
+ cd ${PKG_DB_TMPDIR} && ${SETENV} ${INSTALL_SCRIPTS_ENV} \
+ ${_PKG_DEBUG_SCRIPT} ${INSTALL_FILE} ${PKGNAME} \
+ POST-INSTALL; \
+ fi
# rc.d scripts are automatically generated and installed into the rc.d
# scripts example directory at the post-install step. The following