Gentoo Archives: gentoo-commits

From: "Ulrich Mueller (ulm)" <ulm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] eselect r483 - in trunk: . modules
Date: Tue, 21 Apr 2009 08:21:51
Message-Id: E1LwBEh-0007WI-PQ@stork.gentoo.org
1 Author: ulm
2 Date: 2009-04-21 08:21:47 +0000 (Tue, 21 Apr 2009)
3 New Revision: 483
4
5 Removed:
6 trunk/modules/compiler.eselect.in
7 Modified:
8 trunk/ChangeLog
9 Log:
10 Remove dead module.
11
12 Modified: trunk/ChangeLog
13 ===================================================================
14 --- trunk/ChangeLog 2009-04-21 06:56:46 UTC (rev 482)
15 +++ trunk/ChangeLog 2009-04-21 08:21:47 UTC (rev 483)
16 @@ -1,5 +1,7 @@
17 2009-04-21 Ulrich Mueller <ulm@g.o>
18
19 + * modules/compiler.eselect.in: Remove dead module.
20 +
21 * modules/rc.eselect (do_show): Add --all option.
22 (describe_show_options): Document it.
23
24
25 Deleted: trunk/modules/compiler.eselect.in
26 ===================================================================
27 --- trunk/modules/compiler.eselect.in 2009-04-21 06:56:46 UTC (rev 482)
28 +++ trunk/modules/compiler.eselect.in 2009-04-21 08:21:47 UTC (rev 483)
29 @@ -1,774 +0,0 @@
30 -# Copyright 2005 Gentoo Foundation
31 -# Distributed under the terms of the GNU General Public License v2
32 -# $Id$
33 -# Author: Jeremy Huddleston <eradicator@g.o>
34 -
35 -inherit config
36 -
37 -# Eselect data
38 -DESCRIPTION="Manage the installed compilers."
39 -MAINTAINER="toolchain@g.o"
40 -SVN_DATE='$Date$'
41 -VERSION=$(svn_date_to_version "${SVN_DATE}" )
42 -EBUILD_VERSION="@PACKAGE_VERSION@"
43 -
44 -# Our data
45 -ROOT=${ROOT:-/}
46 -ENV_FILE="${ROOT}/etc/env.d/05compiler"
47 -CONFIG_D="${ROOT}@configdir@"
48 -WRAPPER="${ROOT}@evallibexecdir@/eselect/compiler/compiler-wrapper"
49 -PROFILE_MANAGER="@evallibexecdir@/eselect/compiler/profile-manager"
50 -
51 -show_extra_help_text() {
52 - write_list_start "Extra options for all actions:"
53 - write_kv_list_entry "-u, --user" "Use ${HOME}/@userconfigdir@ to override global settings."
54 -}
55 -
56 -### Helpers ###
57 -
58 -eval_pm() {
59 - local tmp=$(mktemp -t tmp.XXXXXX)
60 - local retval
61 -
62 - ${PROFILE_MANAGER} --config-dir="${CONFIG_D}" "${@}" > ${tmp}
63 - retval=${?}
64 - source ${tmp}
65 - rm -f ${tmp}
66 - return ${retval}
67 -}
68 -
69 -list_all_profiles() {
70 - local preopts="${@}"
71 - local ctarget
72 - local profiles_v
73 - local i=0
74 -
75 - for ctarget in ${COMPILER_CONFIG_ALL_CTARGETS} ; do
76 - if (( i == 0 )) ; then
77 - (( i++ ))
78 - else
79 - echo -n " "
80 - fi
81 -
82 - profiles_v="COMPILER_CONFIG_PROFILES_${ctarget//[-.]/_}"
83 - echo -n ${!profiles_v}
84 - done
85 -
86 - echo ""
87 -}
88 -
89 -# Return the binaries in the passed directory, but don't include any with a CTARGET prefix
90 -# Currently this just extracts the prefix from the directory by assuming
91 -# the directory matches */usr/<CTARGET>/gcc-bin/*
92 -# TODO: Cleanup to work better with non-gcc
93 -get_bins() {
94 - local dir=${1}
95 - local file
96 - local basefile
97 - local prefix
98 -
99 - if [[ ${dir#*/usr/} != ${dir} && ${dir%/gcc-bin/*} != ${dir} ]] ; then
100 - prefix=${dir#*/usr/}
101 - prefix=${prefix%/gcc-bin/*}
102 - fi
103 -
104 - local i=0
105 - for file in ${dir}/* ; do
106 - basefile=$(basename ${file})
107 - basefile=${basefile#${prefix}-}
108 -
109 - if [[ -x ${file} && ! -h ${file} ]] && ! has ${basefile} ${retval} ; then
110 - if (( i == 0 )) ; then
111 - (( i++ ))
112 - else
113 - echo -n " "
114 - fi
115 - echo -n ${basefile}
116 - fi
117 - done
118 - echo ""
119 -}
120 -
121 -### ACTIONS ###
122 -
123 -### list action ###
124 -describe_list() {
125 - echo "List all installed compiler profiles."
126 -}
127 -
128 -do_list() {
129 - local ctarget
130 - local profiles_v
131 - local set_v
132 - local profile
133 - local i
134 - local active='*'
135 - local preopts=""
136 -
137 - while [[ ${#} -gt 0 ]]; do
138 - local opt=${1}
139 - shift
140 - case ${opt} in
141 - --user|-u)
142 - preopts="${preopts} --user"
143 - ;;
144 - *)
145 - die -q "Invalid option: ${opt}"
146 - ;;
147 - esac
148 - done
149 -
150 - eval_pm ${preopts} get-profiles || die -q "Failed to get data on installed profiles."
151 -
152 - ((i = 0))
153 - for ctarget in ${COMPILER_CONFIG_ALL_CTARGETS} ; do
154 - write_list_start "Available compilers for CTARGET $(highlight "${ctarget}")"
155 -
156 - profiles_v="COMPILER_CONFIG_PROFILES_${ctarget//[-.]/_}"
157 - for profile in ${!profiles_v} ; do
158 - ((i++))
159 - write_numbered_list_entry $i "${profile}"
160 - done
161 - done
162 -
163 - echo ""
164 -
165 - write_list_start "Activated profiles:"
166 - for ctarget in ${COMPILER_CONFIG_SET_CTARGETS} ; do
167 - set_v="COMPILER_CONFIG_SET_${ctarget//[-.]/_}"
168 - if [[ ${ctarget} == ${COMPILER_CONFIG_DEFAULT_CTARGET} ]] ; then
169 - write_kv_list_entry "${ctarget} $(highlight "${active}")" "${!set_v}"
170 - else
171 - write_kv_list_entry "${ctarget}" "${!set_v}"
172 - fi
173 - done
174 -}
175 -
176 -### show action ###
177 -describe_show() {
178 - echo "Print the current active configuration. It can take a CTARGET argument"
179 -}
180 -
181 -do_show() {
182 - local ctarget
183 - local preopts=""
184 -
185 - while [[ ${#} -gt 0 ]]; do
186 - local opt=${1}
187 - shift
188 - case ${opt} in
189 - --user|-u)
190 - preopts="${preopts} --user"
191 - ;;
192 - *)
193 - ctarget=${opt}
194 - ;;
195 - esac
196 - done
197 -
198 - eval_pm ${preopts} get-profiles || die -q "Failed to get data on installed profiles."
199 -
200 - if [[ -z ${ctarget} ]] ; then
201 - ctarget=${COMPILER_CONFIG_DEFAULT_CTARGET}
202 - fi
203 -
204 - local set_v="COMPILER_CONFIG_SET_${ctarget//[-.]/_}"
205 - if [[ -n ${!set_v} ]] ; then
206 - echo ${!set_v}
207 - return 0
208 - else
209 - echo "(none)"
210 - return 2
211 - fi
212 -}
213 -
214 -### getval action ###
215 -describe_getval() {
216 - echo "Print information for the given profile. It takes a variable name as an argument."
217 -}
218 -
219 -describe_getval_parameters() {
220 - echo "<value>"
221 -}
222 -
223 -describe_getval_options() {
224 - echo "<value> : The value to get (see below)."
225 - echo "-c, --ctarget=<CTARGET> : Get the variable for the active profile of the given CTARGET."
226 - echo "-p, --profile=<PROFILE> : Get the variable for the given profile."
227 - echo ""
228 - echo "BINPATH : The location of the binaries."
229 - echo "INFOPATH : The location of the info documentation."
230 - echo "MANPATH : The location of the man pages."
231 - echo "LDPATH : The location of the libraries."
232 - echo "STDCXX_INCDIR : The stdcxx include dir."
233 - echo "GCC_SPECS : The specs file used."
234 - echo "CFLAGS : The CFLAGS that are automatically prepended."
235 -
236 - #write_list_start "Extra options for 'getval' action:"
237 - #write_kv_list_entry "-c, --ctarget=<CTARGET>" "Get the variable for the active profile of the given CTARGET."
238 - #write_kv_list_entry "-p, --profile=<PROFILE>" "Get the variable for the given profile."
239 - #echo
240 - #write_list_start "Possible values to pass to 'getval' action:"
241 - #write_kv_list_entry "BINPATH" "The location of the binaries."
242 - #write_kv_list_entry "INFOPATH" "The location of the info documentation."
243 - #write_kv_list_entry "MANPATH" "The location of the man pages."
244 - #write_kv_list_entry "LDPATH" "The location of the libraries."
245 - #write_kv_list_entry "STDCXX_INCDIR" "The stdcxx include dir."
246 - #write_kv_list_entry "GCC_SPECS" "The specs file used."
247 - #write_kv_list_entry "CFLAGS" "The CFLAGS that are automatically prepended."
248 -}
249 -
250 -do_getval() {
251 - local ctarget
252 - local profile
253 - local preopts
254 - local var
255 - local set_v
256 -
257 - while [[ ${#} -gt 0 ]]; do
258 - local opt=${1}
259 - shift
260 - case ${opt} in
261 - --user|-u)
262 - preopts="${preopts} --user"
263 - ;;
264 - --ctarget=*)
265 - if [[ -z ${opt#*=} ]] ; then
266 - die -q "No option given to --ctarget"
267 - fi
268 - ctarget=${opt#*=}
269 - ;;
270 - -c)
271 - if [[ ${#} -eq 0 ]] ; then
272 - die -q "No option given to -c"
273 - fi
274 - ctarget=${1}
275 - shift
276 - ;;
277 - --profile=*)
278 - if [[ -z ${opt#*=} ]] ; then
279 - die -q "No option given to --profile"
280 - fi
281 - profile=${opt#*=}
282 - ;;
283 - -p)
284 - if [[ ${#} -eq 0 ]] ; then
285 - die -q "No option given to -p"
286 - fi
287 - profile=${1}
288 - shift
289 - ;;
290 - *)
291 - var=${opt}
292 - esac
293 - done
294 -
295 - if [[ -n ${profile} && -n ${ctarget} ]] ; then
296 - die -q "You can't pass --profile and --ctarget at the same time."
297 - elif [[ -z ${profile} ]] ; then
298 - eval_pm ${preopts} get-profiles || die -q "Failed to get data on installed profiles."
299 -
300 - if [[ -z ${ctarget} ]] ; then
301 - ctarget=${COMPILER_CONFIG_DEFAULT_CTARGET}
302 - fi
303 -
304 - local set_v="COMPILER_CONFIG_SET_${ctarget//-/_}"
305 - [[ -z ${!set_v} ]] && die -q "Invalid CTARGET: ${ctarget}"
306 -
307 - profile=${!set_v}
308 - fi
309 -
310 - eval_pm ${preopts} get-profile ${profile} || die -q "Failed to get data on the profile '${profile}'."
311 - var="COMPILER_CONFIG_${var}"
312 - echo ${!var}
313 -
314 - return 0
315 -}
316 -
317 -### set action ###
318 -describe_set() {
319 - echo "Select a compiler profile."
320 -}
321 -
322 -describe_set_parameters() {
323 - echo "<profile>"
324 -}
325 -
326 -describe_set_options() {
327 - echo "<profile> : The profile to activate, either by name or number."
328 - echo "-b, --bindir=<dir> : Install the wrappers into this directory (default: /usr/bin). If -u is specified and this is not, no wrappers will be installed."
329 - echo "-c, --ctarget=<CTARGET> : Install this profile using the specified CTARGET rather than the default."
330 - echo "-n, --native : Make this the native CTARGET."
331 -
332 - #write_list_start "Extra options for 'set' action:"
333 - #write_kv_list_entry "-b, --bindir=<dir>" "Install the wrappers into this directory. If -u is specified and this is not, no wrappers will be installed."
334 - #write_kv_list_entry "-c, --ctarget=<CTARGET>" "Install this profile using the specified CTARGET rather than the default."
335 - #write_kv_list_entry "-n, --native" "Make this the native CTARGET."
336 -}
337 -
338 -do_set() {
339 - local preopts postopts profile oldprofile ctarget bindir olddefaultbins oldbins newbins set_v userconf ref
340 -
341 - eval_pm ${preopts} get-profiles || die -q "Failed to get data on installed profiles."
342 -
343 - while [[ ${#} -gt 0 ]]; do
344 - local opt=${1}
345 - shift
346 - case ${opt} in
347 - --bindir=*)
348 - if [[ -z ${opt#*=} ]] ; then
349 - die -q "No option given to --bindir"
350 - fi
351 - bindir=${opt#*=}
352 - ;;
353 - -b)
354 - if [[ ${#} -eq 0 ]] ; then
355 - die -q "No option given to -b"
356 - fi
357 - bindir=${1}
358 - shift
359 - ;;
360 - --native|-n)
361 - postopts="${postopts} --native"
362 - ;;
363 - --user|-u)
364 - userconf=1
365 - preopts="${preopts} --user"
366 - ;;
367 - --ctarget=*)
368 - if [[ -z ${opt#*=} ]] ; then
369 - die -q "No option given to --ctarget"
370 - fi
371 - ctarget=${opt#*=}
372 - ;;
373 - -c)
374 - if [[ ${#} -eq 0 ]] ; then
375 - die -q "No option given to -c"
376 - fi
377 - ctarget=${1}
378 - shift
379 - ;;
380 - *)
381 - if is_number ${opt} ; then
382 - profiles=( $(list_all_profiles ${preopts}) )
383 - profile=${profiles[$(( ${opt} - 1 ))]}
384 - if [[ -z ${profile} ]] ; then
385 - die -q "Invalid profile: ${opt}"
386 - fi
387 - else
388 - if ! has ${opt} $(list_all_profiles ${preopts}) ; then
389 - die -q "Invalid profile: ${opt}"
390 - fi
391 - profile=${opt}
392 - fi
393 - ;;
394 - esac
395 - done
396 -
397 - if [[ -z ${profile} ]] ; then
398 - die -q "No profile given to set action."
399 - fi
400 -
401 - # Figure out the ctarget for this compiler
402 - if [[ -z ${ctarget} ]] ; then
403 - eval_pm ${preopts} get-profile ${profile} || die -q "Failed to get data on the desired profiles."
404 - ctarget=${COMPILER_CONFIG_CTARGET}
405 - fi
406 -
407 - # Assume --native if we don't have a default set
408 - if [[ ${COMPILER_CONFIG_DEFAULT_CTARGET} == "(null)" ]] ; then
409 - postopts="${postopts} --native"
410 - else
411 - # Figure out what bins are installed for the default CTARGET in case we are or are becoming default
412 - set_v="COMPILER_CONFIG_SET_${COMPILER_CONFIG_DEFAULT_CTARGET}"
413 - if [[ -n ${!set_v} ]] ; then
414 - oldprofile=${!set_v}
415 -
416 - if eval_pm ${preopts} get-profile ${oldprofile} ; then
417 - olddefaultbins="$(get_bins "${ROOT}/${COMPILER_CONFIG_BINPATH}") ${COMPILER_CONFIG_ALIASES}"
418 - else
419 - write_error_msg "Could not get data on the previous profile for the default CTARGET (${oldprofile})."
420 - write_error_msg "You may have extra wrappers installed that you did not intend."
421 - fi
422 - fi
423 - fi
424 -
425 - # Figure out what bins are installed for the old profile for this CTARGET
426 - set_v="COMPILER_CONFIG_SET_${ctarget//[-.]/_}"
427 - if [[ -n ${!set_v} ]] ; then
428 - oldprofile=${!set_v}
429 -
430 - if eval_pm ${preopts} get-profile ${oldprofile} ; then
431 - oldbins="$(get_bins "${ROOT}/${COMPILER_CONFIG_BINPATH}") ${COMPILER_CONFIG_ALIASES}"
432 - else
433 - write_error_msg "Could not get data on the previous profile for this CTARGET (${oldprofile})."
434 - write_error_msg "You may have extra wrappers installed for the old."
435 - fi
436 - fi
437 -
438 - # Update our profile for the wrapper
439 - ${PROFILE_MANAGER} ${preopts} set ${profile} ${postopts} --ctarget=${ctarget} || die -q "Failed to save the new profile."
440 -
441 - # If we're updating the userconf, but not changing wrappers, leave now...
442 - if [[ ${userconf} == "1" && -z ${bindir} ]] ; then
443 - return 0
444 - fi
445 -
446 - # Get data on the new profile
447 - eval_pm ${preopts} get-profile ${profile} || die -q "Failed to get data on the desired profile after updating config."
448 - eval_pm ${preopts} get-profiles || die -q "Failed to get data on installed profiles after updating config."
449 -
450 - # Select /usr/bin if the location isn't given to us
451 - if [[ -z ${bindir} ]] ; then
452 - bindir="${ROOT}/usr/bin"
453 - fi
454 -
455 - # Remove old wrappers
456 - if [[ ${ctarget} == ${COMPILER_CONFIG_DEFAULT_CTARGET} ]] ; then
457 - for bin in ${olddefaultbins} ; do
458 - [[ -f ${bindir}/${bin} ]] && rm -f "${bindir}/${bin}"
459 - done
460 - fi
461 - for bin in ${oldbins} ; do
462 - [[ -f ${bindir}/${ctarget}-${bin} ]] && rm -f "${bindir}/${ctarget}-${bin}"
463 - done
464 -
465 - # Install the wrappers
466 - set_bins ${ctarget} ${bindir}
467 -
468 - # Update /etc/env.d
469 - if [[ ${userconf} == "1" ]] ; then
470 - return 0
471 - fi
472 -
473 - set_env ${preopts} || die -q "Could not set ${ENV_FILE}"
474 -
475 - do_action env update &> /dev/null
476 -
477 - echo "Successfully set compiler for ${ctarget} to ${profile}."
478 -}
479 -
480 -# Setup the wrapper binaries for the passed CTARGET
481 -set_bins() {
482 - local ctarget="$1"
483 - local bindir="$2"
484 - local bin
485 -
486 - # Get data on the new profile
487 - eval_pm ${preopts} get-profiles || die -q "Failed to get data on installed profiles after updating config."
488 -
489 - local set_v="COMPILER_CONFIG_SET_${ctarget//[-.]/_}"
490 - local profile=${!set_v}
491 -
492 - [[ -z ${profile} ]] && return 1
493 -
494 - eval_pm ${preopts} get-profile ${profile} || die -q "Failed to get data on the desired profile after updating config."
495 -
496 - local newbins="$(get_bins "${ROOT}/${COMPILER_CONFIG_BINPATH}") ${COMPILER_CONFIG_ALIASES}"
497 - for bin in ${newbins} ; do
498 - # We want to figure out the 'reference file' for each
499 - # wrapper (the binary we're 'wrapping') so that we can
500 - # sync mtimes together. This makes things like ccache
501 - # happy. See Bug #70548 for more info.
502 - if has ${bin} ${COMPILER_CONFIG_ALIASES} ; then
503 - set_v="COMPILER_CONFIG_ALIAS_${bin}"
504 - ref="${!set_v}"
505 - else
506 - ref="${bin}"
507 - fi
508 -
509 - if [[ -f ${ROOT}/${COMPILER_CONFIG_BINPATH}/${ref} ]] ; then
510 - ref="${ROOT}/${COMPILER_CONFIG_BINPATH}/${ref}"
511 - elif [[ -f ${ROOT}/${COMPILER_CONFIG_BINPATH}/${ctarget}-${ref} ]] ; then
512 - ref="${ROOT}/${COMPILER_CONFIG_BINPATH}/${ctarget}-${ref}"
513 - elif [[ -f ${ROOT}/${COMPILER_CONFIG_BINPATH}/${COMPILER_CONFIG_BIN_PREFIX}-${ref} ]] ; then
514 - ref="${ROOT}/${COMPILER_CONFIG_BINPATH}/${COMPILER_CONFIG_BIN_PREFIX}-${ref}"
515 - else
516 - die -q "Error determining reference timestamp for binaries. Please file a bug report at http://bugs.gentoo.org."
517 - fi
518 -
519 - cp -f "${WRAPPER}" "${bindir}/${ctarget}-${bin}"
520 - touch -r "${ref}" "${bindir}/${ctarget}-${bin}"
521 -
522 - if [[ ${ctarget} == ${COMPILER_CONFIG_DEFAULT_CTARGET} ]] ; then
523 - cp -f "${WRAPPER}" "${bindir}/${bin}"
524 - touch -r "${ref}" "${bindir}/${bin}"
525 - fi
526 - done
527 -}
528 -
529 -set_env() {
530 - local preopts="${@}"
531 - local env_manpath
532 - local env_infopath
533 - local env_ldpath
534 - local ctarget
535 - local set_v
536 -
537 - eval_pm ${preopts} get-profiles || die -q "Failed to get data on installed profiles."
538 - # Build up the variables for all the active profiles
539 - for ctarget in ${COMPILER_CONFIG_SET_CTARGETS} ; do
540 - set_v="COMPILER_CONFIG_SET_${ctarget//[-.]/_}"
541 - if eval_pm ${preopts} get-profile ${!set_v}; then
542 - [[ -n ${COMPILER_CONFIG_MANPATH} ]] &&
543 - env_manpath="${env_manpath:+"${env_manpath}:"}${COMPILER_CONFIG_MANPATH}"
544 - [[ -n ${COMPILER_CONFIG_INFOPATH} ]] &&
545 - env_infopath="${env_infopath:+"${env_infopath}:"}${COMPILER_CONFIG_INFOPATH}"
546 - [[ -n ${COMPILER_CONFIG_LDPATH} ]] &&
547 - env_ldpath="${env_ldpath:+"${env_ldpath}:"}${COMPILER_CONFIG_LDPATH}"
548 - else
549 - write_error_msg "Unable to get profile information for ${!set_v} which is set for CTARGET ${ctarget}"
550 - fi
551 - done
552 -
553 - # Now write it
554 - store_config ${ENV_FILE} INFOPATH "${env_infopath}"
555 - store_config ${ENV_FILE} MANPATH "${env_manpath}"
556 - store_config ${ENV_FILE} LDPATH "${env_ldpath}"
557 -}
558 -
559 -### unset action
560 -describe_unset() {
561 - echo "Deactivate a selected profile."
562 -}
563 -
564 -do_unset() {
565 - local bindir="${ROOT}/usr/bin"
566 - local preopts
567 - local ctarget
568 -
569 - while [[ ${#} -gt 0 ]]; do
570 - local opt=${1}
571 - shift
572 - case ${opt} in
573 - --bindir=*)
574 - if [[ -z ${opt#*=} ]] ; then
575 - die -q "No option given to --bindir"
576 - fi
577 - bindir=${opt#*=}
578 - ;;
579 - --user|-u)
580 - userconf=1
581 - preopts="${preopts} --user"
582 - ;;
583 - *)
584 - ctarget=${opt}
585 - ;;
586 - esac
587 - done
588 -
589 - if [[ -z ${ctarget} ]] ; then
590 - die -q "You did not give a CTARGET to unset."
591 - fi
592 -
593 - eval_pm ${preopts} get-profiles || die -q "Failed to get data on installed profiles."
594 -
595 - if [[ ${ctarget} == ${COMPILER_CONFIG_DEFAULT_CTARGET} ]] ; then
596 - die -q "You cannot unset the native CTARGET. Pleasse set another CTARGET native first."
597 - fi
598 -
599 - set_v="COMPILER_CONFIG_SET_${ctarget//[-.]/_}"
600 - if eval_pm ${preopts} get-profile ${!set_v} ; then
601 - local bins="$(get_bins "${ROOT}/${COMPILER_CONFIG_BINPATH}") ${COMPILER_CONFIG_ALIASES}"
602 - local bin
603 -
604 - for bin in ${bins} ; do
605 - [[ -f ${bindir}/${ctarget}-${bin} ]] && rm -f "${bindir}/${ctarget}-${bin}"
606 - if [[ ${ctarget} == ${COMPILER_CONFIG_DEFAULT_CTARGET} ]] ; then
607 - [[ -f ${bindir}/${bin} ]] && rm -f "${bindir}/${bin}"
608 - fi
609 - done
610 - else
611 - return 1
612 - fi
613 -
614 - ${PROFILE_MANAGER} ${preopts} unset ${ctarget} || die -q "Failed to unset the profile."
615 -
616 - return 0
617 -}
618 -
619 -### update action
620 -describe_update() {
621 - echo "Refresh all the installed wrappers."
622 -}
623 -
624 -do_update() {
625 - local ctarget
626 - local bindir="${ROOT}/usr/bin"
627 - local preopts
628 -
629 - while [[ ${#} -gt 0 ]]; do
630 - local opt=${1}
631 - shift
632 - case ${opt} in
633 - --bindir=*)
634 - if [[ -z ${opt#*=} ]] ; then
635 - die -q "No option given to --bindir"
636 - fi
637 - bindir=${opt#*=}
638 - ;;
639 - --user|-u)
640 - userconf=1
641 - preopts="${preopts} --user"
642 - ;;
643 - esac
644 - done
645 -
646 - # Get data on the new profile
647 - eval_pm ${preopts} get-profiles || die -q "Failed to get data on installed profiles after updating config."
648 -
649 - for ctarget in ${COMPILER_CONFIG_SET_CTARGETS} ; do
650 - set_bins ${ctarget} ${bindir}
651 - done
652 -}
653 -
654 -### migrate action ###
655 -describe_migrate() {
656 - echo "Convert gcc-1.x profiles. This will not overwrite existing profiles, so you should backup ${CONFIG_D} first."
657 -}
658 -
659 -do_migrate() {
660 - local envd="${ROOT}/etc/env.d/gcc/"
661 - local file
662 -
663 - [[ -d ${CONFIG_D} ]] || mkdir -p ${CONFIG_D}
664 -
665 - for file in ${envd}/* ; do
666 - [[ -f ${file} ]] || continue
667 -
668 - local basefile=$(basename ${file})
669 -
670 - # Skip the config files for now
671 - [[ ${basefile#config*} != ${basefile} ]] && continue
672 -
673 - local ctarget=$(split_old_gcc_ver "${basefile}" | cut -f1 -d' ')
674 - local version=$(split_old_gcc_ver "${basefile}" | cut -f2 -d' ')
675 -
676 - [[ -f "${CONFIG_D}/${ctarget}-${version}.conf" ]] || migrate_profile ${ctarget}-${version}
677 - done
678 -
679 - for file in ${envd}/config* ; do
680 - [[ -f ${file} ]] || continue
681 -
682 - local basefile=$(basename ${file})
683 - local ctarget
684 -
685 - local oldprofile=$(load_config "${file}" CURRENT)
686 - local prof_ctarget=$(split_old_gcc_ver ${oldprofile} | cut -f1 -d' ')
687 - local version=$(split_old_gcc_ver ${oldprofile} | cut -f2 -d' ')
688 - local spec=$(split_old_gcc_ver ${oldprofile} | cut -f3 -d' ')
689 - [[ -z ${spec} ]] && spec="default"
690 -
691 - if [[ ${basefile} == "config" ]] ; then
692 - ctarget=$(split_old_gcc_ver $(load_config "${file}" CURRENT) | cut -f1 -d' ')
693 - if [[ $(do_show) == "(none)" ]] ; then
694 - do_set "--ctarget=${ctarget}" "${prof_ctarget}-${version}/${spec}" --native
695 - fi
696 - else
697 - ctarget=${basefile#config-}
698 - if [[ $(do_show ${ctarget}) == "(none)" ]] ; then
699 - do_set "--ctarget=${ctarget}" "${prof_ctarget}-${version}/${spec}"
700 - fi
701 - fi
702 -
703 - done
704 -}
705 -
706 -migrate_profile() {
707 - local profile=$1
708 - local doneglobal=0
709 - local conf="${CONFIG_D}/${profile}.conf"
710 - local ctarget=$(split_old_gcc_ver ${profile} | cut -f1 -d' ')
711 - local val
712 -
713 - [[ -f ${conf} ]] && return 1
714 -
715 - for file in ${envd}/${profile}* ; do
716 - if [[ ${doneglobal} == 0 ]] ; then
717 - local binpath=$(load_config "${file}" PATH)
718 -
719 - echo "[global]" > ${conf}
720 - echo " version=${profile}" >> ${conf}
721 - echo " binpath=${binpath}" >> ${conf}
722 -
723 - val=$(load_config "${file}" MANPATH)
724 - [[ -n ${val} ]] && echo " manpath=${val}" >> ${conf}
725 -
726 - val=$(load_config "${file}" INFOPATH)
727 - [[ -n ${val} ]] && echo " infopath=${val}" >> ${conf}
728 -
729 - val=$(load_config "${file}" STDCXX_INCDIR)
730 - [[ -n ${val} ]] && echo " stdcxx_incdif=${val}" >> ${conf}
731 -
732 - echo " alias_cc=gcc" >> ${conf}
733 - if [[ -f "${binpath}/${ctarget}-gfortran" || -f "${binpath}/gfortran" ]] ; then
734 - echo " alias_g77=gfortran" >> ${conf}
735 - elif [[ -f "${binpath}/${ctarget}-g77" || -f "${binpath}/g77" ]] ; then
736 - echo " alias_gfortran=g77" >> ${conf}
737 - fi
738 -
739 - echo >> ${conf}
740 - doneglobal=1
741 - fi
742 -
743 - local spec=$(split_old_gcc_ver $(basename ${file}) | cut -f3 -d' ')
744 - [[ -z ${spec} ]] && spec="default"
745 -
746 - echo "[${spec}]" >> ${conf}
747 - echo " ctarget=${ctarget}" >> ${conf}
748 -
749 - val=$(load_config "${file}" LDPATH)
750 - [[ -n ${val} ]] && echo " ldpath=${val}" >> ${conf}
751 -
752 - val=$(load_config "${file}" GCC_SPECS)
753 - [[ -n ${val} ]] && echo " specs=${val}" >> ${conf}
754 -
755 - echo >> ${conf}
756 - done
757 -}
758 -
759 -# Taken from gcc-config-1.3.12:
760 -split_old_gcc_ver() {
761 -# Split up the gcc profile into components:
762 -# TARGET-VER[-specs] -> TARGET VER [specs]
763 -# arm-linux-3.3.6 -> arm-linux 3.3.6
764 -# x86_64-linux-4.0.1-pre1234 -> x86_64-linux 4.0.1-pre1234
765 -# sh-linux-3.4.4-hardened -> sh-linux 3.4.4 hardened
766 -#
767 -# So below we will start at the end and run a small state machine ...
768 -# specs [3]
769 -# accept everything
770 -# specs -> version transition [3->2]
771 -# when we find a version component
772 -# version [2]
773 -# accept only version components (see the regex)
774 -# version -> target transition [2->1]
775 -# when we hit a non version component
776 -# target [1]
777 -# accept everything we have left
778 -#
779 - echo "$@" | awk -F- '
780 - function pushit(onme, pushee) {
781 - return (onme == "" ? pushee : pushee"-"onme);
782 - }
783 - {
784 - state=3
785 - targ=""
786 - ver=""
787 - spec=""
788 - for (i=NF; i > 0; --i) {
789 - if (state >= 2) {
790 - if ($i ~ /^(alpha|beta|pre|rc|p)?[[:digit:].]+$/) {
791 - ver=pushit(ver, $i)
792 - state=2
793 - } else if (state == 3)
794 - spec=pushit(spec, $i)
795 - else
796 - state=1
797 - }
798 - if (state == 1)
799 - targ = pushit(targ, $i)
800 - }
801 - print targ " " ver (spec != "" ? " " spec : "")
802 - }'
803 -}