chantra / rpms / rpm

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