zwp10758 / rpms / kernel

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