tazlito rev 143

Improve writeiso (reltim rootfs size)
author Christophe Lincoln <pankso@slitaz.org>
date Sun Jan 24 19:21:32 2010 +0100 (2010-01-24)
parents 413df610d881
children 489f1156542e
files tazlito
line diff
     1.1 --- a/tazlito	Sun Jan 24 01:18:20 2010 +0100
     1.2 +++ b/tazlito	Sun Jan 24 19:21:32 2010 +0100
     1.3 @@ -355,6 +355,26 @@
     1.4  	mv $(basename $1).gz $ROOTCD/boot
     1.5  }
     1.6  
     1.7 +# Compression functions for writeiso.
     1.8 +write_lzma_initramfs()
     1.9 +{
    1.10 +	echo -n "Creating rootfs.gz with lzma compression... "
    1.11 +	cat /tmp/list | cpio -o -H newc | lzma e -si -so > /rootfs.gz
    1.12 +	echo 1 > /tmp/rootfs
    1.13 +}
    1.14 +write_gzip_initramfs()
    1.15 +{
    1.16 +	echo "Creating rootfs.gz with gzip compression... "
    1.17 +	cat /tmp/list | cpio -o -H newc | gzip -9 > /rootfs.gz
    1.18 +	echo 1 > /tmp/rootfs
    1.19 +}
    1.20 +write_initramfs()
    1.21 +{
    1.22 +	echo "Creating rootfs.gz without compression... "
    1.23 +	cat /tmp/list | cpio -o -H newc > /rootfs.gz
    1.24 +	echo 1 > /tmp/rootfs
    1.25 +}
    1.26 +
    1.27  distro_sizes()
    1.28  {
    1.29  	echo "Build date      : `date +%Y%m%d\ \at\ \%H:%M:%S`"
    1.30 @@ -1468,7 +1488,7 @@
    1.31  		echo ""
    1.32  		;;
    1.33  	writeiso)
    1.34 -		# Writefs to ISO image including /home unlike gen-distro we dont use
    1.35 +				# Writefs to ISO image including /home unlike gen-distro we dont use
    1.36  		# packages to generate a rootfs, we build a compressed rootfs with all 
    1.37  		# the current filesystem similar to 'tazusb writefs'.
    1.38  		#
    1.39 @@ -1499,33 +1519,21 @@
    1.40  		rm /var/cache/tazpkg/* -r -f
    1.41  		rm -rf /home/slitaz/distro
    1.42  
    1.43 -		# Optionally remove sound card selection
    1.44 -		echo -n "Do you wish to remove the sound card selection (No/yes/exit) ? "
    1.45 +		# Optionally remove sound card selection and screen resolution.
    1.46 +		echo "Do you wish to remove the sound card and screen config ? "
    1.47 +		echo -n "Press ENTER to keep or anser (No|yes|exit): "
    1.48  		read anser
    1.49  		case $anser in
    1.50  			e|E|"exit"|Exit)
    1.51  				exit 0 ;;
    1.52  			y|Y|yes|Yes)
    1.53 -				echo -n "Removing current sound card selection..."
    1.54 +				echo -n "Removing current sound card and screen configuration..."
    1.55  				rm -f /var/lib/sound-card-driver
    1.56 -				rm -f /etc/asound.state ;;
    1.57 -			*)
    1.58 -				echo -n "Keeping current sound card selection..." ;;
    1.59 -		esac
    1.60 -		status
    1.61 -		
    1.62 -		# Optionally remove screen resolution
    1.63 -		echo -n "Do you wish to remove the screen resolution (No/yes/exit) ? "
    1.64 -		read anser
    1.65 -		case $anser in
    1.66 -			e|E|"exit"|Exit)
    1.67 -				exit 0 ;;
    1.68 -			y|Y|yes|Yes)
    1.69 -				echo -n "Removing current screen resolution..."
    1.70 +				rm -f /etc/asound.state
    1.71  				rm -f /etc/X11/screen.conf 
    1.72  				rm -f /etc/X11/xorg.conf ;;
    1.73  			*)
    1.74 -				echo -n "Keeping current screen resolution..." ;;
    1.75 +				echo -n "Keeping current sound card and screen configuration..." ;;
    1.76  		esac
    1.77  		status
    1.78  		
    1.79 @@ -1537,25 +1545,29 @@
    1.80  		do
    1.81  			echo $dir >>/tmp/list
    1.82  		done
    1.83 +		rm -f /tmp/rootfs
    1.84  
    1.85 -		# Generate initramfs with specified compression
    1.86 +		# Generate initramfs with specified compression and display rootf
    1.87 +		# size in realtime.
    1.88  		if [ "$COMPRESSION" = "lzma" ]; then
    1.89 -			echo -n "Creating rootfs.gz with lzma compression... "
    1.90 -			cat /tmp/list | cpio -o -H newc | lzma e -si -so > /rootfs.gz
    1.91 -
    1.92 +			write_lzma_initramfs &
    1.93  		elif [ "$COMPRESSION" = "gzip" ]; then
    1.94 -			echo -n "Creating rootfs.gz with gzip compression... "
    1.95 -			cat /tmp/list | cpio -o -H newc | gzip -9 > /rootfs.gz
    1.96 -
    1.97 +			write_gzip_initramfs &
    1.98  		else
    1.99 -			echo -n "Creating rootfs.gz without compression... "
   1.100 -			cat /tmp/list | cpio -o -H newc > /rootfs.gz
   1.101 +			write_initramfs &
   1.102  		fi
   1.103 -		status
   1.104 +		sleep 2
   1.105 +		echo -en "\nFilesystem size:"
   1.106 +		while [ ! -f /tmp/rootfs ]
   1.107 +		do
   1.108 +			sleep 1
   1.109 +			echo -en "\\033[18G`du -sh /rootfs.gz | awk '{print $1}'`    "
   1.110 +		done
   1.111 +		echo -e "\n"
   1.112  
   1.113  		# Move freshly generated rootfs to the cdrom.
   1.114  		mkdir -p $ROOTCD/boot
   1.115 -		mv /rootfs.gz $ROOTCD/boot
   1.116 +		mv -f /rootfs.gz $ROOTCD/boot
   1.117  		
   1.118  		# Now we need the kernel and isolinux files.
   1.119  		if mount /dev/cdrom /media/cdrom 2>/dev/null; then
   1.120 @@ -1563,7 +1575,11 @@
   1.121  			cp -a /media/cdrom/boot/isolinux $ROOTCD/boot
   1.122  			umount /media/cdrom
   1.123  		else
   1.124 -			echo -e "\nUnable to mount the cdrom to copy the Kernel and needed files.\n"
   1.125 +			echo -e "
   1.126 +Unable to mount the cdrom to copy the Kernel and needed files. When SliTaz
   1.127 +is running in RAM the kernel and bootloader files are keeped on the cdrom.
   1.128 +Please insert a LiveCD or unmount curent cdrom to let Tazlito handle the media.\n"
   1.129 +			echo -en "----\nENTER to continue..."; read i
   1.130  			exit 1
   1.131  		fi
   1.132