tazlito rev 231

tazlito: set lzma'd rootfs size field
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Sep 03 14:49:04 2011 +0200 (2011-09-03)
parents 92b0fd269334
children fe324ebcadff
files tazlito
line diff
     1.1 --- a/tazlito	Tue Aug 30 10:24:39 2011 +0200
     1.2 +++ b/tazlito	Sat Sep 03 14:49:04 2011 +0200
     1.3 @@ -323,6 +323,18 @@
     1.4  	echo "-d$(lzma_history_bits $1) -mt$(grep '^processor' < /proc/cpuinfo | wc -l)"
     1.5  }
     1.6  
     1.7 +lzma_set_size()
     1.8 +{
     1.9 +	# Update size field for lzma'd file packed using -so switch
    1.10 +	local n
    1.11 +	local i
    1.12 +	n=$(unlzma -c $1 | wc -c)
    1.13 +	for i in $(seq 1 8); do
    1.14 +		printf '\\\\x%02X' $(($n & 255))
    1.15 +		n=$(($n >> 8))
    1.16 +	done | xargs echo -en | dd of=$1 conv=notrunc bs=1 seek=5 2> /dev/null
    1.17 +}
    1.18 +
    1.19  # Pack rootfs
    1.20  pack_rootfs()
    1.21  {
    1.22 @@ -333,6 +345,7 @@
    1.23  	elif [ -x /usr/bin/lzma -a "$COMPRESSION" != "gzip" ]; then
    1.24  		echo -n "Generating lzma'ed initramfs... "
    1.25  		lzma e -si -so $(lzma_switches $1) > $2
    1.26 +		lzma_set_size $2
    1.27  	else
    1.28  		echo "Generating gziped initramfs... "
    1.29  		gzip -9 > $2
    1.30 @@ -346,6 +359,7 @@
    1.31  	if [ "$COMPRESSION" = "lzma" ]; then
    1.32  		echo -n "Creating rootfs.gz with lzma compression... "
    1.33  		cat /tmp/list | cpio -o -H newc | lzma e -si -so > /rootfs.gz
    1.34 +		lzma_set_size /rootfs.gz
    1.35  	elif [ "$COMPRESSION" = "gzip" ]; then
    1.36  		echo "Creating rootfs.gz with gzip compression... "
    1.37  		cat /tmp/list | cpio -o -H newc | gzip -9 > /rootfs.gz