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 360991580E0 for ; Tue, 03 Jun 2025 13:34:58 +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 21AAC3430AC for ; Tue, 03 Jun 2025 13:34:58 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 7F68211047D; Tue, 03 Jun 2025 13:34:51 +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 75DCE11047D for ; Tue, 03 Jun 2025 13:34:51 +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 2C25C34308A for ; Tue, 03 Jun 2025 13:34:51 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 9AC8D28F2 for ; Tue, 03 Jun 2025 13:34:49 +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: <1748957683.0f385908e8f2a5b9faa672dfa5db4d718a1e63c1.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: 0f385908e8f2a5b9faa672dfa5db4d718a1e63c1 X-VCS-Branch: master Date: Tue, 03 Jun 2025 13:34:49 +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: 66c03121-861c-4d75-9e4e-f60c1717a45d X-Archives-Hash: 4d64d96465277225ef77c86036d75be8 commit: 0f385908e8f2a5b9faa672dfa5db4d718a1e63c1 Author: Kerin Millar plushkava net> AuthorDate: Tue Jun 3 04:49:45 2025 +0000 Commit: Sam James gentoo org> CommitDate: Tue Jun 3 13:34:43 2025 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=0f385908 estrip: name and employ boolean variables sensibly As a prelude to further refactoring, this commit adjusts the manner in which some of the quasi-boolean variables are named and handled. Firstly, some of them have been renamed, as shown beneath. banner => do_banner * prepstrip => do_prepstrip PRESERVE_XATTR => do_preserve_xattr SKIP_STRIP => do_skip splitdebug => do_splitdebug strip_this => do_strip was_not_writeable => was_writeable * * logical sense inverted In doing so, it establishes a consistent naming scheme for those that are globally scoped, by way of the "do_" prefix, with 'was_writeable' remaining the only exception. Further, by refraining from employing upper case names, there can be no confusion as to whether they are expected to have originated from the process environment. Secondly, all boolean variables are now evaluated in the arithmetic context. That goes for all of the variables mentioned above, as well as the 'already_stripped' variable, which is local to the process_elf() function. Signed-off-by: Kerin Millar plushkava.net> Signed-off-by: Sam James gentoo.org> bin/estrip | 88 +++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 47 insertions(+), 41 deletions(-) diff --git a/bin/estrip b/bin/estrip index 92d7836eb0..7df22b5883 100755 --- a/bin/estrip +++ b/bin/estrip @@ -23,15 +23,17 @@ if ! ___eapi_has_prefix_variables; then EPREFIX= ED=${D} fi -banner=false -SKIP_STRIP=false -if ${PORTAGE_RESTRICT_strip} || ${FEATURES_nostrip} ; then - SKIP_STRIP=true - banner=true - ${FEATURES_installsources} || exit 0 +if ! ${PORTAGE_RESTRICT_strip} && ! ${FEATURES_nostrip}; then + do_banner=1 + do_skip=0 +elif ! ${FEATURES_installsources}; then + exit 0 +else + do_banner=0 + do_skip=1 fi -prepstrip=false +do_prepstrip=0 while [[ $# -gt 0 ]] ; do case $1 in @@ -119,7 +121,7 @@ while [[ $# -gt 0 ]] ; do ;; --prepallstrip) [[ $# -eq 1 ]] || die "${0##*/}: $1 takes no additional arguments" - prepstrip=true + do_prepstrip=1 break ;; *) @@ -131,9 +133,9 @@ while [[ $# -gt 0 ]] ; do done set -- "${ED}" -PRESERVE_XATTR=false +do_preserve_xattr=0 if [[ ${KERNEL} == linux ]] && ${FEATURES_xattr} ; then - PRESERVE_XATTR=true + do_preserve_xattr=1 if type -P getfattr >/dev/null && type -P setfattr >/dev/null ; then dump_xattrs() { getfattr -d -m - --absolute-names "$1" @@ -370,37 +372,38 @@ process_elf() { sleep 1 done - [ -f "${inode_link}_stripped" ] && already_stripped=true || already_stripped=false - - if ! ${already_stripped} ; then - if ${PRESERVE_XATTR} ; then + if [[ -f ${inode_link}_stripped ]]; then + already_stripped=1 + else + already_stripped=0 + if (( do_preserve_xattr )); then xt_data=$(dump_xattrs "${x}") fi save_elf_sources "${x}" dedup_elf_debug "${x}" "${inode_link}_dedupdebug" fi - if ${strip_this} ; then + if (( do_strip )); then # See if we can split & strip at the same time - if ${splitdebug} && [[ -n ${SPLIT_STRIP_FLAGS} ]] ; then + if (( do_splitdebug )) && [[ ${SPLIT_STRIP_FLAGS} ]]; then local shortname="${x##*/}.debug" local splitdebug="${tmpdir}/splitdebug/${shortname}.${BASHPID}" - ${already_stripped} || \ - ${STRIP} "${strip_flags[@]}" \ - -f "${splitdebug}" \ - -F "${shortname}" \ - "${x}" + if (( ! already_stripped )); then + ${STRIP} "${strip_flags[@]}" -f "${splitdebug}" -F "${shortname}" "${x}" + fi save_elf_debug "${x}" "${inode_link}_debug" "${splitdebug}" else - if ${splitdebug} ; then + if (( do_splitdebug )); then save_elf_debug "${x}" "${inode_link}_debug" fi - ${already_stripped} || ${STRIP} "${strip_flags[@]}" "${x}" + if (( ! already_stripped )); then + ${STRIP} "${strip_flags[@]}" "${x}" + fi fi fi - if ${already_stripped} ; then + if (( already_stripped )); then rm -f "${x}" || die "rm failed unexpectedly" ln "${inode_link}_stripped" "${x}" || die "ln failed unexpectedly" else @@ -420,12 +423,12 @@ process_ar() { __vecho " ${x:${#ed_noslash}}" - if ${strip_this} ; then + if (( do_strip )); then # If we have split debug enabled, then do not strip this. # There is no concept of splitdebug for objects not yet # linked in (only for finally linked ELFs), so we have to # retain the debug info in the archive itself. - if ! ${splitdebug} ; then + if (( ! do_splitdebug )); then ${STRIP} -g "${x}" && ${RANLIB} "${x}" fi fi @@ -479,7 +482,7 @@ fi cd "${tmpdir}/inodes" || die "cd failed unexpectedly" -if ${prepstrip}; then +if (( do_prepstrip )); then while read -r x ; do inode_link=$(get_inode_number "${x}") || die "stat failed unexpectedly" echo "${x}" >> "${inode_link}" || die "echo failed unexpectedly" @@ -513,9 +516,9 @@ for inode_link in *; do while read -r x do - if ! ${banner} ; then + if (( do_banner )); then __vecho "strip: ${STRIP} ${portage_strip_flags[*]}" - banner=true + do_banner=0 fi ( @@ -523,34 +526,37 @@ for inode_link in *; do f=$(file -S "${x}") || exit 0 [[ -z ${f} ]] && exit 0 - if ${SKIP_STRIP} ; then - strip_this=false - elif ! ${prepstrip}; then - strip_this=true + if (( do_skip )); then + do_strip=0 + elif (( ! do_prepstrip )); then + do_strip=1 else # The noglob funk is to support STRIP_MASK="/*/booga" and to keep # the for loop from expanding the globs. # The eval echo is to support STRIP_MASK="/*/{booga,bar}". set -o noglob - strip_this=true + do_strip=1 for m in $(eval echo ${STRIP_MASK}) ; do - [[ ${x#"${ED%/}"} == ${m} ]] && strip_this=false && break + if [[ ${x#"${ED%/}"} == ${m} ]]; then + do_strip=0 + break + fi done set +o noglob fi if ${FEATURES_splitdebug} && ! ${PORTAGE_RESTRICT_splitdebug} ; then - splitdebug=true + do_splitdebug=1 else - splitdebug=false + do_splitdebug=0 fi # In Prefix we are usually an unprivileged user, so we can't strip # unwritable objects. Make them temporarily writable for the # stripping. - was_not_writable=false + was_writable=1 if [[ ! -w ${x} ]] ; then - was_not_writable=true + was_writable=0 chmod u+w "${x}" fi @@ -567,12 +573,12 @@ for inode_link in *; do ${f} == *"SB shared object"* ]] ; then process_elf "${x}" "${inode_link}" "${portage_strip_flags[@]}" elif [[ ${f} == *"SB relocatable"* ]] ; then - [[ ${x} == *.ko ]] || splitdebug=false + [[ ${x} == *.ko ]] || do_splitdebug=0 read -rd '' -a safe_strip_flags <<<"${SAFE_STRIP_FLAGS}" process_elf "${x}" "${inode_link}" "${safe_strip_flags[@]}" fi - if ${was_not_writable} ; then + if (( ! was_writable )); then chmod u-w "${x}" fi ) &