Gentoo Archives: gentoo-commits

From: Sergei Trofimovich <slyfox@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/binutils-config:master commit in: src/, /
Date: Thu, 21 May 2020 21:58:26
Message-Id: 1590098126.36eba05752348258a79bbe6a9937e6e406c262e6.slyfox@gentoo
1 commit: 36eba05752348258a79bbe6a9937e6e406c262e6
2 Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
3 AuthorDate: Thu May 21 21:55:26 2020 +0000
4 Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
5 CommitDate: Thu May 21 21:55:26 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/binutils-config.git/commit/?id=36eba057
7
8 binutils-config: add build-time and runtime switches to disable native symlinks
9
10 We have two knobs here:
11 1. Build-time knob USE_NATIVE_LINKS to set a default, defaults to 'yes' (existing behaviour)
12 2. Run-time --enable-native-links / --disable-native-links knobs. These are not persistent
13 across binutils-config runs and are meant for manual testing. Undocumented for now.
14
15 Reported-by: Kent Fredric
16 Bug: https://bugs.gentoo.org/724454
17 Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>
18
19 Makefile | 19 +++++++++++++++++--
20 src/binutils-config | 16 ++++++++++++++--
21 2 files changed, 31 insertions(+), 4 deletions(-)
22
23 diff --git a/Makefile b/Makefile
24 index 7fd7959..aee6da8 100644
25 --- a/Makefile
26 +++ b/Makefile
27 @@ -1,3 +1,10 @@
28 +# configurable options:
29 +# Avoid installing native symlinks like:
30 +# /usr/bin/as -> ${CTARGET}-as
31 +# and keep only
32 +# ${CTARGET}-as
33 +USE_NATIVE_LINKS ?= yes
34 +
35 EPREFIX ?=
36
37 PN = binutils-config
38 @@ -14,11 +21,19 @@ MKDIR_P = mkdir -p -m 755
39 INSTALL_EXE = install -m 755
40 INSTALL_DATA = install -m 644
41
42 -all: # no-op
43 +all: .binutils-config
44 +
45 +.binutils-config: src/binutils-config
46 + sed \
47 + -e 's:@GENTOO_EPREFIX@:$(EPREFIX):g' \
48 + -e 's:@PV@:$(PV):g' \
49 + -e 's:@USE_NATIVE_LINKS@:$(USE_NATIVE_LINKS):g' \
50 + $< > $@
51 + chmod a+rx $@
52
53 install: all
54 $(MKDIR_P) $(DESTDIR)$(BINDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(ESELECTDIR) $(DESTDIR)$(MANDIR)/man8
55 - $(INSTALL_EXE) src/binutils-config $(DESTDIR)$(BINDIR)
56 + $(INSTALL_EXE) .binutils-config $(DESTDIR)$(BINDIR)/binutils-config
57 $(INSTALL_DATA) README $(DESTDIR)$(DOCDIR)
58 $(INSTALL_DATA) src/binutils.eselect $(DESTDIR)$(ESELECTDIR)
59 $(INSTALL_DATA) src/binutils-config.8 $(DESTDIR)$(MANDIR)/man8
60
61 diff --git a/src/binutils-config b/src/binutils-config
62 index 69ca530..e6819a8 100755
63 --- a/src/binutils-config
64 +++ b/src/binutils-config
65 @@ -1,5 +1,5 @@
66 #!/bin/bash
67 -# Copyright 1999-2019 Gentoo Authors
68 +# Copyright 1999-2020 Gentoo Authors
69 # Distributed under the terms of the GNU General Public License v2
70
71 # Format of /etc/env.d/binutils/:
72 @@ -130,8 +130,17 @@ switch_profile() {
73 for x in * ; do
74 atomic_ln "${BINPATH}/${x}" "${ROOT}/${BINPATH_LINKS}" "${x}"
75 atomic_ln "${BINPATH_LINKS}/${x}" "${EROOT}/usr/bin" "${TARGET}-${x}"
76 - if [[ ${TARGET} == ${HOST} ]] ; then
77 + if [[ ${TARGET} == ${HOST} -a ${USE_NATIVE_LINKS} == yes ]] ; then
78 atomic_ln "${TARGET}-${x}" "${EROOT}/usr/bin" "${x}"
79 + else
80 + # Remove native links if exist from previous
81 + # installations or set by user manually. binutils-config
82 + # owns these symlinks.
83 + #
84 + # TODO: cleanup symlinks not just known to this
85 + # release/configuration of binutils, but also list
86 + # all possible ones.
87 + rm -f "${EROOT}/usr/bin/${x}"
88 fi
89 done
90
91 @@ -357,6 +366,7 @@ DOIT="switch_profile"
92 PROFILE="current"
93 HOST=""
94 TARGET=""
95 +USE_NATIVE_LINKS="@USE_NATIVE_LINKS@"
96 unset UARG
97
98 select_action() {
99 @@ -377,6 +387,8 @@ while [[ $# -gt 0 ]] ; do
100 -u|--uninstall) select_action uninstall_target ;;
101 -d|--debug) DEBUG="yes" ;;
102 -h|--help) usage 0 ;;
103 + --enable-native-links) USE_NATIVE_LINKS="yes" ;;
104 + --disable-native-links) USE_NATIVE_LINKS="no" ;;
105 -V|--version)
106 ver="@PV@"
107 echo "binutils-config-${ver/@'PV'@/git}"