summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2014-02-17 19:44:57 +0100
committerUlrich Müller <ulm@gentoo.org>2014-02-17 19:44:57 +0100
commit38dfbfb46db3a4f8b8a7cf118ba65bdde78b02a8 (patch)
tree73e10e03bef037f3f2229cc2a9890027f681074f
parentUse xz for compression of tarball. (diff)
downloademacs-tools-38dfbfb46db3a4f8b8a7cf118ba65bdde78b02a8.tar.gz
emacs-tools-38dfbfb46db3a4f8b8a7cf118ba65bdde78b02a8.tar.bz2
emacs-tools-38dfbfb46db3a4f8b8a7cf118ba65bdde78b02a8.zip
New module for gnuserv/gnuclient.
* gnuclient.eselect: New file, eselect module for gnuserv/gnuclient, bug 177936. * gnuclient.eselect.5: New file, man page. * Makefile (MODULES, MANPAGES, DISTFILES): Update.
-rw-r--r--ChangeLog5
-rw-r--r--Makefile7
-rw-r--r--gnuclient.eselect202
-rw-r--r--gnuclient.eselect.580
4 files changed, 291 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 8e00232..3ac52d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2014-02-17 Ulrich Müller <ulm@gentoo.org>
+ * gnuclient.eselect: New file, eselect module for
+ gnuserv/gnuclient, bug 177936.
+ * gnuclient.eselect.5: New file, man page.
+ * Makefile (MODULES, MANPAGES, DISTFILES): Update.
+
* Makefile (dist): Use xz for compression.
(clean): Remove *.xz.
diff --git a/Makefile b/Makefile
index 984a1e0..e59e7cd 100644
--- a/Makefile
+++ b/Makefile
@@ -6,10 +6,11 @@ PV = $(shell sed '/^[ \t]*VERSION=/!d;s/.*="\?\([^ \t"]*\).*/\1/;q' \
emacs.eselect)
P = $(PN)-$(PV)
-MODULES = emacs.eselect ctags.eselect etags.eselect
-MANPAGES = emacs.eselect.5 ctags.eselect.5 etags.eselect.5
+MODULES = emacs.eselect ctags.eselect etags.eselect gnuclient.eselect
+MANPAGES = emacs.eselect.5 ctags.eselect.5 etags.eselect.5 gnuclient.eselect.5
-DISTFILES = emacs.eselect ctags.eselect emacs.eselect.5 ctags.eselect.5 \
+DISTFILES = emacs.eselect ctags.eselect gnuclient.eselect \
+ emacs.eselect.5 ctags.eselect.5 gnuclient.eselect.5 \
ChangeLog Makefile
.PHONY: all dist clean
diff --git a/gnuclient.eselect b/gnuclient.eselect
new file mode 100644
index 0000000..27420cf
--- /dev/null
+++ b/gnuclient.eselect
@@ -0,0 +1,202 @@
+# -*-eselect-*-
+# Copyright 2005-2014 Gentoo Foundation
+# Distributed under the terms of the GNU GPL version 2 or later
+#
+# DOCUMENTATION
+# Following actions possible
+# * show do_show()
+# * list do_list()
+# * set do_set()
+# * update do_update()
+#
+# Behaviour:
+# do_show():
+# Checks if /usr/bin/gnuclient is a link and if the target exists,
+# if yes, it outputs the currently linked gnuclient implementation.
+# If it is no symlink, the user is told so, the same if there is
+# no /usr/bin/gnuclient or the target does not exist.
+# do_list(): List all available gnuclient implementations.
+# do_set(): Set a version to be target of the symlink.
+# do_update(): Set the target to the "best" available version.
+
+DESCRIPTION="Manage /usr/bin/gnuclient implementations"
+MAINTAINER="emacs@gentoo.org"
+VERSION="1.14"
+
+BINARYLIST="gnuclient gnudoit gnuattach"
+MANPAGELIST="gnuclient gnudoit gnuattach gnuserv"
+
+find_targets() {
+ # Return the list of available gnuclient implementations
+ local j
+ for j in gnuclient-{emacs,xemacs}; do
+ [[ -f ${EROOT}/usr/bin/${j} ]] && echo ${j}
+ done
+}
+
+remove_symlinks() {
+ # Remove existing symlinks to binaries and man pages
+ local f
+ for f in ${BINARYLIST}; do
+ rm -f "${EROOT}/usr/bin/${f}"
+ done
+ for f in ${MANPAGELIST}; do
+ rm -f "${EROOT}"/usr/share/man/man1/${f}.1*
+ done
+}
+
+set_bin_symlinks() {
+ # Set symlinks to binaries
+ local target=${1#gnuclient-} f
+ for f in ${BINARYLIST}; do
+ # set symlink only if target binary actually exists
+ if [[ -f ${EROOT}/usr/bin/${f}-${target} ]]; then
+ ln -s "${f}-${target}" "${EROOT}/usr/bin/${f}" || die \
+ "Couldn't set ${f}-${target} ${EROOT}/usr/bin/${f} symlink"
+ fi
+ done
+}
+
+set_man_symlinks() {
+ # Set symlinks to man pages
+ local target=${1#gnuclient-} extension f i
+ for f in ${MANPAGELIST}; do
+ for i in "${EROOT}"/usr/share/man/man1/${f}-${target}.1*; do
+ if [[ -f ${i} ]]; then
+ # target file exists; determine compress extension
+ extension=${i##*/${f}-${target}.1}
+ ln -s "${f}-${target}.1${extension}" \
+ "${EROOT}/usr/share/man/man1/${f}.1${extension}"
+ fi
+ done
+ done
+}
+
+set_symlinks() {
+ # Set symlinks to binaries and man pages
+ local target=$1 targets
+ # target may be specified by its name or its index
+ if is_number "${target}"; then
+ # numeric index, find the target's name
+ targets=( $(find_targets) )
+ [[ ${target} -ge 1 && ${target} -le ${#targets[@]} ]] \
+ || die -q "Number out of range: $1"
+ target=${targets[target-1]}
+ fi
+
+ # is the target valid, i.e. does a gnuclient binary with this name exist?
+ [[ -f ${EROOT}/usr/bin/${target} ]] \
+ || die -q "Target \"$1\" doesn't appear to be valid!"
+
+ echo "Switching gnuclient to ${target} ..."
+ remove_symlinks || die -q "Couldn't remove existing symlink"
+ set_bin_symlinks "${target}"
+ set_man_symlinks "${target}"
+ return 0
+}
+
+test_for_root() {
+ # checks if the user has rights to modify /usr/bin/
+ [[ -w ${EROOT}/usr/bin ]] || die -q "You need root privileges!"
+}
+
+### show action ###
+
+describe_show() {
+ echo "Show the current target of the gnuclient symlink"
+}
+
+do_show() {
+ [[ $# -gt 0 ]] && die -q "Too many parameters"
+
+ write_list_start "Current target of gnuclient symlink:"
+ if [[ -L ${EROOT}/usr/bin/gnuclient && -e ${EROOT}/usr/bin/gnuclient ]]
+ then
+ write_kv_list_entry \
+ "$(basename "$(readlink "${EROOT}/usr/bin/gnuclient")")" ""
+ elif [[ -e ${EROOT}/usr/bin/gnuclient ]]; then
+ write_kv_list_entry \
+ "(not a symlink or target of symlink does not exist)" ""
+ else
+ write_kv_list_entry "(unset)" ""
+ fi
+}
+
+### list action ###
+
+describe_list() {
+ echo "List available gnuclient symlink targets"
+}
+
+do_list() {
+ [[ $# -gt 0 ]] && die -q "Too many parameters"
+
+ local i targets
+ targets=( $(find_targets) )
+
+ for (( i = 0; i < ${#targets[@]}; i++ )); do
+ # Highlight the currently chosen version
+ [[ ${targets[i]} = \
+ "$(basename "$(readlink "${EROOT}/usr/bin/gnuclient")")" ]] \
+ && targets[i]=$(highlight_marker "${targets[i]}")
+ done
+ write_list_start "Available gnuclient symlink targets:"
+ write_numbered_list -m "(none found)" "${targets[@]}"
+}
+
+### set action ###
+
+describe_set() {
+ echo "Set a new gnuclient symlink"
+}
+
+describe_set_options() {
+ echo "target : Target name or number (from 'list' action)"
+}
+
+describe_set_parameters() {
+ echo "<target>"
+}
+
+do_set() {
+ [[ -z $1 ]] && die -q "You didn't tell me what to set the symlink to"
+ [[ $# -gt 1 ]] && die -q "Too many parameters"
+ test_for_root
+
+ if [[ -e ${EROOT}/usr/bin/gnuclient && ! -L ${EROOT}/usr/bin/gnuclient ]]
+ then
+ die -q "${EROOT}/usr/bin/gnuclient exists but is not a symlink"
+ fi
+
+ set_symlinks "$1" || die -q "Couldn't set a new symlink"
+}
+
+### update action ###
+
+describe_update() {
+ echo "Automatically update the gnuclient symlink"
+}
+
+describe_update_options() {
+ echo "ifunset : Do not override currently set version"
+}
+
+do_update() {
+ [[ -z $1 || $1 = ifunset || $1 = --if-unset ]] || die -q "Usage error"
+ [[ $# -gt 1 ]] && die -q "Too many parameters"
+ test_for_root
+
+ if [[ -L ${EROOT}/usr/bin/gnuclient ]]; then
+ if [[ $1 == *if*unset && -e ${EROOT}/usr/bin/gnuclient ]]; then
+ return 0
+ fi
+ remove_symlinks || die -q "Couldn't remove existing symlink"
+ elif [[ -e ${EROOT}/usr/bin/gnuclient ]]; then
+ die -q "${EROOT}/usr/bin/gnuclient exists but is not a symlink"
+ fi
+
+ local targets=( $(find_targets) )
+ if [[ ${#targets[@]} -gt 0 ]]; then
+ set_symlinks "${targets[0]}" || die -q "Couldn't set a new symlink"
+ fi
+}
diff --git a/gnuclient.eselect.5 b/gnuclient.eselect.5
new file mode 100644
index 0000000..de6bcaf
--- /dev/null
+++ b/gnuclient.eselect.5
@@ -0,0 +1,80 @@
+.\" -*- coding: utf-8 -*-
+.\" Copyright 2007-2014 Gentoo Foundation
+.\" Distributed under the terms of the GNU GPL version 2 or later
+.\"
+.TH gnuclient.eselect 5 "February 2014" "Gentoo Linux" eselect
+.SH NAME
+gnuclient.eselect \- The gnuserv/gnuclient module for Gentoo's eselect
+.SH SYNOPSIS
+.B eselect gnuclient
+.RB [ help | usage | version ]
+.br
+.B eselect gnuclient list
+.br
+.B eselect gnuclient set
+.I target
+.br
+.B eselect gnuclient show
+.br
+.B eselect gnuclient update
+.RB [ ifunset ]
+.SH DESCRIPTION
+.B eselect
+is Gentoo's configuration and management tool. It features modules
+that care for the individual administrative tasks.
+
+.B gnuserv
+and
+.B gnuclient
+are a server and client that allow the user to request a running
+(X)Emacs process to edit the named files or evaluate lisp forms.
+.SH ACTION: LIST
+.B eselect gnuclient list
+.br
+List all installed gnuclient versions.
+
+# eselect gnuclient list
+.br
+Available gnuclient symlink targets:
+.br
+ [1] gnuclient-emacs
+ [2] gnuclient-xemacs *
+.SH ACTION: SET
+.B eselect gnuclient set
+.I target
+.br
+Activate the selected gnuclient version.
+.I target
+can be either an identification number given by
+.B eselect gnuclient list
+or the name of one installed version.
+
+# eselect gnuclient set 1
+.br
+Switching gnuclient to gnuclient-emacs ...
+.SH ACTION: SHOW
+.B eselect gnuclient show
+.br
+Print the currently activated gnuclient version.
+
+# eselect gnuclient show
+.br
+Current target of symlink:
+.br
+ gnuclient-emacs
+.SH ACTION: UPDATE
+.B eselect gnuclient update
+.RB [ ifunset ]
+.br
+Update the gnuclient symlink. If option
+.B ifunset
+is given, an existing implementation is not overridden.
+
+# eselect gnuclient update
+.br
+Switching gnuclient to gnuclient-emacs ...
+.SH AUTHOR
+Ulrich Müller <ulm@gentoo.org>
+.SH SEE ALSO
+.BR eselect (1),
+.BR gnuserv (1)