1 |
commit: 5e5578dee160428f92c73771ab1529bf089b4ea4 |
2 |
Author: Andrew Savchenko <bircoph <AT> gmail <DOT> com> |
3 |
AuthorDate: Mon Sep 2 11:15:14 2013 +0000 |
4 |
Commit: Andrew Savchenko <bircoph <AT> gmail <DOT> com> |
5 |
CommitDate: Mon Sep 2 11:15:14 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/sci.git;a=commit;h=5e5578de |
7 |
|
8 |
app-admin/eselect: sync with portage version |
9 |
|
10 |
--- |
11 |
app-admin/eselect/ChangeLog | 6 + |
12 |
app-admin/eselect/eselect-1.3.8-r100.ebuild | 72 +++ |
13 |
.../eselect/files/eselect-1.3.8-alternatives.patch | 616 +++++++++++++++++++++ |
14 |
3 files changed, 694 insertions(+) |
15 |
|
16 |
diff --git a/app-admin/eselect/ChangeLog b/app-admin/eselect/ChangeLog |
17 |
index a6e5296..f016d96 100644 |
18 |
--- a/app-admin/eselect/ChangeLog |
19 |
+++ b/app-admin/eselect/ChangeLog |
20 |
@@ -2,6 +2,12 @@ |
21 |
# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2 |
22 |
# $Header: /var/cvsroot/gentoo-x86/app-admin/eselect/ChangeLog,v 1.179 2011/01/22 21:38:52 ulm Exp $ |
23 |
|
24 |
+*eselect-1.3.8-r100 (02 Sep 2013) |
25 |
+ |
26 |
+ 02 Sep 2013; Andrew Savchenko <bircoph@×××××.com> +eselect-1.3.8-r100.ebuild, |
27 |
+ +files/eselect-1.3.8-alternatives.patch: |
28 |
+ Bump to latest eselect. |
29 |
+ |
30 |
18 Jul 2013; Sébastien Fabbro <bicatali@g.o> eselect-1.3.7-r100.ebuild: |
31 |
app-admin/eselect: Re-add emacs and vim flags |
32 |
|
33 |
|
34 |
diff --git a/app-admin/eselect/eselect-1.3.8-r100.ebuild b/app-admin/eselect/eselect-1.3.8-r100.ebuild |
35 |
new file mode 100644 |
36 |
index 0000000..3df9e37 |
37 |
--- /dev/null |
38 |
+++ b/app-admin/eselect/eselect-1.3.8-r100.ebuild |
39 |
@@ -0,0 +1,72 @@ |
40 |
+# Copyright 1999-2013 Gentoo Foundation |
41 |
+# Distributed under the terms of the GNU General Public License v2 |
42 |
+# $Header: $ |
43 |
+ |
44 |
+EAPI=5 |
45 |
+ |
46 |
+inherit autotools eutils bash-completion-r1 |
47 |
+ |
48 |
+DESCRIPTION="Gentoo's multi-purpose configuration and management tool" |
49 |
+HOMEPAGE="https://wiki.gentoo.org/wiki/Project:Eselect" |
50 |
+SRC_URI="mirror://gentoo/${P}.tar.xz" |
51 |
+ |
52 |
+LICENSE="GPL-2+ || ( GPL-2+ CC-BY-SA-2.5 )" |
53 |
+SLOT="0" |
54 |
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~x64-freebsd ~x86-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~arm-linux ~ia64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" |
55 |
+IUSE="doc emacs vim-syntax" |
56 |
+ |
57 |
+RDEPEND="sys-apps/sed |
58 |
+ || ( |
59 |
+ sys-apps/coreutils |
60 |
+ sys-freebsd/freebsd-bin |
61 |
+ app-misc/realpath |
62 |
+ )" |
63 |
+DEPEND="${RDEPEND} |
64 |
+ app-arch/xz-utils |
65 |
+ doc? ( dev-python/docutils )" |
66 |
+RDEPEND="!app-admin/eselect-news |
67 |
+ ${RDEPEND} |
68 |
+ sys-apps/file |
69 |
+ sys-libs/ncurses" |
70 |
+ |
71 |
+PDEPEND="emacs? ( app-emacs/eselect-mode ) |
72 |
+ vim-syntax? ( app-vim/eselect-syntax )" |
73 |
+ |
74 |
+src_prepare() { |
75 |
+ epatch "${FILESDIR}"/${P}-alternatives.patch |
76 |
+ AT_M4DIR="." eautoreconf |
77 |
+} |
78 |
+ |
79 |
+src_compile() { |
80 |
+ emake |
81 |
+ use doc && emake html |
82 |
+} |
83 |
+ |
84 |
+src_install() { |
85 |
+ emake DESTDIR="${D}" install |
86 |
+ newbashcomp misc/${PN}.bashcomp ${PN} |
87 |
+ dodoc AUTHORS ChangeLog NEWS README TODO doc/*.txt |
88 |
+ use doc && dohtml *.html doc/* |
89 |
+ |
90 |
+ # needed by news module |
91 |
+ keepdir /var/lib/gentoo/news |
92 |
+ if ! use prefix; then |
93 |
+ fowners root:portage /var/lib/gentoo/news |
94 |
+ fperms g+w /var/lib/gentoo/news |
95 |
+ fi |
96 |
+ |
97 |
+ # band aid for prefix |
98 |
+ if use prefix; then |
99 |
+ cd "${ED}"/usr/share/eselect/libs |
100 |
+ sed -i "s:ALTERNATIVESDIR_ROOTLESS=\"${EPREFIX}:ALTERNATIVESDIR_ROOTLESS=\":" alternatives.bash || die |
101 |
+ fi |
102 |
+} |
103 |
+ |
104 |
+pkg_postinst() { |
105 |
+ # fowners in src_install doesn't work for the portage group: |
106 |
+ # merging changes the group back to root |
107 |
+ if ! use prefix; then |
108 |
+ chgrp portage "${EROOT}/var/lib/gentoo/news" \ |
109 |
+ && chmod g+w "${EROOT}/var/lib/gentoo/news" |
110 |
+ fi |
111 |
+} |
112 |
|
113 |
diff --git a/app-admin/eselect/files/eselect-1.3.8-alternatives.patch b/app-admin/eselect/files/eselect-1.3.8-alternatives.patch |
114 |
new file mode 100644 |
115 |
index 0000000..1e3b0ea |
116 |
--- /dev/null |
117 |
+++ b/app-admin/eselect/files/eselect-1.3.8-alternatives.patch |
118 |
@@ -0,0 +1,616 @@ |
119 |
+Index: bin/eselect.in |
120 |
+=================================================================== |
121 |
+--- bin/eselect.in (revision 863) |
122 |
++++ bin/eselect.in (working copy) |
123 |
+@@ -22,10 +22,15 @@ |
124 |
+ # Where are modules installed by default? |
125 |
+ ESELECT_DEFAULT_MODULES_PATH="${ESELECT_DATA_PATH}/modules" |
126 |
+ |
127 |
++# Where are auto-generated modules placed? (e.g. from alternatives-2.eclass) |
128 |
++ESELECT_AUTO_GENERATED_MODULES_PATH="${ESELECT_DEFAULT_MODULES_PATH}/auto" |
129 |
++ |
130 |
+ # Look in these places for modules |
131 |
+-ESELECT_MODULES_PATH=( \ |
132 |
+- "${HOME}/.eselect/modules" \ |
133 |
+- "${ESELECT_DEFAULT_MODULES_PATH}" ) |
134 |
++ESELECT_MODULES_PATH=( |
135 |
++ "${HOME}/.eselect/modules" |
136 |
++ "${ESELECT_DEFAULT_MODULES_PATH}" |
137 |
++ "${ESELECT_AUTO_GENERATED_MODULES_PATH}" |
138 |
++) |
139 |
+ |
140 |
+ # Look in this place for libraries |
141 |
+ ESELECT_CORE_PATH="${ESELECT_DATA_PATH}/libs" |
142 |
+--- bin/Makefile.am.orig 2013-09-02 14:35:05.328684465 +0400 |
143 |
++++ bin/Makefile.am 2013-09-02 14:49:50.895842067 +0400 |
144 |
+@@ -4,6 +4,7 @@ |
145 |
+ dosed = @SED@ -e 's,\@BASH\@,$(BASH),g' \ |
146 |
+ -e 's,\@DATADIR\@,$(datadir),g' \ |
147 |
+ -e 's,\@EPREFIX\@,$(EPREFIX),g' \ |
148 |
++ -e 's,\@LIBEXECDIR\@,$(datadir),g' \ |
149 |
+ -e 's,\@VERSION\@,$(VERSION)$(EXTRAVERSION),g' |
150 |
+ |
151 |
+ % : %.in |
152 |
+Index: libs/Makefile.am |
153 |
+=================================================================== |
154 |
+--- libs/Makefile.am (revision 863) |
155 |
++++ libs/Makefile.am (working copy) |
156 |
+@@ -1,6 +1,7 @@ |
157 |
+ eselectlibsdir = $(datadir)/$(PACKAGE_NAME)/libs/ |
158 |
+ |
159 |
+ eselectlibs_DATA = \ |
160 |
++ alternatives.bash \ |
161 |
+ config.bash \ |
162 |
+ core.bash \ |
163 |
+ default.eselect \ |
164 |
+@@ -14,6 +15,7 @@ |
165 |
+ tests.bash |
166 |
+ |
167 |
+ EXTRA_DIST = \ |
168 |
++ alternatives.bash.in \ |
169 |
+ config.bash.in \ |
170 |
+ core.bash.in \ |
171 |
+ default.eselect.in \ |
172 |
+@@ -30,7 +32,8 @@ |
173 |
+ -e 's,\@SED\@,@SED@,g' \ |
174 |
+ -e 's,\@PORTAGEQ\@,@PORTAGEQ@,g' \ |
175 |
+ -e 's,\@ENV_UPDATE\@,@ENV_UPDATE@,g' \ |
176 |
+- -e 's,\@CANONICALISE\@,@CANONICALISE@,g' |
177 |
++ -e 's,\@CANONICALISE\@,@CANONICALISE@,g' \ |
178 |
++ -e 's,\@sysconfdir\@,@sysconfdir@,g' |
179 |
+ |
180 |
+ %.bash : %.bash.in |
181 |
+ @$(dosed) $< > $@ |
182 |
+--- libs/alternatives.bash.in.orig 1970-01-01 01:00:00.000000000 +0100 |
183 |
++++ libs/alternatives.bash.in 2011-09-06 18:55:43.000000000 +0100 |
184 |
+@@ -0,0 +1,550 @@ |
185 |
++# Copyright 2008 Mike Kelly |
186 |
++# Copyright 2009 David Leverton |
187 |
++# Copyright 2010 Bo Ørsted Andresen |
188 |
++# 2010: Adapted to eselect Sebastien Fabbro (who doesn't like copyrights) |
189 |
++# Distributed under the terms of the GNU General Public License v2 |
190 |
++ |
191 |
++inherit config output path-manipulation |
192 |
++ |
193 |
++ALTERNATIVESDIR_ROOTLESS="@sysconfdir@/env.d/alternatives" |
194 |
++ALTERNATIVESDIR="${EROOT}${ALTERNATIVESDIR_ROOTLESS}" |
195 |
++ |
196 |
++get_current_provider() { |
197 |
++ local dieprefix="Could not determine current provider for ${ALTERNATIVE}" |
198 |
++ if [[ -L ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current ]]; then |
199 |
++ local provider=$(readlink "${ALTERNATIVESDIR}/${ALTERNATIVE}/_current" || die "${dieprefix}: readlink ${symlink} failed") |
200 |
++ [[ ${provider} == */* ]] && die "${dieprefix}: malformed target for ${symlink}" |
201 |
++ |
202 |
++ if [[ -L ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider} || |
203 |
++ ( -e ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider} && ! -d ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider} ) ]]; then |
204 |
++ die "${dieprefix}: ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider} is not a directory" |
205 |
++ fi |
206 |
++ |
207 |
++ echo "${provider}" |
208 |
++ |
209 |
++ elif [[ -e ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current ]]; then |
210 |
++ die "${dieprefix}: ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current is not a symlink" |
211 |
++ fi |
212 |
++} |
213 |
++ |
214 |
++compare_importance() { |
215 |
++ local IFS=. |
216 |
++ local a=( ${1} ) b=( ${2} ) |
217 |
++ local -i i=0 |
218 |
++ while (( i<${#a[@]} && i<${#b[@]} )); do |
219 |
++ if (( a[i]<b[i] )); then |
220 |
++ return 0 |
221 |
++ elif (( a[i]>b[i] )); then |
222 |
++ return 1 |
223 |
++ fi |
224 |
++ i+=1 |
225 |
++ done |
226 |
++ (( i<${#b[@]} )) |
227 |
++} |
228 |
++ |
229 |
++sort_providers() { |
230 |
++ local begin=${1:-0} |
231 |
++ local count=${2:-${#providers[@]}} |
232 |
++ [[ ${count} -le 1 ]] && return 0 |
233 |
++ sort_providers ${begin} $((count/2)) |
234 |
++ sort_providers $((begin+count/2)) $((count-count/2)) |
235 |
++ local left=( "${providers[@]:begin:count/2}" ) |
236 |
++ local right=( "${providers[@]:begin+count/2:count-count/2}" ) |
237 |
++ local -i x i=0 j=0 |
238 |
++ for (( x=begin; x<begin+count; ++x )); do |
239 |
++ if (( j>=${#right[@]} )) || { (( i<${#left[@]} )) && compare_importance "${left[i]%%:*}" "${right[j]%%:*}"; }; then |
240 |
++ providers[x]=${left[i++]} |
241 |
++ else |
242 |
++ providers[x]=${right[j++]} |
243 |
++ fi |
244 |
++ done |
245 |
++} |
246 |
++ |
247 |
++get_providers() { |
248 |
++ local p= importance providers=() |
249 |
++ for p in "${ALTERNATIVESDIR}/${ALTERNATIVE}"/* ; do |
250 |
++ [[ -d ${p} && ! -L ${p} ]] || continue |
251 |
++ p=${p##*/} |
252 |
++ |
253 |
++ importance=$(< "${ALTERNATIVESDIR}/${ALTERNATIVE}/${p}/_importance") |
254 |
++ importance=${importance:-0} |
255 |
++ [[ "${importance}" =~ ^[0123456789]+(\.[0123456789]+)*$ ]] || die "_importance (${importance}) for ${p} is not a dot-separated list of integers" |
256 |
++ |
257 |
++ providers+=( "${importance}:${p}" ) |
258 |
++ done |
259 |
++ |
260 |
++ sort_providers |
261 |
++ for (( p=${#providers[@]}-1 ; p>=0 ; --p )); do |
262 |
++ echo "${providers[p]#*:}" |
263 |
++ done |
264 |
++} |
265 |
++ |
266 |
++### show action ### |
267 |
++describe_show() { |
268 |
++ echo "Show the current provider in use for ${ALTERNATIVE}" |
269 |
++} |
270 |
++ |
271 |
++do_show() { |
272 |
++ [[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module" |
273 |
++ local current="$(get_current_provider)" |
274 |
++ if [[ -z "${current}" ]] ; then |
275 |
++ echo "(none)" |
276 |
++ return 2 |
277 |
++ fi |
278 |
++ echo "${current}" |
279 |
++} |
280 |
++ |
281 |
++options_show() { |
282 |
++ : |
283 |
++} |
284 |
++ |
285 |
++### list action ### |
286 |
++describe_list() { |
287 |
++ echo "Lists all available providers for ${ALTERNATIVE}" |
288 |
++} |
289 |
++ |
290 |
++do_list() { |
291 |
++ [[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module" |
292 |
++ local n cur= providers=( $(get_providers) ) |
293 |
++ write_list_start "Available providers for ${ALTERNATIVE}:" |
294 |
++ |
295 |
++ cur="$(get_current_provider)" |
296 |
++ |
297 |
++ if [[ -n "${providers[@]}" ]] ; then |
298 |
++ for (( n = 0 ; n < ${#providers[@]} ; ++n )) ; do |
299 |
++ [[ ${cur} == "${providers[${n}]}" ]] && \ |
300 |
++ providers[${n}]="${providers[${n}]} $(highlight '*')" |
301 |
++ done |
302 |
++ write_numbered_list "${providers[@]}" |
303 |
++ else |
304 |
++ write_kv_list_entry "(none found)" "" |
305 |
++ fi |
306 |
++} |
307 |
++ |
308 |
++options_list() { |
309 |
++ : |
310 |
++} |
311 |
++ |
312 |
++### files action ### |
313 |
++describe_files() { |
314 |
++ echo "Lists symlinks provided by the currently selected provider" |
315 |
++} |
316 |
++ |
317 |
++do_files() { |
318 |
++ [[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module" |
319 |
++ |
320 |
++ local cur="$(get_current_provider)" p= |
321 |
++ [[ -n "${cur}" ]] || die -q "No selected provider, hence no symlinks provided" |
322 |
++ local dieprefix="Could not list symlinks provided for ${ALTERNATIVE}" |
323 |
++ |
324 |
++ local errors symlink rootsymlink |
325 |
++ while read -r -d '' symlink; do |
326 |
++ rootsymlink="${EROOT}${symlink}" |
327 |
++ rootsymlink=${rootsymlink//+(\/)/\/} |
328 |
++ echo "${rootsymlink}" |
329 |
++ if [[ -L ${rootsymlink} ]]; then |
330 |
++ if [[ ! -e ${rootsymlink} ]]; then |
331 |
++ write_error_msg "${rootsymlink} is dangling symlink" |
332 |
++ errors=yes |
333 |
++ fi |
334 |
++ elif [[ -d ${rootsymlink} ]]; then |
335 |
++ write_error_msg "${rootsymlink} is a directory" |
336 |
++ errors=yes |
337 |
++ elif [[ -e ${rootsymlink} ]]; then |
338 |
++ write_error_msg "${rootsymlink} exists but is not a symlink" |
339 |
++ errors=yes |
340 |
++ else |
341 |
++ write_error_msg "${rootsymlink} does not exist" |
342 |
++ errors=yes |
343 |
++ fi |
344 |
++ done <"${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list" |
345 |
++} |
346 |
++ |
347 |
++options_files() { |
348 |
++ : |
349 |
++} |
350 |
++ |
351 |
++### set action ### |
352 |
++ |
353 |
++describe_set() { |
354 |
++ echo "Sets a provider for ${ALTERNATIVE}" |
355 |
++} |
356 |
++ |
357 |
++describe_set_parameters() { |
358 |
++ echo "[ --force ] <provider>" |
359 |
++} |
360 |
++ |
361 |
++describe_set_options() { |
362 |
++ echo "--force : overwrite or remove existing non-symlink files (but not directories) if necessary" |
363 |
++ echo "<provider> : the name of the provider to use or the index of the provider preceeded by a dash" |
364 |
++} |
365 |
++ |
366 |
++do_set() { |
367 |
++ [[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module" |
368 |
++ |
369 |
++ local force provider providers |
370 |
++ if [[ ${1} == --force ]]; then |
371 |
++ force=yes |
372 |
++ shift |
373 |
++ fi |
374 |
++ |
375 |
++ if [[ ${1} == -+([[:digit:]]) ]]; then |
376 |
++ providers=( $(get_providers) ) |
377 |
++ (( ${1#-} <= ${#providers[@]} )) || die -q "The given provider with index (${1#-}) does not exist" |
378 |
++ provider=${providers[${1#-}-1]} |
379 |
++ else |
380 |
++ provider="${1}" |
381 |
++ fi |
382 |
++ [[ -z "${provider}" ]] && die -q "Missing required parameter 'provider'" |
383 |
++ local dieprefix="Could not set provider ${provider} for alternative ${ALTERNATIVE}" |
384 |
++ |
385 |
++ if [[ ! -d ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider} ]] ; then |
386 |
++ if is_number ${provider} ; then |
387 |
++ providers=( $(get_providers) ) |
388 |
++ [[ -n ${providers[${1#-}-1]} ]] && |
389 |
++ die -q "The given provider (${provider}) does not exist, did you mean -${provider} (${providers[${1#-}-1]})?" |
390 |
++ fi |
391 |
++ die -q "The given provider (${provider}) does not exist" |
392 |
++ fi |
393 |
++ |
394 |
++ local symlink newsymlinks=() oldsymlinks=() |
395 |
++ |
396 |
++ while read -r -d '' symlink; do |
397 |
++ local nicesymlink=${symlink#.} |
398 |
++ nicesymlink=${nicesymlink//+(\/)/\/} |
399 |
++ [[ ${nicesymlink} == /* ]] || die "${dieprefix}: bad symlink ${symlink}?" |
400 |
++ [[ ${nicesymlink} == */ ]] && die "${dieprefix}: bad symlink ${symlink}?" |
401 |
++ |
402 |
++ newsymlinks+=( "${nicesymlink}" ) |
403 |
++ done < <( |
404 |
++ cd "${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider}" || die "${dieprefix}: cd failed" |
405 |
++ find . -type l -print0 | LC_ALL=C sort -r -u -z) |
406 |
++ [[ ${#newsymlinks[@]} -gt 0 ]] || die "${dieprefix}: does not provide any symlinks?" |
407 |
++ |
408 |
++ if [[ -f ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list ]]; then |
409 |
++ while read -r -d '' symlink; do |
410 |
++ local nicesymlink=${symlink//+(\/)/\/} |
411 |
++ [[ ${nicesymlink} == /* ]] || die "${dieprefix}: old provider ${oldcur} provides bad symlink ${symlink}?" |
412 |
++ [[ ${nicesymlink} == */ ]] && die "${dieprefix}: old provider ${oldcur} provides bad symlink ${symlink}?" |
413 |
++ |
414 |
++ oldsymlinks+=( "${nicesymlink}" ) |
415 |
++ done < <(LC_ALL=C sort -r -u -z "${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list") |
416 |
++ [[ ${#oldsymlinks[@]} -gt 0 ]] || die "${dieprefix}: old provider ${oldcur} does not provide any symlinks?" |
417 |
++ |
418 |
++ elif [[ -L ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list || -e ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list ]]; then |
419 |
++ die "${dieprefix}: ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list is not a file" |
420 |
++ fi |
421 |
++ |
422 |
++ local pass errors= |
423 |
++ for pass in check perform; do |
424 |
++ local -i new_i=0 old_i=0 |
425 |
++ while [[ -n ${newsymlinks[new_i]} || -n ${oldsymlinks[old_i]} ]]; do |
426 |
++ |
427 |
++ if ( LC_ALL=C; [[ ${newsymlinks[new_i]} < ${oldsymlinks[old_i]} ]] ); then |
428 |
++ if [[ ${pass} == check ]]; then |
429 |
++ if [[ -L ${EROOT}${oldsymlinks[old_i]} ]]; then |
430 |
++ : |
431 |
++ elif [[ -d ${EROOT}${oldsymlinks[old_i]} ]]; then |
432 |
++ 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}" |
433 |
++ errors=yes |
434 |
++ elif [[ -e ${EROOT}${oldsymlinks[old_i]} ]]; then |
435 |
++ if [[ -n ${force} ]]; then |
436 |
++ write_warning_msg "Removing ${EROOT}${oldsymlinks[old_i]} due to --force: is not a symlink" |
437 |
++ else |
438 |
++ write_error_msg "Refusing to remove ${EROOT}${oldsymlinks[old_i]}: is not a symlink (use --force to override)" |
439 |
++ errors=yes |
440 |
++ fi |
441 |
++ fi |
442 |
++ |
443 |
++ elif [[ ${pass} == perform ]]; then |
444 |
++ rm -f "${ROOT}${oldsymlinks[old_i]}" || die "${dieprefix}: rm failed" |
445 |
++ else |
446 |
++ die "${dieprefix}: unknown \${pass} ${pass}???" |
447 |
++ fi |
448 |
++ |
449 |
++ old_i+=1 |
450 |
++ |
451 |
++ else |
452 |
++ local target=${ALTERNATIVESDIR_ROOTLESS#/}/${ALTERNATIVE}/_current${newsymlinks[new_i]} dir=${newsymlinks[new_i]%/*} |
453 |
++ while [[ -n ${dir} ]]; do |
454 |
++ target=../${target} |
455 |
++ dir=${dir%/*} |
456 |
++ done |
457 |
++ |
458 |
++ if [[ ${pass} == check ]]; then |
459 |
++ if [[ -L ${EROOT}${newsymlinks[new_i]} ]]; then |
460 |
++ : |
461 |
++ elif [[ -d ${EROOT}${newsymlinks[new_i]} ]]; then |
462 |
++ 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}" |
463 |
++ errors=yes |
464 |
++ elif [[ -e ${EROOT}${newsymlinks[new_i]} ]]; then |
465 |
++ if [[ -n ${force} ]]; then |
466 |
++ write_warning_msg "Overwriting ${EROOT}${newsymlinks[new_i]} due to --force: is not a symlink" |
467 |
++ else |
468 |
++ write_error_msg "Refusing to overwrite ${EROOT}${newsymlinks[new_i]}: is not a symlink (use --force to override)" |
469 |
++ errors=yes |
470 |
++ fi |
471 |
++ fi |
472 |
++ |
473 |
++ elif [[ ${pass} == perform ]]; then |
474 |
++ mkdir -p "${EROOT}${newsymlinks[new_i]%/*}" || die "${dieprefix}: mkdir -p failed" |
475 |
++ ln -snf "${target#/}" "${EROOT}${newsymlinks[new_i]}" || die "${dieprefix}: ln -snf failed" |
476 |
++ else |
477 |
++ die "${dieprefix}: unknown \${pass} ${pass}???" |
478 |
++ fi |
479 |
++ |
480 |
++ [[ ${newsymlinks[new_i]} == ${oldsymlinks[old_i]} ]] && old_i+=1 |
481 |
++ new_i+=1 |
482 |
++ fi |
483 |
++ done |
484 |
++ |
485 |
++ [[ -n ${errors} ]] && die "${dieprefix}: see previous errors" |
486 |
++ done |
487 |
++ |
488 |
++ local oldcur="$(get_current_provider)" |
489 |
++ ln -snf "${provider}" "${ALTERNATIVESDIR}/${ALTERNATIVE}/_current" || die "${dieprefix}: ln -snf failed" |
490 |
++ |
491 |
++ : >"${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list" || die "${dieprefix}: emptying/creating _current_list failed" |
492 |
++ for symlink in "${newsymlinks[@]}"; do |
493 |
++ echo -n -e "${symlink}\\0" >>"${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list" || die "${dieprefix}: appending ${symlink} to _current_list failed" |
494 |
++ done |
495 |
++ return 0 |
496 |
++} |
497 |
++ |
498 |
++_options_parameters() { |
499 |
++ [[ -n ${2} && ${2} != --descriptions ]] && die -q "Unrecognised option ${2}" |
500 |
++ local describe_func=describe_${1#options_}_options descriptions=${2} opt options oldifs=$IFS |
501 |
++ if is_function ${describe_func}; then |
502 |
++ IFS=$'\n' |
503 |
++ options=( $(${describe_func}) ) |
504 |
++ IFS=$oldifs |
505 |
++ for opt in "${options[@]}"; do |
506 |
++ [[ ${opt} == --* ]] || continue |
507 |
++ if [[ -n ${descriptions} ]]; then |
508 |
++ echo "${opt/ : /:}" |
509 |
++ else |
510 |
++ echo "${opt%% : *}" |
511 |
++ fi |
512 |
++ done |
513 |
++ fi |
514 |
++} |
515 |
++ |
516 |
++options_set() { |
517 |
++ _options_parameters $FUNCNAME "$@" |
518 |
++ get_providers |
519 |
++} |
520 |
++ |
521 |
++### update action ### |
522 |
++ |
523 |
++describe_update() { |
524 |
++ echo "Set a default provider if no valid one currently exists" |
525 |
++} |
526 |
++ |
527 |
++describe_update_parameters() { |
528 |
++ echo "[--ignore] <provider>" |
529 |
++} |
530 |
++ |
531 |
++describe_update_options() { |
532 |
++ echo "--ignore : update to any valid provider EXCEPT the specified provider" |
533 |
++ echo "<provider> : the name of the provider to use" |
534 |
++} |
535 |
++ |
536 |
++do_update() { |
537 |
++ [[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module" |
538 |
++ |
539 |
++ local p cur=$(get_current_provider) providers=( $(get_providers) ) ignore |
540 |
++ if [[ "--ignore" == ${1} ]] ; then |
541 |
++ # Try everything except setting the provider to the given |
542 |
++ # one. So, if it isn't the given one, we end up doing |
543 |
++ # nothing. Bug #128 |
544 |
++ shift |
545 |
++ ignore=${1} |
546 |
++ fi |
547 |
++ |
548 |
++ if [[ ${cur} == ${1} && -z ${ignore} ]]; then |
549 |
++ # if current provider was just updated, reselect it since it could have changed |
550 |
++ do_set "${cur}" && return 0 |
551 |
++ elif [[ -n ${cur} && ${cur} != ${ignore} ]] ; then |
552 |
++ # verify existing provider's symlinks |
553 |
++ local p= bad=0 |
554 |
++ while read -r -d '' p ; do |
555 |
++ [[ -L "${EROOT}${p}" && -e "${EROOT}${p}" ]] || (( bad++ )) |
556 |
++ done < "${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list" |
557 |
++ |
558 |
++ [[ "${bad}" -eq 0 ]] && return 0 |
559 |
++ # fix existing provider if possible |
560 |
++ has "${cur}" "${providers[@]}" && do_set "${cur}" && return 0 |
561 |
++ elif has "${1}" "${providers[@]}" && [[ -z ${ignore} ]] ; then |
562 |
++ # switch to new provider if none was set before or it can't be fixed |
563 |
++ do_set "${1}" && return 0 |
564 |
++ fi |
565 |
++ |
566 |
++ # if no valid provider has been selected switch to first available, valid |
567 |
++ # provider, sorted according to importance |
568 |
++ for p in "${providers[@]}"; do |
569 |
++ [[ ${ignore} != ${p} ]] && do_set "${p}" && return 0 |
570 |
++ done |
571 |
++ |
572 |
++ # if a provider is set but no providers are available anymore cleanup |
573 |
++ cur=$(get_current_provider) |
574 |
++ if [[ -n ${cur} ]]; then |
575 |
++ do_unset "${cur}" && return 2 |
576 |
++ fi |
577 |
++ # if no provider is set and none are available that are not ignored, return 2 for cleanup |
578 |
++ [[ -z ${providers[@]} || ${providers[@]} == ${ignore} ]] && return 2 |
579 |
++ |
580 |
++ # we tried everything to select a valid provider, but failed |
581 |
++ return 1 |
582 |
++} |
583 |
++ |
584 |
++options_update() { |
585 |
++ _options_parameters $FUNCNAME "$@" |
586 |
++ get_providers |
587 |
++} |
588 |
++ |
589 |
++### unset action ### |
590 |
++ |
591 |
++describe_unset() { |
592 |
++ echo "Unset any symlinks created for the current provider for ${ALTERNATIVE}." |
593 |
++} |
594 |
++ |
595 |
++describe_unset_parameters() { |
596 |
++ echo "[ --force ]" |
597 |
++} |
598 |
++ |
599 |
++describe_unset_options() { |
600 |
++ echo "--force : remove existing non-symlink files (but not directories) if necessary" |
601 |
++} |
602 |
++ |
603 |
++do_unset() { |
604 |
++ [[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module" |
605 |
++ |
606 |
++ local force= |
607 |
++ if [[ ${1} == --force ]]; then |
608 |
++ force=yes |
609 |
++ shift |
610 |
++ fi |
611 |
++ |
612 |
++ local cur="$(get_current_provider)" p= |
613 |
++ [[ -n "${cur}" ]] || die -q "Nothing to unset" |
614 |
++ local dieprefix="Could not unset provider for ${ALTERNATIVE}" |
615 |
++ |
616 |
++ local one=false symlink pass errors= |
617 |
++ for pass in check perform; do |
618 |
++ while read -r -d '' symlink; do |
619 |
++ one=true |
620 |
++ if [[ ${pass} == check ]]; then |
621 |
++ if [[ -L ${EROOT}${symlink} ]]; then |
622 |
++ : |
623 |
++ elif [[ -d ${EROOT}${symlink} ]]; then |
624 |
++ write_error_msg "Can't remove ${EROOT}${symlink}: is a directory${force:+ which is a fatal error that cannot be ignored by --force}" |
625 |
++ errors=yes |
626 |
++ elif [[ -e ${EROOT}${symlink} ]]; then |
627 |
++ if [[ -n ${force} ]]; then |
628 |
++ write_warning_msg "Removing ${EROOT}${symlink} due to --force: is not a symlink" |
629 |
++ else |
630 |
++ write_error_msg "Refusing to remove ${EROOT}${symlink}: is not a symlink (use --force to override)" |
631 |
++ errors=yes |
632 |
++ fi |
633 |
++ fi |
634 |
++ |
635 |
++ elif [[ ${pass} == perform ]]; then |
636 |
++ rm -f "${EROOT}${symlink}" || die "${dieprefix}: rm failed" |
637 |
++ else |
638 |
++ die "${dieprefix}: unknown \${pass} ${pass}???" |
639 |
++ fi |
640 |
++ done <"${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list" |
641 |
++ |
642 |
++ [[ -n ${errors} ]] && die "${dieprefix}: see previous errors" |
643 |
++ done |
644 |
++ |
645 |
++ ${one} || die "${dieprefix}: does not provide any symlinks?" |
646 |
++ |
647 |
++ rm "${ALTERNATIVESDIR}/${ALTERNATIVE}"/{_current,_current_list} || die "${dieprefix}: rm failed" |
648 |
++} |
649 |
++ |
650 |
++options_unset() { |
651 |
++ _options_parameters $FUNCNAME "$@" |
652 |
++ get_current_provider |
653 |
++} |
654 |
++ |
655 |
++### script action ### |
656 |
++ |
657 |
++describe_script() { |
658 |
++ echo "Output an evalable script fragment to set PATH, LD_LIBRARY_PATH and MANPATH to use the specified provider" |
659 |
++} |
660 |
++ |
661 |
++describe_script_parameters() { |
662 |
++ echo "[--sh | --csh] [<provider>]" |
663 |
++} |
664 |
++ |
665 |
++describe_script_options() { |
666 |
++ echo "--sh : use Bourne shell syntax (default)" |
667 |
++ echo "--csh : use C shell syntax" |
668 |
++ echo "<provider> : the provider to use or the index of the provider preceeded by a dash (if not specified, use the system default)" |
669 |
++} |
670 |
++ |
671 |
++do_script() { |
672 |
++ [[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module" |
673 |
++ local syntax=sh provider providers |
674 |
++ if [[ ${1} == --sh ]]; then |
675 |
++ shift |
676 |
++ elif [[ ${1} == --csh ]]; then |
677 |
++ syntax=csh |
678 |
++ shift |
679 |
++ fi |
680 |
++ |
681 |
++ if [[ ${1} == -+([[:digit:]]) ]]; then |
682 |
++ providers=( $(get_providers) ) |
683 |
++ (( ${1#-} <= ${#providers[@]} )) || die -q "The given provider with index (${1#-}) does not exist" |
684 |
++ provider=${providers[${1#-}-1]} |
685 |
++ else |
686 |
++ provider="${1}" |
687 |
++ fi |
688 |
++ [[ -z "${provider}" ]] && die -q "Missing required parameter 'provider'" |
689 |
++ |
690 |
++ if [[ ! -d ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider} ]] ; then |
691 |
++ if is_number ${provider} ; then |
692 |
++ providers=( $(get_providers) ) |
693 |
++ [[ -n ${providers[${1#-}-1]} ]] && |
694 |
++ die -q "The given provider (${provider}) does not exist, did you mean -${provider} (${providers[${1#-}-1]})?" |
695 |
++ fi |
696 |
++ die -q "The given provider (${provider}) does not exist" |
697 |
++ fi |
698 |
++ |
699 |
++ local variables=( PATH LD_LIBRARY_PATH MANPATH ) |
700 |
++ [[ -n ${!default_*} ]] && local ${!default_*} |
701 |
++ local default_LD_LIBRARY_PATH=$(grep '^[^#]' "${EROOT}"/etc/ld.so.conf | tr '\n' ':')/lib:/usr/lib |
702 |
++ local default_MANPATH=$(MANPATH= man -C"${EROOT}"/etc/man.conf -w) |
703 |
++ |
704 |
++ local var IFS=: |
705 |
++ for var in "${variables[@]}"; do |
706 |
++ local defvar=default_${var} path paths=( ) |
707 |
++ for path in ${!var}; do |
708 |
++ [[ ${path} == ${ALTERNATIVESDIR_ROOTLESS}/${ALTERNATIVE}/* ]] && continue |
709 |
++ [[ -n ${provider} && -d ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider}/${path#/} ]] && paths+=( "${ALTERNATIVESDIR_ROOTLESS}/${ALTERNATIVE}/${provider}/${path#/}" ) |
710 |
++ paths+=( "${path}" ) |
711 |
++ done |
712 |
++ |
713 |
++ [[ -n ${provider} ]] && for path in ${!defvar}; do |
714 |
++ [[ -d ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider}/${path#/} ]] && paths+=( "${ALTERNATIVESDIR_ROOTLESS}/${ALTERNATIVE}/${provider}/${path#/}" ) |
715 |
++ done |
716 |
++ |
717 |
++ local newval=${paths[*]} |
718 |
++ if [[ ${newval} != ${!var} ]]; then |
719 |
++ newval=${newval//\'/\'\\\'\'} |
720 |
++ if [[ ${syntax} == sh ]]; then |
721 |
++ echo "${var}='${newval}'; export ${var}" |
722 |
++ else |
723 |
++ echo "setenv ${var} '${newval}'" |
724 |
++ fi |
725 |
++ fi |
726 |
++ done |
727 |
++} |
728 |
++ |
729 |
++options_script() { |
730 |
++ _options_parameters $FUNCNAME "$@" |
731 |
++ get_providers |
732 |
++} |
733 |
++ |
734 |
++# vim: set ft=eselect sw=4 sts=4 ts=4 et tw=80 : |