Gentoo Archives: gentoo-commits

From: Aisha Tammy <gentoo@×××××.cc>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/sci:master commit in: app-admin/eselect/, app-admin/eselect/files/
Date: Fri, 25 Sep 2020 21:59:43
Message-Id: 1601071148.c86fdf3185ceba586750afebd47360a7d0cb0256.epsilon-0@gentoo
1 commit: c86fdf3185ceba586750afebd47360a7d0cb0256
2 Author: Aisha Tammy <gentoo <AT> aisha <DOT> cc>
3 AuthorDate: Fri Sep 25 21:59:08 2020 +0000
4 Commit: Aisha Tammy <gentoo <AT> aisha <DOT> cc>
5 CommitDate: Fri Sep 25 21:59:08 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/sci.git/commit/?id=c86fdf31
7
8 app-admin/eselect: drop package
9
10 present in ::gentoo
11
12 Package-Manager: Portage-3.0.8, Repoman-3.0.1
13 Signed-off-by: Aisha Tammy <gentoo <AT> aisha.cc>
14
15 app-admin/eselect/eselect-1.4.13-r101.ebuild | 73 -
16 app-admin/eselect/eselect-9999.ebuild | 71 -
17 .../files/eselect-1.4.13-alternatives.patch | 1603 --------------------
18 app-admin/eselect/metadata.xml | 7 -
19 4 files changed, 1754 deletions(-)
20
21 diff --git a/app-admin/eselect/eselect-1.4.13-r101.ebuild b/app-admin/eselect/eselect-1.4.13-r101.ebuild
22 deleted file mode 100644
23 index 602a3c8e8..000000000
24 --- a/app-admin/eselect/eselect-1.4.13-r101.ebuild
25 +++ /dev/null
26 @@ -1,73 +0,0 @@
27 -# Copyright 1999-2018 Gentoo Foundation
28 -# Distributed under the terms of the GNU General Public License v2
29 -
30 -EAPI=6
31 -
32 -inherit autotools eutils bash-completion-r1
33 -
34 -DESCRIPTION="Gentoo's multi-purpose configuration and management tool"
35 -HOMEPAGE="https://wiki.gentoo.org/wiki/Project:Eselect"
36 -SRC_URI="https://dev.gentoo.org/~ulm/eselect/${P}.tar.xz"
37 -
38 -LICENSE="GPL-2+ || ( GPL-2+ CC-BY-SA-3.0 )"
39 -SLOT="0"
40 -KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
41 -IUSE="doc emacs vim-syntax"
42 -
43 -RDEPEND="
44 - !app-eselect/eselect-blas
45 - !app-eselect/eselect-lapack
46 - || (
47 - sys-apps/coreutils
48 - sys-freebsd/freebsd-bin
49 - app-misc/realpath
50 - )"
51 -DEPEND="${RDEPEND}
52 - app-arch/xz-utils
53 - doc? ( dev-python/docutils )"
54 -RDEPEND="!app-admin/eselect-news
55 - ${RDEPEND}
56 - sys-apps/file
57 - sys-libs/ncurses"
58 -
59 -PDEPEND="emacs? ( app-emacs/eselect-mode )
60 - vim-syntax? ( app-vim/eselect-syntax )"
61 -
62 -PATCHES=( "${FILESDIR}"/${P}-alternatives.patch )
63 -
64 -src_prepare() {
65 - default
66 - AT_M4DIR="." eautoreconf
67 -}
68 -
69 -src_compile() {
70 - default
71 - use doc && emake html
72 -}
73 -
74 -src_install() {
75 - default
76 - newbashcomp misc/${PN}.bashcomp ${PN}
77 - dodoc AUTHORS ChangeLog NEWS README TODO doc/*.txt
78 - use doc && dohtml *.html doc/*
79 -
80 - # needed by news module
81 - keepdir /var/lib/gentoo/news
82 - if use prefix; then
83 - sed -i \
84 - "s:ALTERNATIVESDIR_ROOTLESS=\"${EPREFIX}:ALTERNATIVESDIR_ROOTLESS=\":" \
85 - "${ED}"/usr/share/eselect/libs/alternatives-common.bash || die
86 - else
87 - fowners root:portage /var/lib/gentoo/news
88 - fperms g+w /var/lib/gentoo/news
89 - fi
90 -}
91 -
92 -pkg_postinst() {
93 - # fowners in src_install doesn't work for the portage group:
94 - # merging changes the group back to root
95 - if ! use prefix; then
96 - chgrp portage "${EROOT}/var/lib/gentoo/news" \
97 - && chmod g+w "${EROOT}/var/lib/gentoo/news"
98 - fi
99 -}
100
101 diff --git a/app-admin/eselect/eselect-9999.ebuild b/app-admin/eselect/eselect-9999.ebuild
102 deleted file mode 100644
103 index 8cae96147..000000000
104 --- a/app-admin/eselect/eselect-9999.ebuild
105 +++ /dev/null
106 @@ -1,71 +0,0 @@
107 -# Copyright 1999-2018 Gentoo Foundation
108 -# Distributed under the terms of the GNU General Public License v2
109 -
110 -EAPI=6
111 -
112 -inherit autotools git-r3 bash-completion-r1
113 -
114 -DESCRIPTION="Gentoo's multi-purpose configuration and management tool"
115 -HOMEPAGE="https://wiki.gentoo.org/wiki/Project:Eselect"
116 -EGIT_REPO_URI="git://github.com/gentoo-science/eselect.git"
117 -EGIT_BRANCH="alternatives"
118 -
119 -LICENSE="GPL-2+ || ( GPL-2+ CC-BY-SA-3.0 )"
120 -SLOT="0"
121 -IUSE="doc emacs vim-syntax"
122 -
123 -RDEPEND="
124 - !app-eselect/eselect-blas
125 - !app-eselect/eselect-lapack
126 - || (
127 - sys-apps/coreutils
128 - sys-freebsd/freebsd-bin
129 - app-misc/realpath
130 - )"
131 -DEPEND="${RDEPEND}
132 - app-arch/xz-utils
133 - doc? ( dev-python/docutils )"
134 -RDEPEND="!app-admin/eselect-news
135 - ${RDEPEND}
136 - sys-apps/file
137 - sys-libs/ncurses"
138 -
139 -PDEPEND="emacs? ( app-emacs/eselect-mode )
140 - vim-syntax? ( app-vim/eselect-syntax )"
141 -
142 -src_prepare() {
143 - default
144 - AT_M4DIR="." eautoreconf
145 -}
146 -
147 -src_compile() {
148 - default
149 - use doc && emake html
150 -}
151 -
152 -src_install() {
153 - default
154 - newbashcomp misc/${PN}.bashcomp ${PN}
155 - dodoc AUTHORS ChangeLog NEWS README TODO doc/*.txt
156 - use doc && dohtml *.html doc/*
157 -
158 - # needed by news module
159 - keepdir /var/lib/gentoo/news
160 - if use prefix; then
161 - sed -i \
162 - "s:ALTERNATIVESDIR_ROOTLESS=\"${EPREFIX}:ALTERNATIVESDIR_ROOTLESS=\":" \
163 - "${ED}"/usr/share/eselect/libs/alternatives-common.bash || die
164 - else
165 - fowners root:portage /var/lib/gentoo/news
166 - fperms g+w /var/lib/gentoo/news
167 - fi
168 -}
169 -
170 -pkg_postinst() {
171 - # fowners in src_install doesn't work for the portage group:
172 - # merging changes the group back to root
173 - if ! use prefix; then
174 - chgrp portage "${EROOT}/var/lib/gentoo/news" \
175 - && chmod g+w "${EROOT}/var/lib/gentoo/news"
176 - fi
177 -}
178
179 diff --git a/app-admin/eselect/files/eselect-1.4.13-alternatives.patch b/app-admin/eselect/files/eselect-1.4.13-alternatives.patch
180 deleted file mode 100644
181 index c47887fe6..000000000
182 --- a/app-admin/eselect/files/eselect-1.4.13-alternatives.patch
183 +++ /dev/null
184 @@ -1,1603 +0,0 @@
185 - bin/Makefile.am | 1 +
186 - bin/eselect.in | 150 +++++++++++-
187 - libs/Makefile.am | 7 +-
188 - libs/alternatives-common.bash.in | 510 +++++++++++++++++++++++++++++++++++++++
189 - libs/alternatives.bash.in | 316 ++++++++++++++++++++++++
190 - modules/Makefile.am | 1 +
191 - modules/alternatives.eselect | 178 ++++++++++++++
192 - modules/modules.eselect | 288 ++++++++++++++--------
193 - 8 files changed, 1343 insertions(+), 108 deletions(-)
194 -
195 -diff --git a/bin/Makefile.am b/bin/Makefile.am
196 -index 20902c1..ad08867 100644
197 ---- a/bin/Makefile.am
198 -+++ b/bin/Makefile.am
199 -@@ -4,6 +4,7 @@ EXTRA_DIST = eselect.in
200 - dosed = @SED@ -e 's%\@BASH\@%$(BASH)%g' \
201 - -e 's%\@DATADIR\@%$(datadir)%g' \
202 - -e 's%\@EPREFIX\@%$(EPREFIX)%g' \
203 -+ -e 's%\@LIBEXECDIR\@%$(datadir)%g' \
204 - -e 's%\@VERSION\@%$(VERSION)$(EXTRAVERSION)%g'
205 -
206 - % : %.in
207 -diff --git a/bin/eselect.in b/bin/eselect.in
208 -index 432f4e8..840eb94 100755
209 ---- a/bin/eselect.in
210 -+++ b/bin/eselect.in
211 -@@ -22,10 +22,18 @@ ESELECT_DATA_PATH="@DATADIR@/eselect"
212 - # Where are modules installed by default?
213 - ESELECT_DEFAULT_MODULES_PATH="${ESELECT_DATA_PATH}/modules"
214 -
215 -+# Where are auto-generated modules placed? (e.g. from alternatives-2.eclass)
216 -+ESELECT_AUTO_GENERATED_MODULES_PATH="${ESELECT_DEFAULT_MODULES_PATH}/auto"
217 -+
218 -+# Where the users store their modules
219 -+ESELECT_USER_MODULES_PATH="${ROOT}${HOME}/.eselect/modules"
220 -+
221 - # Look in these places for modules
222 --ESELECT_MODULES_PATH=( \
223 -- "${HOME}/.eselect/modules" \
224 -- "${ESELECT_DEFAULT_MODULES_PATH}" )
225 -+ESELECT_MODULES_PATH=(
226 -+ "${ESELECT_USER_MODULES_PATH}}"
227 -+ "${ESELECT_DEFAULT_MODULES_PATH}"
228 -+ "${ESELECT_AUTO_GENERATED_MODULES_PATH}"
229 -+)
230 -
231 - # Look in this place for libraries
232 - ESELECT_CORE_PATH="${ESELECT_DATA_PATH}/libs"
233 -@@ -66,12 +74,27 @@ fi
234 - # Load core functions
235 - source "${ESELECT_CORE_PATH}/core.bash" || exit 255
236 - # Load necessary functions for the main script
237 --inherit manip output path-manipulation tests
238 -+inherit manip output path-manipulation tests config
239 -
240 - # Sneaky trick to make die in subshells work. If you don't get
241 - # it, don't ask...
242 - trap 'echo "exiting" >&2; exit 250' 15
243 -
244 -+# es_find_module foo
245 -+# Find and echo the filename of the foo module. If there's no foo module,
246 -+# die.
247 -+es_find_module() {
248 -+ local modname="$1" modpath="" modfile=""
249 -+ [[ -z ${modname} ]] && die "Usage: ${FUNCNAME} <module>"
250 -+ for modpath in "${ESELECT_MODULES_PATH[@]}" ; do
251 -+ [[ -f ${modpath}/${modname}.eselect ]] && break
252 -+ done
253 -+
254 -+ modfile="${modpath}/${modname}.eselect"
255 -+ [[ -r ${modfile} ]] || die -q "Can't load module ${modname}"
256 -+ echo ${modfile}
257 -+}
258 -+
259 - # es_do_usage
260 - # Display eselect usage
261 - es_do_usage() {
262 -@@ -83,14 +106,10 @@ es_do_usage() {
263 - es_do_help() {
264 - es_do_usage
265 - echo
266 -- # display all recognized global options
267 -- write_list_start "Global options:"
268 -- write_kv_list_entry "--brief" "Make output shorter"
269 -- write_kv_list_entry "--colour=<yes|no|auto>" \
270 -- "Enable or disable colour output (default 'auto')"
271 -+ es_do_list-options
272 - echo
273 - # display all available eselect modules
274 -- do_action modules list
275 -+ es_do_list-modules
276 - }
277 -
278 - # es_do_version
279 -@@ -102,6 +121,114 @@ es_do_version() {
280 - echo "Distributed under the terms of the GNU GPL version 2 or later."
281 - }
282 -
283 -+# es_do_list-options
284 -+# Display all recognized global options
285 -+es_do_list-options() {
286 -+ write_list_start "Global options:"
287 -+ write_kv_list_entry "--brief" "Make output shorter"
288 -+ write_kv_list_entry "--colour=<yes|no|auto>" "Enable or disable colour output (default 'auto')"
289 -+ write_kv_list_entry "--debug" "Debug eselect (enable set -x)"
290 -+}
291 -+
292 -+# es_do_list-modules
293 -+# Display all available eselect modules DEPRECATED
294 -+es_do_list-modules() {
295 -+ do_action modules list $@
296 -+}
297 -+
298 -+### print-* actions, for use with bash_completion and zsh-completion ###
299 -+
300 -+# es_do_print-modules
301 -+#
302 -+# Display all availble eselect modules in a way that's useful to bash
303 -+# completion / zsh completion
304 -+es_do_print-modules() {
305 -+ local ret=1 path module group groupname want_descriptions
306 -+
307 -+ while [[ -n $@ ]]; do
308 -+ case "${1}" in
309 -+ --descriptions)
310 -+ want_descriptions='yes' ;;
311 -+ --group)
312 -+ groupname=${2}
313 -+ [[ -z "$groupname" ]] && die -q "Required option (group name) missing."
314 -+ shift ;;
315 -+ esac
316 -+ shift
317 -+ done
318 -+
319 -+ if [[ ${groupname} == Built-in || -z ${groupname} ]]; then
320 -+ for module in help usage version print-{modules,actions,options}; do
321 -+ echo "${module}"
322 -+ done
323 -+ [[ ${groupname} == Built-in ]] && return 0
324 -+ fi
325 -+
326 -+ # TODO: factor this out in modules.eselect's do_list()
327 -+ for path in "${ESELECT_MODULES_PATH[@]}" ; do
328 -+ [[ -d "${path}" ]] || continue
329 -+ for file in "${path}"/*.eselect ; do
330 -+ [[ -f "${file}" ]] || continue
331 -+ if [[ -n "${groupname}" ]]; then
332 -+ group=$(load_config "${file}" ESELECT_MODULE_GROUP)
333 -+ [[ "${groupname}" == "${group}" ||
334 -+ ( "${groupname}" == Extra && -z "${group}" ) ]] || continue
335 -+ fi
336 -+ module="${file##*/}"
337 -+ module="${module%%.eselect}"
338 -+ echo "${module}${want_descriptions:+:$(load_config "${file}" DESCRIPTION)}"
339 -+ ret=0
340 -+ done
341 -+ done
342 -+ return $ret
343 -+}
344 -+
345 -+# es_do_print-actions
346 -+#
347 -+# Display all available actions for the given module.
348 -+es_do_print-actions() {
349 -+ local modfile="$(es_find_module "${1}")" actions action want_descriptions
350 -+ [[ "${2}" == "--descriptions" ]] && want_descriptions='yes'
351 -+ (
352 -+ source "${modfile}" 2>/dev/null \
353 -+ || die "Couldn't source ${modfile}"
354 -+ actions=( $(declare -F \
355 -+ | sed -n -e 's/^declare\s\+-f\s\+do_//p' \
356 -+ | egrep -v '^(action|help|usage|version)$' \
357 -+ | sort ) )
358 -+ for action in "${actions[@]}" ; do
359 -+ echo "${action}${want_descriptions:+:$(describe_${action})}"
360 -+ done
361 -+ )
362 -+}
363 -+
364 -+# es_do_print-options
365 -+#
366 -+# Display all available options for the given module and action
367 -+es_do_print-options() {
368 -+ local modfile action want_descriptions
369 -+
370 -+ [[ "${1}" == "--descriptions" ]] && want_descriptions='yes' && shift
371 -+
372 -+ if [[ -z ${1} ]]; then
373 -+ echo "--debug${want_descriptions:+:Debug eselect (enable set -x)}"
374 -+ echo "--no-color${want_descriptions:+:Disable coloured output}"
375 -+ echo "--no-colour${want_descriptions:+:Disable coloured output}"
376 -+ elif [[ -n ${2} ]]; then
377 -+ modfile="$(es_find_module "${1}")"
378 -+ action=${2}
379 -+ shift 2
380 -+ (
381 -+ source "${modfile}" 2>/dev/null \
382 -+ || die "Couldn't source ${modfile}"
383 -+ is_function options_${action} || return 1
384 -+ options_${action} ${want_descriptions:+--descriptions} "$@" || return 2
385 -+ )
386 -+ else
387 -+ die "Usage: ${FUNCNAME} [--descriptions] [<module> <action>]"
388 -+ fi
389 -+}
390 -+
391 - ### main code ###
392 -
393 - # figure out what the action is. we need to know whether we're
394 -@@ -143,6 +270,9 @@ while [[ ${1##--} != "$1" ]]; do
395 - *) die -q "Invalid argument for ${1%%=*} option" ;;
396 - esac
397 - ;;
398 -+ debug)
399 -+ set -x
400 -+ ;;
401 - help|version)
402 - [[ -z ${action} ]] || die -q "Too many parameters"
403 - action=${1##--}
404 -diff --git a/libs/Makefile.am b/libs/Makefile.am
405 -index 6ebd08e..c19f173 100644
406 ---- a/libs/Makefile.am
407 -+++ b/libs/Makefile.am
408 -@@ -1,6 +1,8 @@
409 - eselectlibsdir = $(datadir)/$(PACKAGE_NAME)/libs/
410 -
411 - eselectlibs_DATA = \
412 -+ alternatives.bash \
413 -+ alternatives-common.bash \
414 - config.bash \
415 - core.bash \
416 - default.eselect \
417 -@@ -14,6 +16,8 @@ eselectlibs_DATA = \
418 - tests.bash
419 -
420 - EXTRA_DIST = \
421 -+ alternatives.bash.in \
422 -+ alternatives-common.bash.in \
423 - config.bash.in \
424 - core.bash.in \
425 - default.eselect.in \
426 -@@ -31,7 +35,8 @@ dosed = @SED@ \
427 - -e 's%\@PORTAGEQ\@%@PORTAGEQ@%g' \
428 - -e 's%\@ENV_UPDATE\@%@ENV_UPDATE@%g' \
429 - -e 's%\@CANONICALISE\@%@CANONICALISE@%g' \
430 -- -e 's%\@libdir\@%@libdir@%g'
431 -+ -e 's%\@libdir\@%@libdir@%g' \
432 -+ -e 's%\@sysconfdir\@%@sysconfdir@%g'
433 -
434 - %.bash : %.bash.in
435 - @$(dosed) $< > $@
436 -diff --git a/libs/alternatives-common.bash.in b/libs/alternatives-common.bash.in
437 -new file mode 100644
438 -index 0000000..8753b89
439 ---- /dev/null
440 -+++ b/libs/alternatives-common.bash.in
441 -@@ -0,0 +1,510 @@
442 -+# Copyright (c) 2005-2015 Gentoo Foundation
443 -+# Copyright (c) 2008 Mike Kelly
444 -+# Copyright (c) 2009-2013 David Leverton
445 -+# Copyright (c) 2009-2014 Bo Ørsted Andresen
446 -+#
447 -+# This file is part of the 'eselect' tools framework.
448 -+#
449 -+# eselect is free software: you can redistribute it and/or modify it under the
450 -+# terms of the GNU General Public License as published by the Free Software
451 -+# Foundation, either version 2 of the License, or (at your option) any later
452 -+# version.
453 -+#
454 -+# eselect is distributed in the hope that it will be useful, but WITHOUT ANY
455 -+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
456 -+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
457 -+#
458 -+# You should have received a copy of the GNU General Public License along with
459 -+# eselect. If not, see <http://www.gnu.org/licenses/>.
460 -+
461 -+inherit config output path-manipulation tests
462 -+
463 -+: "${ALTERNATIVESDIR_ROOTLESS:=@sysconfdir@/env.d/alternatives}"
464 -+: "${ALTERNATIVESDIR_ROOT:=${ROOT%/}}"
465 -+ALTERNATIVESDIR="${ALTERNATIVESDIR_ROOT}${ALTERNATIVESDIR_ROOTLESS}"
466 -+
467 -+get_current_provider() {
468 -+ local dieprefix="Could not determine current provider for ${ALTERNATIVE}"
469 -+ if [[ -L ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current ]]; then
470 -+ local provider=$(readlink "${ALTERNATIVESDIR}/${ALTERNATIVE}/_current" || die "${dieprefix}: readlink ${symlink} failed")
471 -+ [[ ${provider} == */* ]] && die "${dieprefix}: malformed target for ${symlink}"
472 -+
473 -+ if [[ -L ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider} ||
474 -+ ( -e ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider} && ! -d ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider} ) ]]; then
475 -+ die "${dieprefix}: ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider} is not a directory"
476 -+ fi
477 -+
478 -+ echo "${provider}"
479 -+
480 -+ elif [[ -e ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current ]]; then
481 -+ die "${dieprefix}: ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current is not a symlink"
482 -+ fi
483 -+}
484 -+
485 -+compare_importance() {
486 -+ local IFS=.
487 -+ local a=( ${1} ) b=( ${2} )
488 -+ local -i i=0
489 -+ while (( i<${#a[@]} && i<${#b[@]} )); do
490 -+ if (( a[i]<b[i] )); then
491 -+ return 0
492 -+ elif (( a[i]>b[i] )); then
493 -+ return 1
494 -+ fi
495 -+ i+=1
496 -+ done
497 -+ (( i<${#b[@]} ))
498 -+}
499 -+
500 -+sort_providers() {
501 -+ local begin=${1:-0}
502 -+ local count=${2:-${#providers[@]}}
503 -+ [[ ${count} -le 1 ]] && return 0
504 -+ sort_providers ${begin} $((count/2))
505 -+ sort_providers $((begin+count/2)) $((count-count/2))
506 -+ local left=( "${providers[@]:begin:count/2}" )
507 -+ local right=( "${providers[@]:begin+count/2:count-count/2}" )
508 -+ local -i x i=0 j=0
509 -+ for (( x=begin; x<begin+count; ++x )); do
510 -+ if (( j>=${#right[@]} )) || { (( i<${#left[@]} )) && compare_importance "${left[i]%%:*}" "${right[j]%%:*}"; }; then
511 -+ providers[x]=${left[i++]}
512 -+ else
513 -+ providers[x]=${right[j++]}
514 -+ fi
515 -+ done
516 -+}
517 -+
518 -+get_providers() {
519 -+ local p= importance providers=()
520 -+ for p in "${ALTERNATIVESDIR}/${ALTERNATIVE}"/* ; do
521 -+ [[ -d ${p} && ! -L ${p} ]] || continue
522 -+ p=${p##*/}
523 -+
524 -+ [[ -e "${ALTERNATIVESDIR}/${ALTERNATIVE}/${p}/_importance" ]] && \
525 -+ importance=$(< "${ALTERNATIVESDIR}/${ALTERNATIVE}/${p}/_importance")
526 -+ importance=${importance:-0}
527 -+ [[ "${importance}" =~ ^[0123456789]+(\.[0123456789]+)*$ ]] || die "_importance (${importance}) for ${p} is not a dot-separated list of integers"
528 -+
529 -+ providers+=( "${importance}:${p}" )
530 -+ done
531 -+
532 -+ sort_providers
533 -+ for (( p=${#providers[@]}-1 ; p>=0 ; --p )); do
534 -+ echo "${providers[p]#*:}"
535 -+ done
536 -+}
537 -+
538 -+has_provider() {
539 -+ local provider=${1} item providers=( $(get_providers) )
540 -+ for item in ${providers[@]}; do
541 -+ [[ ${item} == ${provider} ]] && return 0
542 -+ done
543 -+ return 1
544 -+}
545 -+
546 -+_options_parameters() {
547 -+ [[ -n ${2} && ${2} != --descriptions ]] && die -q "Unrecognised option ${2}"
548 -+ local describe_func=describe_${1#options_}_options descriptions=${2} opt options oldifs=$IFS
549 -+ if is_function ${describe_func}; then
550 -+ IFS=$'\n'
551 -+ options=( $(${describe_func}) )
552 -+ IFS=$oldifs
553 -+ for opt in "${options[@]}"; do
554 -+ [[ ${opt} == --* ]] || continue
555 -+ if [[ -n ${descriptions} ]]; then
556 -+ echo "${opt/ : /:}"
557 -+ else
558 -+ echo "${opt%% : *}"
559 -+ fi
560 -+ done
561 -+ fi
562 -+}
563 -+
564 -+### set action stub ###
565 -+
566 -+# not available in "eselect alternatives", but needed by do_update
567 -+
568 -+alternatives_do_set() {
569 -+ [[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module"
570 -+
571 -+ local force provider providers
572 -+ if [[ ${1} == --force ]]; then
573 -+ force=yes
574 -+ shift
575 -+ fi
576 -+ local idx=${1}
577 -+ if [[ ${1} == +(-|+|[[:digit:]]) ]]; then
578 -+ idx=${1#+(-|+)}
579 -+ providers=( $(get_providers) )
580 -+ (( ${idx} <= ${#providers[@]} )) || die -q "The given provider with index (${idx}) does not exist"
581 -+ provider=${providers[${idx}-1]}
582 -+ else
583 -+ provider="${1}"
584 -+ fi
585 -+ [[ -z "${provider}" ]] && die -q "Missing required parameter 'provider'"
586 -+ local dieprefix="Could not set provider ${provider} for alternative ${ALTERNATIVE}"
587 -+
588 -+ if [[ ! -d ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider} ]] ; then
589 -+ if is_number ${provider} ; then
590 -+ providers=( $(get_providers) )
591 -+ [[ -n ${providers[${idx}-1]} ]] && \
592 -+ die -q "The given provider (${provider}) does not exist"
593 -+ fi
594 -+ die -q "The given provider (${provider}) does not exist"
595 -+ fi
596 -+
597 -+ local symlink newsymlinks=() oldsymlinks=()
598 -+
599 -+ while read -r -d '' symlink; do
600 -+ local nicesymlink=${symlink#.}
601 -+ nicesymlink=${nicesymlink//+(\/)/\/}
602 -+ [[ ${nicesymlink} == /* ]] || die "${dieprefix}: bad symlink ${symlink}?"
603 -+ [[ ${nicesymlink} == */ ]] && die "${dieprefix}: bad symlink ${symlink}?"
604 -+
605 -+ newsymlinks+=( "${nicesymlink}" )
606 -+ done < <(
607 -+ cd "${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider}" || die "${dieprefix}: cd failed"
608 -+ find . -type l -print0 | LC_ALL=C sort -r -u -z)
609 -+ [[ ${#newsymlinks[@]} -gt 0 ]] || die "${dieprefix}: does not provide any symlinks?"
610 -+
611 -+ if [[ -f ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list ]]; then
612 -+ while read -r -d '' symlink; do
613 -+ local nicesymlink=${symlink//+(\/)/\/}
614 -+ [[ ${nicesymlink} == /* ]] || die "${dieprefix}: old provider ${oldcur} provides bad symlink ${symlink}?"
615 -+ [[ ${nicesymlink} == */ ]] && die "${dieprefix}: old provider ${oldcur} provides bad symlink ${symlink}?"
616 -+
617 -+ oldsymlinks+=( "${nicesymlink}" )
618 -+ done < <(LC_ALL=C sort -r -u -z "${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list")
619 -+ [[ ${#oldsymlinks[@]} -gt 0 ]] || die "${dieprefix}: old provider ${oldcur} does not provide any symlinks?"
620 -+
621 -+ elif [[ -L ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list || -e ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list ]]; then
622 -+ die "${dieprefix}: ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list is not a file"
623 -+ fi
624 -+
625 -+ local pass errors=
626 -+ for pass in check perform; do
627 -+ local -i new_i=0 old_i=0
628 -+ while [[ -n ${newsymlinks[new_i]} || -n ${oldsymlinks[old_i]} ]]; do
629 -+
630 -+ if ( LC_ALL=C; [[ ${newsymlinks[new_i]} < ${oldsymlinks[old_i]} ]] ); then
631 -+ if [[ ${pass} == check ]]; then
632 -+ if [[ -L ${EROOT%/}${oldsymlinks[old_i]} ]]; then
633 -+ :
634 -+ elif [[ -d ${EROOT%/}${oldsymlinks[old_i]} ]]; then
635 -+ write_error_msg "Can't remove ${EROOT%/}${oldsymlinks[old_i]}: is a directory${force:+ which is a fatal error that cannot be ignored by --force}"
636 -+ errors=yes
637 -+ elif [[ -e ${EROOT%/}${oldsymlinks[old_i]} ]]; then
638 -+ if [[ -n ${force} ]]; then
639 -+ write_warning_msg "Removing ${EROOT%/}${oldsymlinks[old_i]} due to --force: is not a symlink"
640 -+ else
641 -+ write_error_msg "Refusing to remove ${EROOT%/}${oldsymlinks[old_i]}: is not a symlink (use --force to override)"
642 -+ errors=yes
643 -+ fi
644 -+ fi
645 -+
646 -+ elif [[ ${pass} == perform ]]; then
647 -+ rm -f "${EROOT%/}${oldsymlinks[old_i]}" || die "${dieprefix}: rm failed"
648 -+ else
649 -+ die "${dieprefix}: unknown \${pass} ${pass}???"
650 -+ fi
651 -+
652 -+ old_i+=1
653 -+
654 -+ else
655 -+ local target=${ALTERNATIVESDIR_ROOTLESS#${EPREFIX}/}/${ALTERNATIVE}/_current${newsymlinks[new_i]} dir=${newsymlinks[new_i]%/*}
656 -+ while [[ -n ${dir} ]]; do
657 -+ target=../${target}
658 -+ dir=${dir%/*}
659 -+ done
660 -+
661 -+ if [[ ${pass} == check ]]; then
662 -+ if [[ -L ${EROOT%/}${newsymlinks[new_i]} ]]; then
663 -+ :
664 -+ elif [[ -d ${EROOT%/}${newsymlinks[new_i]} ]]; then
665 -+ write_error_msg "Can't overwrite ${EROOT%/}${newsymlinks[new_i]}: is a directory${force:+ which is a fatal error that cannot be ignored by --force}"
666 -+ errors=yes
667 -+ elif [[ -e ${EROOT%/}${newsymlinks[new_i]} ]]; then
668 -+ if [[ -n ${force} ]]; then
669 -+ write_warning_msg "Overwriting ${EROOT%/}${newsymlinks[new_i]} due to --force: is not a symlink"
670 -+ else
671 -+ write_error_msg "Refusing to overwrite ${EROOT%/}${newsymlinks[new_i]}: is not a symlink (use --force to override)"
672 -+ errors=yes
673 -+ fi
674 -+ fi
675 -+
676 -+ elif [[ ${pass} == perform ]]; then
677 -+ mkdir -p "${EROOT%/}${newsymlinks[new_i]%/*}" || die "${dieprefix}: mkdir -p failed"
678 -+ ln -snf "${target#/}" "${EROOT%/}${newsymlinks[new_i]}" || die "${dieprefix}: ln -snf failed"
679 -+ else
680 -+ die "${dieprefix}: unknown \${pass} ${pass}???"
681 -+ fi
682 -+
683 -+ [[ ${newsymlinks[new_i]} == ${oldsymlinks[old_i]} ]] && old_i+=1
684 -+ new_i+=1
685 -+ fi
686 -+ done
687 -+
688 -+ [[ -n ${errors} ]] && die "${dieprefix}: see previous errors"
689 -+ done
690 -+
691 -+ local oldcur="$(get_current_provider)"
692 -+ ln -snf "${provider}" "${ALTERNATIVESDIR}/${ALTERNATIVE}/_current" || die "${dieprefix}: ln -snf failed"
693 -+
694 -+ : >"${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list" || die "${dieprefix}: emptying/creating _current_list failed"
695 -+ for symlink in "${newsymlinks[@]}"; do
696 -+ echo -n -e "${symlink}\\0" >>"${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list" || die "${dieprefix}: appending ${symlink} to _current_list failed"
697 -+ done
698 -+ return 0
699 -+}
700 -+
701 -+### add action ###
702 -+alternatives_describe_add() {
703 -+ echo "Add provider to selected alternative"
704 -+}
705 -+
706 -+alternatives_describe_add_parameters() {
707 -+ echo "<provider> <importance> <source> <target> [<source> <target> [...]]"
708 -+}
709 -+
710 -+alternatives_describe_add_options() {
711 -+ echo "<provider> : the name of the alternative provider"
712 -+ echo "<importance> : interger value, representing the importance of the provider"
713 -+ echo "<source> : source of the symlink"
714 -+ echo "<target> : destination for the symlink"
715 -+}
716 -+
717 -+alternatives_do_add() {
718 -+ [[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module"
719 -+
720 -+ (( $# >= 4 )) && (( ($#-2)%2 == 0)) || \
721 -+ die "exactly 3+N*2 arguments where N>=1 required"
722 -+ local provider=${1}
723 -+ local importance=${2}
724 -+ shift 2
725 -+ local index src target ret=0
726 -+ local provider_dir="${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider}"
727 -+
728 -+ # Creating base dir
729 -+ if [[ ! -e "${provider_dir}" ]]; then
730 -+ mkdir -p "${provider_dir}" || die "Failed to create ${provider_dir}"
731 -+ elif [[ ! -d "${provider_dir}" ]]; then
732 -+ die "${provider_dir} exists but is a file"
733 -+ else
734 -+ die "${provider_dir} already present. You need to remove it before adding it again"
735 -+ fi
736 -+
737 -+ # Make sure importance is a signed integer
738 -+ if [[ -n ${importance} ]] && ! [[ ${importance} =~ ^[0-9]+(\.[0-9]+)*$ ]]; then
739 -+ die "Invalid importance (${importance}) detected"
740 -+ else
741 -+ # Setting importance
742 -+ echo ${importance} > "${provider_dir}/_importance"
743 -+ fi
744 -+
745 -+ # Process source-target pairs
746 -+ while (( $# >= 2 )); do
747 -+ src=${1//+(\/)/\/}; target=${2//+(\/)/\/}
748 -+ if [[ ${src} != /* ]]; then
749 -+ die "Source path must be absolute, but got ${src}"
750 -+ else
751 -+ local reltarget= dir=${provider_dir#${ALTERNATIVESDIR_ROOT}${EPREFIX}}${src%/*}
752 -+ while [[ -n ${dir} ]]; do
753 -+ reltarget+=../
754 -+ dir=${dir%/*}
755 -+ done
756 -+
757 -+ reltarget=${reltarget%/}
758 -+ [[ ${target} == /* ]] || reltarget+=${src%/*}/
759 -+ reltarget+=${target}
760 -+ mkdir -p "${provider_dir}${src%/*}" || die "Failed to create ${provider_dir}${src%/*}"
761 -+ ln -sf "${reltarget}" "${provider_dir}${src}" || die "Failed to create symlink"
762 -+ # The -e test will fail if existing symlink points to non-existing target,
763 -+ # so check for -L also.
764 -+ # Say ${ED}/sbin/init exists and links to /bin/systemd (which doesn't exist yet).
765 -+# if [[ -e ${ED}${src} || -L ${ED}${src} ]]; then
766 -+# local fulltarget=${target}
767 -+# [[ ${fulltarget} != /* ]] && fulltarget=${src%/*}/${fulltarget}
768 -+# if [[ -e ${ED}${fulltarget} || -L ${ED}${fulltarget} ]]; then
769 -+# die "${src} defined as provider for ${fulltarget}, but both already exist in \${ED}"
770 -+# else
771 -+# mv "${ED}${src}" "${ED}${fulltarget}" || die
772 -+# fi
773 -+# fi
774 -+ fi
775 -+ shift 2
776 -+ done
777 -+}
778 -+
779 -+alternatives_options_add() {
780 -+ _options_parameters ${FUNCNAME#alternatives_} "$@"
781 -+}
782 -+
783 -+### remove action ###
784 -+
785 -+alternatives_describe_remove() {
786 -+ echo "Remove a provider for selected alternative"
787 -+}
788 -+
789 -+alternatives_describe_remove_parameters() {
790 -+ echo "<provider>"
791 -+}
792 -+
793 -+alternatives_describe_remove_options() {
794 -+ echo "<provider> : the name of the alternative provider to be removed"
795 -+}
796 -+
797 -+alternatives_do_remove() {
798 -+ [[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module"
799 -+
800 -+ if [[ -d "${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider}" ]]; then
801 -+ rm -r "${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider}" || \
802 -+ die "Failed to remove '${provider}' for '${ALTERNATIVE}'"
803 -+ else
804 -+ einfo "'${provider}' is not a provider for '${ALTERNATIVE}'"
805 -+ fi
806 -+}
807 -+
808 -+alternatives_options_remove() {
809 -+ _options_parameters ${FUNCNAME#alternatives_} "$@"
810 -+}
811 -+
812 -+### update action ###
813 -+
814 -+# available in both "eselect alternatives" and individual modules
815 -+
816 -+alternatives_describe_update() {
817 -+ echo "Set a default provider if no valid one currently exists"
818 -+}
819 -+
820 -+alternatives_describe_update_parameters() {
821 -+ echo "[--best] [--ignore] <provider>"
822 -+}
823 -+
824 -+alternatives_describe_update_options() {
825 -+ echo "--best : update to the best provider even if one is already selected"
826 -+ echo "--ignore : update to any valid provider EXCEPT the specified provider"
827 -+ echo "<provider> : the name of the provider to use"
828 -+}
829 -+
830 -+alternatives_do_update() {
831 -+ [[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module"
832 -+
833 -+ local p cur=$(get_current_provider) providers=( $(get_providers) ) best ignore
834 -+ if [[ "--best" == ${1} ]] ; then
835 -+ shift
836 -+ best=1
837 -+ fi
838 -+ if [[ "--ignore" == ${1} ]] ; then
839 -+ # Try everything except setting the provider to the given
840 -+ # one. So, if it isn't the given one, we end up doing
841 -+ # nothing. Bug #128
842 -+ shift
843 -+ ignore=${1}
844 -+ fi
845 -+ [[ -n ${best} && -n ${1} && -z ${ignore} ]] && die -q "Cannot specify both --best and a provider"
846 -+
847 -+ if [[ -n ${best} ]] ; then
848 -+ # set best provider
849 -+ : # fall through to "switch to first available" loop below
850 -+ elif [[ $# == "0" ]] && [[ -z ${cur} ]]; then
851 -+ # if nothing is specified
852 -+ : # fall through to "switch to first available" loop below
853 -+ elif [[ ${cur} == ${1} && -z ${ignore} ]]; then
854 -+ # if current provider was just updated, reselect it since it could have changed
855 -+ alternatives_do_set "${cur}" && return 0
856 -+ elif [[ -n ${cur} && ${cur} != ${ignore} ]] ; then
857 -+ # verify existing provider's symlinks
858 -+ local p= bad=0
859 -+ while read -r -d '' p ; do
860 -+ [[ -L "${EROOT%/}${p}" && -e "${EROOT%/}${p}" ]] || (( bad++ ))
861 -+ done < "${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list"
862 -+
863 -+ [[ "${bad}" -eq 0 ]] && return 0
864 -+ # fix existing provider if possible
865 -+ has "${cur}" "${providers[@]}" && alternatives_do_set "${cur}" && return 0
866 -+ elif has "${1}" "${providers[@]}" && [[ -z ${ignore} ]] ; then
867 -+ # switch to new provider if none was set before or it can't be fixed
868 -+ alternatives_do_set "${1}" && return 0
869 -+ fi
870 -+
871 -+ # if no valid provider has been selected switch to first available, valid
872 -+ # provider, sorted according to importance
873 -+ for p in "${providers[@]}"; do
874 -+ [[ ${ignore} != ${p} ]] && alternatives_do_set "${p}" && return 0
875 -+ done
876 -+
877 -+ # if a provider is set but no providers are available anymore cleanup
878 -+ cur=$(get_current_provider)
879 -+ if [[ -n ${cur} ]]; then
880 -+ alternatives_do_unset "${cur}" && return 2
881 -+ fi
882 -+ # if no provider is set and none are available that are not ignored, return 2 for cleanup
883 -+ [[ -z ${providers[@]} || ${providers[@]} == ${ignore} ]] && return 2
884 -+
885 -+ # we tried everything to select a valid provider, but failed
886 -+ return 1
887 -+}
888 -+
889 -+alternatives_options_update() {
890 -+ _options_parameters ${FUNCNAME#alternatives_} "$@"
891 -+ if [[ -n ${ALTERNATIVE} ]]; then
892 -+ get_providers
893 -+ else
894 -+ for alt in ${ALTERNATIVESDIR_ROOTLESS}/_*/*/_importance; do
895 -+ echo ${alt} | cut -d/ -f5
896 -+ done | sort -u
897 -+ fi
898 -+}
899 -+
900 -+### unset action stub ###
901 -+
902 -+# not available in "eselect alternatives", but needed by do_update
903 -+
904 -+alternatives_do_unset() {
905 -+ [[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module"
906 -+
907 -+ local force=
908 -+ if [[ ${1} == --force ]]; then
909 -+ force=yes
910 -+ shift
911 -+ fi
912 -+
913 -+ local cur="$(get_current_provider)" p=
914 -+ [[ -n "${cur}" ]] || die -q "Nothing to unset"
915 -+ local dieprefix="Could not unset provider for ${ALTERNATIVE}"
916 -+
917 -+ local one=false symlink pass errors=
918 -+ for pass in check perform; do
919 -+ while read -r -d '' symlink; do
920 -+ one=true
921 -+ if [[ ${pass} == check ]]; then
922 -+ if [[ -L ${EROOT%/}${symlink} ]]; then
923 -+ :
924 -+ elif [[ -d ${EROOT%/}${symlink} ]]; then
925 -+ write_error_msg "Can't remove ${EROOT%/}${symlink}: is a directory${force:+ which is a fatal error that cannot be ignored by --force}"
926 -+ errors=yes
927 -+ elif [[ -e ${EROOT%/}${symlink} ]]; then
928 -+ if [[ -n ${force} ]]; then
929 -+ write_warning_msg "Removing ${EROOT%/}${symlink} due to --force: is not a symlink"
930 -+ else
931 -+ write_error_msg "Refusing to remove ${EROOT%/}${symlink}: is not a symlink (use --force to override)"
932 -+ errors=yes
933 -+ fi
934 -+ fi
935 -+
936 -+ elif [[ ${pass} == perform ]]; then
937 -+ rm -f "${EROOT%/}${symlink}" || die "${dieprefix}: rm failed"
938 -+ else
939 -+ die "${dieprefix}: unknown \${pass} ${pass}???"
940 -+ fi
941 -+ done <"${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list"
942 -+
943 -+ [[ -n ${errors} ]] && die "${dieprefix}: see previous errors"
944 -+ done
945 -+
946 -+ ${one} || die "${dieprefix}: does not provide any symlinks?"
947 -+
948 -+ rm "${ALTERNATIVESDIR}/${ALTERNATIVE}"/{_current,_current_list} || die "${dieprefix}: rm failed"
949 -+}
950 -+
951 -+# vim: set ft=eselect sw=4 sts=4 ts=4 et tw=80 :
952 -diff --git a/libs/alternatives.bash.in b/libs/alternatives.bash.in
953 -new file mode 100644
954 -index 0000000..cf4fa36
955 ---- /dev/null
956 -+++ b/libs/alternatives.bash.in
957 -@@ -0,0 +1,316 @@
958 -+# Copyright (c) 2005-2015 Gentoo Foundation
959 -+# Copyright (c) 2008 Mike Kelly
960 -+# Copyright (c) 2009-2013 David Leverton
961 -+# Copyright (c) 2009-2014 Bo Ørsted Andresen
962 -+#
963 -+# This file is part of the 'eselect' tools framework.
964 -+#
965 -+# eselect is free software: you can redistribute it and/or modify it under the
966 -+# terms of the GNU General Public License as published by the Free Software
967 -+# Foundation, either version 2 of the License, or (at your option) any later
968 -+# version.
969 -+#
970 -+# eselect is distributed in the hope that it will be useful, but WITHOUT ANY
971 -+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
972 -+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
973 -+#
974 -+# You should have received a copy of the GNU General Public License along with
975 -+# eselect. If not, see <http://www.gnu.org/licenses/>.
976 -+
977 -+inherit alternatives-common
978 -+
979 -+### show action ###
980 -+describe_show() {
981 -+ echo "Show the current provider in use for ${ALTERNATIVE}"
982 -+}
983 -+
984 -+do_show() {
985 -+ [[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module"
986 -+ local current="$(get_current_provider)"
987 -+ if [[ -z "${current}" ]] ; then
988 -+ echo "(none)"
989 -+ return 2
990 -+ fi
991 -+ echo "${current}"
992 -+}
993 -+
994 -+options_show() {
995 -+ :
996 -+}
997 -+
998 -+### list action ###
999 -+describe_list() {
1000 -+ echo "Lists all available providers for ${ALTERNATIVE}"
1001 -+}
1002 -+
1003 -+do_list() {
1004 -+ [[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module"
1005 -+ local n cur= providers=( $(get_providers) )
1006 -+ write_list_start "Available providers for ${ALTERNATIVE}:"
1007 -+
1008 -+ cur="$(get_current_provider)"
1009 -+
1010 -+ if [[ -n "${providers[@]}" ]] ; then
1011 -+ for (( n = 0 ; n < ${#providers[@]} ; ++n )) ; do
1012 -+ [[ ${cur} == "${providers[${n}]}" ]] && \
1013 -+ providers[${n}]="${providers[${n}]} $(highlight '*')"
1014 -+ done
1015 -+ write_numbered_list "${providers[@]}"
1016 -+ else
1017 -+ write_kv_list_entry "(none found)" ""
1018 -+ fi
1019 -+}
1020 -+
1021 -+options_list() {
1022 -+ :
1023 -+}
1024 -+
1025 -+### files action ###
1026 -+describe_files() {
1027 -+ echo "Lists symlinks provided by the currently selected provider"
1028 -+}
1029 -+
1030 -+do_files() {
1031 -+ [[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module"
1032 -+
1033 -+ local cur="$(get_current_provider)" p=
1034 -+ [[ -n "${cur}" ]] || die -q "No selected provider, hence no symlinks provided"
1035 -+ local dieprefix="Could not list symlinks provided for ${ALTERNATIVE}"
1036 -+
1037 -+ local errors symlink rootsymlink
1038 -+ while read -r -d '' symlink; do
1039 -+ rootsymlink="${EROOT%/}${symlink}"
1040 -+ rootsymlink=${rootsymlink//+(\/)/\/}
1041 -+ echo "${rootsymlink}"
1042 -+ if [[ -L ${rootsymlink} ]]; then
1043 -+ if [[ ! -e ${rootsymlink} ]]; then
1044 -+ write_error_msg "${rootsymlink} is dangling symlink"
1045 -+ errors=yes
1046 -+ fi
1047 -+ elif [[ -d ${rootsymlink} ]]; then
1048 -+ write_error_msg "${rootsymlink} is a directory"
1049 -+ errors=yes
1050 -+ elif [[ -e ${rootsymlink} ]]; then
1051 -+ write_error_msg "${rootsymlink} exists but is not a symlink"
1052 -+ errors=yes
1053 -+ else
1054 -+ write_error_msg "${rootsymlink} does not exist"
1055 -+ errors=yes
1056 -+ fi
1057 -+ done <"${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list"
1058 -+}
1059 -+
1060 -+options_files() {
1061 -+ :
1062 -+}
1063 -+
1064 -+### set action ###
1065 -+
1066 -+describe_set() {
1067 -+ echo "Sets a provider for ${ALTERNATIVE}"
1068 -+}
1069 -+
1070 -+describe_set_parameters() {
1071 -+ echo "[ --force ] <provider>"
1072 -+}
1073 -+
1074 -+describe_set_options() {
1075 -+ echo "--force : overwrite or remove existing non-symlink files (but not directories) if necessary"
1076 -+ echo "<provider> : the name of the provider to use or the index of the provider preceeded by a dash"
1077 -+}
1078 -+
1079 -+do_set() {
1080 -+ # implementation defined in alternatives-common.bash as needed by do_update
1081 -+ alternatives_do_set "$@"
1082 -+}
1083 -+
1084 -+options_set() {
1085 -+ _options_parameters $FUNCNAME "$@"
1086 -+ get_providers
1087 -+}
1088 -+
1089 -+### add action ###
1090 -+
1091 -+describe_add() {
1092 -+ alternatives_describe_add
1093 -+}
1094 -+
1095 -+describe_add_parameters() {
1096 -+ alternatives_describe_add_parameters
1097 -+}
1098 -+
1099 -+describe_add_options() {
1100 -+ alternatives_describe_add_options
1101 -+}
1102 -+
1103 -+do_add() {
1104 -+ alternatives_do_add
1105 -+
1106 -+ # make sure we have something selected
1107 -+ eselect ${provider} show > /dev/null || eselect ${provider} update --best
1108 -+}
1109 -+
1110 -+### remove action ###
1111 -+
1112 -+describe_remove() {
1113 -+ alternatives_describe_remove
1114 -+}
1115 -+
1116 -+describe_remove_parameters() {
1117 -+ alternatives_describe_remove_parameters
1118 -+}
1119 -+
1120 -+describe_remove_options() {
1121 -+ alternatives_describe_remove_options
1122 -+}
1123 -+
1124 -+do_remove() {
1125 -+ local ret
1126 -+ alternatives_do_remove
1127 -+
1128 -+# if no provider is present, remove whole alternative
1129 -+ eselect ${provider} update --best > /dev/null; ret=$?
1130 -+ case ret in
1131 -+ 0)
1132 -+ # All good
1133 -+ :;;
1134 -+ 2)
1135 -+ # No provider present anymore
1136 -+ eselect alternatives remove ${ALTERNATIVE};;
1137 -+ *)
1138 -+ write_error_msg "Failed to remove ${ALTERNATIVE}"
1139 -+ errors=yes
1140 -+ esac
1141 -+}
1142 -+
1143 -+### update action ###
1144 -+
1145 -+# all functions implemented in alternatives-common.bash as defined for
1146 -+# both "eselect alternatives" and individual modules
1147 -+
1148 -+describe_update() {
1149 -+ alternatives_describe_update
1150 -+}
1151 -+
1152 -+describe_update_parameters() {
1153 -+ alternatives_describe_update_parameters
1154 -+}
1155 -+
1156 -+describe_update_options() {
1157 -+ alternatives_describe_update_options
1158 -+}
1159 -+
1160 -+do_update() {
1161 -+ alternatives_do_update "$@"
1162 -+}
1163 -+
1164 -+options_update() {
1165 -+ alternatives_options_update
1166 -+}
1167 -+
1168 -+### unset action ###
1169 -+
1170 -+describe_unset() {
1171 -+ echo "Unset any symlinks created for the current provider for ${ALTERNATIVE}."
1172 -+}
1173 -+
1174 -+describe_unset_parameters() {
1175 -+ echo "[ --force ]"
1176 -+}
1177 -+
1178 -+describe_unset_options() {
1179 -+ echo "--force : remove existing non-symlink files (but not directories) if necessary"
1180 -+}
1181 -+
1182 -+do_unset() {
1183 -+ # implementation defined in alternatives-common.bash as needed by do_update
1184 -+ alternatives_do_unset "$@"
1185 -+}
1186 -+
1187 -+options_unset() {
1188 -+ _options_parameters $FUNCNAME "$@"
1189 -+ get_current_provider
1190 -+}
1191 -+
1192 -+### script action ###
1193 -+
1194 -+describe_script() {
1195 -+ echo "Output an evalable script fragment to set PATH, LD_LIBRARY_PATH and MANPATH to use the specified provider"
1196 -+}
1197 -+
1198 -+describe_script_parameters() {
1199 -+ echo "[--sh | --csh] [<provider>]"
1200 -+}
1201 -+
1202 -+describe_script_options() {
1203 -+ echo "--sh : use Bourne shell syntax (default)"
1204 -+ echo "--csh : use C shell syntax"
1205 -+ echo "<provider> : the provider to use or the index of the provider (if not specified, use the system default)"
1206 -+}
1207 -+
1208 -+do_script() {
1209 -+ [[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module"
1210 -+ local syntax=sh provider providers
1211 -+ if [[ ${1} == --sh ]]; then
1212 -+ shift
1213 -+ elif [[ ${1} == --csh ]]; then
1214 -+ syntax=csh
1215 -+ shift
1216 -+ fi
1217 -+
1218 -+ local idx=${!}
1219 -+ if [[ ${idx} == +(-|+|[[:digit:]]) ]]; then
1220 -+ idx=${1#+(-|+)}
1221 -+ providers=( $(get_providers) )
1222 -+ (( ${idx} <= ${#providers[@]} )) || die -q "The given provider with index (${idx}) does not exist"
1223 -+ provider=${providers[${idx}-1]}
1224 -+ else
1225 -+ provider="${idx}"
1226 -+ fi
1227 -+ [[ -z "${provider}" ]] && die -q "Missing required parameter 'provider'"
1228 -+
1229 -+ if [[ ! -d ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider} ]] ; then
1230 -+ if is_number ${provider} ; then
1231 -+ providers=( $(get_providers) )
1232 -+ [[ -n ${providers[${idx}-1]} ]] && \
1233 -+ die -q "The given provider (${provider}) does not exist"
1234 -+ fi
1235 -+ die -q "The given provider (${provider}) does not exist"
1236 -+ fi
1237 -+
1238 -+ local variables=( PATH LD_LIBRARY_PATH MANPATH )
1239 -+ [[ -n ${!default_*} ]] && local ${!default_*}
1240 -+ local default_LD_LIBRARY_PATH=$(grep '^[^#]' "${EROOT%/}"/etc/ld.so.conf | tr '\n' ':')/lib:/usr/lib
1241 -+ local default_MANPATH=$(MANPATH= man -C"${EROOT%/}"/etc/man.conf -w)
1242 -+
1243 -+ local var IFS=:
1244 -+ for var in "${variables[@]}"; do
1245 -+ local defvar=default_${var} path paths=( )
1246 -+ for path in ${!var}; do
1247 -+ [[ ${path} == ${ALTERNATIVESDIR_ROOTLESS}/${ALTERNATIVE}/* ]] && continue
1248 -+ [[ -n ${provider} && -d ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider}/${path#/} ]] && paths+=( "${ALTERNATIVESDIR_ROOTLESS}/${ALTERNATIVE}/${provider}/${path#/}" )
1249 -+ paths+=( "${path}" )
1250 -+ done
1251 -+
1252 -+ [[ -n ${provider} ]] && for path in ${!defvar}; do
1253 -+ [[ -d ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider}/${path#/} ]] && paths+=( "${ALTERNATIVESDIR_ROOTLESS}/${ALTERNATIVE}/${provider}/${path#/}" )
1254 -+ done
1255 -+
1256 -+ local newval=${paths[*]}
1257 -+ if [[ ${newval} != ${!var} ]]; then
1258 -+ newval=${newval//\'/\'\\\'\'}
1259 -+ if [[ ${syntax} == sh ]]; then
1260 -+ echo "${var}='${newval}'; export ${var}"
1261 -+ else
1262 -+ echo "setenv ${var} '${newval}'"
1263 -+ fi
1264 -+ fi
1265 -+ done
1266 -+}
1267 -+
1268 -+options_script() {
1269 -+ _options_parameters $FUNCNAME "$@"
1270 -+ get_providers
1271 -+}
1272 -+
1273 -+# vim: set ft=eselect sw=4 sts=4 ts=4 et tw=80 :
1274 -diff --git a/modules/Makefile.am b/modules/Makefile.am
1275 -index 75ebe02..92127b6 100644
1276 ---- a/modules/Makefile.am
1277 -+++ b/modules/Makefile.am
1278 -@@ -1,6 +1,7 @@
1279 - modulesdir=$(datadir)/$(PACKAGE_NAME)/modules/
1280 -
1281 - modules_DATA = \
1282 -+ alternatives.eselect \
1283 - editor.eselect \
1284 - env.eselect \
1285 - kernel.eselect \
1286 -diff --git a/modules/alternatives.eselect b/modules/alternatives.eselect
1287 -new file mode 100644
1288 -index 0000000..840b9c5
1289 ---- /dev/null
1290 -+++ b/modules/alternatives.eselect
1291 -@@ -0,0 +1,178 @@
1292 -+# Copyright (c) 2005-2015 Gentoo Foundation
1293 -+# Copyright (c) 2008 Mike Kelly
1294 -+# Copyright (c) 2009-2013 David Leverton
1295 -+# Copyright (c) 2009-2014 Bo Ørsted Andresen
1296 -+#
1297 -+# This file is part of the 'eselect' tools framework.
1298 -+#
1299 -+# eselect is free software: you can redistribute it and/or modify it under the
1300 -+# terms of the GNU General Public License as published by the Free Software
1301 -+# Foundation, either version 2 of the License, or (at your option) any later
1302 -+# version.
1303 -+#
1304 -+# eselect is distributed in the hope that it will be useful, but WITHOUT ANY
1305 -+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
1306 -+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
1307 -+#
1308 -+# You should have received a copy of the GNU General Public License along with
1309 -+# eselect. If not, see <http://www.gnu.org/licenses/>.
1310 -+
1311 -+inherit alternatives-common
1312 -+
1313 -+DESCRIPTION="Maintain Alternatives symlinks"
1314 -+VERSION="20150521"
1315 -+MAINTAINER="sci@g.o"
1316 -+
1317 -+show_extra_help_text() {
1318 -+ cat <<- ENDOFTEXT
1319 -+ This module is intended for internal use when a package is installed,
1320 -+ updated or removed. For alternatives for which it is likely that
1321 -+ users will need control over which provider is selected, there will be
1322 -+ a separate eselect module installed to do so.
1323 -+ ENDOFTEXT
1324 -+}
1325 -+
1326 -+# all functions implemented in alternatives-common.bash as defined for
1327 -+# both "eselect alternatives" and individual modules
1328 -+
1329 -+### update action ###
1330 -+
1331 -+describe_update() {
1332 -+ alternatives_describe_update
1333 -+}
1334 -+
1335 -+describe_update_parameters() {
1336 -+ echo "<alternative> $(alternatives_describe_update_parameters)"
1337 -+}
1338 -+
1339 -+describe_update_options() {
1340 -+ echo "<alternative> : the name of the alternative to set a provider for"
1341 -+ alternatives_describe_update_options
1342 -+}
1343 -+
1344 -+do_update() {
1345 -+ local ALTERNATIVE=$1
1346 -+ shift
1347 -+ [[ -z "${ALTERNATIVE}" ]] && die -q "Missing required parameter 'alternative'"
1348 -+ alternatives_do_update "$@"
1349 -+}
1350 -+
1351 -+options_update() {
1352 -+ alternatives_options_update
1353 -+}
1354 -+
1355 -+### create action ###
1356 -+
1357 -+describe_create() {
1358 -+ echo "Create a new alternative"
1359 -+}
1360 -+
1361 -+describe_create_parameters() {
1362 -+ echo "<alternative>"
1363 -+}
1364 -+
1365 -+describe_create_options() {
1366 -+ echo "<alternative> : the name of the alternative to create"
1367 -+}
1368 -+
1369 -+do_create() {
1370 -+ [[ $# == 1 ]] || die "Need exactly one alternative name"
1371 -+
1372 -+ local auto_dir="${ESELECT_AUTO_GENERATED_MODULES_PATH}"
1373 -+ local auto_file="${auto_dir}/${1}.eselect"
1374 -+
1375 -+ if [[ ! -e "${auto_file}" ]]; then
1376 -+ if [[ ! -e "${auto_dir}" ]]; then
1377 -+ mkdir -p "${auto_dir}" || die "Failed to create ${auto_dir}"
1378 -+ elif [[ ! -d "${auto_dir}" ]]; then
1379 -+ die "${auto_dir} exists but is a file"
1380 -+ fi
1381 -+ cat >> ${auto_file} <<- ENDOFTEXT
1382 -+ DESCRIPTION="${DESCRIPTION} for ${1}"
1383 -+ VERSION="${VERSION}"
1384 -+ MAINTAINER="${MAINTAINER}"
1385 -+ ESELECT_MODULE_GROUP="Alternatives"
1386 -+
1387 -+ ALTERNATIVE="${1}"
1388 -+
1389 -+ inherit alternatives
1390 -+ ENDOFTEXT
1391 -+ fi
1392 -+}
1393 -+
1394 -+### delete action ###
1395 -+
1396 -+describe_delete() {
1397 -+ echo "Delete an existing alternative"
1398 -+}
1399 -+
1400 -+describe_delete_parameters() {
1401 -+ echo "<alternative>"
1402 -+}
1403 -+
1404 -+describe_delete_options() {
1405 -+ echo "<alternative> : the name of the alternative to delete"
1406 -+}
1407 -+
1408 -+do_delete() {
1409 -+ [[ $# == 1 ]] || die "Need exactly one alternative name"
1410 -+
1411 -+ local auto_dir="${ESELECT_AUTO_GENERATED_MODULES_PATH}"
1412 -+ local auto_file="${auto_dir}/${1}.eselect"
1413 -+
1414 -+ if [[ -e "${auto_file}" ]]; then
1415 -+ rm "${auto_file}" || die "Failed to remove alternative: ${1}"
1416 -+ fi
1417 -+}
1418 -+
1419 -+### add action ###
1420 -+
1421 -+describe_add() {
1422 -+ alternatives_describe_add
1423 -+}
1424 -+
1425 -+describe_add_parameters() {
1426 -+ echo "<alternative> $(alternatives_describe_add_parameters)"
1427 -+}
1428 -+
1429 -+describe_add_options() {
1430 -+ echo "<alternative> : the name of the alternative to add a provider for"
1431 -+ alternatives_describe_add_options
1432 -+}
1433 -+
1434 -+do_add() {
1435 -+ local ALTERNATIVE=$1
1436 -+ shift
1437 -+ [[ -z "${ALTERNATIVE}" ]] && die -q "Missing required parameter 'alternative'"
1438 -+ alternatives_do_add "$@"
1439 -+}
1440 -+
1441 -+options_add() {
1442 -+ alternatives_options_add
1443 -+}
1444 -+
1445 -+### remove action ###
1446 -+
1447 -+describe_remove() {
1448 -+ alternatives_describe_remove
1449 -+}
1450 -+
1451 -+describe_remove_parameters() {
1452 -+ echo "<alternative> $(alternatives_describe_remove_parameters)"
1453 -+}
1454 -+
1455 -+describe_remove_options() {
1456 -+ echo "<alternative> : the name of the alternative to remove a provider from"
1457 -+ alternatives_describe_remove_options
1458 -+}
1459 -+
1460 -+do_remove() {
1461 -+ local ALTERNATIVE=$1
1462 -+ shift
1463 -+ [[ -z "${ALTERNATIVE}" ]] && die -q "Missing required parameter 'alternative'"
1464 -+ alternatives_do_remove "$@"
1465 -+}
1466 -+
1467 -+options_remove() {
1468 -+ alternatives_options_remove
1469 -+}
1470 -diff --git a/modules/modules.eselect b/modules/modules.eselect
1471 -index 5bc78ca..23c1e59 100644
1472 ---- a/modules/modules.eselect
1473 -+++ b/modules/modules.eselect
1474 -@@ -2,7 +2,7 @@
1475 - # Copyright 2006-2018 Gentoo Foundation
1476 - # Distributed under the terms of the GNU GPL version 2 or later
1477 -
1478 --inherit config
1479 -+inherit config output tests
1480 -
1481 - DESCRIPTION="Query eselect modules"
1482 - MAINTAINER="eselect@g.o"
1483 -@@ -15,57 +15,94 @@ describe_list() {
1484 - echo "List all available modules"
1485 - }
1486 -
1487 --describe_list_options() {
1488 -- echo "--only-names : Output names of modules only"
1489 --}
1490 --
1491 - # List all installed modules
1492 - do_list() {
1493 -- local only_names path file module name desc
1494 -- local -a extra_modules
1495 --
1496 -- if [[ ${1#--} = only-names ]]; then
1497 -- only_names=1
1498 -- shift
1499 -- fi
1500 -- [[ $# -gt 0 ]] && die -q "Too many parameters"
1501 --
1502 -- for path in "${ESELECT_MODULES_PATH[@]}" ; do
1503 -- [[ -d ${path} ]] || continue
1504 -- for file in "${path}"/*.eselect ; do
1505 -- [[ -f ${file} ]] || continue
1506 -- extra_modules=( "${extra_modules[@]}" "${file}" )
1507 -- done
1508 -- done
1509 --
1510 -- if [[ -n ${only_names} ]]; then
1511 -- # This is mainly intended for bash completion
1512 -- echo "help"
1513 -- echo "usage"
1514 -- echo "version"
1515 -- for module in "${extra_modules[@]}" ; do
1516 -- name=${module##*/}
1517 -- echo "${name%%.eselect}"
1518 -- done
1519 -- else
1520 -- write_list_start "Built-in modules:"
1521 -- write_kv_list_entry "help" "Display a help message"
1522 -- write_kv_list_entry "usage" "Display a usage message"
1523 -- write_kv_list_entry "version" "Display version information"
1524 --
1525 -- if [[ ${#extra_modules[@]} -gt 0 ]] ; then
1526 -- echo
1527 -- write_list_start "Extra modules:"
1528 -- for module in "${extra_modules[@]}" ; do
1529 -- name=${module##*/}
1530 -- name=${name%%.eselect}
1531 -- desc=$(ESELECT_MODULE_NAME=${name} \
1532 -- load_config "${module}" DESCRIPTION)
1533 -- desc=${desc:-No description available}
1534 -- write_kv_list_entry "${name}" "${desc}"
1535 -- done
1536 -- fi
1537 -- fi
1538 -+ local path file module name desc group groups Extra_modules
1539 -+
1540 -+ write_list_start "Built-in modules:"
1541 -+ write_kv_list_entry "help" "Display a help message"
1542 -+ write_kv_list_entry "usage" "Display a usage message"
1543 -+ write_kv_list_entry "version" "Display version information"
1544 -+ write_kv_list_entry "print-modules" "Print eselect modules"
1545 -+ write_kv_list_entry "print-actions" "Print actions for a given module"
1546 -+ write_kv_list_entry "print-options" "Print options for a given action"
1547 -+
1548 -+ for path in "${ESELECT_MODULES_PATH[@]}" ; do
1549 -+ [[ -d ${path} ]] || continue
1550 -+ for file in ${path}/*.eselect ; do
1551 -+ [[ -f ${file} ]] || continue
1552 -+ group=$(load_config "${file}" ESELECT_MODULE_GROUP)
1553 -+ if [[ -n ${group} ]]; then
1554 -+ has ${group} ${groups} || groups+=" ${group}"
1555 -+ declare ${group}_modules+=" ${file}"
1556 -+ else
1557 -+ Extra_modules+=" ${file}"
1558 -+ fi
1559 -+ done
1560 -+ done
1561 -+
1562 -+ for group in ${groups} Extra; do
1563 -+ local m
1564 -+ m="${group}_modules"
1565 -+ if [[ -n ${!m} ]] ; then
1566 -+ echo
1567 -+ write_list_start "${group} modules:"
1568 -+ for module in ${!m}; do
1569 -+ name=${module##*/}
1570 -+ name=${name%%.eselect}
1571 -+ desc=$(load_config "${module}" DESCRIPTION)
1572 -+ desc=${desc:-No description available}
1573 -+ write_kv_list_entry "${name}" "${desc}"
1574 -+ done
1575 -+ fi
1576 -+ done
1577 -+}
1578 -+
1579 -+### group action
1580 -+
1581 -+describe_group() {
1582 -+ echo "Lists all available modules belonging to a specified group."
1583 -+}
1584 -+
1585 -+describe_group_parameters() {
1586 -+ echo "<group>"
1587 -+}
1588 -+
1589 -+do_group() {
1590 -+ local path file groupname="$1" group module modules name desc
1591 -+ [[ -z "$groupname" ]] && die -q "Required option (group name) missing."
1592 -+
1593 -+ if [[ ${groupname} == Built-in ]]; then
1594 -+ write_list_start "Built-in modules:"
1595 -+ write_kv_list_entry "help" "Display a help message"
1596 -+ write_kv_list_entry "usage" "Display a usage message"
1597 -+ write_kv_list_entry "version" "Display version information"
1598 -+ return 0
1599 -+ fi
1600 -+
1601 -+ for path in "${ESELECT_MODULES_PATH[@]}" ; do
1602 -+ [[ -d ${path} ]] || continue
1603 -+ for file in ${path}/*.eselect ; do
1604 -+ [[ -f ${file} ]] || continue
1605 -+ group=$(load_config "${file}" ESELECT_MODULE_GROUP)
1606 -+ [[ ${groupname} == ${group} ||
1607 -+ ( ${groupname} == Extra && -z ${group} ) ]] || continue
1608 -+ modules+=" ${file}"
1609 -+ done
1610 -+ done
1611 -+
1612 -+ if [[ -n ${modules} ]] ; then
1613 -+ write_list_start "${groupname} modules:"
1614 -+ for module in ${modules}; do
1615 -+ name=${module##*/}
1616 -+ name=${name%%.eselect}
1617 -+ desc=$(load_config "${module}" DESCRIPTION)
1618 -+ desc=${desc:-No description available}
1619 -+ write_kv_list_entry "${name}" "${desc}"
1620 -+ done
1621 -+ else
1622 -+ die -q "No modules belonging to ${groupname} was found"
1623 -+ fi
1624 - }
1625 -
1626 - ### has action
1627 -@@ -75,56 +112,113 @@ describe_has() {
1628 - }
1629 -
1630 - describe_has_parameters() {
1631 -- echo "<module>"
1632 -+ echo "<module>"
1633 - }
1634 -
1635 - do_has() {
1636 -- [[ -z $1 ]] && die -q "Required option (module name) missing"
1637 -- [[ $# -gt 1 ]] && die -q "Too many parameters"
1638 --
1639 -- local modname=$1 modpath
1640 -- for modpath in "${ESELECT_MODULES_PATH[@]}" ; do
1641 -- [[ -f ${modpath}/${modname}.eselect ]] && return 0
1642 -- done
1643 -- return 1
1644 -+ [[ -z $1 ]] && die -q "Required option (module name) missing"
1645 -+ [[ $# -gt 1 ]] && die -q "Too many parameters"
1646 -+ local modname="$1" modpath
1647 -+ [[ -z "$modname" ]] && die -q "Required option (module name) missing."
1648 -+ for modpath in "${ESELECT_MODULES_PATH[@]}" ; do
1649 -+ [[ -f "${modpath}/${modname}.eselect" ]] && return 0
1650 -+ done
1651 -+ return 1
1652 - }
1653 -
1654 - ### add action
1655 --# *** Commented out. Do we really want to have an eselect module that is
1656 --# *** installing other modules in a system directory? Also, this should
1657 --# *** go together with a "remove" action.
1658 --
1659 --# describe_add() {
1660 --# echo "Install the given module file somewhere that eselect can find it."
1661 --# echo "By default, install to \$HOME/.eselect/modules/, unless running as "
1662 --# echo "root. Then, install to ${ESELECT_DATA_PATH}/modules/."
1663 --# }
1664 --
1665 --# describe_add_parameters() {
1666 --# echo "<module_file>"
1667 --# }
1668 --
1669 --# do_add() {
1670 --# local local_path="${ROOT}${HOME}/.eselect/modules/" module_file
1671 --# local force_default=0
1672 --#
1673 --# if [[ $1 = "--force-default-location" ]] ; then
1674 --# force_default=1
1675 --# shift
1676 --# fi
1677 --# module_file=$1
1678 --#
1679 --# [[ -z ${module_file} ]] && die -q "Required option (module file) missing"
1680 --#
1681 --# # TODO: Don't install the module "somewhere", depending on write access.
1682 --# # Add an option to control if it goes to the user's or to the system dir.
1683 --# if ! cp "${module_file}" "${ESELECT_DEFAULT_MODULES_PATH}" &> /dev/null ; then
1684 --# [[ ${force_default} == 1 ]] \
1685 --# && die -q "Failed to install module file to default modules path"
1686 --#
1687 --# mkdir -p "${local_path}" \
1688 --# || die -q "Failed to create module install directory"
1689 --# cp "${module_file}" "${local_path}" \
1690 --# || die -q "Failed to install module file"
1691 --# fi
1692 --# }
1693 -+
1694 -+describe_add() {
1695 -+ echo "Install a module file"
1696 -+}
1697 -+
1698 -+describe_add_options() {
1699 -+ echo "--default : install as global module (default if root)"
1700 -+ echo "--user : install as user's module"
1701 -+}
1702 -+
1703 -+describe_add_parameters() {
1704 -+ echo "<module_file>"
1705 -+}
1706 -+
1707 -+do_add() {
1708 -+ local module_file module_path
1709 -+ case $1 in
1710 -+ --default)
1711 -+ module_path="${ESELECT_DEFAULT_MODULES_PATH}"
1712 -+ shift
1713 -+ ;;
1714 -+ --user)
1715 -+ module_path="${ESELECT_USER_MODULES_PATH}"
1716 -+ mkdir -p "${module_path}" || die -q "Failed to create directory ${module_path}"
1717 -+ shift
1718 -+ ;;
1719 -+ *) : ;;
1720 -+ esac
1721 -+ module_file=$1
1722 -+
1723 -+ [[ -z ${module_file} ]] && die -q "Required module file missing"
1724 -+
1725 -+ if [[ -n ${module_path} ]]; then
1726 -+ cp "${module_file}" "${module_path}" &> /dev/null || \
1727 -+ die -q "Failed to install module file to ${module_path}"
1728 -+ else
1729 -+ if ! cp "${module_file}" "${ESELECT_DEFAULT_MODULES_PATH}" &> /dev/null ; then
1730 -+ mkdir -p "${ESELECT_USER_MODULES_PATH}" \
1731 -+ || die -q "Failed to create directory ${ESELECT_USER_MODULES_PATH}"
1732 -+ cp "${module_file}" "${ESELECT_USER_MODULES_PATH}" \
1733 -+ || die -q "Failed to install module file ${module_file}"
1734 -+ fi
1735 -+ fi
1736 -+}
1737 -+
1738 -+### remove action
1739 -+
1740 -+describe_remove() {
1741 -+ echo "Remove the given module name"
1742 -+}
1743 -+
1744 -+describe_remove_options() {
1745 -+ echo "--default : remove global module (default if root)"
1746 -+ echo "--alternatives : remove generated alternatives module"
1747 -+ echo "--user : remove user module"
1748 -+}
1749 -+
1750 -+describe_remove_parameters() {
1751 -+ echo "<module>"
1752 -+}
1753 -+
1754 -+do_remove() {
1755 -+ local module_name module_path ret
1756 -+ case $1 in
1757 -+ --alternatives)
1758 -+ module_path="${ESELECT_GENERATED_MODULES_PATH}"
1759 -+ shift
1760 -+ ;;
1761 -+ --default)
1762 -+ module_path="${ESELECT_DEFAULT_MODULES_PATH}"
1763 -+ shift
1764 -+ ;;
1765 -+ --user)
1766 -+ module_path="${ESELECT_USER_MODULES_PATH}"
1767 -+ shift
1768 -+ ;;
1769 -+ *) : ;;
1770 -+ esac
1771 -+ module_name=$1
1772 -+
1773 -+ [[ -z ${module_name} ]] && die -q "Required module name missing"
1774 -+
1775 -+ if [[ -n ${module_path} ]]; then
1776 -+ rm "${module_path}/${module_name}.eselect" &> /dev/null
1777 -+ ret=$?
1778 -+ else
1779 -+ for module_path in "${ESELECT_MODULES_PATH[@]}" ; do
1780 -+ rm "${module_path}/${module_name}.eselect" &> /dev/null
1781 -+ ret=$?
1782 -+ done
1783 -+ fi
1784 -+ [[ ${ret} != 0 ]] && die -q "Failed to remove module ${module_name}"
1785 -+}
1786 -+
1787 -+# vim: set ft=eselect sw=4 sts=4 ts=4 et tw=80 :
1788
1789 diff --git a/app-admin/eselect/metadata.xml b/app-admin/eselect/metadata.xml
1790 deleted file mode 100644
1791 index 8c8d15633..000000000
1792 --- a/app-admin/eselect/metadata.xml
1793 +++ /dev/null
1794 @@ -1,7 +0,0 @@
1795 -<?xml version="1.0" encoding="UTF-8"?>
1796 -<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
1797 -<pkgmetadata>
1798 - <maintainer type="person">
1799 - <email>bicatali@g.o</email>
1800 - </maintainer>
1801 -</pkgmetadata>