Gentoo Archives: gentoo-commits

From: "Mike Frysinger (vapier)" <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in sys-devel/binutils-config/files: binutils-config-3
Date: Thu, 29 Sep 2011 20:27:07
Message-Id: 20110929202656.C7E4E2004C@flycatcher.gentoo.org
1 vapier 11/09/29 20:26:56
2
3 Modified: binutils-config-3
4 Log:
5 Make linker switching more general, and add a `die` helper.
6
7 (Portage version: 2.2.0_alpha59/cvs/Linux x86_64)
8
9 Revision Changes Path
10 1.6 sys-devel/binutils-config/files/binutils-config-3
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/binutils-config/files/binutils-config-3?rev=1.6&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/binutils-config/files/binutils-config-3?rev=1.6&content-type=text/plain
14 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/binutils-config/files/binutils-config-3?r1=1.5&r2=1.6
15
16 Index: binutils-config-3
17 ===================================================================
18 RCS file: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/binutils-config-3,v
19 retrieving revision 1.5
20 retrieving revision 1.6
21 diff -u -r1.5 -r1.6
22 --- binutils-config-3 29 Aug 2011 00:56:46 -0000 1.5
23 +++ binutils-config-3 29 Sep 2011 20:26:56 -0000 1.6
24 @@ -1,7 +1,7 @@
25 #!/bin/bash
26 # Copyright 1999-2011 Gentoo Foundation
27 # Distributed under the terms of the GNU General Public License v2
28 -# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/binutils-config-3,v 1.5 2011/08/29 00:56:46 vapier Exp $
29 +# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/binutils-config-3,v 1.6 2011/09/29 20:26:56 vapier Exp $
30
31 # Format of /etc/env.d/binutils/:
32 # config-TARGET: CURRENT=version for TARGET
33 @@ -21,6 +21,7 @@
34 exit 1
35 }
36 esyslog() { :; }
37 +die() { eerror "${argv0}: $*"; exit 1; }
38 umask 022
39
40 usage() {
41 @@ -34,8 +35,7 @@
42 ${GOOD}-d, --debug${NORMAL} Execute with debug output
43
44 ${HILITE}General Cruft:${NORMAL}
45 - ${GOOD}--gold${NORMAL} Switch linker to gold (if supported)
46 - ${GOOD}--bfd${NORMAL} Switch linker to [older] bfd (if supported)
47 + ${GOOD}--linker${NORMAL} <linker> Switch to specified linker (if supported)
48
49 ${HILITE}Arch Specific Cruft:${NORMAL}
50 ${GOOD}--amd64${NORMAL} Install extra amd64 links (x86_64)
51 @@ -241,8 +241,7 @@
52
53 uninstall_target() {
54 if [[ ${TARGET} == ${HOST} ]] ; then
55 - eerror "${argv0}: Refusing to uninstall native binutils"
56 - exit 1
57 + die "refusing to uninstall native binutils"
58 fi
59
60 shopt -s nullglob
61 @@ -253,8 +252,7 @@
62 rm -f "${ENV_D}"/${PROFILE}
63 done
64 if [[ -z ${PROFILE} ]] && [[ ! -e ${ENV_D}/config-${TARGET} ]] ; then
65 - eerror "${argv0}: No profiles exist for '${TARGET}'"
66 - exit 1
67 + die "no profiles exist for '${TARGET}'"
68 fi
69
70 rm -f "${ENV_D}"/config-${TARGET} "${ROOT}"/etc/ld.so.conf.d/05binutils.conf
71 @@ -352,23 +350,26 @@
72 }
73
74 switch_linker() {
75 - local ld=$1
76 + local bpath ld=$1
77 +
78 + case ${ld} in
79 + ld.*) ;;
80 + *) die "not supported: linker must start with 'ld.'" ;;
81 + esac
82
83 setup_env || return 1
84 + bpath="${ROOT}/${BINPATH}"
85
86 # does this binutils even support the requested linker ?
87 - if [[ ! -e ${ROOT}/${BINPATH}/ld.${ld} ]] ; then
88 - eerror "${argv0}: sorry, but ${PROFILE} doesn't support the ${ld} linker"
89 - exit 1
90 + if [[ ! -e ${bpath}/${ld} ]] ; then
91 + die "sorry, but ${PROFILE} doesn't support the ${ld} linker"
92 fi
93
94 # switch it up
95 ebegin "Setting default linker to ${ld} for ${PROFILE}"
96 - atomic_ln ld.${ld} "${ROOT}/${BINPATH}" ld
97 + atomic_ln ${ld} "${bpath}" ld
98 eend $?
99 }
100 -switch_linker_gold() { switch_linker gold ; }
101 -switch_linker_bfd() { switch_linker bfd ; }
102
103 set_HOST() {
104 # Set HOST to CHOST if it isn't already set
105 @@ -391,8 +392,7 @@
106 NEED_ACTION="no"
107 DOIT=$1
108 else
109 - eerror "${argv0}: one action at a time!"
110 - exit 1
111 + die "one action at a time!"
112 fi
113 }
114
115 @@ -401,15 +401,14 @@
116 shift
117 case ${x} in
118 -c|--get-current-profile) select_action get_current_profile ;;
119 - -l|--list-profiles) select_action list_profiles ;;
120 + -l|--list|--list-profiles) select_action list_profiles ;;
121 -u|--uninstall) select_action uninstall_target ;;
122 - --gold) select_action switch_linker_gold ;;
123 - --bfd) select_action switch_linker_bfd ;;
124 + --linker) select_action "switch_linker $1"; shift ;;
125 -d|--debug) DEBUG="yes" ;;
126 -h|--help) usage 0 ;;
127 -V|--version)
128 unset Header
129 - cvsver="$Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/binutils-config-3,v 1.5 2011/08/29 00:56:46 vapier Exp $"
130 + cvsver="$Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/binutils-config-3,v 1.6 2011/09/29 20:26:56 vapier Exp $"
131 cvsver=${cvsver##*binutils-config-}
132 bver=${cvsver%%,v *}
133 cvsver=${cvsver#* }
134 @@ -429,13 +428,11 @@
135 fi
136 ;;
137 -*)
138 - eerror "${0##*/}: Invalid switch! Try '--help'."
139 - exit 1
140 + die "invalid switch! Try '--help'."
141 ;;
142 *)
143 if [[ ${UARG+set} == "set" ]] ; then
144 - eerror "${argv0}: only one profile/target at a time please"
145 - exit 1
146 + die "only one profile/target at a time please"
147 fi
148 NEED_ACTION="maybe"
149 UARG=${x}
150 @@ -483,8 +480,7 @@
151 if [[ -f ${ENV_D}/${HOST}-${x} ]] ; then
152 x=${HOST}-${x}
153 else
154 - eerror "${argv0}: Could not locate '$x' in '${ENV_D}/'!"
155 - exit 1
156 + die "could not locate '$x' in '${ENV_D}/'!"
157 fi
158 PROFILE=${x}
159 else