commit: 6ea5744893ada1ef87362b60b046ec674e7c9910
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Mon Jun 9 19:51:04 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jun 11 03:26:17 2025 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=6ea57448
estrip: refactor some of the code out into functions
Relocate the code that attends to the --ignore and --queue options into
two new functions, respectively named do_ignore() and do_queue().
It should be noted that the code contained by the new functions is
over-indented so as to prevent the patch from being incomprehensible.
The indentation shall be adjusted by the next commit.
See-also: d015284bbdcdd36b5932a882d11fef9bf0941b96
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/estrip | 89 +++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 47 insertions(+), 42 deletions(-)
diff --git a/bin/estrip b/bin/estrip
index 2dada0577c..a149731b57 100755
--- a/bin/estrip
+++ b/bin/estrip
@@ -324,41 +324,10 @@ restore_xattrs() {
restore_xattrs "$@"
}
-declare -A has_feature
-declare -A has_restriction
-
-for key in compressdebug dedupdebug installsources nostrip splitdebug xattr; do
- contains_word "$key" "${FEATURES}"
- has_feature[$key]=$(( $? == 0 ))
-done
-
-for key in binchecks dedupdebug installsources splitdebug strip; do
- contains_word "$key" "${PORTAGE_RESTRICT}"
- has_restriction[$key]=$(( $? == 0 ))
-done
-
-if ! ___eapi_has_prefix_variables; then
- EPREFIX= ED=${D}
-fi
+do_ignore() {
+ local -a skip_dirs
+ local skip
-if (( ! has_restriction[strip] && ! has_feature[nostrip] )); then
- do_banner=1
- do_skip=0
-elif (( ! has_feature[installsources] )); then
- exit 0
-else
- do_banner=0
- do_skip=1
-fi
-
-do_prepstrip=0
-
-while [[ $# -gt 0 ]] ; do
- case $1 in
- --ignore)
- shift
-
- skip_dirs=()
for skip; do
if [[ -d ${ED%/}/${skip#/} ]]; then
skip_dirs+=( "${ED%/}/${skip#/}" )
@@ -370,13 +339,12 @@ while [[ $# -gt 0 ]] ; do
if (( ${#skip_dirs[@]} )); then
find "${skip_dirs[@]}" -name '*.estrip' -delete || die
fi
+}
- exit 0
- ;;
- --queue)
- shift
+do_queue() {
+ local needed_entry_file needed_entry find_path path
+ local -a find_paths scanelf_results
- find_paths=()
for path; do
if [[ -e ${ED%/}/${path#/} ]]; then
find_paths+=( "${ED%/}/${path#/}" )
@@ -396,7 +364,6 @@ while [[ $# -gt 0 ]] ; do
# need to worry about unknown files appearing)
#
# 2. the files we're interested in right now
- scanelf_results=()
if [[ -f "${PORTAGE_BUILDDIR}"/build-info/NEEDED ]] ;
then
# The arguments may not be exact files
(probably aren't), but search paths/directories
# which should then be searched recursively.
@@ -427,10 +394,48 @@ while [[ $# -gt 0 ]] ; do
(( ${#scanelf_results[@]} )) && printf "%s\n"
"${scanelf_results[@]}"
find "${find_paths[@]}" -type f ! -type l -name
'*.a'
)
-
- unset scanelf_results needed_entry needed_entry_file
find_path
fi
+}
+
+declare -A has_feature
+declare -A has_restriction
+
+for key in compressdebug dedupdebug installsources nostrip splitdebug xattr; do
+ contains_word "$key" "${FEATURES}"
+ has_feature[$key]=$(( $? == 0 ))
+done
+
+for key in binchecks dedupdebug installsources splitdebug strip; do
+ contains_word "$key" "${PORTAGE_RESTRICT}"
+ has_restriction[$key]=$(( $? == 0 ))
+done
+
+if ! ___eapi_has_prefix_variables; then
+ EPREFIX= ED=${D}
+fi
+
+if (( ! has_restriction[strip] && ! has_feature[nostrip] )); then
+ do_banner=1
+ do_skip=0
+elif (( ! has_feature[installsources] )); then
+ exit 0
+else
+ do_banner=0
+ do_skip=1
+fi
+do_prepstrip=0
+
+while [[ $# -gt 0 ]] ; do
+ case $1 in
+ --ignore)
+ shift
+ do_ignore "$@"
+ exit 0
+ ;;
+ --queue)
+ shift
+ do_queue "$@"
exit 0
;;
--dequeue)