l30013671 / rpms / kernel

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