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 9F17315807A for ; Thu, 05 Jun 2025 11:22:28 +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 891FF343163 for ; Thu, 05 Jun 2025 11:22:28 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id D14BF11049F; Thu, 05 Jun 2025 11:22:16 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (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 CBEBA11049F for ; Thu, 05 Jun 2025 11:22:16 +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)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 7EE5E34312A for ; Thu, 05 Jun 2025 11:22:16 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id DED75291E for ; Thu, 05 Jun 2025 11:22:13 +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: <1749122525.8c824b934b77a8d23f82e07606e9f8be707a8cf4.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/phase-functions.sh X-VCS-Directories: bin/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 8c824b934b77a8d23f82e07606e9f8be707a8cf4 X-VCS-Branch: master Date: Thu, 05 Jun 2025 11:22:13 +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: b8048575-6a6c-41ac-87e8-5f83bf687c7d X-Archives-Hash: a434262ca0edd06da65642c2e0631797 commit: 8c824b934b77a8d23f82e07606e9f8be707a8cf4 Author: Kerin Millar plushkava net> AuthorDate: Thu Jun 5 05:52:00 2025 +0000 Commit: Sam James gentoo org> CommitDate: Thu Jun 5 11:22:05 2025 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=8c824b93 phase-functions.sh: reduce the degree of indentation in __dyn_install() Presently, the __dyn_install() function guards the routine that records the sizes of WORKDIR and D with a test for the existence of the du(1) utility. Decrease the indentation level of the entire routine by repositioning the test and simply exiting the subshell in the highly unlikely event that the utility be missing. It is unclear to me why the test is present, given that it is a standard utility and is required by POSIX to exist. Further, use the hash builtin instead of the type builtin. While type -P does coerce bash into performing a PATH search, the manner in which du is invoked still permits for it to be a function or alias. Using hash also confers the benefit of pre-warming the cache that the shell employs for Command Search and Execution. Signed-off-by: Kerin Millar plushkava.net> Signed-off-by: Sam James gentoo.org> bin/phase-functions.sh | 102 ++++++++++++++++++++++++------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh index 19b643d9d5..a35cd5129e 100644 --- a/bin/phase-functions.sh +++ b/bin/phase-functions.sh @@ -628,58 +628,58 @@ __dyn_install() { __vecho __ebuild_phase post_src_install - # record build & installed size in build log - if type -P du &>/dev/null; then - # subshell to avoid polluting the caller env with the helper - # functions below - ( - local nsz=( $(du -ks "${WORKDIR}") ) - local isz=( $(du -ks "${D}") ) - # align $1 to the right to the width of the widest of $1 and $2 - padl() { - local s1=$1 - local s2=$2 - local width=${#s1} - [[ ${#s2} -gt ${width} ]] && width=${#s2} - printf "%*s" ${width} "${s1}" - } - - # transform number in KiB into MiB, GiB or TiB based on size - human() { - local s1=$1 - local units=( KiB MiB GiB TiB ) - - s1=$((s1 * 10)) - while [[ ${s1} -gt 10240 && ${#units[@]} -gt 1 ]] ; do - s1=$((s1 / 1024 )) - units=( ${units[@]:1} ) - done - - local r=${s1: -1} - s1=$((s1 / 10)) - printf "%s.%s %s" "${s1}" "${r}" "${units[0]}" - } - - size() { - local s1=$1 - local s2=$2 - local out="$(padl "${s1}" "${s2}") KiB" - - if [[ ${s1} -gt 1024 ]] ; then - s1=$(human ${s1}) - if [[ ${s2} -gt 1024 ]] ; then - s2=$(human ${s2}) - s1=$(padl "${s1}" "${s2}") - fi - out+=" (${s1})" + # Record the sizes of WORKDIR and D to the build log. Employ a subshell + # so as to avoid polluting the caller's environment with several helper + # functions. + ( + hash du 2>/dev/null || exit 0 + + local nsz=( $(du -ks "${WORKDIR}") ) + local isz=( $(du -ks "${D}") ) + # align $1 to the right to the width of the widest of $1 and $2 + padl() { + local s1=$1 + local s2=$2 + local width=${#s1} + [[ ${#s2} -gt ${width} ]] && width=${#s2} + printf "%*s" ${width} "${s1}" + } + + # transform number in KiB into MiB, GiB or TiB based on size + human() { + local s1=$1 + local units=( KiB MiB GiB TiB ) + + s1=$((s1 * 10)) + while [[ ${s1} -gt 10240 && ${#units[@]} -gt 1 ]] ; do + s1=$((s1 / 1024 )) + units=( ${units[@]:1} ) + done + + local r=${s1: -1} + s1=$((s1 / 10)) + printf "%s.%s %s" "${s1}" "${r}" "${units[0]}" + } + + size() { + local s1=$1 + local s2=$2 + local out="$(padl "${s1}" "${s2}") KiB" + + if [[ ${s1} -gt 1024 ]] ; then + s1=$(human ${s1}) + if [[ ${s2} -gt 1024 ]] ; then + s2=$(human ${s2}) + s1=$(padl "${s1}" "${s2}") fi - echo "${out}" - } - einfo "Final size of build directory: $(size ${nsz[0]} ${isz[0]})" - einfo "Final size of installed tree: $(size ${isz[0]} ${nsz[0]})" - ) - __vecho - fi + out+=" (${s1})" + fi + echo "${out}" + } + einfo "Final size of build directory: $(size ${nsz[0]} ${isz[0]})" + einfo "Final size of installed tree: $(size ${isz[0]} ${nsz[0]})" + ) + __vecho cd "${PORTAGE_BUILDDIR}"/build-info set -f