From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 450B91580E0 for ; Tue, 03 Jun 2025 20:50:16 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 2C2BD343124 for ; Tue, 03 Jun 2025 20:50:16 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id A612C11047D; Tue, 03 Jun 2025 20:50:09 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 9CC4311047D for ; Tue, 03 Jun 2025 20:50:09 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 39E653430D5 for ; Tue, 03 Jun 2025 20:50:09 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 658402903 for ; Tue, 03 Jun 2025 20:50:07 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1748983793.b10a9a5a8c8a532911f2396472ad8af94d93bc3f.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/estrip X-VCS-Directories: bin/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: b10a9a5a8c8a532911f2396472ad8af94d93bc3f X-VCS-Branch: master Date: Tue, 03 Jun 2025 20:50:07 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: e649bbcc-4866-4e56-bef8-a8c5c7c4a1cf X-Archives-Hash: 382dfb3cddeb71635f1b44de66968c58 commit: b10a9a5a8c8a532911f2396472ad8af94d93bc3f Author: Kerin Millar plushkava net> AuthorDate: Tue Jun 3 17:43:42 2025 +0000 Commit: Sam James gentoo org> CommitDate: Tue Jun 3 20:49:53 2025 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=b10a9a5a estrip: track issued warnings context-sensitively Presently, estrip will raise warnings in the event that is tasked with doing something that requires for a given tool to be available, yet is unable to find it. It endeavours never to print the same warning twice and accomplishes this by unsetting the applicable key of the 'path_of' map, whose empty value will have conveyed the absence of the tool. Such is all well and good. However, my attention was drawn to a still-open GitHub PR which demonstrates a need for tracking whether warnings have already been issued for a tool in a given context. For example, there may be a need to warn of the absence of debugedit(1) on account of needing it to fulfil the behaviour of the "splitdebug" feature, whereas there may also be a need to warn on account of needing to fulfil the behaviour of the "installsources" feature. One way to address this would to go back to using individual scalar variables to track whether a given warning has been issued. Rather than do that, this commit introduces an associative array by the name of 'warned_for', whose keys are expected to be the name of a given tool, and its values, strings comprised by space-separated warning categories. The code beneath demonstrates how it is intended to be used in practice. if [[ ! ${path_of[brush]} ]]; then # The brush tool is missing but needed for detangling. if ! contains_word "hair-detangle" "${warned_for[brush]}"; then # No warning yet issued. Go ahead and issue one now. warned_for[brush]+=" hair-detangle" ewarn "The hair-detangle feature requires the brush tool" fi return 0 fi Link: https://github.com/gentoo/portage/pull/1436 Signed-off-by: Kerin Millar plushkava.net> Signed-off-by: Sam James gentoo.org> bin/estrip | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/estrip b/bin/estrip index 211aece3a3..1f4cfceb27 100755 --- a/bin/estrip +++ b/bin/estrip @@ -166,6 +166,10 @@ for bin in strip objcopy readelf ranlib; do path_of[$bin]=$bin done +# Declare a map to keep track of whether warnings in certain categories have +# been issued for a missing tool. +declare -A warned_for + # Figure out what tool set we're using to strip stuff unset SAFE_STRIP_FLAGS DEF_STRIP_FLAGS SPLIT_STRIP_FLAGS case $("${path_of[strip]}" --version 2>/dev/null) in @@ -214,8 +218,8 @@ save_elf_sources() { if (( ! has_feature[installsources] || has_restriction[installsources] )); then return elif [[ ! ${path_of[debugedit]} ]]; then - if [[ -v 'path_of[debugedit]' ]]; then - unset -v 'path_of[debugedit]' + if ! contains_word installsources "${warned_for[debugedit]}"; then + warned_for[debugedit]+=" installsources" ewarn "FEATURES=installsources is enabled but the debugedit binary could not be" ewarn "found. This feature will not work unless debugedit is installed!" fi @@ -257,8 +261,8 @@ dedup_elf_debug() { debug-print-function "${FUNCNAME}" "$@" if [[ ! ${path_of[dwz]} ]]; then - if [[ -v 'path_of[dwz]' ]]; then - unset -v 'path_of[dwz]' + if ! contains_word dedupdebug "${warned_for[dwz]}"; then + warned_for[dwz]+=" dedupdebug" ewarn "FEATURES=dedupdebug is enabled but the dwz binary could not be" ewarn "found. This feature will not work unless dwz is installed!" fi