summaryrefslogtreecommitdiff
path: root/packaging/qemu-accel-armv7l.spec
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/qemu-accel-armv7l.spec')
-rw-r--r--packaging/qemu-accel-armv7l.spec42
1 files changed, 38 insertions, 4 deletions
diff --git a/packaging/qemu-accel-armv7l.spec b/packaging/qemu-accel-armv7l.spec
index 70012d1..86130b2 100644
--- a/packaging/qemu-accel-armv7l.spec
+++ b/packaging/qemu-accel-armv7l.spec
@@ -244,10 +244,44 @@ function patch_binary {
fi
}
-for binary in $binaries
-do
- patch_binary $binary $LD
-done
+# Spawn single job which reads input to extract filename by index
+function run_single_job() {
+ local arg="$1"
+ while :; do
+ # Reads (FILENUM_DIGITS + 1) bytes. Note: to drop redirection usage we
+ # need dd with support for status=none
+ filenum=$(dd bs=$(( FILENUM_DIGITS + 1 )) count=1 2>/dev/null)
+ if [[ -z "$filenum" ]]; then
+ break
+ fi
+ # Get filename for 0x$filenum index and process it
+ patch_binary "${bin_array[$((0x$filenum))]}" "$LD"
+ done
+}
+
+# Converting to the bash array to allow access by index
+bin_array=($binaries)
+# Use processors count + arbitrary addend.
+n_jobs=$(( $(/usr/bin/getconf _NPROCESSORS_ONLN) + 3 ))
+# Supports up to 16^FILENUM_DIGITS - 1 files:
+# 16^5 - 1 = 1.048.575 files
+FILENUM_DIGITS=5
+
+# Send the input for the jobs: enumerate all files
+for ((file = 0; file < ${#bin_array[@]}; file++)); do
+ printf "%0${FILENUM_DIGITS}x\\n" $file
+done | (
+ # Implementing simple Round-robin scheduling routine
+ exec 3<&0
+ echo "Spawn $n_jobs jobs"
+ for ((i = 0; i < n_jobs; i++)); do
+ # The shell redirects stdin to /dev/null for background jobs. Work
+ # around this by duplicating fd 0
+ run_single_job $i <&3 &
+ done
+ wait
+)
+
set -x
%{?multilib: