richardphibel / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
672c60
From fc2c986d8f5e4174885ae377750185339636f062 Mon Sep 17 00:00:00 2001
672c60
From: Florian Festi <ffesti@redhat.com>
672c60
Date: Mon, 15 Apr 2019 15:46:09 +0200
672c60
Subject: [PATCH] Use  RPM_BUILD_NCPUS in brp-strip-static-archive
672c60
672c60
to speed the script up for large number of files to be looked at.
672c60
Use xargs -P instead of find -exec.
672c60
672c60
Add xargs to the test environment
672c60
672c60
Resolves rhbz1691822
672c60
---
672c60
 scripts/brp-strip-static-archive | 8 +++++---
672c60
 tests/Makefile.am                | 2 +-
672c60
 2 files changed, 6 insertions(+), 4 deletions(-)
672c60
672c60
diff --git a/scripts/brp-strip-static-archive b/scripts/brp-strip-static-archive
672c60
index ddd3b2422..4dc449061 100755
672c60
--- a/scripts/brp-strip-static-archive
672c60
+++ b/scripts/brp-strip-static-archive
672c60
@@ -5,6 +5,7 @@ if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
672c60
 fi
672c60
 
672c60
 STRIP=${1:-strip}
672c60
+NCPUS=${RPM_BUILD_NCPUS:-1}
672c60
 
672c60
 case `uname -a` in
672c60
 Darwin*) exit 0 ;;
672c60
@@ -12,9 +13,10 @@ Darwin*) exit 0 ;;
672c60
 esac
672c60
 
672c60
 # Strip static libraries.
672c60
-for f in `find "$RPM_BUILD_ROOT" -type f -a -exec file {} \; | \
672c60
-        grep -v "^${RPM_BUILD_ROOT}/\?usr/lib/debug"  | \
672c60
+for f in `find "$RPM_BUILD_ROOT" -type f | \
672c60
+	grep -v "^${RPM_BUILD_ROOT}/\?usr/lib/debug" | \
672c60
+	xargs -r -P$NCPUS -n16 file | sed 's/:  */: /' | \
672c60
 	grep 'current ar archive' | \
672c60
-	sed -n -e 's/^\(.*\):[ 	]*current ar archive/\1/p'`; do
672c60
+	sed -n -e 's/^\(.*\):[  ]*current ar archive/\1/p'`; do
672c60
 	$STRIP -g "$f"
672c60
 done
672c60
diff --git a/tests/Makefile.am b/tests/Makefile.am
672c60
index e2d759d82..ad9549a68 100644
672c60
--- a/tests/Makefile.am
672c60
+++ b/tests/Makefile.am
672c60
@@ -144,7 +144,7 @@ populate_testing:
672c60
 	for d in dev etc magic tmp var; do if [ ! -d testing/$${d} ]; then mkdir testing/$${d}; fi; done
672c60
 	for node in urandom stdin stderr stdout null full; do ln -s /dev/$${node} testing/dev/$${node}; done
672c60
 	for cf in hosts resolv.conf passwd shadow group gshadow mtab ; do [ -f /etc/$${cf} ] && ln -s /etc/$${cf} testing/etc/$${cf}; done
672c60
-	for prog in gzip cat patch tar sh ln chmod rm mkdir uname grep sed find file ionice mktemp nice cut sort diff touch install wc coreutils; do p=`which $${prog}`; if [ "$${p}" != "" ]; then ln -s $${p} testing/$(bindir)/; fi; done
672c60
+	for prog in gzip cat patch tar sh ln chmod rm mkdir uname grep sed find file ionice mktemp nice cut sort diff touch install wc coreutils xargs; do p=`which $${prog}`; if [ "$${p}" != "" ]; then ln -s $${p} testing/$(bindir)/; fi; done
672c60
 	for d in /proc /sys /selinux /etc/selinux; do if [ -d $${d} ]; then ln -s $${d} testing/$${d}; fi; done
672c60
 	(cd testing/magic && file -C)
672c60
 	HOME=$(abs_builddir)/testing gpg2 --import ${abs_srcdir}/data/keys/*.secret
672c60
-- 
672c60
2.21.0
672c60