2018-05-16 23:23:02 +02:00
|
|
|
# $NetBSD: alternatives.mk,v 1.13 2018/05/16 21:23:02 rillig Exp $
|
2005-01-25 14:13:35 +01:00
|
|
|
#
|
|
|
|
# This Makefile fragment handles the alternatives system, registering a
|
|
|
|
# package in the database.
|
|
|
|
#
|
2006-11-10 21:48:41 +01:00
|
|
|
# User-settable variables:
|
|
|
|
#
|
|
|
|
# (none)
|
|
|
|
#
|
|
|
|
# Package-settable variables:
|
|
|
|
#
|
|
|
|
# ALTERNATIVES_SRC
|
|
|
|
# A _single_ file that contains the alternatives provided by the
|
|
|
|
# package.
|
|
|
|
#
|
|
|
|
# Default value: The name of the ALTERNATIVES file in the package
|
|
|
|
# directory, if it exists. Otherwise, nothing.
|
|
|
|
#
|
2018-05-16 23:23:02 +02:00
|
|
|
# Each line of the alternatives file contains two filenames:
|
|
|
|
#
|
|
|
|
# wrapper alternative
|
|
|
|
#
|
|
|
|
# The wrapper is the command that is run by the user.
|
|
|
|
# The alternative is the implementation of that command that is
|
|
|
|
# provided by the package.
|
2007-09-29 17:56:04 +02:00
|
|
|
# Both paths are relative to PREFIX.
|
2018-05-16 23:23:02 +02:00
|
|
|
# The paths may use placeholders of the form @VARNAME@, which are
|
|
|
|
# replaced with the actual values as per FILES_SUBST.
|
2007-09-29 17:56:04 +02:00
|
|
|
#
|
2006-11-10 21:48:41 +01:00
|
|
|
# Variables defined by this file:
|
|
|
|
#
|
|
|
|
# PKG_ALTERNATIVES
|
|
|
|
# The path to the pkg_alternatives command.
|
2005-01-25 14:13:35 +01:00
|
|
|
#
|
2018-05-16 23:23:02 +02:00
|
|
|
# Keywords: alternatives
|
2005-01-25 14:13:35 +01:00
|
|
|
|
|
|
|
.if !defined(ALTERNATIVES_MK)
|
|
|
|
ALTERNATIVES_MK= # defined
|
|
|
|
|
2007-05-07 11:32:11 +02:00
|
|
|
_VARGROUPS+= alternatives
|
|
|
|
_PKG_VARS.alternatives= ALTERNATIVES_SRC
|
|
|
|
_SYS_VARS.alternatives= PKG_ALTERNATIVES
|
|
|
|
|
2006-11-10 21:48:41 +01:00
|
|
|
.if exists(${.CURDIR}/ALTERNATIVES)
|
2005-01-25 14:13:35 +01:00
|
|
|
ALTERNATIVES_SRC?= ${.CURDIR}/ALTERNATIVES
|
|
|
|
.endif
|
2006-11-10 21:48:41 +01:00
|
|
|
ALTERNATIVES_SRC?= # none
|
2005-01-25 14:13:35 +01:00
|
|
|
|
|
|
|
.if !empty(ALTERNATIVES_SRC)
|
|
|
|
|
|
|
|
${WRKDIR}/.altinstall: ${ALTERNATIVES_SRC}
|
2005-01-25 17:29:16 +01:00
|
|
|
@{ ${ECHO} 'if ${TEST} $${STAGE} = "POST-INSTALL"; then'; \
|
2005-01-25 14:13:35 +01:00
|
|
|
${ECHO} '${CAT} >./+ALTERNATIVES <<EOF'; \
|
|
|
|
${SED} ${FILES_SUBST_SED} <${ALTERNATIVES_SRC}; \
|
|
|
|
${ECHO} 'EOF'; \
|
2005-01-25 17:29:16 +01:00
|
|
|
${ECHO} 'if ${TEST} -x ${PKG_ALTERNATIVES}; then'; \
|
2005-01-25 17:48:53 +01:00
|
|
|
${ECHO} '${PKG_ALTERNATIVES} -gs register ./+ALTERNATIVES'; \
|
2005-01-25 17:29:16 +01:00
|
|
|
${ECHO} 'fi'; \
|
2005-01-25 14:13:35 +01:00
|
|
|
${ECHO} 'fi'; \
|
|
|
|
} >${WRKDIR}/.altinstall
|
|
|
|
|
|
|
|
${WRKDIR}/.altdeinstall: ${ALTERNATIVES_SRC}
|
2005-01-25 17:29:16 +01:00
|
|
|
@{ ${ECHO} 'if ${TEST} $${STAGE} = "DEINSTALL"; then'; \
|
|
|
|
${ECHO} 'if ${TEST} -x ${PKG_ALTERNATIVES}; then'; \
|
2005-01-25 17:48:53 +01:00
|
|
|
${ECHO} '${PKG_ALTERNATIVES} -gs unregister ./+ALTERNATIVES'; \
|
2005-01-25 17:29:16 +01:00
|
|
|
${ECHO} 'fi'; \
|
2005-01-25 14:13:35 +01:00
|
|
|
${ECHO} '${RM} -f ./+ALTERNATIVES'; \
|
|
|
|
${ECHO} 'fi'; \
|
|
|
|
} >${WRKDIR}/.altdeinstall
|
|
|
|
|
|
|
|
PRINT_PLIST_AWK+= /^libdata\/alternatives\// { next; }
|
|
|
|
|
2015-11-25 14:05:47 +01:00
|
|
|
PKG_ALTERNATIVES= ${LOCALBASE}/sbin/pkg_alternatives
|
2005-01-25 14:13:35 +01:00
|
|
|
|
2006-06-16 00:13:58 +02:00
|
|
|
INSTALL_TEMPLATES+= ${WRKDIR}/.altinstall
|
|
|
|
DEINSTALL_TEMPLATES+= ${WRKDIR}/.altdeinstall
|
2005-01-25 14:13:35 +01:00
|
|
|
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.endif # ALTERNATIVES_MK
|