dcavalca / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone

Blame 0001-Use-RPM_BUILD_NCPUS-in-brp-strip-static-archive.patch

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