wok-stable rev 9342

lzma, xz: add lzma --size
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Mar 19 12:43:20 2011 +0100 (2011-03-19)
parents 2a2419122241
children 90ab20b44e0f
files lzma/stuff/lzma xz/stuff/lzma
line diff
     1.1 --- a/lzma/stuff/lzma	Sat Mar 19 11:26:36 2011 +0100
     1.2 +++ b/lzma/stuff/lzma	Sat Mar 19 12:43:20 2011 +0100
     1.3 @@ -2,6 +2,17 @@
     1.4  
     1.5  case "$1" in
     1.6  d|e|b) exec /usr/bin/lzma-alone $@;;
     1.7 +--size) size=$(dd if=$2 bs=1 skip=5 count=8 2> /dev/null | od -t d8 | awk '{ print $2; exit }') 
     1.8 +	if [ $size -eq -1 ]; then
     1.9 +		size=$(unlzma -c $2 | wc -c)
    1.10 +		n=$size
    1.11 +		for i in $(seq 1 8); do
    1.12 +			printf '\\\\x%02X' $(($n & 255))
    1.13 +			n=$(($n >> 8))
    1.14 +		done | xargs echo -en | dd of=$2 conv=notrunc bs=1 seek=5 2> /dev/null
    1.15 +	fi
    1.16 +	echo $size
    1.17 +	exit ;;
    1.18  --version|-V|--help|-h|-\?) exec /usr/bin/lzma-alone;;
    1.19  esac
    1.20  
     2.1 --- a/xz/stuff/lzma	Sat Mar 19 11:26:36 2011 +0100
     2.2 +++ b/xz/stuff/lzma	Sat Mar 19 12:43:20 2011 +0100
     2.3 @@ -84,9 +84,19 @@
     2.4  esac
     2.5  
     2.6  # First look if help is needed.
     2.7 -[ "$1" ] || usage
     2.8  case "$1" in
     2.9 -	--version|-V|--help|-h|-\?|'') usage;;
    2.10 +--version|-V|--help|-h|-\?|'') usage;;
    2.11 +--size) size=$(dd if=$2 bs=1 skip=5 count=8 2> /dev/null | od -t d8 | awk '{ print $2; exit }') 
    2.12 +	if [ $size -eq -1 ]; then
    2.13 +		size=$(unlzma -c $2 | wc -c)
    2.14 +		n=$size
    2.15 +		for i in $(seq 1 8); do
    2.16 +			printf '\\\\x%02X' $(($n & 255))
    2.17 +			n=$(($n >> 8))
    2.18 +		done | xargs echo -en | dd of=$2 conv=notrunc bs=1 seek=5 2> /dev/null
    2.19 +	fi
    2.20 +	echo $size
    2.21 +	exit ;;
    2.22  esac
    2.23  
    2.24  # lzma_utils or lzma_alone ?