Blame SOURCES/parallel_xz.sh

9713b0
#!/bin/sh
9713b0
# Reads filenames on stdin, xz-compresses each in place.
9713b0
# Not optimal for "compress relatively few, large files" scenario!
9713b0
9713b0
# How many xz's to run in parallel:
9713b0
procgroup=""
9713b0
while test "$#" != 0; do
9713b0
	# Get it from -jNUM
9713b0
	N="${1#-j}"
9713b0
	if test "$N" = "$1"; then
9713b0
		# Not -j<something> - warn and ignore
9713b0
		echo "parallel_xz: warning: unrecognized argument: '$1'"
9713b0
	else
9713b0
		procgroup="$N"
9713b0
	fi
9713b0
	shift
9713b0
done
9713b0
9713b0
# If told to use only one cpu:
9713b0
test "$procgroup" || exec xargs -r xz
9713b0
test "$procgroup" = 1 && exec xargs -r xz
9713b0
9713b0
# xz has some startup cost. If files are really small,
9713b0
# this cost might be significant. To combat this,
9713b0
# process several files (in sequence) by each xz process via -n 16:
9713b0
exec xargs -r -n 16 -P "$procgroup" xz