wok-6.x rev 18771

iso2exe: update /init
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Dec 31 15:49:20 2015 +0100 (2015-12-31)
parents 61e23282014d
children e8de1b7505ef
files syslinux/stuff/iso2exe/init syslinux/stuff/iso2exe/taziso
line diff
     1.1 --- a/syslinux/stuff/iso2exe/init	Thu Dec 31 14:51:53 2015 +0200
     1.2 +++ b/syslinux/stuff/iso2exe/init	Thu Dec 31 15:49:20 2015 +0100
     1.3 @@ -640,7 +640,7 @@
     1.4  fddata()
     1.5  {
     1.6  	[ -e /sys/block/fd0 ] && 
     1.7 -	[ $(get 28 /mnt/$ISO 1 2> /dev/null || echo 0) -ne 0 ] &&
     1.8 +	[ $(get 26 /mnt/$ISO 1 2> /dev/null || echo 0) -ne 0 ] &&
     1.9  	echo -en "\"$1\"	\"$2\""
    1.10  }
    1.11  
    1.12 @@ -678,6 +678,42 @@
    1.13  	wodim -v -blank=fast
    1.14  }
    1.15  
    1.16 +customsector()
    1.17 +{
    1.18 +	echo $(($(get 32848 "/mnt/$ISO" 4)+16))
    1.19 +}
    1.20 +
    1.21 +hascustomconf()
    1.22 +{
    1.23 +	[ "$(ddq bs=2k skip=$(customsector) if="/mnt/$ISO" | ddq bs=1 count=6)" \
    1.24 +	  == "#!boot" ]
    1.25 +}
    1.26 +
    1.27 +gotcustomconf()
    1.28 +{
    1.29 +	hascustomconf && menuitem "$@"
    1.30 +}
    1.31 +
    1.32 +getcustomconf()
    1.33 +{
    1.34 +	cd /mnt
    1.35 +	ddq bs=2k skip=$(customsector) if="$ISO" | while read line; do
    1.36 +		case "$line" in
    1.37 +		\#!boot*) ;;
    1.38 +		append=*) echo ${line#append=} > cmdline && ls -l cmdline ;;
    1.39 +		initrd:*) cnt=${line#initrd:}
    1.40 +			  { ddq bs=512 count=$(($cnt / 512));
    1.41 +			    ddq bs=1 count=$(($cnt % 512)); } > initrd &&
    1.42 +			  ls -l initrd
    1.43 +			  break ;;
    1.44 +		*)	  break ;;	  
    1.45 +		esac
    1.46 +	done
    1.47 +	cd - > /dev/null
    1.48 +	echo -e "\rPress RETURN to continue."
    1.49 +	read n
    1.50 +}
    1.51 +
    1.52  gotisomd5()
    1.53  {
    1.54  	[ "$(which md5sum 2> /dev/null)" ] &&
    1.55 @@ -699,14 +735,188 @@
    1.56  		[ $(((1+$s+$(get $(($n+1)) /mnt/$ISO 1)) % 65536)) -eq 0 ] &&
    1.57  		echo "OK" || echo "ERROR"
    1.58  	fi
    1.59 +	if hascustomconf; then
    1.60 +		echo -en "\rChecking iso custom config..."
    1.61 +		TMP=/tmp/$(basename $0)$$md5
    1.62 +		md5="$(ddq bs=2k skip=$(customsector) if=/mnt/$ISO | while read line; do
    1.63 +			case "$line" in
    1.64 +			\#!boot*) echo ${line#*boot } > $TMP ;;
    1.65 +			append=*) echo $line ;;
    1.66 +			initrd:*) echo $line
    1.67 +				  cnt=${line#initrd:}
    1.68 +				  ddq bs=512 count=$((cnt / 512))
    1.69 +				  ddq bs=1 count=$((cnt % 512))
    1.70 +				  break ;;
    1.71 +			*)	  break ;;	  
    1.72 +			esac
    1.73 +		done | md5sum | cut -c1-32)"
    1.74 +		[ "$md5" == "$(cat $TMP)" ] && echo "OK" || echo "ERROR"
    1.75 +		rm -f $TMP
    1.76 +	fi
    1.77  	rm -f /tmp/wait
    1.78  	echo -e "\rPress RETURN to continue."
    1.79  	read n
    1.80  }
    1.81  
    1.82 +if [ "$1" == "--build" ]; then	#install-begin
    1.83 +	uuencode -m - < ifmem.bin | sed -e '/^ifmemcode$/r/dev/stdin' \
    1.84 +	  -e '/^ifmemcode$/d' -i $0
    1.85 +	uuencode -m - < bootloader.bin | sed -e '/^bootloader$/r/dev/stdin' \
    1.86 +	  -e '/^bootloader$/d' -e '/install-begin$/,/install-end$/d' -i $0
    1.87 +	exit
    1.88 +fi	#install-end
    1.89 +parse_isolinux()
    1.90 +{
    1.91 +	awk 'BEGIN { IGNORECASE=1 }
    1.92 +function multi(n)
    1.93 +{
    1.94 +	auto=$n
    1.95 +	for (--n; n < NF; n+=2) {
    1.96 +		s=$n
    1.97 +		if (s ~ /M$/) s = substr(s,0,length(s)-1)
    1.98 +		else s /= 1024
    1.99 +		sizes=int(s) " " sizes
   1.100 +	}
   1.101 +	next
   1.102 +}
   1.103 +{
   1.104 +	if ($1 == "LABEL") {
   1.105 +		label=$2
   1.106 +		if (auto == "") auto=label
   1.107 +	}
   1.108 +	if ($1 == "KERNEL" || $1 == "COM32") kernel[label]=$2
   1.109 +	if ($1 == "INITRD") initrd[label]=$2
   1.110 +	if ($1 == "APPEND") {
   1.111 +		i=2
   1.112 +		if (kernel[label] ~ "ifmem.c32") multi(3)
   1.113 +		if (kernel[label] ~ "c32box.c32") {
   1.114 +			if ($2 == "linux") { kernel[label]=$3; i=4 }
   1.115 +			if ($2 == "ifmem") multi(4)
   1.116 +		}
   1.117 +		if (kernel[label] ~ "ifcpu64.c32") { auto=$4; next }
   1.118 +		while (i <= NF) {
   1.119 +			if ($i ~ "^initrd=") initrd[label]=substr($i,8)
   1.120 +			else cmdline[label]=cmdline[label] " " $i
   1.121 +			i++
   1.122 +		}
   1.123 +	}
   1.124 +}
   1.125 +END {
   1.126 +	print "KERNEL=\"" kernel[auto] "\""
   1.127 +	print "INITRD=\"" initrd[auto] "\""
   1.128 +	print "CMDLINE=\"" substr(cmdline[auto],2) "\""
   1.129 +	print "SIZES=\"" sizes "\""
   1.130 +}'
   1.131 +}
   1.132 +
   1.133 +locase()
   1.134 +{
   1.135 +	echo "$1" | tr [A-Z] [a-z]
   1.136 +}
   1.137 +
   1.138 +ifmemcode()
   1.139 +{
   1.140 +	uudecode <<EOT
   1.141 +ifmemcode
   1.142 +EOT
   1.143 +}
   1.144 +
   1.145 +floppyset()
   1.146 +{
   1.147 +	gotcdfile isolinux.cfg
   1.148 +	parse_isolinux < $file > /tmp/var$$
   1.149 +	. /tmp/var$$
   1.150 +	for i in $media/$KERNEL $(dirname $file)/$KERNEL $media/$(locase $KERNEL) \
   1.151 +		 $(dirname $file)/$(locase $KERNEL); do
   1.152 +		[ -s $i ] && KERNEL=$i && break
   1.153 +	done
   1.154 +	rm -f /tmp/var$$ 
   1.155 +	[ $(get 514 $KERNEL 4) -eq 1400005704 ] || return
   1.156 +	n=$(($(get 497 $KERNEL 1)+1))
   1.157 +	ddq bs=512 count=$n if=$KERNEL of=/tmp/fd$$
   1.158 +	uudecode <<EOT | ddq of=/tmp/fd$$ conv=notrunc
   1.159 +bootloader
   1.160 +EOT
   1.161 +	pos=$(($n*512))
   1.162 +	if [ -n "$CMDLINE" ]; then
   1.163 +		echo -n "$CMDLINE" | ddq bs=512 count=1 conv=sync >> /tmp/fd$$
   1.164 +		bytes2bin $n | ddq conv=notrunc \
   1.165 +			bs=1 seek=497 count=1 of=/tmp/fd$$
   1.166 +		words2bin $pos | ddq conv=notrunc \
   1.167 +			bs=1 seek=34 count=2 of=/tmp/fd$$
   1.168 +		[ $(get 518 $KERNEL 4) -ge 514 ] &&
   1.169 +		words2bin 32768 9 | ddq conv=notrunc \
   1.170 +			bs=1 seek=552 count=4 of=/tmp/fd$$
   1.171 +	fi
   1.172 +	syssize=$(echo $(get 500 /tmp/fd$$ 4))
   1.173 +	ddq bs=512 skip=$n if=$KERNEL | cat - /dev/zero | \
   1.174 +	ddq bs=512 count=$((($syssize+31)/32)) conv=sync >> /tmp/fd$$
   1.175 +	base=$(stat -c %s /tmp/fd$$)
   1.176 +	len=
   1.177 +	if [ "$INITRD" ]; then
   1.178 +		l=0
   1.179 +		for i in ${INITRD//,/ }; do
   1.180 +			for j in $media/$i $(dirname $KERNEL)/$i $media/$(locase $i) \
   1.181 +				 $(dirname $KERNEL)/$(locase $i); do
   1.182 +				[ -s $j ] && i=$j && break
   1.183 +			done
   1.184 +			ddq if=$i >> /tmp/fd$$
   1.185 +			l=$(($l+$(stat -c %s $i)))
   1.186 +			r=$((4 - ($l % 4)))
   1.187 +			if [ $r -ne 4 ]; then
   1.188 +				ddq if=/dev/zero bs=1 count=$r >> /tmp/fd$$
   1.189 +				l=$(($l + $r))
   1.190 +			fi
   1.191 +			case "$i:$INITRD" in
   1.192 +				*rootfs.gz:*rootfs.gz,*) continue	# loram
   1.193 +			esac
   1.194 +			len="$len $l"; l=0
   1.195 +		done
   1.196 +		rdadrs=${RDADRS:-$(((($syssize*16)+0x1F0000) & -4096))}
   1.197 +		words2bin $(($rdadrs & 0xFFFF)) $(($rdadrs >> 16)) | ddq \
   1.198 +			conv=notrunc bs=1 seek=536 count=4 of=/tmp/fd$$
   1.199 +	fi
   1.200 +	n=$(echo $len | wc -w)
   1.201 +	if [ $((494 - $(get 494 /tmp/fd$$))) -ge $(($n * 4)) ]; then
   1.202 +		i=$(($(get 494 /tmp/fd$$)))
   1.203 +		bytes2bin $(($i + ($n*4) - 256)) | ddq bs=1 conv=notrunc \
   1.204 +			seek=496 count=1 of=/tmp/fd$$
   1.205 +	else
   1.206 +		i=$(($pos + 0x1FC - ($n*4)))
   1.207 +		bytes2bin $(($i % 256)) $((i / 256)) 252 | ddq bs=1 \
   1.208 +			conv=notrunc seek=494 count=3 of=/tmp/fd$$
   1.209 +		s=$(($i - 2*$(echo "$SIZES" | wc -w)))
   1.210 +		p=$(($s - $(ifmemcode | wc -c)))
   1.211 +		ifmemcode | ddq bs=1 conv=notrunc seek=$p of=/tmp/fd$$
   1.212 +		words2bin $SIZES | ddq bs=1 conv=notrunc seek=$s of=/tmp/fd$$
   1.213 +		bytes2bin 154 $(($p%256)) $(($p/256)) 0 144 | \
   1.214 +		ddq bs=1 conv=notrunc seek=60 of=/tmp/fd$$
   1.215 +	fi
   1.216 +	for r in $len ; do
   1.217 +		words2bin $(($r & 0xFFFF)) $(($r >> 16)) | ddq conv=notrunc \
   1.218 +			bs=1 seek=$i count=4 of=/tmp/fd$$
   1.219 +		i=$(($i + 4))
   1.220 +	done
   1.221 +	split -b 1440k /tmp/fd$$ fd$$
   1.222 +	rm -f /tmp/fd$$
   1.223 +	n=1; i=0; r=0
   1.224 +	set -- $len
   1.225 +	ls fd$$* | while read file ; do
   1.226 +		if [ $i -gt $(($1+$base)) ]; then
   1.227 +			shift
   1.228 +			r=$(($r+100)); n=0; i=0; base=0
   1.229 +		fi
   1.230 +		ddq of=$file bs=18k seek=80 count=0
   1.231 +		i=$(($i+1474560))
   1.232 +		printf "mv %s fd%03d.img\n" $file $(($r+$n))
   1.233 +		n=$(($n+1))
   1.234 +	done | sh
   1.235 +	ls fd???.img
   1.236 +}
   1.237 +
   1.238  fdbootstrap()
   1.239  {
   1.240 -	sz=$((512 * $(echo $(get 28 /mnt/$ISO 1))))
   1.241 +	sz=$((512 * $(echo $(get 26 /mnt/$ISO 1))))
   1.242  	$DIALOG --clear \
   1.243  		--title " Create a floppy bootstrap " \
   1.244  		--yes-label "Continue" --yesno \
   1.245 @@ -954,6 +1164,16 @@
   1.246  	rm -rf /tmp/data
   1.247  }
   1.248  
   1.249 +flavor()
   1.250 +{
   1.251 +	cd /mnt
   1.252 +	name="$(flavdata | cpio -t 2> /dev/null | sed 's/.[a-z]*$//;q')"
   1.253 +	echo "Create ${name:=flavor}.flavor..."
   1.254 +	tazlito iso2flavor "/mnt/$ISO" $name
   1.255 +	ls -l $name.flavor 2> /dev/null || sleep 5
   1.256 +	cd - > /dev/null
   1.257 +}
   1.258 +
   1.259  shell()
   1.260  {
   1.261  	trap text 2 
   1.262 @@ -975,7 +1195,7 @@
   1.263  which $DIALOG 2> /dev/null || DIALOG=tinydialog
   1.264  dmesg > /tmp/dmesg
   1.265  
   1.266 -isotitle="$(basename $ISO)  $(stat -c %y /cdrom/media/. | sed 's/ .*//'\
   1.267 +isotitle="$(basename $ISO)  $(stat -c %y /media/cdrom | sed 's/ .*//'\
   1.268  	  )  $(blkid /mnt/$ISO | sed 's/.*LABEL="\([^"]*\).*/\1/')"
   1.269  while true; do
   1.270  	trap shell 2 
   1.271 @@ -990,6 +1210,7 @@
   1.272  $(cdfile boot/bzImage	"live"		"Linux RAM boot (full desktop)") \
   1.273  			"text"		"Linux RAM boot" \
   1.274  $(cdfile "README*"	"readme"	"Show the README file") \
   1.275 +$(gotcustomconf		"getcustomconf"	"Get custom config") \
   1.276  $(gotisomd5		"isomd5"	"Check the ISO image") \
   1.277  $(cdfile "md5sum*"	"md5"		"Check the ISO files") \
   1.278  $(cdfile "sha*sum*"	"sha"		"Check the ISO files") \
   1.279 @@ -1000,15 +1221,17 @@
   1.280  $(xfile tazusb		"usbkey"	"USB key read/write installation") \
   1.281  $(ishybrid		"usbbootkey"	"USB boot key (read only)") \
   1.282  $(hasflavinfo		"showfavinfo"	"Show flavor extra info") \
   1.283 +$(xfile tazlito		"flavor"	"Get flavor file") \
   1.284  $(fddata		"fdbootstrap"	"Create a floppy bootstrap") \
   1.285 +$(cdfile isolinux.cfg	"floppyset"	"Boot floppy set") \
   1.286  			"tazboot"	"Get tazboot.exe Linux loader" \
   1.287  $(cdexe boot/bzImage	"bzimage"	"Get linux DOS/EXE file") \
   1.288  $(cdexe "memtest*"	"memtest"	"Get Memtest86 DOS/EXE file") \
   1.289  $(cdfilef "memtest*"	"fdmemtest"	"Create a Memtest86 boot floppy") \
   1.290 -$(cdfilex "memtest*"	"runmemtest"	"Start Memtest86") \
   1.291 +$(:||cdfilex "memtest*"	"runmemtest"	"Start Memtest86") \
   1.292  $(cdexe "?pxe"		"pxe"		"Get SliTaz Web boot DOS/EXE utility") \
   1.293  $(cdfilef "?pxe"	"fdpxe"		"Create a SliTaz Web boot floppy") \
   1.294 -$(cdfilex "?pxe"	"runpxe"	"Start the SliTaz Web boot utility") \
   1.295 +$(:||cdfilex "?pxe"	"runpxe"	"Start the SliTaz Web boot utility") \
   1.296  $(xfile reboot		"restart"	"Restart the computer") \
   1.297  $(xfile poweroff	"stop"		"Power off") \
   1.298  			"bootlog"	"Linux boot messages" \
     2.1 --- a/syslinux/stuff/iso2exe/taziso	Thu Dec 31 14:51:53 2015 +0200
     2.2 +++ b/syslinux/stuff/iso2exe/taziso	Thu Dec 31 15:49:20 2015 +0100
     2.3 @@ -1107,7 +1107,11 @@
     2.4  	name="$(flavdata | cpio -t 2> /dev/null | sed 's/.[a-z]*$//;q')"
     2.5  	echo "Create ${name:=flavor}.flavor..."
     2.6  	tazlito iso2flavor "$ISO" $name
     2.7 -	ls -l $name.flavor
     2.8 +	ls -l $name.flavor 2> /dev/null && return
     2.9 +	sleep 5
    2.10 +	[ "$1" ] && return
    2.11 +	echo -e "\rPress RETURN to continue."
    2.12 +	read n
    2.13  }
    2.14  
    2.15  if [ "$1" == "--build" ]; then	#install-begin
    2.16 @@ -1343,6 +1347,6 @@
    2.17  	retval=$?
    2.18  	exec 3>&-
    2.19  	rm -f /tmp/dialog$$
    2.20 -	[ $retval -eq 0 ] || break
    2.21 +	[ $retval -eq 0 ] || quit
    2.22  	$value
    2.23  done