From: Thanh Ha Date: Tue, 17 Oct 2017 01:45:02 +0000 (-0400) Subject: Use parallel to sign when available X-Git-Tag: v0.11.0~6 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=bfa488e82eacd8feb9412b6af66330b551d40c39;p=releng%2Flftools.git Use parallel to sign when available Speed up the signing process by using parallel when available. Change-Id: I8a4bebde397b59491039ef6591796f3bfb1db2e8 Signed-off-by: Thanh Ha --- 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 }