wok rev 17635

syslinux-tools: add taziso
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Feb 14 18:17:26 2015 +0100 (2015-02-14)
parents f940e42dac11
children 77c3484cda94
files syslinux-tools/receipt syslinux/stuff/iso2exe/init syslinux/stuff/iso2exe/taziso
line diff
     1.1 --- a/syslinux-tools/receipt	Sat Feb 14 17:35:42 2015 +0200
     1.2 +++ b/syslinux-tools/receipt	Sat Feb 14 18:17:26 2015 +0100
     1.3 @@ -21,5 +21,6 @@
     1.4  	cp -a $src/iso2exe/isohybrid.exe $fs/usr/share/boot
     1.5  	cp -a $src/iso2exe/meminfo.exe $fs/usr/share/boot
     1.6  	cp -a $src/iso2exe/tazboot.exe $fs/usr/share/boot
     1.7 +	cp -a $src/iso2exe/taziso $fs/usr/bin
     1.8  	find $fs/usr -exec chown root.root {} \;
     1.9  }
     2.1 --- a/syslinux/stuff/iso2exe/init	Sat Feb 14 17:35:42 2015 +0200
     2.2 +++ b/syslinux/stuff/iso2exe/init	Sat Feb 14 18:17:26 2015 +0100
     2.3 @@ -298,12 +298,12 @@
     2.4  		sleep 5
     2.5  		return 1
     2.6  	fi
     2.7 -	dowait "Install root filesystem in /slitaz.."
     2.8 +	dotwait "Install root filesystem in /slitaz.."
     2.9  	if [ "$1" ]; then
    2.10  		if [ -d /media/cdrom/fs ]; then
    2.11  			( cd /mnt/slitaz/fs; find | cpio -o -H newc ) | gzip -9
    2.12  		else
    2.13 -			ls_r /media/cdrom/boot/rootfs* | xargs cat
    2.14 +			ls_r /media/cdrom/boot/rootfs*gz | xargs cat
    2.15  		fi > /mnt/slitaz/boot/rootfs.gz
    2.16  		tazusbinitfs /mnt/slitaz/boot/rootfs.gz
    2.17  		initrd=rootfs.gz
    2.18 @@ -316,18 +316,18 @@
    2.19  				[ -s $(basename $i) ] && continue
    2.20  				cpio -i $i
    2.21  			done
    2.22 -			for i in $(ls_r /media/cdrom/boot/rootfs*); do
    2.23 +			for i in $(ls_r /media/cdrom/boot/rootfs*gz); do
    2.24  				mount -o loop,ro $i /sqfs/mnt
    2.25  				cp -a /sqfs/mnt/. /mnt/slitaz
    2.26  				umount -d /sqfs/mnt
    2.27  			done
    2.28  		else
    2.29 -			for i in $(ls_r /media/cdrom/boot/rootfs*); do
    2.30 +			for i in $(ls_r /media/cdrom/boot/rootfs*gz); do
    2.31  				uncpio $i /mnt/slitaz
    2.32  			done
    2.33  		fi
    2.34 -		cp -a /etc/locale.conf /tmp/slitaz/etc 2> /dev/null
    2.35 -		cp -a /etc/keymap.conf /tmp/slitaz/etc 2> /dev/null
    2.36 +		cp -a /etc/locale.conf /mnt/slitaz/etc 2> /dev/null
    2.37 +		cp -a /etc/keymap.conf /mnt/slitaz/etc 2> /dev/null
    2.38  		mkinitrd /mnt/slitaz/boot/initrd
    2.39  		initrd=initrd
    2.40  		extraargs="mount=$(getuuid) subroot=slitaz"
    2.41 @@ -413,7 +413,7 @@
    2.42  	if [ -d /media/cdrom/fs ]; then
    2.43  		cp -a /media/cdrom/fs/. /
    2.44  	else
    2.45 -		for i in $(ls_r /media/cdrom/boot/rootfs*); do
    2.46 +		for i in $(ls_r /media/cdrom/boot/rootfs*gz); do
    2.47  			uncpio $i
    2.48  		done
    2.49  	fi
    2.50 @@ -466,8 +466,8 @@
    2.51  
    2.52  gotcdfile()
    2.53  {
    2.54 -	for i in /media/cdrom/$1 /media/cdrom/*/$1 \
    2.55 -			/media/cdrom/*/isolinux/$1 ; do
    2.56 +	for i in "/media/cdrom/$1" "/media/cdrom/*/$1" \
    2.57 +			"/media/cdrom/*/isolinux/$1" ; do
    2.58  		file=$(ls $i 2> /dev/null | sed q)
    2.59  		[ -s "$file" ] && break
    2.60  	done
    2.61 @@ -475,14 +475,14 @@
    2.62  
    2.63  sha()
    2.64  {
    2.65 -	gotcdfile sha*sum*
    2.66 +	gotcdfile "sha*sum*"
    2.67  	sha=$(basename $file)
    2.68  	md5 "${sha%sum*}sum -c ${file#/media/cdrom/}"
    2.69  }
    2.70  
    2.71  readme()
    2.72  {
    2.73 -	gotcdfile README*
    2.74 +	gotcdfile "README*"
    2.75  	$DIALOG --clear \
    2.76  		--title " Readme " \
    2.77  		--textbox $file 24 78
    2.78 @@ -518,7 +518,7 @@
    2.79  computers. BIOS based memory tests are a quick, cursory check and often
    2.80  miss many of the failures that are detected by Memtest86.\n
    2.81  " 12 70
    2.82 -	[ $? -eq 0 ] && gotcdfile memtest* && cp $file /mnt/memtest.exe
    2.83 +	[ $? -eq 0 ] && gotcdfile "memtest*" && cp $file /mnt/memtest.exe
    2.84  }
    2.85  
    2.86  mkfat12()
    2.87 @@ -563,12 +563,12 @@
    2.88  miss many of the failures that are detected by Memtest86.\n\n
    2.89  Please insert a blank disk in floppy drive.\n
    2.90  " 12 70
    2.91 -	[ $? -eq 0 ] && gotcdfile memtest* && mkfloppy $file
    2.92 +	[ $? -eq 0 ] && gotcdfile "memtest*" && mkfloppy $file
    2.93  }
    2.94  
    2.95  pxe()
    2.96  {
    2.97 -	gotcdfile ?pxe
    2.98 +	gotcdfile "?pxe"
    2.99  	$DIALOG --clear \
   2.100  		--title " Create $(basename $file).exe ? " \
   2.101  		--yes-label "Install" --yesno \
   2.102 @@ -592,7 +592,7 @@
   2.103  from the Web using PXE and HTTP protocols.\n\n
   2.104  Please insert a blank disk in floppy drive.\n
   2.105  " 12 70
   2.106 -	[ $? -eq 0 ] && gotcdfile ?pxe && mkfloppy $file
   2.107 +	[ $? -eq 0 ] && gotcdfile "?pxe" && mkfloppy $file
   2.108  }
   2.109  
   2.110  gotposixovl()
   2.111 @@ -648,21 +648,24 @@
   2.112  gotisomd5()
   2.113  {
   2.114  	[ "$(which md5sum 2> /dev/null)" ] &&
   2.115 -	[ $(get 18 /dev/loop0) -ne 0 ] && echo -en "\"$1\"	\"$2\""
   2.116 +	[ $(get 0 /mnt/$ISO) -eq 23117 ] &&
   2.117 +	[ $(get 18 /mnt/$ISO) -ne 0 ] && echo -en "\"$1\"	\"$2\""
   2.118  }
   2.119  
   2.120  isomd5()
   2.121  {
   2.122  	dotwait "Checking iso image"
   2.123 -	[ "$(ddq if=/dev/loop0 bs=2k skip=16 \
   2.124 -	     count=$(echo $(get 32848 /dev/loop0 4)) | md5sum)" == \
   2.125 -	  "$(ddq if=/dev/loop0 bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \
   2.126 +	[ "$(ddq if=/mnt/$ISO bs=2k skip=16 \
   2.127 +	     count=$(echo $(get 32848 /mnt/$ISO 4)) | md5sum)" == \
   2.128 +	  "$(ddq if=/mnt/$ISO bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \
   2.129  	     sed 's/ //g')  -" ] && echo "OK" || echo "ERROR"
   2.130 -	echo -en "\rChecking iso hybrid boot"
   2.131 -	n=$(($(get 2 /dev/loop0)-1+($(get 4 /dev/loop0)-1)*512))
   2.132 -	s=$(get 0 /dev/loop0 2 $n | awk '{ i+= $0 } END { print i }')
   2.133 -	[ $(((1+$s+$(get $(($n+1)) /dev/loop0 1)) % 65536)) -eq 0 ] &&
   2.134 -	echo "OK" || echo "ERROR"
   2.135 +	echo -en "\rChecking iso hybrid boot..."
   2.136 +	n=$(($(get 2 /mnt/$ISO)-1+($(get 4 /mnt/$ISO)-1)*512))
   2.137 +	if [ $n -lt 40000 -a $n -gt 32768 ]; then
   2.138 +		s=$(get 0 /mnt/$ISO 2 $n | awk '{ i+= $0 } END { print i }')
   2.139 +		[ $(((1+$s+$(get $(($n+1)) /mnt/$ISO 1)) % 65536)) -eq 0 ] &&
   2.140 +		echo "OK" || echo "ERROR"
   2.141 +	fi
   2.142  	rm -f /tmp/wait
   2.143  	echo -e "\rPress RETURN to continue."
   2.144  	read n
   2.145 @@ -878,12 +881,12 @@
   2.146  
   2.147  runmemtest()
   2.148  {
   2.149 -	gotcdfile memtest* && dokexec
   2.150 +	gotcdfile "memtest*" && dokexec
   2.151  }
   2.152  
   2.153  runpxe()
   2.154  {
   2.155 -	gotcdfile ?pxe && dokexec
   2.156 +	gotcdfile "?pxe" && dokexec
   2.157  }
   2.158  
   2.159  shell()
   2.160 @@ -919,10 +922,10 @@
   2.161  $(xfile tazlocale	"tazlocale"	"Select locale (${locale:-none})") \
   2.162  $(cdfile boot/bzImage	"live"		"Linux RAM boot (full desktop)") \
   2.163  			"text"		"Linux RAM boot" \
   2.164 -$(cdfile README*	"readme"	"Show the README file") \
   2.165 +$(cdfile "README*"	"readme"	"Show the README file") \
   2.166  $(gotisomd5		"isomd5"	"Check the ISO image") \
   2.167 -$(cdfile md5sum*	"md5"		"Check the ISO files") \
   2.168 -$(cdfile sha*sum*	"sha"		"Check the ISO files") \
   2.169 +$(cdfile "md5sum*"	"md5"		"Check the ISO files") \
   2.170 +$(cdfile "sha*sum*"	"sha"		"Check the ISO files") \
   2.171  $(gotposixovl		"install"	"Hard disk installation (UMSDOS way)") \
   2.172  $(gotposixovl		"installtaz"	"Hard disk installation (TAZUSB way)") \
   2.173  $(xfile tazusb		"usbkey"	"USB key read/write installation") \
   2.174 @@ -930,12 +933,12 @@
   2.175  $(fddata		"fdbootstrap"	"Create a floppy bootstrap") \
   2.176  			"tazboot"	"Get tazboot.exe Linux loader" \
   2.177  $(cdexe boot/bzImage	"bzimage"	"Get linux DOS/EXE file") \
   2.178 -$(cdexe memtest*	"memtest"	"Get Memtest86 DOS/EXE file") \
   2.179 -$(cdfilef memtest*	"fdmemtest"	"Create a Memtest86 boot floppy") \
   2.180 -$(cdfilex memtest*	"runmemtest"	"Start Memtest86") \
   2.181 -$(cdexe ?pxe		"pxe"		"Get SliTaz Web boot DOS/EXE utility") \
   2.182 -$(cdfilef ?pxe		"fdpxe"		"Create a SliTaz Web boot floppy") \
   2.183 -$(cdfilex ?pxe		"runpxe"	"Start the SliTaz Web boot utility") \
   2.184 +$(cdexe "memtest*"	"memtest"	"Get Memtest86 DOS/EXE file") \
   2.185 +$(cdfilef "memtest*"	"fdmemtest"	"Create a Memtest86 boot floppy") \
   2.186 +$(cdfilex "memtest*"	"runmemtest"	"Start Memtest86") \
   2.187 +$(cdexe "?pxe"		"pxe"		"Get SliTaz Web boot DOS/EXE utility") \
   2.188 +$(cdfilef "?pxe"	"fdpxe"		"Create a SliTaz Web boot floppy") \
   2.189 +$(cdfilex "?pxe"	"runpxe"	"Start the SliTaz Web boot utility") \
   2.190  $(xfile reboot		"restart"	"Restart the computer") \
   2.191  $(xfile poweroff	"stop"		"Power off") \
   2.192  			"bootlog"	"Linux boot messages" \
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/syslinux/stuff/iso2exe/taziso	Sat Feb 14 18:17:26 2015 +0100
     3.3 @@ -0,0 +1,909 @@
     3.4 +#!/bin/sh
     3.5 +
     3.6 +[ $(id -u) -eq 0 ] || exec su -c "$0 $@"
     3.7 +
     3.8 +DIALOG=dialog
     3.9 +
    3.10 +ddq()
    3.11 +{
    3.12 +	dd $@ 2> /dev/null
    3.13 +}
    3.14 +
    3.15 +get()
    3.16 +{
    3.17 +	od -v -j $1 -N ${4:-${3:-2}} -t u${3:-2} -w${3:-2} -An $2 2>/dev/null ||
    3.18 +	hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %d\n\"" $2
    3.19 +}
    3.20 +
    3.21 +bytes2bin()
    3.22 +{
    3.23 +	for i in $@ ; do
    3.24 +		printf '\\\\x%02X' $(($i&255))
    3.25 +	done | xargs echo -en
    3.26 +}
    3.27 +
    3.28 +words2bin()
    3.29 +{
    3.30 +	for i in $@ ; do
    3.31 +		printf '\\\\x%02X\\\\x%02X' $(($i&255)) $((($i>>8)&255))
    3.32 +	done | xargs echo -en
    3.33 +}
    3.34 +
    3.35 +gettazboot()
    3.36 +{
    3.37 +	echo "Creating $(basename $1) ..."
    3.38 +	if [ $(get 0 $ISO) -eq 23117 ]; then
    3.39 +		O=$(($(get 66 $ISO) - 0xC0))
    3.40 +		L=$(($(get 20 $ISO) - 0xC0 - $(get 24 $ISO) - $O))
    3.41 +		S=$((32+$L))
    3.42 +		P=$((($S+511)/512))
    3.43 +		E=$((4096-(32*$P)))
    3.44 +		words2bin 0x5A4D $(($S%512)) $P 0 2 $E -1 $((${2:-0}-16)) \
    3.45 +				-2 0 256 -16 28 0x6C53 0x5469 0x7A61 > $1
    3.46 +		ddq bs=1 count=$L skip=$(echo $O) if=$ISO >> $1
    3.47 +	else
    3.48 +		wget -O $1 http://mirror.slitaz.org/boot/tazboot.exe
    3.49 +	fi
    3.50 +}
    3.51 +
    3.52 +uncpio()
    3.53 +{
    3.54 +	[ -s "$1" ] || return
    3.55 +	echo -en "\n Extracting $(basename $1) ..."
    3.56 +	case $(get 0 $1) in
    3.57 +	*35615)	( zcat || gunzip ) ;;
    3.58 +	*14333) unxz ;;
    3.59 +	*\ 93)	unlzma ;;
    3.60 +	*)	cat ;;
    3.61 +	esac < $1 | ( cd ${2:-/} ; cpio -idmu > /dev/null 2>&1 )
    3.62 +}
    3.63 +
    3.64 +dotwait()
    3.65 +{
    3.66 +	echo -n "${1:-Install filesystem}.."
    3.67 +	touch /tmp/wait
    3.68 +	while [ -e /tmp/wait ]; do
    3.69 +		echo -n "." > /dev/tty
    3.70 +		sleep 1
    3.71 +	done &
    3.72 +}
    3.73 +
    3.74 +getuuid()
    3.75 +{
    3.76 +	dev=$(mount | sed "/ $(echo $mnt | sed 's|/|\\/|g') /!d;s/ .*//;s|/dev/||;q")
    3.77 +	[ "$dev" ] &&
    3.78 +	blkid | sed "/$dev:/!d;s/.* UUID=.\\([^ ]*\\)\".*/\\1/" ||
    3.79 +	echo "/dev/hda1"
    3.80 +}
    3.81 +
    3.82 +tazusbinitfs()
    3.83 +{
    3.84 +	PAD=$(($(stat -c %s $1) % 4))
    3.85 +	[ $PAD -ne 0 ] && ddq if=/dev/zero bs=1 count=$((4 - $PAD)) >> $1
    3.86 +	mkdir -p /tmp/fs$$/etc /tmp/fs$$/lib /tmp/fs$$/home
    3.87 +	cp -a /etc/locale.conf /tmp/fs$$/etc 2> /dev/null
    3.88 +	cp -a /etc/keymap.conf /tmp/fs$$/etc 2> /dev/null
    3.89 +	cat > /tmp/fs$$/init1 <<EOT
    3.90 +#!/bin/sh
    3.91 +sed -i 's|sbin/init|init2|' /init
    3.92 +exec /init
    3.93 +EOT
    3.94 +	cat > /tmp/fs$$/init2 <<EOT
    3.95 +#!/bin/sh
    3.96 +
    3.97 +mount -t proc /proc /proc
    3.98 +for i in /lib/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2
    3.99 +v=\$(sed '/\\/home=/!d;s|.*/home=\\([^ ]*\\).*|\\1|' /proc/cmdline /cmdline 2> /dev/null)
   3.100 +mount / -o remount,rw
   3.101 +mkdir /mnt/dos
   3.102 +rm -f /cmdline 2> /dev/null
   3.103 +mount / -o remount,ro
   3.104 +mnt=/mnt/dos/\${v#*/}
   3.105 +dev=\$( (blkid /dev/[sh]d* || blkid) | grep \${v%%/*} | sed 's/:.*//;q')
   3.106 +echo "Mount \$dev in /mnt/dos for \$v..." | tee -a /run/boot.log
   3.107 +mount \$dev /mnt/dos
   3.108 +if [ ! -d /mnt/dos/slitaz ]; then
   3.109 +	umount /mnt/dos 2> /dev/null
   3.110 +	(blkid /dev/[sh]d* || blkid) | while read dev line; do
   3.111 +		case "\$line" in
   3.112 +		*ntfs*|*vfat*|*msdos*) ;;
   3.113 +		*) continue ;;
   3.114 +		esac
   3.115 +		mount \${dev%:} /mnt/dos
   3.116 +		[ -d /mnt/dos/slitaz ] && break
   3.117 +		umount /mnt/dos
   3.118 +	done
   3.119 +fi
   3.120 +mount.posixovl -F \$mnt -- -oallow_other -odefault_permissions -osuid
   3.121 +mount --bind \$mnt /home
   3.122 +umount /proc
   3.123 +exec /sbin/init
   3.124 +EOT
   3.125 +	chmod 755 /tmp/fs$$/init?
   3.126 +	( cd /tmp/fs$$ ; find * | cpio -o -H newc ) | gzip -9 >> $1
   3.127 +	rm -rf /tmp/fs$$
   3.128 +}
   3.129 +
   3.130 +mkinitrd()
   3.131 +{
   3.132 +	echo -en "\nCreating $(basename $1) "
   3.133 +	fs=/tmp/fs$$
   3.134 +	for i in bin lib dev proc tmp mnt etc ; do
   3.135 +		mkdir -p $fs/$i
   3.136 +	done
   3.137 +	for i in /dev/console /dev/null /dev/tty /dev/tty0 /dev/tty1 /dev/tty2 \
   3.138 +		 /dev/fuse /dev/hd* /dev/sd* ; do
   3.139 +		cp -a $2$i $fs/dev/
   3.140 +	done
   3.141 +	for i in /bin/busybox $(which mount.posixovl) $(which blkid); do
   3.142 +		cp $(LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $i | \
   3.143 +		sed 's|.*=> \(.*/lib/l[^ ]*\).*|\1|;/^\//!d') $fs/lib
   3.144 +		cp $i $fs/bin
   3.145 +	done
   3.146 +	cp -a /lib/ld-* $fs/lib
   3.147 +	for i in $(busybox | sed '/Current/,$!d'); do
   3.148 +		[ -e $fs/bin/${i%,} ] || ln -s busybox $fs/bin/${i%,}
   3.149 +	done
   3.150 +	ln -s /proc/mounts $fs/etc/mtab
   3.151 +	sed 's/ .*//' /proc/modules | while read mod ; do
   3.152 +		find /lib/modules/ | grep $mod.ko | \
   3.153 +			sed 's|.*|cp & $fs/lib|' | sh
   3.154 +	done
   3.155 +	cat > $fs/init <<EOT
   3.156 +#!/bin/sh
   3.157 +
   3.158 +arg()
   3.159 +{
   3.160 +	grep -q \$1 /proc/cmdline &&
   3.161 +	val="\$(sed "s/.*\$1=\\([^ ]*\\).*/\\1/" < /proc/cmdline)" &&
   3.162 +	echo "\$2 \$val"
   3.163 +}
   3.164 +
   3.165 +mount -t proc /proc /proc
   3.166 +  arg debug "shell" && debug=true && set -x
   3.167 +for i in /lib/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2
   3.168 +arg mount "Mount device"
   3.169 +mount \$( (blkid /dev/[sh]d* || blkid) | grep \$val | sed 's/:.*//;q') /mnt
   3.170 +arg subroot "Change root to directory"
   3.171 +if [ -d /mnt/\$val ]; then
   3.172 +	umount /mnt 2> /dev/null
   3.173 +	(blkid /dev/[sh]d* || blkid) | while read dev line; do
   3.174 +		case "\$line" in
   3.175 +		*ntfs*|*vfat*|*msdos*) ;;
   3.176 +		*) continue ;;
   3.177 +		esac
   3.178 +		mount \${dev%:} /mnt
   3.179 +		[ -d /mnt/\$val ] && break
   3.180 +		umount /mnt
   3.181 +	done
   3.182 +fi
   3.183 +mount.posixovl -F /mnt/\$val -- -oallow_other -odefault_permissions -osuid
   3.184 +mount --bind /mnt /mnt/\$val/mnt/dos
   3.185 +mount -o size=0 -t tmpfs tmpfs /mnt/\$val/mnt/dos/\$val
   3.186 +LDSO=\$(ls /mnt/\$val/lib/ld-* | sed q)
   3.187 +export LD_LIBRARY_PATH=\$val/lib:\$val/usr/lib:/lib
   3.188 +  [ "$debug" = "true" ] && sh
   3.189 +umount /proc
   3.190 +exec /bin/switch_root /mnt \${LDSO#/mnt/} \$val/usr/sbin/chroot \$val /sbin/init
   3.191 +EOT
   3.192 +	chmod +x $fs/init
   3.193 +	( cd $fs ; find * | cpio -o -H newc ) | lzma e $1 -si 2> /dev/null
   3.194 +	rm -rf $fs /tmp/wait
   3.195