summaryrefslogtreecommitdiff
path: root/pkgtools/pkg_alternatives
diff options
context:
space:
mode:
authorjmmv <jmmv@pkgsrc.org>2005-01-25 16:27:37 +0000
committerjmmv <jmmv@pkgsrc.org>2005-01-25 16:27:37 +0000
commit3cfcc8be82229d92018f68b27bb29093adb78e97 (patch)
tree7dc97d342ceaef3e03ae57687f61b60f59e10a5d /pkgtools/pkg_alternatives
parent5ff7c8f3a530690cba3d5bd2dcdbddc045d50d5e (diff)
downloadpkgsrc-3cfcc8be82229d92018f68b27bb29093adb78e97.tar.gz
Update to 1.1:
- Add the destroy action, used to remove the alternatives database as well as any known wrappers. - Use the rebuild/destroy actions at install/deinstall time respectively so that this package can be installed at any time and pick up automatically available alternatives from PKG_DBDIR. Per suggestion from reed@ in tech-pkg@.
Diffstat (limited to 'pkgtools/pkg_alternatives')
-rw-r--r--pkgtools/pkg_alternatives/DEINSTALL8
-rw-r--r--pkgtools/pkg_alternatives/INSTALL8
-rw-r--r--pkgtools/pkg_alternatives/Makefile8
-rw-r--r--pkgtools/pkg_alternatives/files/pkg_alternatives.812
-rw-r--r--pkgtools/pkg_alternatives/files/pkg_alternatives.sh39
5 files changed, 70 insertions, 5 deletions
diff --git a/pkgtools/pkg_alternatives/DEINSTALL b/pkgtools/pkg_alternatives/DEINSTALL
new file mode 100644
index 00000000000..7729fc8e426
--- /dev/null
+++ b/pkgtools/pkg_alternatives/DEINSTALL
@@ -0,0 +1,8 @@
+# $NetBSD: DEINSTALL,v 1.1 2005/01/25 16:27:37 jmmv Exp $
+#
+
+case ${STAGE} in
+ DEINSTALL)
+ @PKG_ALTERNATIVES@ -s destroy
+ ;;
+esac
diff --git a/pkgtools/pkg_alternatives/INSTALL b/pkgtools/pkg_alternatives/INSTALL
new file mode 100644
index 00000000000..96b004bde9f
--- /dev/null
+++ b/pkgtools/pkg_alternatives/INSTALL
@@ -0,0 +1,8 @@
+# $NetBSD: INSTALL,v 1.1 2005/01/25 16:27:37 jmmv Exp $
+#
+
+case ${STAGE} in
+ POST-INSTALL)
+ @PKG_ALTERNATIVES@ -s rebuild
+ ;;
+esac
diff --git a/pkgtools/pkg_alternatives/Makefile b/pkgtools/pkg_alternatives/Makefile
index 3a3d33afa03..0c5ca185a20 100644
--- a/pkgtools/pkg_alternatives/Makefile
+++ b/pkgtools/pkg_alternatives/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.1.1.1 2005/01/25 13:00:46 jmmv Exp $
+# $NetBSD: Makefile,v 1.2 2005/01/25 16:27:37 jmmv Exp $
#
-DISTNAME= pkg_alternatives-1.0
+DISTNAME= pkg_alternatives-1.1
CATEGORIES= pkgtools
MASTER_SITES= # empty
DISTFILES= # empty
@@ -21,6 +21,10 @@ WRKSRC= ${WRKDIR}
DATADIR= ${PREFIX}/share/pkg_alternatives
DBDIR= ${PREFIX}/libdata/pkg_alternatives
+DEINSTALL_EXTRA_TMPL+= ${.CURDIR}/DEINSTALL
+INSTALL_EXTRA_TMPL+= ${.CURDIR}/INSTALL
+FILES_SUBST+= PKG_ALTERNATIVES=${PREFIX}/sbin/pkg_alternatives
+
MAKE_DIRS= ${DBDIR}
MAKE_DIRS+= ${PKG_SYSCONFDIR}
diff --git a/pkgtools/pkg_alternatives/files/pkg_alternatives.8 b/pkgtools/pkg_alternatives/files/pkg_alternatives.8
index 3e990da236c..ca90e10ad09 100644
--- a/pkgtools/pkg_alternatives/files/pkg_alternatives.8
+++ b/pkgtools/pkg_alternatives/files/pkg_alternatives.8
@@ -1,4 +1,4 @@
-.\" $NetBSD: pkg_alternatives.8,v 1.1.1.1 2005/01/25 13:00:46 jmmv Exp $
+.\" $NetBSD: pkg_alternatives.8,v 1.2 2005/01/25 16:27:37 jmmv Exp $
.\"
.\" pkg_alternatives - Generic wrappers for programs with similar interfaces
.\" Copyright (c) 2005 Julio M. Merino Vidal <jmmv@NetBSD.org>
@@ -154,6 +154,13 @@ 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 destroy
+Removes the alternative database, found in
+.Pa @DBDIR@ ,
+and all its associated wrappers and manual pages.
+This action is intended to be used by the
+.Nm
+package.
.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
@@ -175,6 +182,9 @@ Basically, it scans the later looking for packages with an
file in them, and, for each of those, the
.Sq register
action is called with the appropriate file name.
+This action is intended to be used by the
+.Nm
+package or in case of database corruption.
.It register Ar package wrapper alternative arguments
Registers a new
.Ar alternative
diff --git a/pkgtools/pkg_alternatives/files/pkg_alternatives.sh b/pkgtools/pkg_alternatives/files/pkg_alternatives.sh
index 86cd6d23e63..0e04a39daad 100644
--- a/pkgtools/pkg_alternatives/files/pkg_alternatives.sh
+++ b/pkgtools/pkg_alternatives/files/pkg_alternatives.sh
@@ -1,6 +1,6 @@
#!@SH@
#
-# $NetBSD: pkg_alternatives.sh,v 1.1.1.1 2005/01/25 13:00:46 jmmv Exp $
+# $NetBSD: pkg_alternatives.sh,v 1.2 2005/01/25 16:27:37 jmmv Exp $
#
# pkg_alternatives - Generic wrappers for programs with similar interfaces
# Copyright (c) 2005 Julio M. Merino Vidal <jmmv@NetBSD.org>
@@ -86,6 +86,41 @@ action_auto_wrapper() {
# -------------------------------------------------------------------------
+# action_destroy_package
+#
+# Destroys the alternatives database and removes all installed wrappers.
+#
+action_destroy_package() {
+ validate_args list ${#} -eq 0
+
+ wrappers=$(cd ${Db_Dir} ; find . -type f)
+
+ for w in ${wrappers}; do
+ wrapper=$(echo ${w} | sed -e 's|^./||')
+ manpage=$(get_manpage ${wrapper})
+ info "removing wrapper \`${wrapper}'"
+ rm -f ${Prefix}/${wrapper}
+ info "removing manual page \`${manpage}'"
+ rm -f ${manpage}
+ done
+
+ info "removing contents of \`@DBDIR@'"
+ rm -rf @DBDIR@/* 2>/dev/null
+ rmdir_p @DBDIR@
+}
+
+# -------------------------------------------------------------------------
+
+# action_destroy_wrapper
+#
+# Unavailable action.
+#
+action_destroy_wrapper() {
+ err "the \`destroy' action cannot be used in wrapper mode"
+}
+
+# -------------------------------------------------------------------------
+
# action_list_package
#
# Lists all available packages that provide alternatives.
@@ -598,7 +633,7 @@ main() {
action=${1}; shift
case ${action} in
- auto|list|manual|rebuild|register|status|unregister)
+ auto|destroy|list|manual|rebuild|register|status|unregister)
action_${action}_${what} "${@}"
;;
*)