dingjian / rpms / kernel-rt

Forked from rpms/kernel-rt 4 years ago
Clone

Blame SOURCES/parallel_xz.sh

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