slitaz-forge rev 572

bootloader: fix multi initrd case
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Jul 30 12:24:36 2014 +0200 (2014-07-30)
parents 7442bb8579e9
children 56cbc73ec11b
files mirror/floppies/builder/bootloader mirror/floppies/floppies
line diff
     1.1 --- a/mirror/floppies/builder/bootloader	Thu Jun 26 13:41:04 2014 +0300
     1.2 +++ b/mirror/floppies/builder/bootloader	Wed Jul 30 12:24:36 2014 +0200
     1.3 @@ -256,7 +256,7 @@
     1.4  		size=$(( ($(stat -c %s "$i") + $INITRDPAD - 1) & -$INITRDPAD ))
     1.5  		[ -n "$DEBUG" ] && echo "initrd $i $size " 1>&2
     1.6  		initrdlen=$(( $initrdlen + $size ))
     1.7 -		[ -n "$ADRSRD" ] || ADRSRD=$(( (($MEM * 0x100000) - $initrdlen) & -$INITRDALIGN ))
     1.8 +		ADRSRD=$(( (($MEM * 0x100000) - $initrdlen) & -$INITRDALIGN ))
     1.9  		store 32 $RamfsAdrOfs $(( $ADRSRD )) $bs initrd adrs
    1.10  		store 32 $RamfsLenOfs $initrdlen $bs initrdlen
    1.11  	done
     2.1 --- a/mirror/floppies/floppies	Thu Jun 26 13:41:04 2014 +0300
     2.2 +++ b/mirror/floppies/floppies	Wed Jul 30 12:24:36 2014 +0200
     2.3 @@ -1,35 +1,30 @@
     2.4  #!/bin/sh
     2.5  
     2.6 -read32()
     2.7 +rd()
     2.8  {
     2.9 -	echo $(od -j $((0x$1)) -N 4 -t u4 -An kernel)
    2.10 +	echo $(od -j $((0x$1)) -N ${2:-4} -t u${2:-4} -An kernel)
    2.11  }
    2.12  
    2.13 -ddsect()
    2.14 +ds()
    2.15  {
    2.16 -	dd bs=512 count=$@ 2> /dev/null
    2.17 +	dd count=$1 bs=${2:-512} 2>/dev/null
    2.18  }
    2.19  
    2.20  case "$1" in
    2.21 -extract)
    2.22 -	ddsect 2 > kernel
    2.23 -	setupsz=$(($(read32 1F1) & 255))
    2.24 -	ddsect $(($setupsz - 1)) >> kernel
    2.25 -	[ $(read32 228) -ne 0 ] &&
    2.26 -	ddsect 1 | strings > cmdline
    2.27 -	syssz=$(read32 1F4)
    2.28 -	syssz=$(( ($syssz + 31) / 32 ))
    2.29 -	ddsect $syssz >> kernel
    2.30 -	ramsz=$(read32 21C)
    2.31 -	ddsect $((($ramsz + 511) / 512)) of=rootfs
    2.32 -	dd bs=1 seek=$ramsz count=0 of=rootfs 2> /dev/null
    2.33 +extract) (
    2.34 +	ds 1
    2.35 +	ds $(rd 1F1 1)
    2.36 +	[ $(rd 228) -ne 0 ] && ds 1 | strings >cmdline
    2.37 +	ds $(( ($(rd 1F4) +31) /32)) ) >kernel
    2.38 +	ds $(( ($(rd 21C) +3) /4)) 4 >rootfs
    2.39  	;;
    2.40  *)	cat <<EOT
    2.41  usage: 
    2.42  # cat fd0*.img | $0 extract
    2.43  	creates kernel, rootfs and cmdline files
    2.44 -# cat fd1*.img | unlzma | cpio -i
    2.45 -# cat fd2*.img | unlzma | cpio -i
    2.46 -...
    2.47  EOT
    2.48 +	for i in 1 2 3; do
    2.49 +		j=" cat fd$i*.img |"
    2.50 +		echo "#$j cpio -i 2>/dev/null ||$j unlzma | cpio -idmu"
    2.51 +	done
    2.52  esac