Line 0
Link Here
|
|
|
1 |
# Copyright 2008 Mike Kelly |
2 |
# Copyright 2009 David Leverton |
3 |
# Copyright 2010 Bo Ørsted Andresen |
4 |
# Distributed under the terms of the GNU General Public License v2 |
5 |
|
6 |
inherit config output path-manipulation |
7 |
|
8 |
ALTERNATIVESDIR_ROOTLESS="@sysconfdir@/env.d/alternatives" |
9 |
ALTERNATIVESDIR="${EROOT}${ALTERNATIVESDIR_ROOTLESS}" |
10 |
|
11 |
get_current_provider() { |
12 |
local dieprefix="Could not determine current provider for ${ALTERNATIVE}" |
13 |
if [[ -L ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current ]]; then |
14 |
local provider=$(readlink "${ALTERNATIVESDIR}/${ALTERNATIVE}/_current" || die "${dieprefix}: readlink ${symlink} failed") |
15 |
[[ ${provider} == */* ]] && die "${dieprefix}: malformed target for ${symlink}" |
16 |
|
17 |
if [[ -L ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider} || |
18 |
( -e ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider} && ! -d ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider} ) ]]; then |
19 |
die "${dieprefix}: ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider} is not a directory" |
20 |
fi |
21 |
|
22 |
echo "${provider}" |
23 |
|
24 |
elif [[ -e ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current ]]; then |
25 |
die "${dieprefix}: ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current is not a symlink" |
26 |
fi |
27 |
} |
28 |
|
29 |
compare_importance() { |
30 |
local IFS=. |
31 |
local a=( ${1} ) b=( ${2} ) |
32 |
local -i i=0 |
33 |
while (( i<${#a[@]} && i<${#b[@]} )); do |
34 |
if (( a[i]<b[i] )); then |
35 |
return 0 |
36 |
elif (( a[i]>b[i] )); then |
37 |
return 1 |
38 |
fi |
39 |
i+=1 |
40 |
done |
41 |
(( i<${#b[@]} )) |
42 |
} |
43 |
|
44 |
sort_providers() { |
45 |
local begin=${1:-0} |
46 |
local count=${2:-${#providers[@]}} |
47 |
[[ ${count} -le 1 ]] && return 0 |
48 |
sort_providers ${begin} $((count/2)) |
49 |
sort_providers $((begin+count/2)) $((count-count/2)) |
50 |
local left=( "${providers[@]:begin:count/2}" ) |
51 |
local right=( "${providers[@]:begin+count/2:count-count/2}" ) |
52 |
local -i x i=0 j=0 |
53 |
for (( x=begin; x<begin+count; ++x )); do |
54 |
if (( j>=${#right[@]} )) || { (( i<${#left[@]} )) && compare_importance "${left[i]%%:*}" "${right[j]%%:*}"; }; then |
55 |
providers[x]=${left[i++]} |
56 |
else |
57 |
providers[x]=${right[j++]} |
58 |
fi |
59 |
done |
60 |
} |
61 |
|
62 |
get_providers() { |
63 |
local p= importance providers=() |
64 |
for p in "${ALTERNATIVESDIR}/${ALTERNATIVE}"/* ; do |
65 |
[[ -d ${p} && ! -L ${p} ]] || continue |
66 |
p=${p##*/} |
67 |
|
68 |
importance=$(< "${ALTERNATIVESDIR}/${ALTERNATIVE}/${p}/_importance") |
69 |
importance=${importance:-0} |
70 |
[[ "${importance}" =~ ^[0123456789]+(\.[0123456789]+)*$ ]] || die "_importance (${importance}) for ${p} is not a dot-separated list of integers" |
71 |
|
72 |
providers+=( "${importance}:${p}" ) |
73 |
done |
74 |
|
75 |
sort_providers |
76 |
for (( p=${#providers[@]}-1 ; p>=0 ; --p )); do |
77 |
echo "${providers[p]#*:}" |
78 |
done |
79 |
} |
80 |
|
81 |
### show action ### |
82 |
describe_show() { |
83 |
echo "Show the current provider in use for ${ALTERNATIVE}" |
84 |
} |
85 |
|
86 |
do_show() { |
87 |
[[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module" |
88 |
local current="$(get_current_provider)" |
89 |
if [[ -z "${current}" ]] ; then |
90 |
echo "(none)" |
91 |
return 2 |
92 |
fi |
93 |
echo "${current}" |
94 |
} |
95 |
|
96 |
options_show() { |
97 |
: |
98 |
} |
99 |
|
100 |
### list action ### |
101 |
describe_list() { |
102 |
echo "Lists all available providers for ${ALTERNATIVE}" |
103 |
} |
104 |
|
105 |
do_list() { |
106 |
[[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module" |
107 |
local n cur= providers=( $(get_providers) ) |
108 |
write_list_start "Available providers for ${ALTERNATIVE}:" |
109 |
|
110 |
cur="$(get_current_provider)" |
111 |
|
112 |
if [[ -n "${providers[@]}" ]] ; then |
113 |
for (( n = 0 ; n < ${#providers[@]} ; ++n )) ; do |
114 |
[[ ${cur} == "${providers[${n}]}" ]] && \ |
115 |
providers[${n}]="${providers[${n}]} $(highlight '*')" |
116 |
done |
117 |
write_numbered_list "${providers[@]}" |
118 |
else |
119 |
write_kv_list_entry "(none found)" "" |
120 |
fi |
121 |
} |
122 |
|
123 |
options_list() { |
124 |
: |
125 |
} |
126 |
|
127 |
### files action ### |
128 |
describe_files() { |
129 |
echo "Lists symlinks provided by the currently selected provider" |
130 |
} |
131 |
|
132 |
do_files() { |
133 |
[[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module" |
134 |
|
135 |
local cur="$(get_current_provider)" p= |
136 |
[[ -n "${cur}" ]] || die -q "No selected provider, hence no symlinks provided" |
137 |
local dieprefix="Could not list symlinks provided for ${ALTERNATIVE}" |
138 |
|
139 |
local errors symlink rootsymlink |
140 |
while read -r -d '' symlink; do |
141 |
rootsymlink="${EROOT}${symlink}" |
142 |
rootsymlink=${rootsymlink//+(\/)/\/} |
143 |
echo "${rootsymlink}" |
144 |
if [[ -L ${rootsymlink} ]]; then |
145 |
if [[ ! -e ${rootsymlink} ]]; then |
146 |
write_error_msg "${rootsymlink} is dangling symlink" |
147 |
errors=yes |
148 |
fi |
149 |
elif [[ -d ${rootsymlink} ]]; then |
150 |
write_error_msg "${rootsymlink} is a directory" |
151 |
errors=yes |
152 |
elif [[ -e ${rootsymlink} ]]; then |
153 |
write_error_msg "${rootsymlink} exists but is not a symlink" |
154 |
errors=yes |
155 |
else |
156 |
write_error_msg "${rootsymlink} does not exist" |
157 |
errors=yes |
158 |
fi |
159 |
done <"${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list" |
160 |
} |
161 |
|
162 |
options_files() { |
163 |
: |
164 |
} |
165 |
|
166 |
### set action ### |
167 |
|
168 |
describe_set() { |
169 |
echo "Sets a provider for ${ALTERNATIVE}" |
170 |
} |
171 |
|
172 |
describe_set_parameters() { |
173 |
echo "[ --force ] <provider>" |
174 |
} |
175 |
|
176 |
describe_set_options() { |
177 |
echo "--force : overwrite or remove existing non-symlink files (but not directories) if necessary" |
178 |
echo "<provider> : the name of the provider to use" |
179 |
} |
180 |
|
181 |
do_set() { |
182 |
[[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module" |
183 |
|
184 |
local force= |
185 |
if [[ ${1} == --force ]]; then |
186 |
force=yes |
187 |
shift |
188 |
fi |
189 |
|
190 |
local provider="${1}" |
191 |
[[ -z "${provider}" ]] && die -q "Missing required parameter 'provider'" |
192 |
if is_number "${provider}" ; then |
193 |
local providers=( $(get_providers) ) |
194 |
(( ${provider} <= ${#providers[@]} )) || die -q "The given provider (${provider}) does not exist" |
195 |
provider=${providers[${provider}-1]} |
196 |
fi |
197 |
local dieprefix="Could not set provider ${provider} for alternative ${ALTERNATIVE}" |
198 |
|
199 |
[[ -d ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider} ]] \ |
200 |
|| die -q "The given provider (${provider}) does not exist" |
201 |
|
202 |
local symlink newsymlinks=() oldsymlinks=() |
203 |
|
204 |
while read -r -d '' symlink; do |
205 |
local nicesymlink=${symlink#.} |
206 |
nicesymlink=${nicesymlink//+(\/)/\/} |
207 |
[[ ${nicesymlink} == /* ]] || die "${dieprefix}: bad symlink ${symlink}?" |
208 |
[[ ${nicesymlink} == */ ]] && die "${dieprefix}: bad symlink ${symlink}?" |
209 |
|
210 |
newsymlinks+=( "${nicesymlink}" ) |
211 |
done < <( |
212 |
cd "${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider}" || die "${dieprefix}: cd failed" |
213 |
find . -type l -print0 | LC_ALL=C sort -r -u -z) |
214 |
[[ ${#newsymlinks[@]} -gt 0 ]] || die "${dieprefix}: does not provide any symlinks?" |
215 |
|
216 |
if [[ -f ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list ]]; then |
217 |
while read -r -d '' symlink; do |
218 |
local nicesymlink=${symlink//+(\/)/\/} |
219 |
[[ ${nicesymlink} == /* ]] || die "${dieprefix}: old provider ${oldcur} provides bad symlink ${symlink}?" |
220 |
[[ ${nicesymlink} == */ ]] && die "${dieprefix}: old provider ${oldcur} provides bad symlink ${symlink}?" |
221 |
|
222 |
oldsymlinks+=( "${nicesymlink}" ) |
223 |
done < <(LC_ALL=C sort -r -u -z "${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list") |
224 |
[[ ${#oldsymlinks[@]} -gt 0 ]] || die "${dieprefix}: old provider ${oldcur} does not provide any symlinks?" |
225 |
|
226 |
elif [[ -L ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list || -e ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list ]]; then |
227 |
die "${dieprefix}: ${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list is not a file" |
228 |
fi |
229 |
|
230 |
local pass errors= |
231 |
for pass in check perform; do |
232 |
local -i new_i=0 old_i=0 |
233 |
while [[ -n ${newsymlinks[new_i]} || -n ${oldsymlinks[old_i]} ]]; do |
234 |
|
235 |
if ( LC_ALL=C; [[ ${newsymlinks[new_i]} < ${oldsymlinks[old_i]} ]] ); then |
236 |
if [[ ${pass} == check ]]; then |
237 |
if [[ -L ${EROOT}${oldsymlinks[old_i]} ]]; then |
238 |
: |
239 |
elif [[ -d ${EROOT}${oldsymlinks[old_i]} ]]; then |
240 |
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}" |
241 |
errors=yes |
242 |
elif [[ -e ${EROOT}${oldsymlinks[old_i]} ]]; then |
243 |
if [[ -n ${force} ]]; then |
244 |
write_warning_msg "Removing ${EROOT}${oldsymlinks[old_i]} due to --force: is not a symlink" |
245 |
else |
246 |
write_error_msg "Refusing to remove ${EROOT}${oldsymlinks[old_i]}: is not a symlink (use --force to override)" |
247 |
errors=yes |
248 |
fi |
249 |
fi |
250 |
|
251 |
elif [[ ${pass} == perform ]]; then |
252 |
rm -f "${ROOT}${oldsymlinks[old_i]}" || die "${dieprefix}: rm failed" |
253 |
else |
254 |
die "${dieprefix}: unknown \${pass} ${pass}???" |
255 |
fi |
256 |
|
257 |
old_i+=1 |
258 |
|
259 |
else |
260 |
local target=${ALTERNATIVESDIR_ROOTLESS#/}/${ALTERNATIVE}/_current${newsymlinks[new_i]} dir=${newsymlinks[new_i]%/*} |
261 |
while [[ -n ${dir} ]]; do |
262 |
target=../${target} |
263 |
dir=${dir%/*} |
264 |
done |
265 |
|
266 |
if [[ ${pass} == check ]]; then |
267 |
if [[ -L ${EROOT}${newsymlinks[new_i]} ]]; then |
268 |
: |
269 |
elif [[ -d ${EROOT}${newsymlinks[new_i]} ]]; then |
270 |
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}" |
271 |
errors=yes |
272 |
elif [[ -e ${EROOT}${newsymlinks[new_i]} ]]; then |
273 |
if [[ -n ${force} ]]; then |
274 |
write_warning_msg "Overwriting ${EROOT}${newsymlinks[new_i]} due to --force: is not a symlink" |
275 |
else |
276 |
write_error_msg "Refusing to overwrite ${EROOT}${newsymlinks[new_i]}: is not a symlink (use --force to override)" |
277 |
errors=yes |
278 |
fi |
279 |
fi |
280 |
|
281 |
elif [[ ${pass} == perform ]]; then |
282 |
mkdir -p "${EROOT}${newsymlinks[new_i]%/*}" || die "${dieprefix}: mkdir -p failed" |
283 |
ln -snf "${target#/}" "${EROOT}${newsymlinks[new_i]}" || die "${dieprefix}: ln -snf failed" |
284 |
else |
285 |
die "${dieprefix}: unknown \${pass} ${pass}???" |
286 |
fi |
287 |
|
288 |
[[ ${newsymlinks[new_i]} == ${oldsymlinks[old_i]} ]] && old_i+=1 |
289 |
new_i+=1 |
290 |
fi |
291 |
done |
292 |
|
293 |
[[ -n ${errors} ]] && die "${dieprefix}: see previous errors" |
294 |
done |
295 |
|
296 |
local oldcur="$(get_current_provider)" |
297 |
ln -snf "${provider}" "${ALTERNATIVESDIR}/${ALTERNATIVE}/_current" || die "${dieprefix}: ln -snf failed" |
298 |
|
299 |
: >"${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list" || die "${dieprefix}: emptying/creating _current_list failed" |
300 |
for symlink in "${newsymlinks[@]}"; do |
301 |
echo -n -e "${symlink}\\0" >>"${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list" || die "${dieprefix}: appending ${symlink} to _current_list failed" |
302 |
done |
303 |
return 0 |
304 |
} |
305 |
|
306 |
_options_parameters() { |
307 |
[[ -n ${2} && ${2} != --descriptions ]] && die -q "Unrecognised option ${2}" |
308 |
local describe_func=describe_${1#options_}_options descriptions=${2} opt options oldifs=$IFS |
309 |
if is_function ${describe_func}; then |
310 |
IFS=$'\n' |
311 |
options=( $(${describe_func}) ) |
312 |
IFS=$oldifs |
313 |
for opt in "${options[@]}"; do |
314 |
[[ ${opt} == --* ]] || continue |
315 |
if [[ -n ${descriptions} ]]; then |
316 |
echo "${opt/ : /:}" |
317 |
else |
318 |
echo "${opt%% : *}" |
319 |
fi |
320 |
done |
321 |
fi |
322 |
} |
323 |
|
324 |
options_set() { |
325 |
_options_parameters $FUNCNAME "$@" |
326 |
get_providers |
327 |
} |
328 |
|
329 |
### update action ### |
330 |
|
331 |
describe_update() { |
332 |
echo "Set a default provider if no valid one currently exists" |
333 |
} |
334 |
|
335 |
describe_update_parameters() { |
336 |
echo "[--ignore] <provider>" |
337 |
} |
338 |
|
339 |
describe_update_options() { |
340 |
echo "--ignore : update to any valid provider EXCEPT the specified provider" |
341 |
echo "<provider> : the name of the provider to use" |
342 |
} |
343 |
|
344 |
do_update() { |
345 |
[[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module" |
346 |
|
347 |
local p cur=$(get_current_provider) providers=( $(get_providers) ) ignore |
348 |
if [[ "--ignore" == ${1} ]] ; then |
349 |
# Try everything except setting the provider to the given |
350 |
# one. So, if it isn't the given one, we end up doing |
351 |
# nothing. Bug #128 |
352 |
shift |
353 |
ignore=${1} |
354 |
fi |
355 |
|
356 |
if [[ ${cur} == ${1} && -z ${ignore} ]]; then |
357 |
# if current provider was just updated, reselect it since it could have changed |
358 |
do_set "${cur}" && return 0 |
359 |
elif [[ -n ${cur} && ${cur} != ${ignore} ]] ; then |
360 |
# verify existing provider's symlinks |
361 |
local p= bad=0 |
362 |
while read -r -d '' p ; do |
363 |
[[ -L "${EROOT}${p}" && -e "${EROOT}${p}" ]] || (( bad++ )) |
364 |
done < "${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list" |
365 |
|
366 |
[[ "${bad}" -eq 0 ]] && return 0 |
367 |
# fix existing provider if possible |
368 |
has "${cur}" "${providers[@]}" && do_set "${cur}" && return 0 |
369 |
elif has "${1}" "${providers[@]}" && [[ -z ${ignore} ]] ; then |
370 |
# switch to new provider if none was set before or it can't be fixed |
371 |
do_set "${1}" && return 0 |
372 |
fi |
373 |
|
374 |
# if no valid provider has been selected switch to first available, valid |
375 |
# provider, sorted according to importance |
376 |
for p in "${providers[@]}"; do |
377 |
[[ ${ignore} != ${p} ]] && do_set "${p}" && return 0 |
378 |
done |
379 |
|
380 |
# if a provider is set but no providers are available anymore cleanup |
381 |
cur=$(get_current_provider) |
382 |
if [[ -n ${cur} ]]; then |
383 |
do_unset "${cur}" && return 2 |
384 |
fi |
385 |
# if no provider is set and none are available that are not ignored, return 2 for cleanup |
386 |
[[ -z ${providers[@]} || ${providers[@]} == ${ignore} ]] && return 2 |
387 |
|
388 |
# we tried everything to select a valid provider, but failed |
389 |
return 1 |
390 |
} |
391 |
|
392 |
options_update() { |
393 |
_options_parameters $FUNCNAME "$@" |
394 |
get_providers |
395 |
} |
396 |
|
397 |
### unset action ### |
398 |
|
399 |
describe_unset() { |
400 |
echo "Unset any symlinks created for the current provider for ${ALTERNATIVE}." |
401 |
} |
402 |
|
403 |
describe_unset_parameters() { |
404 |
echo "[ --force ]" |
405 |
} |
406 |
|
407 |
describe_unset_options() { |
408 |
echo "--force : remove existing non-symlink files (but not directories) if necessary" |
409 |
} |
410 |
|
411 |
do_unset() { |
412 |
[[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module" |
413 |
|
414 |
local force= |
415 |
if [[ ${1} == --force ]]; then |
416 |
force=yes |
417 |
shift |
418 |
fi |
419 |
|
420 |
local cur="$(get_current_provider)" p= |
421 |
[[ -n "${cur}" ]] || die -q "Nothing to unset" |
422 |
local dieprefix="Could not unset provider for ${ALTERNATIVE}" |
423 |
|
424 |
local one=false symlink pass errors= |
425 |
for pass in check perform; do |
426 |
while read -r -d '' symlink; do |
427 |
one=true |
428 |
if [[ ${pass} == check ]]; then |
429 |
if [[ -L ${EROOT}${symlink} ]]; then |
430 |
: |
431 |
elif [[ -d ${EROOT}${symlink} ]]; then |
432 |
write_error_msg "Can't remove ${EROOT}${symlink}: is a directory${force:+ which is a fatal error that cannot be ignored by --force}" |
433 |
errors=yes |
434 |
elif [[ -e ${EROOT}${symlink} ]]; then |
435 |
if [[ -n ${force} ]]; then |
436 |
write_warning_msg "Removing ${EROOT}${symlink} due to --force: is not a symlink" |
437 |
else |
438 |
write_error_msg "Refusing to remove ${EROOT}${symlink}: is not a symlink (use --force to override)" |
439 |
errors=yes |
440 |
fi |
441 |
fi |
442 |
|
443 |
elif [[ ${pass} == perform ]]; then |
444 |
rm -f "${EROOT}${symlink}" || die "${dieprefix}: rm failed" |
445 |
else |
446 |
die "${dieprefix}: unknown \${pass} ${pass}???" |
447 |
fi |
448 |
done <"${ALTERNATIVESDIR}/${ALTERNATIVE}/_current_list" |
449 |
|
450 |
[[ -n ${errors} ]] && die "${dieprefix}: see previous errors" |
451 |
done |
452 |
|
453 |
${one} || die "${dieprefix}: does not provide any symlinks?" |
454 |
|
455 |
rm "${ALTERNATIVESDIR}/${ALTERNATIVE}"/{_current,_current_list} || die "${dieprefix}: rm failed" |
456 |
} |
457 |
|
458 |
options_unset() { |
459 |
_options_parameters $FUNCNAME "$@" |
460 |
get_current_provider |
461 |
} |
462 |
|
463 |
### script action ### |
464 |
|
465 |
describe_script() { |
466 |
echo "Output an evalable script fragment to set PATH, LD_LIBRARY_PATH and MANPATH to use the specified provider" |
467 |
} |
468 |
|
469 |
describe_script_parameters() { |
470 |
echo "[--sh | --csh] [<provider>]" |
471 |
} |
472 |
|
473 |
describe_script_options() { |
474 |
echo "--sh : use Bourne shell syntax (default)" |
475 |
echo "--csh : use C shell syntax" |
476 |
echo "<provider> : the provider to use (if not specified, use the system default)" |
477 |
} |
478 |
|
479 |
do_script() { |
480 |
[[ -z "${ALTERNATIVE}" ]] && die "Need to set ALTERNATIVE in the eselect module" |
481 |
local syntax=sh |
482 |
if [[ ${1} == --sh ]]; then |
483 |
shift |
484 |
elif [[ ${1} == --csh ]]; then |
485 |
syntax=csh |
486 |
shift |
487 |
fi |
488 |
local provider=${1} |
489 |
[[ -z "${provider}" ]] && die -q "Missing required parameter 'provider'" |
490 |
if is_number "${provider}" ; then |
491 |
local providers=( $(get_providers) ) |
492 |
(( ${provider} <= ${#providers[@]} )) || die -q "The given provider (${provider}) does not exist" |
493 |
provider=${providers[${provider}-1]} |
494 |
fi |
495 |
[[ -d ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider} ]] || die -q "The given provider (${provider}) does not exist" |
496 |
|
497 |
local variables=( PATH LD_LIBRARY_PATH MANPATH ) |
498 |
[[ -n ${!default_*} ]] && local ${!default_*} |
499 |
local default_LD_LIBRARY_PATH=$(grep '^[^#]' "${EROOT}"/etc/ld.so.conf | tr '\n' ':')/lib:/usr/lib |
500 |
local default_MANPATH=$(MANPATH= man -C"${EROOT}"/etc/man.conf -w) |
501 |
|
502 |
local var IFS=: |
503 |
for var in "${variables[@]}"; do |
504 |
local defvar=default_${var} path paths=( ) |
505 |
for path in ${!var}; do |
506 |
[[ ${path} == ${ALTERNATIVESDIR_ROOTLESS}/${ALTERNATIVE}/* ]] && continue |
507 |
[[ -n ${provider} && -d ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider}/${path#/} ]] && paths+=( "${ALTERNATIVESDIR_ROOTLESS}/${ALTERNATIVE}/${provider}/${path#/}" ) |
508 |
paths+=( "${path}" ) |
509 |
done |
510 |
|
511 |
[[ -n ${provider} ]] && for path in ${!defvar}; do |
512 |
[[ -d ${ALTERNATIVESDIR}/${ALTERNATIVE}/${provider}/${path#/} ]] && paths+=( "${ALTERNATIVESDIR_ROOTLESS}/${ALTERNATIVE}/${provider}/${path#/}" ) |
513 |
done |
514 |
|
515 |
local newval=${paths[*]} |
516 |
if [[ ${newval} != ${!var} ]]; then |
517 |
newval=${newval//\'/\'\\\'\'} |
518 |
if [[ ${syntax} == sh ]]; then |
519 |
echo "${var}='${newval}'; export ${var}" |
520 |
else |
521 |
echo "setenv ${var} '${newval}'" |
522 |
fi |
523 |
fi |
524 |
done |
525 |
} |
526 |
|
527 |
options_script() { |
528 |
_options_parameters $FUNCNAME "$@" |
529 |
get_providers |
530 |
} |
531 |
|
532 |
# vim: set ft=eselect sw=4 sts=4 ts=4 et tw=80 : |