public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/binutils-config:master commit in: src/
@ 2020-05-21 18:06 Sergei Trofimovich
  0 siblings, 0 replies; 15+ messages in thread
From: Sergei Trofimovich @ 2020-05-21 18:06 UTC (permalink / raw
  To: gentoo-commits

commit:     a0bd7f579bc77f7b1d6b1fa2a1afedcd71bbb0d0
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Thu May 21 18:06:30 2020 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Thu May 21 18:06:30 2020 +0000
URL:        https://gitweb.gentoo.org/proj/binutils-config.git/commit/?id=a0bd7f57

add binutils-config sources as-is

Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 src/binutils-config   | 49 +++++++++++--------------------------
 src/binutils-config.8 | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/binutils.eselect  | 45 ++++++++++++++++++++++++++++++++++
 3 files changed, 126 insertions(+), 35 deletions(-)

diff --git a/src/binutils-config b/src/binutils-config
index 945295c..69ca530 100644
--- a/src/binutils-config
+++ b/src/binutils-config
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2017 Gentoo Foundation
+# Copyright 1999-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # Format of /etc/env.d/binutils/:
@@ -41,9 +41,6 @@ ${HILITE}General Options:${NORMAL}
   ${GOOD}-u, --uninstall${NORMAL}            Remove all signs of specified target
   ${GOOD}-d, --debug${NORMAL}                Execute with debug output
 
-${HILITE}General Cruft:${NORMAL}
-  ${GOOD}--linker${NORMAL} <linker>          Switch to specified linker (if supported)
-
 Profile names are of the form:  ${BRACKET}<CTARGET>-<binutils version>${NORMAL}
 For example:                    ${BRACKET}i686-pc-linux-gnu-2.15.92.0.2${NORMAL}
 
@@ -145,21 +142,26 @@ switch_profile() {
 	cd "${ROOT}/${LIBPATH}" || exit 1
 	if [[ ${TARGET} == ${HOST} ]] ; then
 		dstlib=${EROOT}/usr/${HOST}/lib
-	elif [[ -d ${EROOT}/usr/${TARGET}/lib ]] ; then
-		# true for at least avr and msp targets
-		dstlib=${EROOT}/usr/${TARGET}/lib
 	else
 		dstlib=${EROOT}/usr/${HOST}/${TARGET}/lib
 	fi
 	# When upgrading, we need to clean up ldscripts and libs.
 	# Don't symlink back in the libs -- the binutils-lib package handles
 	# these now.
-	# TODO: Stop requiring even the ldscripts symlink, except
-	# we can't for bare-metal toolchains, so...  bug #147155
+	# TODO: Stop requiring even the ldscripts symlink.
 	mkdir -p "${dstlib}"
 	rm -rf "${ROOT}/${BINPATH_LINKS}"/ldscripts
 	atomic_ln "${LIBPATH}/ldscripts" "${dstlib}" "ldscripts"
-	find -L "${dstlib}" -xtype l -name 'lib*' -exec rm -f {} +
+	find -L "${dstlib}" -xtype l -name 'lib*' -delete
+	# Detect older binutils w/broken rpaths. #562460
+	# We can hardcode the "/lib" part since that's what the binutils
+	# configure scripts have.  They did not include any other path.
+	if [[ $(scanelf -qF '%r#F' "${ROOT}/${BINPATH}/as") == */lib ]] ; then
+		ewarn "Old cross-binutils detected; please re-emerge to fix (see bug #562460)."
+		for x in lib* ; do
+			atomic_ln "${LIBPATH}/${x}" "${dstlib}" "${x}"
+		done
+	fi
 
 	#
 	# Clean out old generated include symlinks
@@ -244,7 +246,7 @@ uninstall_target() {
 
 	local x
 	for x in \
-		addr2line ar as c++filt elf2flt elfedit flthdr gprof \
+		addr2line ar as c++filt dwp elf2flt elfedit flthdr gprof \
 		ld ld.{bfd,gold,real} \
 		nm objcopy objdump ranlib readelf size strings strip
 	do
@@ -342,28 +344,6 @@ list_profiles() {
 	done
 }
 
-switch_linker() {
-	local bpath ld=$1
-
-	case ${ld} in
-	ld.*) ;;
-	*) die "not supported: linker must start with 'ld.'" ;;
-	esac
-
-	setup_env || return 1
-	bpath="${ROOT}/${BINPATH}"
-
-	# does this binutils even support the requested linker ?
-	if [[ ! -e ${bpath}/${ld} ]] ; then
-		die "sorry, but ${PROFILE} doesn't support the ${ld} linker"
-	fi
-
-	# switch it up
-	ebegin "Setting default linker to ${ld} for ${PROFILE}"
-	atomic_ln ${ld} "${bpath}" ld
-	eend $?
-}
-
 set_HOST() {
 	# Set HOST to CHOST if it isn't already set
 	: ${HOST:=${CHOST:-$(portageq envvar CHOST)}}
@@ -395,7 +375,6 @@ while [[ $# -gt 0 ]] ; do
 		-c|--get-current-profile)  select_action get_current_profile ;;
 		-l|--list|--list-profiles) select_action list_profiles ;;
 		-u|--uninstall)            select_action uninstall_target ;;
-		--linker)                  select_action "switch_linker $1"; shift ;;
 		-d|--debug)                DEBUG="yes" ;;
 		-h|--help)                 usage 0 ;;
 		-V|--version)
@@ -425,7 +404,7 @@ set_HOST
 
 # All operations need to know the profile the user wants
 case ${DOIT} in
-switch_profile|switch_linker_*)
+switch_profile)
 	# decode user's profile choice
 	x=${UARG:-$(TARGET=${HOST} set_current_profile)}
 	PROFILE=""

diff --git a/src/binutils-config.8 b/src/binutils-config.8
new file mode 100644
index 0000000..e8e64de
--- /dev/null
+++ b/src/binutils-config.8
@@ -0,0 +1,67 @@
+.TH "BINUTILS-CONFIG" "8" "Jan 2005" "Gentoo" "Gentoo"
+.SH "NAME"
+binutils-config \- manage active versions of the binutils programs
+.SH "DESCRIPTION"
+The \fBbinutils-config\fR script allows you to switch between different 
+versions of binutils when you have installed multiple copies (see
+USE=multislot).  It also allows you to manage multiple cross-compiling
+targets simultaneously.
+
+Remember, you may have one version of binutils active per \fICTARGET\fR,
+and changing the version for one target has no bearing on any other.  So
+changing an active cross-compiler will not break your native compiler
+(i.e. \fICHOST\fR).
+.SH "SYNOPSIS"
+\fBbinutils-config\fR [\fIcrufty options\fR] \fIPROFILE\fR
+
+\fBbinutils-config\fR \fB--get-current-profile\fR \fI[TARGET]\fR
+
+\fBbinutils-config\fR \fB--list-profiles\fR
+
+\fBbinutils-config\fR \fB--uninstall\fR \fITARGET\fR
+.SH "GENERIC OPTIONS"
+.TP
+\fBPROFILE\fR
+Change the system to use the specified binutils version.  This may take the
+form of the list index number (the number shown on the left in the
+\fB\-\-list\-profiles\fR output), a full \fITARGET-VERSION\fR (useful when
+working with cross-compilers), just a \fITARGET\fR where the \fIVERSION\fR
+is picked from the active, or just a binutils \fIVERSION\fR where the
+\fITARGET\fR is assumed to be the native \fIHOST\fR value.
+.TP
+\fBTARGET\fR
+Similiar to \fBPROFILE\fR, but this is only the target and no version info
+(i.e. \fICTARGET\fR or \fICHOST\fR).
+.TP
+\fB\-c\fR, \fB\-\-get\-current\-profile\fR \fI[TARGET]\fR
+Display the active profile for \fITARGET\fR.  If none is specified, the 
+host system's \fITARGET\fR will be shown (i.e. \fICHOST\fR).
+.TP
+\fB\-l\fR, \fB\-\-list\-profiles\fR
+Show all the profiles that your system currently has installed and what
+versions are active.  The active native version is noted with a bright green
+asterisk while the active cross-compiler versions are noted with a light blue
+asterisk.
+.TP
+\fB-u\fR, \fB\-\-uninstall\fR \fITARGET\fR
+This is really for internal use only.  Used to remove all traces of the 
+\fITARGET\fR binutils from your system.
+.SH "REPORTING BUGS"
+Please report bugs via https://bugs.gentoo.org/
+.SH "SEE ALSO"
+.BR ar (1),
+.BR as (1),
+.BR ld (1),
+.BR nm (1),
+.BR objcopy (1),
+.BR ranlib (1),
+.BR readelf (1),
+.BR strings (1),
+.BR strip (1)
+.SH "FILES"
+.nf
+.BR /usr/bin/binutils-config
+.BR /etc/env.d/binutils/*
+.fi
+.SH "AUTHORS"
+Mike Frysinger <vapier@gentoo.org>

diff --git a/src/binutils.eselect b/src/binutils.eselect
new file mode 100644
index 0000000..a89655a
--- /dev/null
+++ b/src/binutils.eselect
@@ -0,0 +1,45 @@
+# -*-eselect-*-  vim: ft=eselect
+# Copyright 2005-2015 Gentoo Foundation
+# Distributed under the terms of the GNU GPL version 2 or later
+
+DESCRIPTION="Manage installed versions of sys-devel/binutils"
+MAINTAINER="toolchain@gentoo.org"
+
+### list action
+
+describe_list() {
+	echo "List all installed version of binutils"
+}
+
+do_list() {
+	binutils-config -l
+}
+
+### set action
+
+describe_set() {
+	echo "Activate one of the installed binutils"
+}
+
+describe_set_parameters() {
+	echo "<target>"
+}
+
+describe_set_options() {
+	echo "target : Target name or number (from 'list' action)"
+}
+
+do_set() {
+	[[ $# -eq 1 ]] || die -q "Please specify exactly one version to activate!"
+	binutils-config "$1"
+}
+
+### show action
+
+describe_show() {
+	echo "Print the currently active binutils version"
+}
+
+do_show() {
+	binutils-config -c
+}


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/binutils-config:master commit in: src/
@ 2020-05-21 22:14 Sergei Trofimovich
  0 siblings, 0 replies; 15+ messages in thread
From: Sergei Trofimovich @ 2020-05-21 22:14 UTC (permalink / raw
  To: gentoo-commits

commit:     2b86807c81dfa118508408931c8cf9627d770c31
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Thu May 21 22:14:26 2020 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Thu May 21 22:14:26 2020 +0000
URL:        https://gitweb.gentoo.org/proj/binutils-config.git/commit/?id=2b86807c

src/binutils-config: unbreak AND syntax for [[ ]]

Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 src/binutils-config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/binutils-config b/src/binutils-config
index e6819a8..fdee7df 100755
--- a/src/binutils-config
+++ b/src/binutils-config
@@ -130,7 +130,7 @@ 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} -a ${USE_NATIVE_LINKS} == yes ]] ; then
+		if [[ ${TARGET} == ${HOST} && ${USE_NATIVE_LINKS} == yes ]] ; then
 			atomic_ln "${TARGET}-${x}" "${EROOT}/usr/bin" "${x}"
 		else
 			# Remove native links if exist from previous


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/binutils-config:master commit in: src/
@ 2020-05-22 13:32 Sergei Trofimovich
  0 siblings, 0 replies; 15+ messages in thread
From: Sergei Trofimovich @ 2020-05-22 13:32 UTC (permalink / raw
  To: gentoo-commits

commit:     b1403d22c477e1801fa5c1f611a5509720fe2407
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Fri May 22 13:31:23 2020 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Fri May 22 13:31:23 2020 +0000
URL:        https://gitweb.gentoo.org/proj/binutils-config.git/commit/?id=b1403d22

src/binutils-config: add --nocolor option

For symmetry with gcc-config. Will allow iterating through
targets in pkg_*() phases.

Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 src/binutils-config | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/binutils-config b/src/binutils-config
index fdee7df..4dc4939 100755
--- a/src/binutils-config
+++ b/src/binutils-config
@@ -36,6 +36,7 @@ cat << USAGE_END
 Usage: ${HILITE}binutils-config${NORMAL} ${GOOD}[options]${NORMAL} ${BRACKET}[binutils profile]${NORMAL}
 
 ${HILITE}General Options:${NORMAL}
+  ${GOOD}-C, --nocolor${NORMAL}              Disable color output
   ${GOOD}-c, --get-current-profile${NORMAL}  Print current profile
   ${GOOD}-l, --list-profiles${NORMAL}        Print a list of available profiles
   ${GOOD}-u, --uninstall${NORMAL}            Remove all signs of specified target
@@ -385,6 +386,7 @@ while [[ $# -gt 0 ]] ; do
 		-c|--get-current-profile)  select_action get_current_profile ;;
 		-l|--list|--list-profiles) select_action list_profiles ;;
 		-u|--uninstall)            select_action uninstall_target ;;
+		-C|--nocolor) ;; # nothing to do; functions.sh parsed this for us
 		-d|--debug)                DEBUG="yes" ;;
 		-h|--help)                 usage 0 ;;
 		--enable-native-links)     USE_NATIVE_LINKS="yes" ;;


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/binutils-config:master commit in: src/
@ 2020-05-22 23:13 Sergei Trofimovich
  0 siblings, 0 replies; 15+ messages in thread
From: Sergei Trofimovich @ 2020-05-22 23:13 UTC (permalink / raw
  To: gentoo-commits

commit:     9fc1728560e2cd81d27dd85dc766152ddccf65c5
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Fri May 22 23:12:45 2020 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Fri May 22 23:12:45 2020 +0000
URL:        https://gitweb.gentoo.org/proj/binutils-config.git/commit/?id=9fc17285

binutils-config: document current binary assumptions

There is a difference in gcc / binutils layout:
binutils binaries are always unprefixed.

Bug: https://bugs.gentoo.org/724454
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 src/binutils-config | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/binutils-config b/src/binutils-config
index 4dc4939..cb7b905 100755
--- a/src/binutils-config
+++ b/src/binutils-config
@@ -126,6 +126,18 @@ switch_profile() {
 
 	setup_env || return 1
 
+	# Facts on binutils's private binary dir contents:
+	#
+	# Native directory looks like:
+	#     /usr/x86_64-pc-linux-gnu/binutils-bin/2.34
+	#   Contents are unprefixed tools:
+	#   - ar, as, nm, ...
+	#
+	# Cross directory looks like:
+	#    /usr/x86_64-pc-linux-gnu/ia64-unknown-linux-gnu/binutils-bin/2.34
+	#   Contents are also unprefixed tools:
+	#   - ar, as, nm, ...
+
 	cd "${ROOT}/${BINPATH}" || exit 1
 	mkdir -p "${ROOT}/${BINPATH_LINKS}" "${EROOT}/usr/bin"
 	for x in * ; do


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/binutils-config:master commit in: src/
@ 2020-05-23  7:42 Sergei Trofimovich
  0 siblings, 0 replies; 15+ messages in thread
From: Sergei Trofimovich @ 2020-05-23  7:42 UTC (permalink / raw
  To: gentoo-commits

commit:     a9d04f80c3d5ec32168b1389a5db79cc780b05ef
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Sat May 23 07:37:53 2020 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Sat May 23 07:37:53 2020 +0000
URL:        https://gitweb.gentoo.org/proj/binutils-config.git/commit/?id=a9d04f80

binutils-config: fix native link removal by cross-compilers, bug #724454

commit 36eba05752348258a7 ("binutils-config: add build-time
and runtime switches to disable native symlinks").

Added symlink deletion for USE_NATIVE_LINKS=no mode.
It had a bug: it unconditionally deleted native symlinks
if binutils-config is called on a cross-binutils installation.

I missed the case because I assumed that tool names
in binutils' private directory match gcc' private directory.

The change is not to perform symlink cleanup for unprefixed
binaries for cross-binutils.

Reported-by: Ionen Wolkens
Bug: https://bugs.gentoo.org/724454
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 src/binutils-config | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/binutils-config b/src/binutils-config
index cb7b905..da99021 100755
--- a/src/binutils-config
+++ b/src/binutils-config
@@ -143,17 +143,19 @@ 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} && ${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}"
+		if [[ ${TARGET} == ${HOST} ]] ; then
+			if [[ ${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
 		fi
 	done
 


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/binutils-config:master commit in: src/
@ 2020-06-21 12:36 Sergei Trofimovich
  0 siblings, 0 replies; 15+ messages in thread
From: Sergei Trofimovich @ 2020-06-21 12:36 UTC (permalink / raw
  To: gentoo-commits

commit:     94639ce75a496f0fa5499e9fe91162556891370f
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 21 12:34:06 2020 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Sun Jun 21 12:34:06 2020 +0000
URL:        https://gitweb.gentoo.org/proj/binutils-config.git/commit/?id=94639ce7

src/binutils-config: add --get-bin-path / --get-lib-path

The options are symmetric to gcc-config's --get-bin-path / --get-lib-path.

Useful to quickly get unprefixed tools into $PATH as:
    export PATH="$(gcc-config -B):$(binutils-config -B):$PATH"

Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 src/binutils-config | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/binutils-config b/src/binutils-config
index da99021..625c1b8 100755
--- a/src/binutils-config
+++ b/src/binutils-config
@@ -42,6 +42,11 @@ ${HILITE}General Options:${NORMAL}
   ${GOOD}-u, --uninstall${NORMAL}            Remove all signs of specified target
   ${GOOD}-d, --debug${NORMAL}                Execute with debug output
 
+  ${GOOD}-B, --get-bin-path${NORMAL}         Print path where binaries of the given/current
+                             profile are located.
+  ${GOOD}-L, --get-lib-path${NORMAL}         Print path where libraries of the given/current
+                             profile are located.
+
 Profile names are of the form:  ${BRACKET}<CTARGET>-<binutils version>${NORMAL}
 For example:                    ${BRACKET}i686-pc-linux-gnu-2.15.92.0.2${NORMAL}
 
@@ -321,6 +326,16 @@ set_current_profile() {
 }
 get_current_profile() { echo "${PROFILE}" ; }
 
+get_bin_path() {
+	setup_env || return 1
+	echo "${BINPATH}"
+}
+
+get_lib_path() {
+	setup_env || return 1
+	echo "${LIBPATH}"
+}
+
 list_profiles() {
 	local x i target
 
@@ -397,6 +412,8 @@ while [[ $# -gt 0 ]] ; do
 	x=$1
 	shift
 	case ${x} in
+		-B|--get-bin-path)         select_action get_bin_path ;;
+		-L|--get-lib-path)         select_action get_lib_path ;;
 		-c|--get-current-profile)  select_action get_current_profile ;;
 		-l|--list|--list-profiles) select_action list_profiles ;;
 		-u|--uninstall)            select_action uninstall_target ;;


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/binutils-config:master commit in: src/
@ 2021-02-28  9:39 Sergei Trofimovich
  0 siblings, 0 replies; 15+ messages in thread
From: Sergei Trofimovich @ 2021-02-28  9:39 UTC (permalink / raw
  To: gentoo-commits

commit:     c68523143e0a69b2a8d409cb679ca96aa4370a9b
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 28 09:38:55 2021 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Sun Feb 28 09:38:55 2021 +0000
URL:        https://gitweb.gentoo.org/proj/binutils-config.git/commit/?id=c6852314

binutils-config: add support for special 'latest' version for profile switch

To ease switching to latest version add special 'latest' verison.
Works for both "latest" and "<CTARGET>-latest" forms.

Bug: https://bugs.gentoo.org/765664
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 src/binutils-config | 46 +++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 39 insertions(+), 7 deletions(-)

diff --git a/src/binutils-config b/src/binutils-config
index 625c1b8..6604a14 100755
--- a/src/binutils-config
+++ b/src/binutils-config
@@ -31,6 +31,10 @@ esyslog() { :; }
 die() { eerror "${argv0}: $*"; exit 1; }
 umask 022
 
+# *BSD SED does not work as-is, use GNU SED. TODO: find details.
+SED=$(type -P gsed)
+: ${SED:=$(type -P sed)}
+
 usage() {
 cat << USAGE_END
 Usage: ${HILITE}binutils-config${NORMAL} ${GOOD}[options]${NORMAL} ${BRACKET}[binutils profile]${NORMAL}
@@ -47,7 +51,8 @@ ${HILITE}General Options:${NORMAL}
   ${GOOD}-L, --get-lib-path${NORMAL}         Print path where libraries of the given/current
                              profile are located.
 
-Profile names are of the form:  ${BRACKET}<CTARGET>-<binutils version>${NORMAL}
+Profile names are of the form:  ${BRACKET}<CTARGET>-<binutils version>${NORMAL}, ${BRACKET}latest${NORMAL},
+                                ${BRACKET}<CTARGET>-latest${NORMAL}, ${BRACKET}latest${NORMAL}.
 For example:                    ${BRACKET}i686-pc-linux-gnu-2.15.92.0.2${NORMAL}
 
 For more info, please see ${HILITE}binutils-config${NORMAL}(8).
@@ -56,6 +61,26 @@ USAGE_END
 	exit ${1:-1}
 }
 
+# Usage: version_sorted_paths <CHOST>
+# Returns paths ordered by version from olders to newest.
+# We use the following hack: assume the input containst digits only in places of versions
+# Normalizer:
+#    echo "hello-world-1.2.3.444.56778" | ${SED} -e 's/[0-9]\+/0000&/g' | ${SED} -e 's/0*\([0-9]\{4\}\)/\1/g'
+#    hello-world-0001.0002.0003.0444.56778
+# That way we can have 9.0 < 10.0 order.
+# TODO: explore how portable 'sort -V' is and try using that instead.
+version_sorted_paths() {
+	local p mangled_v
+	for p in "$@"; do
+		# TODO: avoid -r
+		mangled_v=$(printf "%s" "${p}" |
+			${SED} -e 's/[0-9]\+/0000&/g' |
+			${SED} -e 's/0*\([0-9]\{4\}\)/\1/g'
+		)
+		printf "%s %s\n" "${mangled_v}" "${p}"
+	done | LANG=C sort | $SED -e 's/^.* //g'
+}
+
 mv_if_diff() {
 	if cmp -s "$1" "$2" ; then
 		rm -f "$1"
@@ -454,7 +479,7 @@ switch_profile)
 	x=${UARG:-$(TARGET=${HOST} set_current_profile)}
 	PROFILE=""
 	if [[ -z $(echo ${x} | tr -d '[:digit:]') ]] ; then
-		# User gave us a # representing the profile
+		# User gave us a profile index number from '--list-profiles'
 		i=1
 		for y in "${ENV_D}"/* ; do
 			[[ ${y/config-} != ${y} ]] && continue
@@ -468,15 +493,22 @@ switch_profile)
 	fi
 
 	if [[ -z ${PROFILE} ]] ; then
-		# User gave us a full HOST-ver
+		# User gave us "latest" or "<CTARGET>-latest".
+		if [[ ${x} == latest ]]; then
+			x=$(version_sorted_paths "${ENV_D}"/${HOST}-* | tail -1)
+		elif [[ ${x} == *-latest ]]; then
+			x=$(version_sorted_paths "${ENV_D}"/${x%-latest}-* | tail -1)
+		fi
+
+		# User gave us a full <CTARGET-version>, <CTARGET> or <version>
 		x=${x##*/}
 		if [[ -f ${ENV_D}/${x} ]] ; then
-			# Valid HOST-ver yeah!
+			# Valid <CTARGET-version>
 			PROFILE=${x}
 		else
-			# Not a valid HOST-ver ...
+			# Not a valid <CTARGET-version>
 			if [[ ! -f ${ENV_D}/config-${x} ]] ; then
-				# Maybe they just gave us a ver ...
+				# Maybe they just gave us a <version>. Infer <CTARGET>.
 				if [[ -f ${ENV_D}/${HOST}-${x} ]] ; then
 					x=${HOST}-${x}
 				else
@@ -484,7 +516,7 @@ switch_profile)
 				fi
 				PROFILE=${x}
 			else
-				# Maybe they just gave us a target ... pick active profile
+				# Maybe they just gave us a <CTARGET>. Pick active profile
 				PROFILE=$(TARGET=${x} set_current_profile)
 			fi
 		fi


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/binutils-config:master commit in: src/
@ 2022-01-08 19:15 Mike Gilbert
  0 siblings, 0 replies; 15+ messages in thread
From: Mike Gilbert @ 2022-01-08 19:15 UTC (permalink / raw
  To: gentoo-commits

commit:     d7aedfa1bc07a252041cc12bffb3c7a81e067121
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Sat Jan  8 19:05:55 2022 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Sat Jan  8 19:15:17 2022 +0000
URL:        https://gitweb.gentoo.org/proj/binutils-config.git/commit/?id=d7aedfa1

Use @GENTOO_EPREFIX@ instead of @GENTOO_PORTAGE_EPREFIX@

This matches the sed expression in the Makefile, and the expression used
in gcc-config.

Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 src/binutils-config | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/binutils-config b/src/binutils-config
index 6604a14..28bb044 100755
--- a/src/binutils-config
+++ b/src/binutils-config
@@ -6,8 +6,8 @@
 #  config-TARGET:	CURRENT=version for TARGET
 #  TARGET-VER:		has a TARGET and VER variable
 
-EPREFIX="@GENTOO_PORTAGE_EPREFIX@"
-if [[ ${EPREFIX} == "@"GENTOO_PORTAGE_EPREFIX"@" ]] ; then
+EPREFIX="@GENTOO_EPREFIX@"
+if [[ ${EPREFIX} == "@"GENTOO_EPREFIX"@" ]] ; then
 	EPREFIX=""
 fi
 


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/binutils-config:master commit in: src/
@ 2022-01-13  7:43 Mike Frysinger
  0 siblings, 0 replies; 15+ messages in thread
From: Mike Frysinger @ 2022-01-13  7:43 UTC (permalink / raw
  To: gentoo-commits

commit:     b3d5707738167a15b9a12d73b855d16784f63d05
Author:     Joakim Tjernlund <Joakim.Tjernlund <AT> infinera <DOT> com>
AuthorDate: Tue Jan  4 09:19:06 2022 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Jan 13 07:42:52 2022 +0000
URL:        https://gitweb.gentoo.org/proj/binutils-config.git/commit/?id=b3d57077

binutils-config: skip updating empty env.d files

If the package doesn't have any info or man pages, we won't create
an env.d file, so don't try moving it.

Closes: https://bugs.gentoo.org/796260
Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund <AT> infinera.com>
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

 src/binutils-config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/binutils-config b/src/binutils-config
index 28bb044..8b62868 100755
--- a/src/binutils-config
+++ b/src/binutils-config
@@ -253,7 +253,7 @@ switch_profile() {
 		rm -f "${ee}"
 		[[ -d ${ROOT}/${DATAPATH}/man  ]] && echo "MANPATH=${DATAPATH}/man"   >> "${ee}"
 		[[ -d ${ROOT}/${DATAPATH}/info ]] && echo "INFOPATH=${DATAPATH}/info" >> "${ee}"
-		mv_if_diff "${ee}" "${e}"
+		[[ -e "${ee}" ]] && mv_if_diff "${ee}" "${e}"
 	fi
 
 	local c="${ENV_D}/config-${TARGET}"


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/binutils-config:master commit in: src/
@ 2022-09-23  0:11 Sam James
  0 siblings, 0 replies; 15+ messages in thread
From: Sam James @ 2022-09-23  0:11 UTC (permalink / raw
  To: gentoo-commits

commit:     2e3168da737f7382d3cf61adbaa0ea2c240819d4
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 23 00:11:08 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Sep 23 00:11:24 2022 +0000
URL:        https://gitweb.gentoo.org/proj/binutils-config.git/commit/?id=2e3168da

binutils-config: use portable Bash shebang

Signed-off-by: Sam James <sam <AT> gentoo.org>

 src/binutils-config | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/binutils-config b/src/binutils-config
index 8b62868..4219f93 100755
--- a/src/binutils-config
+++ b/src/binutils-config
@@ -1,5 +1,5 @@
-#!/bin/bash
-# Copyright 1999-2020 Gentoo Authors
+#!/usr/bin/env bash
+# Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # Format of /etc/env.d/binutils/:


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/binutils-config:master commit in: src/
@ 2023-01-03  1:02 Sam James
  0 siblings, 0 replies; 15+ messages in thread
From: Sam James @ 2023-01-03  1:02 UTC (permalink / raw
  To: gentoo-commits

commit:     80d2c435a58d88cfe71f37378bffae35e072408f
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  2 17:21:05 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jan  3 01:01:35 2023 +0000
URL:        https://gitweb.gentoo.org/proj/binutils-config.git/commit/?id=80d2c435

Allow EPREFIX to be overridden for manipulating prefixed ROOT

This use case was totally broken. We need to hardcode BROOT instead, as
we don't want to source /lib/gentoo/functions.sh from ROOT

We did the same with gcc-config. This aligns the start of these scripts.

Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 src/binutils-config | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/binutils-config b/src/binutils-config
index 4219f93..37ea77c 100755
--- a/src/binutils-config
+++ b/src/binutils-config
@@ -1,28 +1,25 @@
 #!/usr/bin/env bash
-# Copyright 1999-2022 Gentoo Authors
+# Copyright 1999-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # Format of /etc/env.d/binutils/:
 #  config-TARGET:	CURRENT=version for TARGET
 #  TARGET-VER:		has a TARGET and VER variable
 
-EPREFIX="@GENTOO_EPREFIX@"
-if [[ ${EPREFIX} == "@"GENTOO_EPREFIX"@" ]] ; then
-	EPREFIX=""
-fi
-
 : ${ROOT:=/}
 [[ ${ROOT} != */ ]] && ROOT="${ROOT}/"
 [[ ${ROOT} != /* ]] && ROOT="${PWD%/}/${ROOT}"
-
+BROOT="@GENTOO_EPREFIX@"
+[[ ${BROOT} == @*@ ]] && BROOT=""
+: ${EPREFIX="${BROOT}"}
 EROOT="${ROOT%/}${EPREFIX}/"
 
-cd "${EPREFIX}/"
+cd "${BROOT}/"
 
 trap ":" INT QUIT TSTP
 
 argv0=${0##*/}
-FUNCTIONS_SH="${EPREFIX}/lib/gentoo/functions.sh"
+FUNCTIONS_SH="${BROOT}/lib/gentoo/functions.sh"
 source ${FUNCTIONS_SH} || {
 	echo "${argv0}: Could not source ${FUNCTIONS_SH}!" 1>&2
 	exit 1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/binutils-config:master commit in: src/
@ 2023-01-03  1:02 Sam James
  0 siblings, 0 replies; 15+ messages in thread
From: Sam James @ 2023-01-03  1:02 UTC (permalink / raw
  To: gentoo-commits

commit:     0c8928b6b49603c0a3e0bcf1640da708865d20fe
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  2 17:24:12 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jan  3 01:01:35 2023 +0000
URL:        https://gitweb.gentoo.org/proj/binutils-config.git/commit/?id=0c8928b6

Read CHOST with portageq from EROOT and not /

Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>
Closes: https://github.com/gentoo/binutils-config/pull/1
Signed-off-by: Sam James <sam <AT> gentoo.org>

 src/binutils-config | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/binutils-config b/src/binutils-config
index 37ea77c..a28366a 100755
--- a/src/binutils-config
+++ b/src/binutils-config
@@ -13,6 +13,7 @@ BROOT="@GENTOO_EPREFIX@"
 [[ ${BROOT} == @*@ ]] && BROOT=""
 : ${EPREFIX="${BROOT}"}
 EROOT="${ROOT%/}${EPREFIX}/"
+export PORTAGE_CONFIGROOT="${EROOT}"
 
 cd "${BROOT}/"
 


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/binutils-config:master commit in: src/
@ 2024-07-28 13:00 Andreas K. Hüttel
  0 siblings, 0 replies; 15+ messages in thread
From: Andreas K. Hüttel @ 2024-07-28 13:00 UTC (permalink / raw
  To: gentoo-commits

commit:     d26221d21a851f84a639b44477f6dd94056a7058
Author:     Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 26 20:34:47 2024 +0000
Commit:     Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
CommitDate: Fri Jul 26 20:34:47 2024 +0000
URL:        https://gitweb.gentoo.org/proj/binutils-config.git/commit/?id=d26221d2

Print error message on empty determined CHOST

No error exit yet, until we've fixed our problems.

Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>

 src/binutils-config | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/binutils-config b/src/binutils-config
index a28366a..c8de31a 100755
--- a/src/binutils-config
+++ b/src/binutils-config
@@ -409,6 +409,12 @@ list_profiles() {
 set_HOST() {
 	# Set HOST to CHOST if it isn't already set
 	: ${HOST:=${CHOST:-$(portageq envvar CHOST)}}
+
+	if [[ -z ${HOST} ]] ; then
+		eerror "Cannot determine CHOST. Something is badly broken."
+		# once our current stage build problems are fixed, let's enable this:
+		# exit 1
+	fi
 }
 
 ENV_D="${EROOT}etc/env.d/binutils"


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/binutils-config:master commit in: src/
@ 2024-07-28 13:00 Andreas K. Hüttel
  0 siblings, 0 replies; 15+ messages in thread
From: Andreas K. Hüttel @ 2024-07-28 13:00 UTC (permalink / raw
  To: gentoo-commits

commit:     93501357fa01314bb5c7893a6fc38f927f135a96
Author:     Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 26 20:51:50 2024 +0000
Commit:     Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
CommitDate: Sun Jul 28 12:56:42 2024 +0000
URL:        https://gitweb.gentoo.org/proj/binutils-config.git/commit/?id=93501357

Remove bad binutils symlinks in /usr/libexec/gcc/${HOST}/

Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>

 src/binutils-config | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/binutils-config b/src/binutils-config
index c8de31a..519f1f0 100755
--- a/src/binutils-config
+++ b/src/binutils-config
@@ -168,6 +168,9 @@ switch_profile() {
 
 	cd "${ROOT}/${BINPATH}" || exit 1
 	mkdir -p "${ROOT}/${BINPATH_LINKS}" "${EROOT}/usr/bin"
+
+	local bad_symlinks_removed="0"
+
 	for x in * ; do
 		atomic_ln "${BINPATH}/${x}" "${ROOT}/${BINPATH_LINKS}" "${x}"
 		atomic_ln "${BINPATH_LINKS}/${x}" "${EROOT}/usr/bin" "${TARGET}-${x}"
@@ -184,9 +187,21 @@ switch_profile() {
 				# all possible ones.
 				rm -f "${EROOT}/usr/bin/${x}"
 			fi
+
+			# Some stages errorneously could not figure out CHOST and installed
+			# symlinks into the path ${EROOT}/usr/libexec/gcc/${HOST}. These need
+			# to go away.
+			if [[ -e "${EROOT}/usr/libexec/gcc/${HOST}/${x}" ]] ; then
+				rm -f "${EROOT}/usr/libexec/gcc/${HOST}/${x}"
+				bad_symlinks_removed="1"
+			fi
 		fi
 	done
 
+	if [[ ${bad_symlinks_removed} == "1" ]] ; then
+		einfo "binutils-config removed errorneous, leftover symlinks in ${EROOT}/usr/libexec/gcc/${HOST}"
+	fi
+
 	#
 	# Generate library / ldscripts symlinks
 	#


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/binutils-config:master commit in: src/
@ 2024-07-28 14:36 Andreas K. Hüttel
  0 siblings, 0 replies; 15+ messages in thread
From: Andreas K. Hüttel @ 2024-07-28 14:36 UTC (permalink / raw
  To: gentoo-commits

commit:     bf4b9fcbb4ce432731ac90fbbb3bcf73beb51820
Author:     Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 28 14:24:28 2024 +0000
Commit:     Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
CommitDate: Sun Jul 28 14:35:40 2024 +0000
URL:        https://gitweb.gentoo.org/proj/binutils-config.git/commit/?id=bf4b9fcb

Fix test for broken symlinks (-e is false, -h is true)

Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>

 src/binutils-config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/binutils-config b/src/binutils-config
index 519f1f0..43d38e5 100755
--- a/src/binutils-config
+++ b/src/binutils-config
@@ -191,7 +191,7 @@ switch_profile() {
 			# Some stages errorneously could not figure out CHOST and installed
 			# symlinks into the path ${EROOT}/usr/libexec/gcc/${HOST}. These need
 			# to go away.
-			if [[ -e "${EROOT}/usr/libexec/gcc/${HOST}/${x}" ]] ; then
+			if [[ -h "${EROOT}/usr/libexec/gcc/${HOST}/${x}" ]] ; then
 				rm -f "${EROOT}/usr/libexec/gcc/${HOST}/${x}"
 				bad_symlinks_removed="1"
 			fi


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-07-28 14:36 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-03  1:02 [gentoo-commits] proj/binutils-config:master commit in: src/ Sam James
  -- strict thread matches above, loose matches on Subject: below --
2024-07-28 14:36 Andreas K. Hüttel
2024-07-28 13:00 Andreas K. Hüttel
2024-07-28 13:00 Andreas K. Hüttel
2023-01-03  1:02 Sam James
2022-09-23  0:11 Sam James
2022-01-13  7:43 Mike Frysinger
2022-01-08 19:15 Mike Gilbert
2021-02-28  9:39 Sergei Trofimovich
2020-06-21 12:36 Sergei Trofimovich
2020-05-23  7:42 Sergei Trofimovich
2020-05-22 23:13 Sergei Trofimovich
2020-05-22 13:32 Sergei Trofimovich
2020-05-21 22:14 Sergei Trofimovich
2020-05-21 18:06 Sergei Trofimovich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox