pkgsrc/mk/alternatives.mk
jlam daad0f3d6c 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.
2006-03-14 01:14:26 +00:00

57 lines
1.7 KiB
Makefile

# $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.
#
# The ALTERNATIVES_SRC variable contains the path to a file listing the
# alternatives provided by the package. It defaults to the ALTERNATIVES
# file in the current directory if found. If this variable is empty, no
# actions are taken by this file.
#
.if !defined(ALTERNATIVES_MK)
ALTERNATIVES_MK= # defined
.if !defined(ALTERNATIVES_SRC)
. if exists(${.CURDIR}/ALTERNATIVES)
ALTERNATIVES_SRC?= ${.CURDIR}/ALTERNATIVES
. else
ALTERNATIVES_SRC?=
. endif
.endif
.if !empty(ALTERNATIVES_SRC)
${WRKDIR}/.altinstall: ${ALTERNATIVES_SRC}
@{ ${ECHO} 'if ${TEST} $${STAGE} = "POST-INSTALL"; then'; \
${ECHO} '${CAT} >./+ALTERNATIVES <<EOF'; \
${SED} ${FILES_SUBST_SED} <${ALTERNATIVES_SRC}; \
${ECHO} 'EOF'; \
${ECHO} 'if ${TEST} -x ${PKG_ALTERNATIVES}; then'; \
${ECHO} '${PKG_ALTERNATIVES} -gs register ./+ALTERNATIVES'; \
${ECHO} 'fi'; \
${ECHO} 'fi'; \
} >${WRKDIR}/.altinstall
${WRKDIR}/.altdeinstall: ${ALTERNATIVES_SRC}
@{ ${ECHO} 'if ${TEST} $${STAGE} = "DEINSTALL"; then'; \
${ECHO} 'if ${TEST} -x ${PKG_ALTERNATIVES}; then'; \
${ECHO} '${PKG_ALTERNATIVES} -gs unregister ./+ALTERNATIVES'; \
${ECHO} 'fi'; \
${ECHO} '${RM} -f ./+ALTERNATIVES'; \
${ECHO} 'fi'; \
} >${WRKDIR}/.altdeinstall
PRINT_PLIST_AWK+= /^libdata\/alternatives\// { next; }
PRINT_PLIST_AWK+= /^@dirrm libdata\/alternatives/ { next; }
EVAL_PREFIX+= PREFIX.pkg_alternatives=pkg_alternatives
PREFIX.alternatives_DEFAULT= ${LOCALBASE}
PKG_ALTERNATIVES= ${PREFIX.pkg_alternatives}/sbin/pkg_alternatives
INSTALL_TEMPLATE+= ${WRKDIR}/.altinstall
DEINSTALL_TEMPLATE+= ${WRKDIR}/.altdeinstall
.endif
.endif # ALTERNATIVES_MK