commit:     bb88e766897f5e7e0b0a10c48cf99a04edb73a40
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Mar  5 05:32:45 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Mar 28 06:20:45 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=bb88e766

estrip: avoid calling scanelf twice

We can use the previous scanelf data to not call it again to find
all of the dynamically linked executables/libraries which need stripping.

Bug: https://bugs.gentoo.org/749624
Closes: https://github.com/gentoo/portage/pull/794
Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/estrip            |  3 ++-
 bin/misc-functions.sh | 29 +++++++++++++++--------------
 2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/bin/estrip b/bin/estrip
index cdad58c31..686afb763 100755
--- a/bin/estrip
+++ b/bin/estrip
@@ -410,8 +410,9 @@ while read -r x ; do
 done < <(
        # Use sort -u to eliminate duplicates for bug #445336.
        (
-               scanelf -yqRBF '#k%F' -k '.symtab' "$@"
                find "$@" -type f ! -type l -name '*.a'
+               cut -d ' ' -f1 < "${PORTAGE_BUILDDIR}"/build-info/NEEDED \
+                       | sed -e "s:^:${ED}:"
        ) | LC_ALL=C sort -u
 )
 else

diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
index ccb07075f..0e1791937 100755
--- a/bin/misc-functions.sh
+++ b/bin/misc-functions.sh
@@ -151,20 +151,6 @@ install_qa_check() {
                "${PORTAGE_BIN_PATH}"/ecompress --dequeue
        fi
 
-       # If binpkg-dostrip is enabled, apply stripping before creating
-       # the binary package.
-       # Note: disabling it won't help with packages calling prepstrip 
directly.
-       if has binpkg-dostrip ${FEATURES}; then
-               export STRIP_MASK
-               if ___eapi_has_dostrip; then
-                       "${PORTAGE_BIN_PATH}"/estrip --queue 
"${PORTAGE_DOSTRIP[@]}"
-                       "${PORTAGE_BIN_PATH}"/estrip --ignore 
"${PORTAGE_DOSTRIP_SKIP[@]}"
-                       "${PORTAGE_BIN_PATH}"/estrip --dequeue
-               else
-                       prepallstrip
-               fi
-       fi
-
        if has chflags $FEATURES ; then
                # Restore all the file flags that were saved earlier on.
                mtree -U -e -p "${ED}" -k flags < "${T}/bsdflags.mtree" &> 
/dev/null
@@ -249,6 +235,21 @@ install_qa_check() {
                fi
        fi
 
+       # If binpkg-dostrip is enabled, apply stripping before creating
+       # the binary package.
+       # Note: disabling it won't help with packages calling prepstrip 
directly.
+       # We do this after the scanelf bits so that we can reuse the data. bug 
#749624.
+       if has binpkg-dostrip ${FEATURES}; then
+               export STRIP_MASK
+               if ___eapi_has_dostrip; then
+                       "${PORTAGE_BIN_PATH}"/estrip --queue 
"${PORTAGE_DOSTRIP[@]}"
+                       "${PORTAGE_BIN_PATH}"/estrip --ignore 
"${PORTAGE_DOSTRIP_SKIP[@]}"
+                       "${PORTAGE_BIN_PATH}"/estrip --dequeue
+               else
+                       prepallstrip
+               fi
+       fi
+
        # Portage regenerates this on the installed system.
        rm -f "${ED%/}"/usr/share/info/dir{,.gz,.bz2} || die "rm failed!"
 }

Reply via email to