slitaz-tools rev 487

slitaz-installer: add tazlitobox loram support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Apr 24 11:43:47 2010 +0200 (2010-04-24)
parents f70b81b03d05
children bcf8cdeaf6fc
files installer/slitaz-installer
line diff
     1.1 --- a/installer/slitaz-installer	Thu Apr 22 08:38:15 2010 -0400
     1.2 +++ b/installer/slitaz-installer	Sat Apr 24 11:43:47 2010 +0200
     1.3 @@ -15,6 +15,7 @@
     1.4  
     1.5  # We need to know cdrom device and kernel version string to copy files.
     1.6  DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3`
     1.7 +[ -n "$DRIVE_NAME" ] || DRIVE_NAME=cdrom
     1.8  CDROM=/dev/$DRIVE_NAME
     1.9  KERNEL=vmlinuz-`uname -r`
    1.10  TARGET_ROOT=/mnt/target
    1.11 @@ -470,14 +471,78 @@
    1.12  	fi
    1.13  }
    1.14  
    1.15 +need_package()
    1.16 +{
    1.17 +	[ -d /var/lib/tazpkg/installed/$1 ] || tazpkg get-install $1
    1.18 +}
    1.19 +
    1.20 +# extract packed rootfs: squashfs or cromfs
    1.21 +extract_loramfs()
    1.22 +{
    1.23 +	local i
    1.24 +	for i in $(cpio -idvum 2> /dev/null); do
    1.25 +		case "$i" in
    1.26 +		rootfs*)
    1.27 +			need_package squashfs
    1.28 +			if ! unsquashfs $i ; then
    1.29 +				need_package cromfs
    1.30 +				unmkcromfs $i squashfs-root
    1.31 +			fi
    1.32 +			mv -f squashfs-root/* .
    1.33 +			rmdir squashfs-root
    1.34 +			rm -f $i
    1.35 +		esac
    1.36 +	done
    1.37 +}
    1.38 +
    1.39 +# This is a loram rootfs.gz, skip loram bootstrap and extract
    1.40 +extract_first_loramfs()
    1.41 +{
    1.42 +	hexdump -C $1 | grep " 30 37 30 37 " | while read ofs rem; do
    1.43 +		ofs=$((0x$ofs / 4))
    1.44 +		for j in 1 2 3 4; do
    1.45 +			tag=$(dd if=$1 bs=4 skip=$ofs count=2 2> /dev/null)
    1.46 +			if [ "07070100" != "$tag" ]; then
    1.47 +				ofs=$(($ofs + 1))
    1.48 +				continue
    1.49 +			fi
    1.50 +			dd if=$1 skip=$(($ofs / 1024)) bs=4k count=1 2> /dev/null | \
    1.51 +			( dd skip=$(($ofs % 1024)) bs=4 2> /dev/null ; \
    1.52 +			  dd if=$1 skip=$((1 + ($ofs / 1024) )) bs=4k ) | \
    1.53 +				extract_loramfs			  
    1.54 +			break 2
    1.55 +		done
    1.56 +	done
    1.57 +}
    1.58 +
    1.59  # Extract lzma'ed or gziped rootfs.
    1.60  extract_rootfs()
    1.61  {
    1.62 +	local isloramfs
    1.63 +	isloramfs=
    1.64  	cd $TARGET_ROOT
    1.65 +	if [ -d $1/../fs/etc ]; then
    1.66 +		# This is a tazlitobox loram (cdrom)
    1.67 +		cp -a $1/../fs/. .
    1.68 +	else
    1.69  	for i in $(ls $1/rootfs* | sort -r); do
    1.70 +		if [ ! -d etc ]; then
    1.71 +			if [ $( (zcat $i 2>/dev/null || lzma d $i -so) | wc -c) \
    1.72 +					-lt $(stat -c %s $i) ]; then
    1.73 +				# This is a tazlitobox loram (ram)
    1.74 +				isloramfs=$i
    1.75 +				extract_first_loramfs $i
    1.76 +				continue
    1.77 +			fi
    1.78 +		fi
    1.79 +		if [ -n "$isloramfs" ]; then
    1.80 +			extract_loramfs < $i
    1.81 +			continue
    1.82 +		fi
    1.83  		( zcat $i 2>/dev/null || lzma d $i -so || \
    1.84 -		  cat $i ) 2>>$LOG | cpio -id
    1.85 +		  cat $i ) 2>>$LOG | cpio -idu
    1.86  	done 2>>$LOG > /dev/null
    1.87 +	fi
    1.88  	# unpack /usr (double check...)
    1.89  	if ls etc/tazlito | grep -q ".extract"; then
    1.90  		for i in etc/tazlito/*.extract; do