diff options
author | Sergei Trofimovich <slyfox@gentoo.org> | 2020-05-21 22:55:26 +0100 |
---|---|---|
committer | Sergei Trofimovich <slyfox@gentoo.org> | 2020-05-21 22:55:26 +0100 |
commit | 36eba05752348258a79bbe6a9937e6e406c262e6 (patch) | |
tree | d2ebba58eadbd9b8ac9a05e9784006fe6d85d896 | |
parent | README.md: rename to plaitext README (diff) | |
download | binutils-config-36eba05752348258a79bbe6a9937e6e406c262e6.tar.gz binutils-config-36eba05752348258a79bbe6a9937e6e406c262e6.tar.bz2 binutils-config-36eba05752348258a79bbe6a9937e6e406c262e6.zip |
binutils-config: add build-time and runtime switches to disable native symlinks
We have two knobs here:
1. Build-time knob USE_NATIVE_LINKS to set a default, defaults to 'yes' (existing behaviour)
2. Run-time --enable-native-links / --disable-native-links knobs. These are not persistent
across binutils-config runs and are meant for manual testing. Undocumented for now.
Reported-by: Kent Fredric
Bug: https://bugs.gentoo.org/724454
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
-rw-r--r-- | Makefile | 19 | ||||
-rwxr-xr-x | src/binutils-config | 16 |
2 files changed, 31 insertions, 4 deletions
@@ -1,3 +1,10 @@ +# configurable options: +# Avoid installing native symlinks like: +# /usr/bin/as -> ${CTARGET}-as +# and keep only +# ${CTARGET}-as +USE_NATIVE_LINKS ?= yes + EPREFIX ?= PN = binutils-config @@ -14,11 +21,19 @@ MKDIR_P = mkdir -p -m 755 INSTALL_EXE = install -m 755 INSTALL_DATA = install -m 644 -all: # no-op +all: .binutils-config + +.binutils-config: src/binutils-config + sed \ + -e 's:@GENTOO_EPREFIX@:$(EPREFIX):g' \ + -e 's:@PV@:$(PV):g' \ + -e 's:@USE_NATIVE_LINKS@:$(USE_NATIVE_LINKS):g' \ + $< > $@ + chmod a+rx $@ install: all $(MKDIR_P) $(DESTDIR)$(BINDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(ESELECTDIR) $(DESTDIR)$(MANDIR)/man8 - $(INSTALL_EXE) src/binutils-config $(DESTDIR)$(BINDIR) + $(INSTALL_EXE) .binutils-config $(DESTDIR)$(BINDIR)/binutils-config $(INSTALL_DATA) README $(DESTDIR)$(DOCDIR) $(INSTALL_DATA) src/binutils.eselect $(DESTDIR)$(ESELECTDIR) $(INSTALL_DATA) src/binutils-config.8 $(DESTDIR)$(MANDIR)/man8 diff --git a/src/binutils-config b/src/binutils-config index 69ca530..e6819a8 100755 --- a/src/binutils-config +++ b/src/binutils-config @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 1999-2019 Gentoo Authors +# Copyright 1999-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # Format of /etc/env.d/binutils/: @@ -130,8 +130,17 @@ switch_profile() { for x in * ; do atomic_ln "${BINPATH}/${x}" "${ROOT}/${BINPATH_LINKS}" "${x}" atomic_ln "${BINPATH_LINKS}/${x}" "${EROOT}/usr/bin" "${TARGET}-${x}" - if [[ ${TARGET} == ${HOST} ]] ; then + if [[ ${TARGET} == ${HOST} -a ${USE_NATIVE_LINKS} == yes ]] ; then atomic_ln "${TARGET}-${x}" "${EROOT}/usr/bin" "${x}" + else + # Remove native links if exist from previous + # installations or set by user manually. binutils-config + # owns these symlinks. + # + # TODO: cleanup symlinks not just known to this + # release/configuration of binutils, but also list + # all possible ones. + rm -f "${EROOT}/usr/bin/${x}" fi done @@ -357,6 +366,7 @@ DOIT="switch_profile" PROFILE="current" HOST="" TARGET="" +USE_NATIVE_LINKS="@USE_NATIVE_LINKS@" unset UARG select_action() { @@ -377,6 +387,8 @@ while [[ $# -gt 0 ]] ; do -u|--uninstall) select_action uninstall_target ;; -d|--debug) DEBUG="yes" ;; -h|--help) usage 0 ;; + --enable-native-links) USE_NATIVE_LINKS="yes" ;; + --disable-native-links) USE_NATIVE_LINKS="no" ;; -V|--version) ver="@PV@" echo "binutils-config-${ver/@'PV'@/git}" |