Blame SOURCES/parallel_xz.sh

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