linuxtorvalds / rpms / kernel

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