1 |
commit: d3a995fe38d5ed87206c179dab70626520e3a95f |
2 |
Author: Michael Mair-Keimberger <m.mairkeimberger <AT> gmail <DOT> com> |
3 |
AuthorDate: Wed May 20 15:36:47 2020 +0000 |
4 |
Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu May 21 08:22:45 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d3a995fe |
7 |
|
8 |
sys-devel/binutils-config: remove unused files |
9 |
|
10 |
Package-Manager: Portage-2.3.99, Repoman-2.3.22 |
11 |
Signed-off-by: Michael Mair-Keimberger <m.mairkeimberger <AT> gmail.com> |
12 |
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org> |
13 |
|
14 |
sys-devel/binutils-config/files/binutils-config-5 | 490 --------------------- |
15 |
.../binutils-config/files/binutils-config-5.1 | 482 -------------------- |
16 |
2 files changed, 972 deletions(-) |
17 |
|
18 |
diff --git a/sys-devel/binutils-config/files/binutils-config-5 b/sys-devel/binutils-config/files/binutils-config-5 |
19 |
deleted file mode 100644 |
20 |
index 297ea01518c..00000000000 |
21 |
--- a/sys-devel/binutils-config/files/binutils-config-5 |
22 |
+++ /dev/null |
23 |
@@ -1,490 +0,0 @@ |
24 |
-#!/bin/bash |
25 |
-# Copyright 1999-2019 Gentoo Authors |
26 |
-# Distributed under the terms of the GNU General Public License v2 |
27 |
- |
28 |
-# Format of /etc/env.d/binutils/: |
29 |
-# config-TARGET: CURRENT=version for TARGET |
30 |
-# TARGET-VER: has a TARGET and VER variable |
31 |
- |
32 |
-EPREFIX="@GENTOO_PORTAGE_EPREFIX@" |
33 |
-if [[ ${EPREFIX} == "@"GENTOO_PORTAGE_EPREFIX"@" ]] ; then |
34 |
- EPREFIX="" |
35 |
-fi |
36 |
- |
37 |
-: ${ROOT:=/} |
38 |
-[[ ${ROOT} != */ ]] && ROOT="${ROOT}/" |
39 |
-[[ ${ROOT} != /* ]] && ROOT="${PWD%/}/${ROOT}" |
40 |
- |
41 |
-EROOT="${ROOT%/}${EPREFIX}/" |
42 |
- |
43 |
-cd "${EPREFIX}/" |
44 |
- |
45 |
-trap ":" INT QUIT TSTP |
46 |
- |
47 |
-argv0=${0##*/} |
48 |
-FUNCTIONS_SH="${EPREFIX}/lib/gentoo/functions.sh" |
49 |
-source ${FUNCTIONS_SH} || { |
50 |
- echo "${argv0}: Could not source ${FUNCTIONS_SH}!" 1>&2 |
51 |
- exit 1 |
52 |
-} |
53 |
-esyslog() { :; } |
54 |
-die() { eerror "${argv0}: $*"; exit 1; } |
55 |
-umask 022 |
56 |
- |
57 |
-usage() { |
58 |
-cat << USAGE_END |
59 |
-Usage: ${HILITE}binutils-config${NORMAL} ${GOOD}[options]${NORMAL} ${BRACKET}[binutils profile]${NORMAL} |
60 |
- |
61 |
-${HILITE}General Options:${NORMAL} |
62 |
- ${GOOD}-c, --get-current-profile${NORMAL} Print current profile |
63 |
- ${GOOD}-l, --list-profiles${NORMAL} Print a list of available profiles |
64 |
- ${GOOD}-u, --uninstall${NORMAL} Remove all signs of specified target |
65 |
- ${GOOD}-d, --debug${NORMAL} Execute with debug output |
66 |
- |
67 |
-${HILITE}General Cruft:${NORMAL} |
68 |
- ${GOOD}--linker${NORMAL} <linker> Switch to specified linker (if supported) |
69 |
- |
70 |
-Profile names are of the form: ${BRACKET}<CTARGET>-<binutils version>${NORMAL} |
71 |
-For example: ${BRACKET}i686-pc-linux-gnu-2.15.92.0.2${NORMAL} |
72 |
- |
73 |
-For more info, please see ${HILITE}binutils-config${NORMAL}(8). |
74 |
-USAGE_END |
75 |
- |
76 |
- exit ${1:-1} |
77 |
-} |
78 |
- |
79 |
-mv_if_diff() { |
80 |
- if cmp -s "$1" "$2" ; then |
81 |
- rm -f "$1" |
82 |
- else |
83 |
- mv -f "$1" "$2" |
84 |
- fi |
85 |
-} |
86 |
-atomic_ln() { |
87 |
- local target=$1 linkdir=$2 linkname=$3 linktmp linkfull |
88 |
- linktmp="${linkdir}/.binutils-config.tmp.${linkname}" |
89 |
- linkfull="${linkdir}/${linkname}" |
90 |
- if [[ -d ${linkfull} ]] ; then |
91 |
- # if linking to a dir, we need a little magic to |
92 |
- # make it atomic since `mv -T` is not portable |
93 |
- rm -rf "${linktmp}" |
94 |
- mkdir -p "${linktmp}" |
95 |
- ln -sf "${target}" "${linktmp}/${linkname}" |
96 |
- mv "${linktmp}/${linkname}" "${linktmp}/../" |
97 |
- rmdir "${linktmp}" |
98 |
- else |
99 |
- # `ln` will expand into unlink();symlink(); which |
100 |
- # is not atomic for a small amount of time, but |
101 |
- # `mv` is a single rename() call |
102 |
- ln -sf "${target}" "${linktmp}" |
103 |
- mv "${linktmp}" "${linkfull}" |
104 |
- fi |
105 |
-} |
106 |
- |
107 |
-setup_env() { |
108 |
- unset TARGET VER LIBPATH |
109 |
- source "${ENV_D}/${PROFILE}" |
110 |
- if [[ -z ${TARGET} ]] ; then |
111 |
- eerror "${PROFILE} is invalid (no \$TARGET defined) :(" |
112 |
- return 1 |
113 |
- fi |
114 |
- if [[ -z ${VER} ]] ; then |
115 |
- eerror "${PROFILE} is invalid (no \$VER defined) :(" |
116 |
- return 1 |
117 |
- fi |
118 |
- |
119 |
- # |
120 |
- # Generate binary symlinks |
121 |
- # |
122 |
- BINPATH="" |
123 |
- BINPATH_LINKS="" |
124 |
- if [[ ${TARGET} != ${HOST} ]] ; then |
125 |
- # |
126 |
- # Newer paths: /usr/${HOST}/${TARGET}/... |
127 |
- # Older paths: /usr/${TARGET}/... |
128 |
- # |
129 |
- if [[ -d "${EROOT}"/usr/${HOST}/${TARGET}/binutils-bin/${VER} ]] ; then |
130 |
- BINPATH="${EPREFIX}"/usr/${HOST}/${TARGET}/binutils-bin/${VER} |
131 |
- BINPATH_LINKS="${EPREFIX}"/usr/libexec/gcc/${TARGET} |
132 |
- fi |
133 |
- fi |
134 |
- if [[ -z ${BINPATH} ]] ; then |
135 |
- BINPATH="${EPREFIX}"/usr/${TARGET}/binutils-bin/${VER} |
136 |
- BINPATH_LINKS="${EPREFIX}"/usr/${TARGET}/bin |
137 |
- fi |
138 |
-} |
139 |
- |
140 |
-# Lists of headers that various versions have installed. |
141 |
-HEADERS=( |
142 |
- ansidecl.h bfd.h bfdlink.h demangle.h dis-asm.h dyn-string.h |
143 |
- fibheap.h hashtab.h libiberty.h objalloc.h plugin-api.h |
144 |
- splay-tree.h symcat.h |
145 |
-) |
146 |
- |
147 |
-switch_profile() { |
148 |
- local x |
149 |
- |
150 |
- ebegin "Switching to ${PROFILE}" |
151 |
- |
152 |
- setup_env || return 1 |
153 |
- |
154 |
- cd "${ROOT}/${BINPATH}" || exit 1 |
155 |
- mkdir -p "${ROOT}/${BINPATH_LINKS}" "${EROOT}/usr/bin" |
156 |
- for x in * ; do |
157 |
- atomic_ln "${BINPATH}/${x}" "${ROOT}/${BINPATH_LINKS}" "${x}" |
158 |
- atomic_ln "${BINPATH_LINKS}/${x}" "${EROOT}/usr/bin" "${TARGET}-${x}" |
159 |
- if [[ ${TARGET} == ${HOST} ]] ; then |
160 |
- atomic_ln "${TARGET}-${x}" "${EROOT}/usr/bin" "${x}" |
161 |
- fi |
162 |
- done |
163 |
- |
164 |
- # |
165 |
- # Generate library / ldscripts symlinks |
166 |
- # |
167 |
- : ${LIBPATH:=${EPREFIX}/usr/lib/binutils/${TARGET}/${VER}} |
168 |
- cd "${ROOT}/${LIBPATH}" || exit 1 |
169 |
- if [[ ${TARGET} == ${HOST} ]] ; then |
170 |
- dstlib=${EROOT}/usr/${HOST}/lib |
171 |
- else |
172 |
- dstlib=${EROOT}/usr/${HOST}/${TARGET}/lib |
173 |
- fi |
174 |
- # When upgrading, we need to clean up ldscripts and libs. |
175 |
- # Don't symlink back in the libs -- the binutils-lib package handles |
176 |
- # these now. |
177 |
- # TODO: Stop requiring even the ldscripts symlink. |
178 |
- mkdir -p "${dstlib}" |
179 |
- rm -rf "${ROOT}/${BINPATH_LINKS}"/ldscripts |
180 |
- atomic_ln "${LIBPATH}/ldscripts" "${dstlib}" "ldscripts" |
181 |
- find -L "${dstlib}" -xtype l -name 'lib*' -delete |
182 |
- # Detect older binutils w/broken rpaths. #562460 |
183 |
- # We can hardcode the "/lib" part since that's what the binutils |
184 |
- # configure scripts have. They did not include any other path. |
185 |
- if [[ $(scanelf -qF '%r#F' "${ROOT}/${BINPATH}/as") == */lib ]] ; then |
186 |
- ewarn "Old cross-binutils detected; please re-emerge to fix (see bug #562460)." |
187 |
- for x in lib* ; do |
188 |
- atomic_ln "${LIBPATH}/${x}" "${dstlib}" "${x}" |
189 |
- done |
190 |
- fi |
191 |
- |
192 |
- # |
193 |
- # Clean out old generated include symlinks |
194 |
- # |
195 |
- INCPATH=${LIBPATH}/include |
196 |
- if [[ -d ${ROOT}/${INCPATH} ]] ; then |
197 |
- cd "${ROOT}/${INCPATH}" || exit 1 |
198 |
- if [[ ${HOST} == ${TARGET} ]] ; then |
199 |
- # The binutils-lib package handles these files now. |
200 |
- for x in libiberty "${HEADERS[@]}" ; do |
201 |
- x="${EROOT}/usr/include/${x}" |
202 |
- if [[ -L ${x} ]] ; then |
203 |
- rm "${x}" |
204 |
- fi |
205 |
- done |
206 |
- else |
207 |
- # Clean out old path -- cannot use '-exec {} +' syntax here |
208 |
- find . -type f -exec rm -f "${EROOT}/usr/${TARGET}/usr/include/{}" \; |
209 |
- rmdir "${EROOT}/usr/${TARGET}/usr/include" >& /dev/null |
210 |
- rmdir "${EROOT}/usr/${TARGET}/usr" >& /dev/null |
211 |
- rmdir "${EROOT}/usr/${TARGET}" >& /dev/null |
212 |
- fi |
213 |
- fi |
214 |
- |
215 |
- # |
216 |
- # Make sure proper paths get updated |
217 |
- # |
218 |
- local env_update_flag="--no-ldconfig" |
219 |
- if [[ ${TARGET} == ${HOST} ]] ; then |
220 |
- # Delete old config now that binutils-libs installs these files. |
221 |
- # Note: This skips ldconfig update if env.d had LDPATH, but meh. |
222 |
- # Most people have upgraded to ld.so.conf.d, and someone else will |
223 |
- # eventually re-run ldconfig for us. |
224 |
- x="${EROOT}"/etc/ld.so.conf.d/05binutils.conf |
225 |
- if [[ -e ${x} ]]; then |
226 |
- rm -f "${x}" |
227 |
- env_update_flag="" |
228 |
- fi |
229 |
- |
230 |
- DATAPATH="${EPREFIX}"/usr/share/binutils-data/${TARGET}/${VER} |
231 |
- local e="${EROOT}"/etc/env.d/05binutils |
232 |
- local ee="${e}.tmp" |
233 |
- rm -f "${ee}" |
234 |
- [[ -d ${ROOT}/${DATAPATH}/man ]] && echo "MANPATH=${DATAPATH}/man" >> "${ee}" |
235 |
- [[ -d ${ROOT}/${DATAPATH}/info ]] && echo "INFOPATH=${DATAPATH}/info" >> "${ee}" |
236 |
- mv_if_diff "${ee}" "${e}" |
237 |
- fi |
238 |
- |
239 |
- local c="${ENV_D}/config-${TARGET}" |
240 |
- local cc="${c}.tmp" |
241 |
- echo "CURRENT=${VER}" > "${cc}" |
242 |
- mv_if_diff "${cc}" "${c}" |
243 |
- |
244 |
- eend 0 |
245 |
- |
246 |
- # |
247 |
- # Regen env.d if need/can be |
248 |
- # |
249 |
- if [[ ${ROOT} == "/" ]] && [[ ${TARGET} == ${HOST} ]] ; then |
250 |
- env-update ${env_update_flag} |
251 |
- echo |
252 |
- ewarn "Please remember to run:" |
253 |
- echo |
254 |
- ewarn " # . ${EPREFIX}/etc/profile" |
255 |
- echo |
256 |
- fi |
257 |
- |
258 |
- return 0 |
259 |
-} |
260 |
- |
261 |
-uninstall_target() { |
262 |
- : ${TARGET:=${UARG}} |
263 |
- |
264 |
- if [[ ${TARGET} == ${HOST} ]] ; then |
265 |
- die "refusing to uninstall native binutils" |
266 |
- fi |
267 |
- |
268 |
- shopt -s nullglob |
269 |
- PROFILE="" |
270 |
- |
271 |
- for PROFILE in "${ENV_D}"/${TARGET}-* ; do |
272 |
- ewarn "Removing all signs of ${PROFILE##*/}" |
273 |
- rm -f "${ENV_D}"/${PROFILE} |
274 |
- done |
275 |
- if [[ -z ${PROFILE} ]] && [[ ! -e ${ENV_D}/config-${TARGET} ]] ; then |
276 |
- die "no profiles exist for '${TARGET}'" |
277 |
- fi |
278 |
- |
279 |
- rm -f "${ENV_D}"/config-${TARGET} |
280 |
- |
281 |
- local x |
282 |
- for x in \ |
283 |
- addr2line ar as c++filt dwp elf2flt elfedit flthdr gprof \ |
284 |
- ld ld.{bfd,gold,real} \ |
285 |
- nm objcopy objdump ranlib readelf size strings strip |
286 |
- do |
287 |
- x=( |
288 |
- "${EROOT}"/usr/bin/${TARGET}-${x} |
289 |
- "${EROOT}"/usr/{${HOST}/,}${TARGET}/bin/${x} |
290 |
- "${EROOT}"/usr/libexec/gcc/${TARGET}/${x} |
291 |
- ) |
292 |
- rm -f "${x[@]}" |
293 |
- done |
294 |
- for x in "${HEADERS[@]}" ; do |
295 |
- rm -f "${EROOT}"/usr/{${HOST}/,}${TARGET}/{usr/,}include/${x} |
296 |
- done |
297 |
- for x in bfd iberty opcodes ; do |
298 |
- rm -f "${EROOT}"/usr/${HOST}/${TARGET}/lib/lib${x}{{-*,}.so,.a,.la} |
299 |
- done |
300 |
- # Delete broken symlinks |
301 |
- local destdir="${EROOT}/usr/${HOST}/${TARGET}" |
302 |
- rm -f "${destdir}"/lib/ldscripts |
303 |
- find -L "${destdir}"/lib -type l -exec rm {} + |
304 |
- rmdir \ |
305 |
- "${destdir}"/{bin,include,lib,usr} \ |
306 |
- "${destdir}" \ |
307 |
- "${EROOT}"/var/db/pkg/cross-${TARGET} \ |
308 |
- "${EROOT}"/usr/{${HOST}/,}${TARGET}/bin \ |
309 |
- "${EROOT}"/usr/libexec/gcc/${TARGET} \ |
310 |
- 2>/dev/null |
311 |
- |
312 |
- rm -f "${ENV_D}"/${TARGET}-* |
313 |
-} |
314 |
- |
315 |
-set_current_profile() { |
316 |
- if [[ ! -f ${ENV_D}/config-${TARGET} ]] ; then |
317 |
- eerror "${argv0}: unable to locate a profile for target: ${TARGET}" |
318 |
- return 1 |
319 |
- fi |
320 |
- |
321 |
- source "${ENV_D}/config-${TARGET}" |
322 |
- |
323 |
- if [[ -z ${CURRENT} ]] ; then |
324 |
- eerror "${argv0}: no binutils profile is active!" |
325 |
- return 1 |
326 |
- fi |
327 |
- |
328 |
- echo "${TARGET}-${CURRENT}" |
329 |
- |
330 |
- return 0 |
331 |
-} |
332 |
-get_current_profile() { echo "${PROFILE}" ; } |
333 |
- |
334 |
-list_profiles() { |
335 |
- local x i target |
336 |
- |
337 |
- if [[ ${ROOT} != / ]] ; then |
338 |
- echo "Using binutils-config info in ${ROOT}" |
339 |
- fi |
340 |
- |
341 |
- set -- "${ENV_D}"/* |
342 |
- target= |
343 |
- i=1 |
344 |
- |
345 |
- for x ; do |
346 |
- # skip broken links and config files |
347 |
- [[ -f ${x} ]] || continue |
348 |
- [[ ${x} == */config-* ]] && continue |
349 |
- |
350 |
- source "${x}" |
351 |
- if [[ ${target} != ${TARGET} ]] ; then |
352 |
- [[ -n ${target} ]] && echo |
353 |
- target=${TARGET} |
354 |
- fi |
355 |
- |
356 |
- x=${x##*/} |
357 |
- if [[ -e ${ENV_D}/config-${TARGET} ]] ; then |
358 |
- source "${ENV_D}/config-${TARGET}" |
359 |
- if [[ ${VER} == ${CURRENT} ]] ; then |
360 |
- [[ ${TARGET} == ${HOST} ]] \ |
361 |
- && x="${x} ${GOOD}*${NORMAL}" \ |
362 |
- || x="${x} ${HILITE}*${NORMAL}" |
363 |
- fi |
364 |
- fi |
365 |
- |
366 |
- # We would align the [...] field like so: |
367 |
- #printf ' [%*ss] %s\n' ${##} "${i}" "${x}" |
368 |
- # but this breaks simple scripting: `binutils -l | awk '{print $2}'` |
369 |
- |
370 |
- # Or we could align the target col like so: |
371 |
- #printf ' [%s]%*s %s\n' "${i}" $(( ${##} - ${#i} )) "" "${x}" |
372 |
- # but i'm not sold that it looks better |
373 |
- |
374 |
- # So keep it simple ... only makes a diff anyways for crazy people |
375 |
- # like me which have 100+ binutils packages installed ... |
376 |
- echo " [$i] ${x}" |
377 |
- ((++i)) |
378 |
- done |
379 |
-} |
380 |
- |
381 |
-switch_linker() { |
382 |
- local bpath ld=$1 |
383 |
- |
384 |
- case ${ld} in |
385 |
- ld.*) ;; |
386 |
- *) die "not supported: linker must start with 'ld.'" ;; |
387 |
- esac |
388 |
- |
389 |
- setup_env || return 1 |
390 |
- bpath="${ROOT}/${BINPATH}" |
391 |
- |
392 |
- # does this binutils even support the requested linker ? |
393 |
- if [[ ! -e ${bpath}/${ld} ]] ; then |
394 |
- die "sorry, but ${PROFILE} doesn't support the ${ld} linker" |
395 |
- fi |
396 |
- |
397 |
- # switch it up |
398 |
- ebegin "Setting default linker to ${ld} for ${PROFILE}" |
399 |
- atomic_ln ${ld} "${bpath}" ld |
400 |
- eend $? |
401 |
-} |
402 |
- |
403 |
-set_HOST() { |
404 |
- # Set HOST to CHOST if it isn't already set |
405 |
- : ${HOST:=${CHOST:-$(portageq envvar CHOST)}} |
406 |
-} |
407 |
- |
408 |
-ENV_D="${EROOT}etc/env.d/binutils" |
409 |
- |
410 |
-DEBUG="no" |
411 |
-NEED_ACTION="yes" |
412 |
-DOIT="switch_profile" |
413 |
-PROFILE="current" |
414 |
-HOST="" |
415 |
-TARGET="" |
416 |
-unset UARG |
417 |
- |
418 |
-select_action() { |
419 |
- if [[ ${NEED_ACTION} != "no" ]] ; then |
420 |
- NEED_ACTION="no" |
421 |
- DOIT=$1 |
422 |
- else |
423 |
- die "one action at a time!" |
424 |
- fi |
425 |
-} |
426 |
- |
427 |
-while [[ $# -gt 0 ]] ; do |
428 |
- x=$1 |
429 |
- shift |
430 |
- case ${x} in |
431 |
- -c|--get-current-profile) select_action get_current_profile ;; |
432 |
- -l|--list|--list-profiles) select_action list_profiles ;; |
433 |
- -u|--uninstall) select_action uninstall_target ;; |
434 |
- --linker) select_action "switch_linker $1"; shift ;; |
435 |
- -d|--debug) DEBUG="yes" ;; |
436 |
- -h|--help) usage 0 ;; |
437 |
- -V|--version) |
438 |
- ver="@PV@" |
439 |
- echo "binutils-config-${ver/@'PV'@/git}" |
440 |
- exit 0 |
441 |
- ;; |
442 |
- -*) |
443 |
- die "invalid switch! Try '--help'." |
444 |
- ;; |
445 |
- *) |
446 |
- if [[ ${UARG+set} == "set" ]] ; then |
447 |
- die "only one profile/target at a time please" |
448 |
- fi |
449 |
- NEED_ACTION="maybe" |
450 |
- UARG=${x} |
451 |
- ;; |
452 |
- esac |
453 |
-done |
454 |
- |
455 |
-[[ ${NEED_ACTION} == "yes" ]] && usage 1 |
456 |
-[[ ${DEBUG} == "yes" ]] && set -x |
457 |
- |
458 |
-# All operations need to know the current HOST to figure out |
459 |
-# what is a native target and what is a cross target |
460 |
-set_HOST |
461 |
- |
462 |
-# All operations need to know the profile the user wants |
463 |
-case ${DOIT} in |
464 |
-switch_profile|switch_linker_*) |
465 |
- # decode user's profile choice |
466 |
- x=${UARG:-$(TARGET=${HOST} set_current_profile)} |
467 |
- PROFILE="" |
468 |
- if [[ -z $(echo ${x} | tr -d '[:digit:]') ]] ; then |
469 |
- # User gave us a # representing the profile |
470 |
- i=1 |
471 |
- for y in "${ENV_D}"/* ; do |
472 |
- [[ ${y/config-} != ${y} ]] && continue |
473 |
- |
474 |
- if [[ -f ${y} ]] && [[ ${x} -eq ${i} ]] ; then |
475 |
- PROFILE=${y##*/} |
476 |
- break |
477 |
- fi |
478 |
- ((++i)) |
479 |
- done |
480 |
- fi |
481 |
- |
482 |
- if [[ -z ${PROFILE} ]] ; then |
483 |
- # User gave us a full HOST-ver |
484 |
- x=${x##*/} |
485 |
- if [[ -f ${ENV_D}/${x} ]] ; then |
486 |
- # Valid HOST-ver yeah! |
487 |
- PROFILE=${x} |
488 |
- else |
489 |
- # Not a valid HOST-ver ... |
490 |
- if [[ ! -f ${ENV_D}/config-${x} ]] ; then |
491 |
- # Maybe they just gave us a ver ... |
492 |
- if [[ -f ${ENV_D}/${HOST}-${x} ]] ; then |
493 |
- x=${HOST}-${x} |
494 |
- else |
495 |
- die "could not locate '$x' in '${ENV_D}/'!" |
496 |
- fi |
497 |
- PROFILE=${x} |
498 |
- else |
499 |
- # Maybe they just gave us a target ... pick active profile |
500 |
- PROFILE=$(TARGET=${x} set_current_profile) |
501 |
- fi |
502 |
- fi |
503 |
- fi |
504 |
- ;; |
505 |
-*) |
506 |
- # lookup current profile as the user gave us a target |
507 |
- PROFILE=$(TARGET=${UARG:-${HOST}} set_current_profile) || exit 1 |
508 |
- ;; |
509 |
-esac |
510 |
- |
511 |
-eval ${DOIT} |
512 |
- |
513 |
-# vim:ts=4 |
514 |
|
515 |
diff --git a/sys-devel/binutils-config/files/binutils-config-5.1 b/sys-devel/binutils-config/files/binutils-config-5.1 |
516 |
deleted file mode 100644 |
517 |
index 26ff278eece..00000000000 |
518 |
--- a/sys-devel/binutils-config/files/binutils-config-5.1 |
519 |
+++ /dev/null |
520 |
@@ -1,482 +0,0 @@ |
521 |
-#!/bin/bash |
522 |
-# Copyright 1999-2018 Gentoo Foundation |
523 |
-# Distributed under the terms of the GNU General Public License v2 |
524 |
- |
525 |
-# Format of /etc/env.d/binutils/: |
526 |
-# config-TARGET: CURRENT=version for TARGET |
527 |
-# TARGET-VER: has a TARGET and VER variable |
528 |
- |
529 |
-EPREFIX="@GENTOO_PORTAGE_EPREFIX@" |
530 |
-if [[ ${EPREFIX} == "@"GENTOO_PORTAGE_EPREFIX"@" ]] ; then |
531 |
- EPREFIX="" |
532 |
-fi |
533 |
- |
534 |
-: ${ROOT:=/} |
535 |
-[[ ${ROOT} != */ ]] && ROOT="${ROOT}/" |
536 |
-[[ ${ROOT} != /* ]] && ROOT="${PWD%/}/${ROOT}" |
537 |
- |
538 |
-EROOT="${ROOT%/}${EPREFIX}/" |
539 |
- |
540 |
-cd "${EPREFIX}/" |
541 |
- |
542 |
-trap ":" INT QUIT TSTP |
543 |
- |
544 |
-argv0=${0##*/} |
545 |
-FUNCTIONS_SH="${EPREFIX}/lib/gentoo/functions.sh" |
546 |
-source ${FUNCTIONS_SH} || { |
547 |
- echo "${argv0}: Could not source ${FUNCTIONS_SH}!" 1>&2 |
548 |
- exit 1 |
549 |
-} |
550 |
-esyslog() { :; } |
551 |
-die() { eerror "${argv0}: $*"; exit 1; } |
552 |
-umask 022 |
553 |
- |
554 |
-usage() { |
555 |
-cat << USAGE_END |
556 |
-Usage: ${HILITE}binutils-config${NORMAL} ${GOOD}[options]${NORMAL} ${BRACKET}[binutils profile]${NORMAL} |
557 |
- |
558 |
-${HILITE}General Options:${NORMAL} |
559 |
- ${GOOD}-c, --get-current-profile${NORMAL} Print current profile |
560 |
- ${GOOD}-l, --list-profiles${NORMAL} Print a list of available profiles |
561 |
- ${GOOD}-u, --uninstall${NORMAL} Remove all signs of specified target |
562 |
- ${GOOD}-d, --debug${NORMAL} Execute with debug output |
563 |
- |
564 |
-${HILITE}General Cruft:${NORMAL} |
565 |
- ${GOOD}--linker${NORMAL} <linker> Switch to specified linker (if supported) |
566 |
- |
567 |
-Profile names are of the form: ${BRACKET}<CTARGET>-<binutils version>${NORMAL} |
568 |
-For example: ${BRACKET}i686-pc-linux-gnu-2.15.92.0.2${NORMAL} |
569 |
- |
570 |
-For more info, please see ${HILITE}binutils-config${NORMAL}(8). |
571 |
-USAGE_END |
572 |
- |
573 |
- exit ${1:-1} |
574 |
-} |
575 |
- |
576 |
-mv_if_diff() { |
577 |
- if cmp -s "$1" "$2" ; then |
578 |
- rm -f "$1" |
579 |
- else |
580 |
- mv -f "$1" "$2" |
581 |
- fi |
582 |
-} |
583 |
-atomic_ln() { |
584 |
- local target=$1 linkdir=$2 linkname=$3 linktmp linkfull |
585 |
- linktmp="${linkdir}/.binutils-config.tmp.${linkname}" |
586 |
- linkfull="${linkdir}/${linkname}" |
587 |
- if [[ -d ${linkfull} ]] ; then |
588 |
- # if linking to a dir, we need a little magic to |
589 |
- # make it atomic since `mv -T` is not portable |
590 |
- rm -rf "${linktmp}" |
591 |
- mkdir -p "${linktmp}" |
592 |
- ln -sf "${target}" "${linktmp}/${linkname}" |
593 |
- mv "${linktmp}/${linkname}" "${linktmp}/../" |
594 |
- rmdir "${linktmp}" |
595 |
- else |
596 |
- # `ln` will expand into unlink();symlink(); which |
597 |
- # is not atomic for a small amount of time, but |
598 |
- # `mv` is a single rename() call |
599 |
- ln -sf "${target}" "${linktmp}" |
600 |
- mv "${linktmp}" "${linkfull}" |
601 |
- fi |
602 |
-} |
603 |
- |
604 |
-setup_env() { |
605 |
- unset TARGET VER LIBPATH |
606 |
- source "${ENV_D}/${PROFILE}" |
607 |
- if [[ -z ${TARGET} ]] ; then |
608 |
- eerror "${PROFILE} is invalid (no \$TARGET defined) :(" |
609 |
- return 1 |
610 |
- fi |
611 |
- if [[ -z ${VER} ]] ; then |
612 |
- eerror "${PROFILE} is invalid (no \$VER defined) :(" |
613 |
- return 1 |
614 |
- fi |
615 |
- |
616 |
- # |
617 |
- # Generate binary symlinks |
618 |
- # |
619 |
- BINPATH="" |
620 |
- BINPATH_LINKS="" |
621 |
- if [[ ${TARGET} != ${HOST} ]] ; then |
622 |
- # |
623 |
- # Newer paths: /usr/${HOST}/${TARGET}/... |
624 |
- # Older paths: /usr/${TARGET}/... |
625 |
- # |
626 |
- if [[ -d "${EROOT}"/usr/${HOST}/${TARGET}/binutils-bin/${VER} ]] ; then |
627 |
- BINPATH="${EPREFIX}"/usr/${HOST}/${TARGET}/binutils-bin/${VER} |
628 |
- BINPATH_LINKS="${EPREFIX}"/usr/libexec/gcc/${TARGET} |
629 |
- fi |
630 |
- fi |
631 |
- if [[ -z ${BINPATH} ]] ; then |
632 |
- BINPATH="${EPREFIX}"/usr/${TARGET}/binutils-bin/${VER} |
633 |
- BINPATH_LINKS="${EPREFIX}"/usr/${TARGET}/bin |
634 |
- fi |
635 |
-} |
636 |
- |
637 |
-# Lists of headers that various versions have installed. |
638 |
-HEADERS=( |
639 |
- ansidecl.h bfd.h bfdlink.h demangle.h dis-asm.h dyn-string.h |
640 |
- fibheap.h hashtab.h libiberty.h objalloc.h plugin-api.h |
641 |
- splay-tree.h symcat.h |
642 |
-) |
643 |
- |
644 |
-switch_profile() { |
645 |
- local x |
646 |
- |
647 |
- ebegin "Switching to ${PROFILE}" |
648 |
- |
649 |
- setup_env || return 1 |
650 |
- |
651 |
- cd "${ROOT}/${BINPATH}" || exit 1 |
652 |
- mkdir -p "${ROOT}/${BINPATH_LINKS}" "${EROOT}/usr/bin" |
653 |
- for x in * ; do |
654 |
- atomic_ln "${BINPATH}/${x}" "${ROOT}/${BINPATH_LINKS}" "${x}" |
655 |
- atomic_ln "${BINPATH_LINKS}/${x}" "${EROOT}/usr/bin" "${TARGET}-${x}" |
656 |
- if [[ ${TARGET} == ${HOST} ]] ; then |
657 |
- atomic_ln "${TARGET}-${x}" "${EROOT}/usr/bin" "${x}" |
658 |
- fi |
659 |
- done |
660 |
- |
661 |
- # |
662 |
- # Generate library / ldscripts symlinks |
663 |
- # |
664 |
- : ${LIBPATH:=${EPREFIX}/usr/lib/binutils/${TARGET}/${VER}} |
665 |
- cd "${ROOT}/${LIBPATH}" || exit 1 |
666 |
- if [[ ${TARGET} == ${HOST} ]] ; then |
667 |
- dstlib=${EROOT}/usr/${HOST}/lib |
668 |
- else |
669 |
- dstlib=${EROOT}/usr/${HOST}/${TARGET}/lib |
670 |
- fi |
671 |
- # When upgrading, we need to clean up ldscripts and libs. |
672 |
- # Don't symlink back in the libs -- the binutils-lib package handles |
673 |
- # these now. |
674 |
- # TODO: Stop requiring even the ldscripts symlink. |
675 |
- mkdir -p "${dstlib}" |
676 |
- rm -rf "${ROOT}/${BINPATH_LINKS}"/ldscripts |
677 |
- atomic_ln "${LIBPATH}/ldscripts" "${dstlib}" "ldscripts" |
678 |
- find -L "${dstlib}" -xtype l -name 'lib*' -delete |
679 |
- # Detect older binutils w/broken rpaths. #562460 |
680 |
- # We can hardcode the "/lib" part since that's what the binutils |
681 |
- # configure scripts have. They did not include any other path. |
682 |
- if [[ $(scanelf -qF '%r#F' "${ROOT}/${BINPATH}/as") == */lib ]] ; then |
683 |
- ewarn "Old cross-binutils detected; please re-emerge to fix (see bug #562460)." |
684 |
- for x in lib* ; do |
685 |
- atomic_ln "${LIBPATH}/${x}" "${dstlib}" "${x}" |
686 |
- done |
687 |
- fi |
688 |
- |
689 |
- # |
690 |
- # Clean out old generated include symlinks |
691 |
- # |
692 |
- INCPATH=${LIBPATH}/include |
693 |
- if [[ -d ${ROOT}/${INCPATH} ]] ; then |
694 |
- cd "${ROOT}/${INCPATH}" || exit 1 |
695 |
- if [[ ${HOST} != ${TARGET} ]] ; then |
696 |
- # Clean out old path -- cannot use '-exec {} +' syntax here |
697 |
- find . -type f -exec rm -f "${EROOT}/usr/${TARGET}/usr/include/{}" \; |
698 |
- rmdir "${EROOT}/usr/${TARGET}/usr/include" >& /dev/null |
699 |
- rmdir "${EROOT}/usr/${TARGET}/usr" >& /dev/null |
700 |
- rmdir "${EROOT}/usr/${TARGET}" >& /dev/null |
701 |
- fi |
702 |
- fi |
703 |
- |
704 |
- # |
705 |
- # Make sure proper paths get updated |
706 |
- # |
707 |
- local env_update_flag="--no-ldconfig" |
708 |
- if [[ ${TARGET} == ${HOST} ]] ; then |
709 |
- # Delete old config now that binutils-libs installs these files. |
710 |
- # Note: This skips ldconfig update if env.d had LDPATH, but meh. |
711 |
- # Most people have upgraded to ld.so.conf.d, and someone else will |
712 |
- # eventually re-run ldconfig for us. |
713 |
- x="${EROOT}"/etc/ld.so.conf.d/05binutils.conf |
714 |
- if [[ -e ${x} ]]; then |
715 |
- rm -f "${x}" |
716 |
- env_update_flag="" |
717 |
- fi |
718 |
- |
719 |
- DATAPATH="${EPREFIX}"/usr/share/binutils-data/${TARGET}/${VER} |
720 |
- local e="${EROOT}"/etc/env.d/05binutils |
721 |
- local ee="${e}.tmp" |
722 |
- rm -f "${ee}" |
723 |
- [[ -d ${ROOT}/${DATAPATH}/man ]] && echo "MANPATH=${DATAPATH}/man" >> "${ee}" |
724 |
- [[ -d ${ROOT}/${DATAPATH}/info ]] && echo "INFOPATH=${DATAPATH}/info" >> "${ee}" |
725 |
- mv_if_diff "${ee}" "${e}" |
726 |
- fi |
727 |
- |
728 |
- local c="${ENV_D}/config-${TARGET}" |
729 |
- local cc="${c}.tmp" |
730 |
- echo "CURRENT=${VER}" > "${cc}" |
731 |
- mv_if_diff "${cc}" "${c}" |
732 |
- |
733 |
- eend 0 |
734 |
- |
735 |
- # |
736 |
- # Regen env.d if need/can be |
737 |
- # |
738 |
- if [[ ${ROOT} == "/" ]] && [[ ${TARGET} == ${HOST} ]] ; then |
739 |
- env-update ${env_update_flag} |
740 |
- echo |
741 |
- ewarn "Please remember to run:" |
742 |
- echo |
743 |
- ewarn " # . ${EPREFIX}/etc/profile" |
744 |
- echo |
745 |
- fi |
746 |
- |
747 |
- return 0 |
748 |
-} |
749 |
- |
750 |
-uninstall_target() { |
751 |
- : ${TARGET:=${UARG}} |
752 |
- |
753 |
- if [[ ${TARGET} == ${HOST} ]] ; then |
754 |
- die "refusing to uninstall native binutils" |
755 |
- fi |
756 |
- |
757 |
- shopt -s nullglob |
758 |
- PROFILE="" |
759 |
- |
760 |
- for PROFILE in "${ENV_D}"/${TARGET}-* ; do |
761 |
- ewarn "Removing all signs of ${PROFILE##*/}" |
762 |
- rm -f "${ENV_D}"/${PROFILE} |
763 |
- done |
764 |
- if [[ -z ${PROFILE} ]] && [[ ! -e ${ENV_D}/config-${TARGET} ]] ; then |
765 |
- die "no profiles exist for '${TARGET}'" |
766 |
- fi |
767 |
- |
768 |
- rm -f "${ENV_D}"/config-${TARGET} |
769 |
- |
770 |
- local x |
771 |
- for x in \ |
772 |
- addr2line ar as c++filt dwp elf2flt elfedit flthdr gprof \ |
773 |
- ld ld.{bfd,gold,real} \ |
774 |
- nm objcopy objdump ranlib readelf size strings strip |
775 |
- do |
776 |
- x=( |
777 |
- "${EROOT}"/usr/bin/${TARGET}-${x} |
778 |
- "${EROOT}"/usr/{${HOST}/,}${TARGET}/bin/${x} |
779 |
- "${EROOT}"/usr/libexec/gcc/${TARGET}/${x} |
780 |
- ) |
781 |
- rm -f "${x[@]}" |
782 |
- done |
783 |
- for x in "${HEADERS[@]}" ; do |
784 |
- rm -f "${EROOT}"/usr/{${HOST}/,}${TARGET}/{usr/,}include/${x} |
785 |
- done |
786 |
- for x in bfd iberty opcodes ; do |
787 |
- rm -f "${EROOT}"/usr/${HOST}/${TARGET}/lib/lib${x}{{-*,}.so,.a,.la} |
788 |
- done |
789 |
- # Delete broken symlinks |
790 |
- local destdir="${EROOT}/usr/${HOST}/${TARGET}" |
791 |
- rm -f "${destdir}"/lib/ldscripts |
792 |
- find -L "${destdir}"/lib -type l -exec rm {} + |
793 |
- rmdir \ |
794 |
- "${destdir}"/{bin,include,lib,usr} \ |
795 |
- "${destdir}" \ |
796 |
- "${EROOT}"/var/db/pkg/cross-${TARGET} \ |
797 |
- "${EROOT}"/usr/{${HOST}/,}${TARGET}/bin \ |
798 |
- "${EROOT}"/usr/libexec/gcc/${TARGET} \ |
799 |
- 2>/dev/null |
800 |
- |
801 |
- rm -f "${ENV_D}"/${TARGET}-* |
802 |
-} |
803 |
- |
804 |
-set_current_profile() { |
805 |
- if [[ ! -f ${ENV_D}/config-${TARGET} ]] ; then |
806 |
- eerror "${argv0}: unable to locate a profile for target: ${TARGET}" |
807 |
- return 1 |
808 |
- fi |
809 |
- |
810 |
- source "${ENV_D}/config-${TARGET}" |
811 |
- |
812 |
- if [[ -z ${CURRENT} ]] ; then |
813 |
- eerror "${argv0}: no binutils profile is active!" |
814 |
- return 1 |
815 |
- fi |
816 |
- |
817 |
- echo "${TARGET}-${CURRENT}" |
818 |
- |
819 |
- return 0 |
820 |
-} |
821 |
-get_current_profile() { echo "${PROFILE}" ; } |
822 |
- |
823 |
-list_profiles() { |
824 |
- local x i target |
825 |
- |
826 |
- if [[ ${ROOT} != / ]] ; then |
827 |
- echo "Using binutils-config info in ${ROOT}" |
828 |
- fi |
829 |
- |
830 |
- set -- "${ENV_D}"/* |
831 |
- target= |
832 |
- i=1 |
833 |
- |
834 |
- for x ; do |
835 |
- # skip broken links and config files |
836 |
- [[ -f ${x} ]] || continue |
837 |
- [[ ${x} == */config-* ]] && continue |
838 |
- |
839 |
- source "${x}" |
840 |
- if [[ ${target} != ${TARGET} ]] ; then |
841 |
- [[ -n ${target} ]] && echo |
842 |
- target=${TARGET} |
843 |
- fi |
844 |
- |
845 |
- x=${x##*/} |
846 |
- if [[ -e ${ENV_D}/config-${TARGET} ]] ; then |
847 |
- source "${ENV_D}/config-${TARGET}" |
848 |
- if [[ ${VER} == ${CURRENT} ]] ; then |
849 |
- [[ ${TARGET} == ${HOST} ]] \ |
850 |
- && x="${x} ${GOOD}*${NORMAL}" \ |
851 |
- || x="${x} ${HILITE}*${NORMAL}" |
852 |
- fi |
853 |
- fi |
854 |
- |
855 |
- # We would align the [...] field like so: |
856 |
- #printf ' [%*ss] %s\n' ${##} "${i}" "${x}" |
857 |
- # but this breaks simple scripting: `binutils -l | awk '{print $2}'` |
858 |
- |
859 |
- # Or we could align the target col like so: |
860 |
- #printf ' [%s]%*s %s\n' "${i}" $(( ${##} - ${#i} )) "" "${x}" |
861 |
- # but i'm not sold that it looks better |
862 |
- |
863 |
- # So keep it simple ... only makes a diff anyways for crazy people |
864 |
- # like me which have 100+ binutils packages installed ... |
865 |
- echo " [$i] ${x}" |
866 |
- ((++i)) |
867 |
- done |
868 |
-} |
869 |
- |
870 |
-switch_linker() { |
871 |
- local bpath ld=$1 |
872 |
- |
873 |
- case ${ld} in |
874 |
- ld.*) ;; |
875 |
- *) die "not supported: linker must start with 'ld.'" ;; |
876 |
- esac |
877 |
- |
878 |
- setup_env || return 1 |
879 |
- bpath="${ROOT}/${BINPATH}" |
880 |
- |
881 |
- # does this binutils even support the requested linker ? |
882 |
- if [[ ! -e ${bpath}/${ld} ]] ; then |
883 |
- die "sorry, but ${PROFILE} doesn't support the ${ld} linker" |
884 |
- fi |
885 |
- |
886 |
- # switch it up |
887 |
- ebegin "Setting default linker to ${ld} for ${PROFILE}" |
888 |
- atomic_ln ${ld} "${bpath}" ld |
889 |
- eend $? |
890 |
-} |
891 |
- |
892 |
-set_HOST() { |
893 |
- # Set HOST to CHOST if it isn't already set |
894 |
- : ${HOST:=${CHOST:-$(portageq envvar CHOST)}} |
895 |
-} |
896 |
- |
897 |
-ENV_D="${EROOT}etc/env.d/binutils" |
898 |
- |
899 |
-DEBUG="no" |
900 |
-NEED_ACTION="yes" |
901 |
-DOIT="switch_profile" |
902 |
-PROFILE="current" |
903 |
-HOST="" |
904 |
-TARGET="" |
905 |
-unset UARG |
906 |
- |
907 |
-select_action() { |
908 |
- if [[ ${NEED_ACTION} != "no" ]] ; then |
909 |
- NEED_ACTION="no" |
910 |
- DOIT=$1 |
911 |
- else |
912 |
- die "one action at a time!" |
913 |
- fi |
914 |
-} |
915 |
- |
916 |
-while [[ $# -gt 0 ]] ; do |
917 |
- x=$1 |
918 |
- shift |
919 |
- case ${x} in |
920 |
- -c|--get-current-profile) select_action get_current_profile ;; |
921 |
- -l|--list|--list-profiles) select_action list_profiles ;; |
922 |
- -u|--uninstall) select_action uninstall_target ;; |
923 |
- --linker) select_action "switch_linker $1"; shift ;; |
924 |
- -d|--debug) DEBUG="yes" ;; |
925 |
- -h|--help) usage 0 ;; |
926 |
- -V|--version) |
927 |
- ver="@PV@" |
928 |
- echo "binutils-config-${ver/@'PV'@/git}" |
929 |
- exit 0 |
930 |
- ;; |
931 |
- -*) |
932 |
- die "invalid switch! Try '--help'." |
933 |
- ;; |
934 |
- *) |
935 |
- if [[ ${UARG+set} == "set" ]] ; then |
936 |
- die "only one profile/target at a time please" |
937 |
- fi |
938 |
- NEED_ACTION="maybe" |
939 |
- UARG=${x} |
940 |
- ;; |
941 |
- esac |
942 |
-done |
943 |
- |
944 |
-[[ ${NEED_ACTION} == "yes" ]] && usage 1 |
945 |
-[[ ${DEBUG} == "yes" ]] && set -x |
946 |
- |
947 |
-# All operations need to know the current HOST to figure out |
948 |
-# what is a native target and what is a cross target |
949 |
-set_HOST |
950 |
- |
951 |
-# All operations need to know the profile the user wants |
952 |
-case ${DOIT} in |
953 |
-switch_profile|switch_linker_*) |
954 |
- # decode user's profile choice |
955 |
- x=${UARG:-$(TARGET=${HOST} set_current_profile)} |
956 |
- PROFILE="" |
957 |
- if [[ -z $(echo ${x} | tr -d '[:digit:]') ]] ; then |
958 |
- # User gave us a # representing the profile |
959 |
- i=1 |
960 |
- for y in "${ENV_D}"/* ; do |
961 |
- [[ ${y/config-} != ${y} ]] && continue |
962 |
- |
963 |
- if [[ -f ${y} ]] && [[ ${x} -eq ${i} ]] ; then |
964 |
- PROFILE=${y##*/} |
965 |
- break |
966 |
- fi |
967 |
- ((++i)) |
968 |
- done |
969 |
- fi |
970 |
- |
971 |
- if [[ -z ${PROFILE} ]] ; then |
972 |
- # User gave us a full HOST-ver |
973 |
- x=${x##*/} |
974 |
- if [[ -f ${ENV_D}/${x} ]] ; then |
975 |
- # Valid HOST-ver yeah! |
976 |
- PROFILE=${x} |
977 |
- else |
978 |
- # Not a valid HOST-ver ... |
979 |
- if [[ ! -f ${ENV_D}/config-${x} ]] ; then |
980 |
- # Maybe they just gave us a ver ... |
981 |
- if [[ -f ${ENV_D}/${HOST}-${x} ]] ; then |
982 |
- x=${HOST}-${x} |
983 |
- else |
984 |
- die "could not locate '$x' in '${ENV_D}/'!" |
985 |
- fi |
986 |
- PROFILE=${x} |
987 |
- else |
988 |
- # Maybe they just gave us a target ... pick active profile |
989 |
- PROFILE=$(TARGET=${x} set_current_profile) |
990 |
- fi |
991 |
- fi |
992 |
- fi |
993 |
- ;; |
994 |
-*) |
995 |
- # lookup current profile as the user gave us a target |
996 |
- PROFILE=$(TARGET=${UARG:-${HOST}} set_current_profile) || exit 1 |
997 |
- ;; |
998 |
-esac |
999 |
- |
1000 |
-eval ${DOIT} |
1001 |
- |
1002 |
-# vim:ts=4 |