From bfa488e82eacd8feb9412b6af66330b551d40c39 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Mon, 16 Oct 2017 21:45:02 -0400 Subject: [PATCH] Use parallel to sign when available Speed up the signing process by using parallel when available. Change-Id: I8a4bebde397b59491039ef6591796f3bfb1db2e8 Signed-off-by: Thanh Ha --- shell/sign | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/shell/sign b/shell/sign index 5b2bcbc3..4000bbfa 100755 --- a/shell/sign +++ b/shell/sign @@ -57,8 +57,7 @@ sign_dir() { test_gpg_key set -e # Fail immediately if any if signing fails - cd "$dir" - files_to_sign=($(find . -type f ! -name "*.asc" \ + files_to_sign=($(find "$dir" -type f ! -name "*.asc" \ ! -name "*.md5" \ ! -name "*.sha1" \ ! -name "_maven.repositories" \ @@ -67,11 +66,19 @@ sign_dir() { ! -name "maven-metadata-local.xml" \ ! -name "maven-metadata.xml")) - for f in "${files_to_sign[@]}" - do - echo "Signing $f" - "$GPG_BIN" --batch -abq "$f" - done + if hash parallel 2>/dev/null; then + echo "Signing in parallel..." + parallel --jobs 200% --halt now,fail=1 "$GPG_BIN --batch -abq {}" ::: ${files_to_sign[*]} + + echo "Signed the following files:" + printf '%s\n' "${files_to_sign[@]}" + else + echo "GNU `parallel` not found. Signing in serial mode..." + for f in "${files_to_sign[@]}"; do + echo "Signing $f" + "$GPG_BIN" --batch -abq "$f" + done + fi set +e } -- 2.16.6