chantra / rpms / rpm

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