Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: bin/
Date: Sat, 06 Aug 2022 21:01:27
Message-Id: 1659819628.e8f0e06784549fc4c8a06e0a43ff946d6a895683.sam@gentoo
1 commit: e8f0e06784549fc4c8a06e0a43ff946d6a895683
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Mon Aug 1 01:44:02 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Sat Aug 6 21:00:28 2022 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=e8f0e067
7
8 estrip: apply scanelf optimisation to EAPI 7+ / dostrip
9
10 (No need to do ${D%/} etc here as dostrip is in EAPI 7+ only.)
11
12 See: bb88e766897f5e7e0b0a10c48cf99a04edb73a40
13 Bug: https://bugs.gentoo.org/749624
14 Bug: https://bugs.gentoo.org/862606
15 Signed-off-by: Sam James <sam <AT> gentoo.org>
16 Closes: https://github.com/gentoo/portage/pull/879
17 Signed-off-by: Sam James <sam <AT> gentoo.org>
18
19 bin/estrip | 41 ++++++++++++++++++++++++++++++++++++++++-
20 1 file changed, 40 insertions(+), 1 deletion(-)
21
22 diff --git a/bin/estrip b/bin/estrip
23 index 0ed35111d..68ce8bd4d 100755
24 --- a/bin/estrip
25 +++ b/bin/estrip
26 @@ -64,12 +64,51 @@ while [[ $# -gt 0 ]] ; do
27 done
28
29 if [[ ${find_paths[@]} ]]; then
30 + # We can avoid scanelf calls for binaries we already
31 + # checked in install_qa_check (where we generate
32 + # NEEDED for everything installed).
33 + #
34 + # EAPI 7+ has controlled stripping (dostrip) though
35 + # which is why estrip has the queue/dequeue logic,
36 + # so we need to take the intersection of:
37 + # 1. files scanned earlier (all ELF installed)
38 + # (note that this should be a superset of 2., so we don't
39 + # need to worry about unknown files appearing)
40 + #
41 + # 2. the files we're interested in right now
42 + scanelf_results=()
43 + if [[ -f "${PORTAGE_BUILDDIR}"/build-info/NEEDED ]] ; then
44 + # The arguments may not be exact files (probably aren't), but search paths/directories
45 + # which should then be searched recursively.
46 + while IFS= read -r needed_entry ; do
47 + for find_path in "${find_paths[@]}" ; do
48 + # NEEDED has a bunch of entries like:
49 + # /usr/lib64/libfoo.so libc.so
50 + #
51 + # find_path entries may be exact paths (like /usr/lib64/libfoo.so)
52 + # or instead /usr/lib64, or ${ED}/usr, etc.
53 + #
54 + # We check if the beginning (i.e. first entry) of the NEEDED line
55 + # matches the path given
56 + # e.g. find_path="/usr/lib64" will match needed_entry="/usr/lib64/libfoo.so libc.so".
57 + needed_entry_file="${needed_entry% *}"
58 + if [[ "${needed_entry_file}" =~ ^${find_path##${D}} ]] ; then
59 + scanelf_results+=( "${D}${needed_entry_file}" )
60 + fi
61 + done
62 + done < "${PORTAGE_BUILDDIR}"/build-info/NEEDED
63 + else
64 + scanelf_results=$(scanelf -yqRBF '#k%F' -k '.symtab' "${find_paths[@]}")
65 + fi
66 +
67 while IFS= read -r path; do
68 >> "${path}.estrip" || die
69 done < <(
70 - scanelf -yqRBF '#k%F' -k '.symtab' "${find_paths[@]}"
71 + printf "%s\n" "${scanelf_results[@]}"
72 find "${find_paths[@]}" -type f ! -type l -name '*.a'
73 )
74 +
75 + unset scanelf_results needed_entry needed_entry_file find_path
76 fi
77
78 exit 0