pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkg_alternatives Initial import of pkg_altern...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/7e25cf4cf96b
branches:  trunk
changeset: 488162:7e25cf4cf96b
user:      jmmv <jmmv%pkgsrc.org@localhost>
date:      Tue Jan 25 13:00:46 2005 +0000

description:
Initial import of pkg_alternatives, version 1.0:

pkg_alternatives is a tool to manage the alternatives system provided by
The NetBSD Packages Collection, also known as pkgsrc.  It creates, configures
and destroys generic wrappers used to run programs with similar interfaces.

No objections in tech-pkg@.  Agreed with jlam@, who has provided lots of
design suggestions.

diffstat:

 pkgtools/pkg_alternatives/DESCR                     |    3 +
 pkgtools/pkg_alternatives/Makefile                  |   57 +
 pkgtools/pkg_alternatives/PLIST                     |    6 +
 pkgtools/pkg_alternatives/files/pkg_alternatives.8  |  289 +++++++++
 pkgtools/pkg_alternatives/files/pkg_alternatives.sh |  614 ++++++++++++++++++++
 pkgtools/pkg_alternatives/files/wrapper.man         |   70 ++
 pkgtools/pkg_alternatives/files/wrapper.sh          |   64 ++
 7 files changed, 1103 insertions(+), 0 deletions(-)

diffs (truncated from 1131 to 300 lines):

diff -r d69ae67e71e9 -r 7e25cf4cf96b pkgtools/pkg_alternatives/DESCR
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkg_alternatives/DESCR   Tue Jan 25 13:00:46 2005 +0000
@@ -0,0 +1,3 @@
+pkg_alternatives is a tool to manage the alternatives system provided by
+The NetBSD Packages Collection, also known as pkgsrc.  It creates, configures
+and destroys generic wrappers used to run programs with similar interfaces.
diff -r d69ae67e71e9 -r 7e25cf4cf96b pkgtools/pkg_alternatives/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkg_alternatives/Makefile        Tue Jan 25 13:00:46 2005 +0000
@@ -0,0 +1,57 @@
+# $NetBSD: Makefile,v 1.1.1.1 2005/01/25 13:00:46 jmmv Exp $
+#
+
+DISTNAME=      pkg_alternatives-1.0
+CATEGORIES=    pkgtools
+MASTER_SITES=  # empty
+DISTFILES=     # empty
+
+MAINTAINER=    jmmv%NetBSD.org@localhost
+COMMENT=       Generic wrappers for programs with similar interfaces
+
+PKG_INSTALLATION_TYPES=        overwrite pkgviews
+
+EXTRACT_ONLY=          # empty
+NO_CHECKSUM=           YES
+NO_BUILD=              YES
+NO_BUILDLINK=          YES
+USE_PKGINSTALL=                YES
+WRKSRC=                        ${WRKDIR}
+
+DATADIR=               ${PREFIX}/share/pkg_alternatives
+DBDIR=                 ${PREFIX}/libdata/pkg_alternatives
+
+MAKE_DIRS=             ${DBDIR}
+MAKE_DIRS+=            ${PKG_SYSCONFDIR}
+
+PKG_SYSCONFSUBDIR=     pkg_alternatives
+
+SUBST_CLASSES+=                vars
+SUBST_STAGE.vars=      do-configure
+SUBST_MESSAGE.vars=    "Configuring sources."
+SUBST_FILES.vars=      ${WRKSRC}/*
+SUBST_SED.vars=                -e 's|@CONFDIR@|${PKG_SYSCONFDIR}|g'
+SUBST_SED.vars+=       -e 's|@DATADIR@|${DATADIR}|g'
+SUBST_SED.vars+=       -e 's|@DBDIR@|${DBDIR}|g'
+SUBST_SED.vars+=       -e 's|@PKG_DBDIR@|${PKG_DBDIR}|g'
+SUBST_SED.vars+=       -e 's|@PREFIX@|${PREFIX}|g'
+SUBST_SED.vars+=       -e 's|@ROOT_USER@|${ROOT_USER}|g'
+SUBST_SED.vars+=       -e 's|@SH@|${SH}|g'
+
+INSTALLATION_DIRS=     man/man8 sbin
+
+do-extract:
+       ${CP} ${FILESDIR}/pkg_alternatives.sh ${WRKSRC}
+       ${CP} ${FILESDIR}/pkg_alternatives.8 ${WRKSRC}
+       ${CP} ${FILESDIR}/wrapper.sh ${WRKSRC}
+       ${CP} ${FILESDIR}/wrapper.man ${WRKSRC}
+
+do-install:
+       ${INSTALL_SCRIPT} ${WRKSRC}/pkg_alternatives.sh \
+               ${PREFIX}/sbin/pkg_alternatives
+       ${INSTALL_MAN} ${WRKSRC}/pkg_alternatives.8 ${PREFIX}/man/man8/
+       ${INSTALL_DATA_DIR} ${DATADIR}
+       ${INSTALL_DATA} ${WRKSRC}/wrapper.sh ${DATADIR}/
+       ${INSTALL_DATA} ${WRKSRC}/wrapper.man ${DATADIR}/
+
+.include "../../mk/bsd.pkg.mk"
diff -r d69ae67e71e9 -r 7e25cf4cf96b pkgtools/pkg_alternatives/PLIST
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkg_alternatives/PLIST   Tue Jan 25 13:00:46 2005 +0000
@@ -0,0 +1,6 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2005/01/25 13:00:46 jmmv Exp $
+man/man8/pkg_alternatives.8
+share/pkg_alternatives/wrapper.man
+share/pkg_alternatives/wrapper.sh
+sbin/pkg_alternatives
+@dirrm share/pkg_alternatives
diff -r d69ae67e71e9 -r 7e25cf4cf96b pkgtools/pkg_alternatives/files/pkg_alternatives.8
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkg_alternatives/files/pkg_alternatives.8        Tue Jan 25 13:00:46 2005 +0000
@@ -0,0 +1,289 @@
+.\" $NetBSD: pkg_alternatives.8,v 1.1.1.1 2005/01/25 13:00:46 jmmv Exp $
+.\"
+.\" pkg_alternatives - Generic wrappers for programs with similar interfaces
+.\" Copyright (c) 2005 Julio M. Merino Vidal <jmmv%NetBSD.org@localhost>
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Neither the name of The NetBSD Foundation nor the names of its
+.\"    contributors may be used to endorse or promote products derived
+.\"    from this software without specific prior written permission.
+.\" 3. Neither the name of author nor the names of its contributors may
+.\"    be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd January 25, 2005
+.Dt ALTERNATIVES 8
+.Os
+.Sh NAME
+.Nm pkg_alternatives
+.Nd generic wrappers for programs with similar interfaces
+.Sh SYNOPSIS
+.Nm
+.Op Fl sw
+.Op Fl p Ar prefix
+action
+.Ar arg1 ... argN
+.Sh DESCRIPTION
+.Nm
+is a tool to manage the
+.Em alternatives system
+provided by The NetBSD Packages Collection, also known as pkgsrc.
+It creates, configures and destroys generic wrappers used to run programs
+with similar interfaces.
+.Pp
+Consider, for example, the
+.Xr vi 1
+editor.
+Both
+.Xr nvi 1
+and
+.Xr vim 1
+provide very similar functionality, although neither of them is named
+.Sq vi .
+In this situation, it may be useful to have a
+.Em wrapper
+in place of the generic name which points to one of the multiple
+.Em alternatives
+available.
+.Pp
+The alternatives are classified according to the
+.Em package
+they belong to.
+In other words, a concrete package contains a list of all the wrappers it
+affects by providing alternatives to them.
+This makes things easier to the end user and/or the administrator who has
+to deal with them, as they can manually select a package rather than a
+bunch of wrappers.
+.Pp
+Wrappers are identified by its file name relative to the installation
+prefix, i.e.,
+.Pa @PREFIX@
+if the
+.Fl p
+option is not used.
+In the example above, the wrapper could be identified by the
+.Pa bin/vi
+string.
+The identifier is the string used as the
+.Sq wrapper
+argument in all the actions that require it.
+.Pp
+The generic wrapper scans a list of available alternatives and tries to
+execute them in order; the first one that succeeds is the one used for
+that run.
+This list of alternatives is read from multiple configuration files.
+Each one contains a list of possible alternatives, one per line, with
+optional arguments to them.
+Lines starting with
+.Sq #
+are considered comments and are ignored.
+.Pp
+The following configuration files are read, in strict order, for each
+wrapper (replace the
+.Sq wrapper
+word with the wrapper's absolute file name):
+.Bl -tag -width XXXX
+.It ~/.alternatives/wrapper
+This is called the
+.Em user configuration file
+and is only read when not running as
+.Sq @ROOT_USER@ .
+Otherwise, tools such as
+.Xr sudo 8
+could be used to execute any program in the system.
+This file can be freely edited by the user, either by hand or by using
+the
+.Sq manual
+action described below.
+.It @CONFDIR@/wrapper
+This is called the
+.Em system configuration file
+and is read if found.
+This file can be freely edited by the administrator, either by hand or
+by using the
+.Sq manual
+action described below.
+.It @DATADIR@/wrapper
+This is called the
+.Em database configuration file
+and is always read.
+This file must not be edited by hand; packages providing alternatives
+will take care to (un)register themselves from them when (de)installed.
+.El
+.Ss Options
+The following options are available:
+.Bl -tag -width XpXprefixX
+.It Fl p Ar prefix
+Set installation prefix.
+This affects where wrappers and their manual pages are looked for.
+The prefix defaults to
+.Pa @PREFIX@
+if this flag is not given.
+.It Fl s
+Run in silent mode: no output except for errors.
+.It Fl w
+Operate on wrappers rather than on packages.
+This affects the behavior of all actions.
+.El
+.Ss Actions in package mode
+The following table describes each available action and its behavior when
+working in package mode.
+All these actions are at a higher level than the same actions in wrapper
+mode.
+They always end up using the later at some point, so you should also
+read the next section to be aware of the exact effect of each the command.
+.Bl -tag -width XXXX
+.It auto Ar package
+Removes any manual configuration from each wrapper associated to the given
+package.
+This means that all the affected wrappers are then free to choose whichever
+alternative they prefer.
+.It list
+Lists which of the installed packages provide alternatives.
+Any of the packages shown by this command can then be fed back to the
+.Sq auto
+and
+.Sq manual
+actions.
+.It manual Ar package
+Manually selects all the alternatives that belong to
+.Ar package
+to be the default for their respective wrappers.
+.It rebuild
+Rebuilds the alternatives database, found in
+.Pa @DBDIR@ ,
+based on the contents of the package database, usually available in
+.Pa @PKG_DBDIR@ .
+Basically, it scans the later looking for packages with an
+.Pa +ALTERNATIVES
+file in them, and, for each of those, the
+.Sq register
+action is called with the appropriate file name.
+.It register Ar package wrapper alternative arguments
+Registers a new
+.Ar alternative
+for the given
+.Ar wrapper
+in the specified
+.Ar package .
+If the package does not exist in the database, it is created.
+.Pp
+This action must not be used directly; packages providing alternatives
+will take care to execute it at installation time.
+.It status Ar package
+For each wrapper that belongs to
+.Ar package ,
+shows which alternative will be used by it in the next run.
+It also displays all available candidates for each of them.
+.It unregister Ar package
+Removes the
+.Ar package
+from the database.
+All alternatives associated to it are also removed.
+.Pp
+This action must not be used directly; packages providing alternatives
+will take care to execute it at deinstallation time.
+.El
+.Ss Actions in wrapper mode
+The following table describes each available action and its behavior when
+working in wrapper mode.
+Note that these actions work at a very low level as they are used to manage
+wrappers and alternative commands directly.
+In most situations, you will want to use these actions in package mode.
+.Bl -tag -width XXXX
+.It auto Ar wrapper
+Removes any manual configuration created for the given
+.Ar wrapper .
+That is, if running as
+.Sq @ROOT_USER@ ,
+the system configuration file is deleted; otherwise, the user configuration
+file is removed.
+The effect of this action is that the wrapper is then free to choose any
+alternative it wants.



Home | Main Index | Thread Index | Old Index