wok diff syslinux/stuff/iso2exe/taziso @ rev 23820

syslinux: merge init.exe & taziso
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu May 28 08:35:55 2020 +0000 (2020-05-28)
parents 3f40a3c71c48
children c2a80ff9499e
line diff
     1.1 --- a/syslinux/stuff/iso2exe/taziso	Mon May 25 18:40:12 2020 +0000
     1.2 +++ b/syslinux/stuff/iso2exe/taziso	Thu May 28 08:35:55 2020 +0000
     1.3 @@ -46,23 +46,25 @@
     1.4  
     1.5  uncpio()
     1.6  {
     1.7 -	[ -s "$1" ] || return
     1.8 -	echo -en "\n Extracting $(basename $1) ..."
     1.9 -	case $(get 0 $1) in
    1.10 +	i=$1                                                    
    1.11 +	[ $0 = /init.exe ] && sed 's|$| |' /proc/cpuinfo | grep ' lm ' && [ -s ${i}64 ] && i=${i}64
    1.12 +	[ -s "$i" ] || return
    1.13 +	echo -en "\n Extracting $(basename $i) ..."
    1.14 +	case $(get 0 $i) in
    1.15  	*35615)	( zcat || gunzip ) ;;
    1.16  	*14333) unxz ;;
    1.17  	*\ 93)	unlzma ;;
    1.18  	*)	cat ;;
    1.19 -	esac < $1 | ( cd ${2:-/} ; cpio -idmu > /dev/null 2>&1 )
    1.20 +	esac < $i | ( cd ${2:-/} ; cpio -idmu > /dev/null 2>&1 )
    1.21  }
    1.22  
    1.23  dotwait()
    1.24  {
    1.25  	echo -n "${1:-Install filesystem}.."
    1.26 -	touch /tmp/wait
    1.27 +	echo -n > /tmp/wait
    1.28  	[ "$REQUEST_URI" ] && return
    1.29  	while [ -e /tmp/wait ]; do
    1.30 -		echo -n "." > /dev/tty
    1.31 +		echo -n "." > /dev/${tty0:-tty}
    1.32  		sleep 1
    1.33  	done &
    1.34  }
    1.35 @@ -200,6 +202,11 @@
    1.36  	ls -r $@ 2> /dev/null || ls $@
    1.37  }
    1.38  
    1.39 +is_loram()                                                                   
    1.40 +{                                                                            
    1.41 +	[ -s /lib/modules/squashfs.ko* ]                                     
    1.42 +}                                                                            
    1.43 +
    1.44  doinstall()
    1.45  {
    1.46  	unset useposixovl
    1.47 @@ -224,9 +231,21 @@
    1.48  		initrd=rootfs.gz
    1.49  		extraargs="/home=$(getuuid)/slitaz rdinit=/init1"
    1.50  	else
    1.51 -		for i in $(ls_r $media/boot/rootfs*gz); do
    1.52 -			uncpio $i $mnt/slitaz
    1.53 -		done
    1.54 +		if [ -d $media/fs ]; then                                
    1.55 +                        cp -a $media/fs/. $mnt/slitaz                    
    1.56 +                elif is_loram; then                                            
    1.57 +                        for i in $(ls_r $media/boot/rootfs*); do         
    1.58 +                                losetup -o 124 /dev/loop7 $i                   
    1.59 +                                mount -t squashfs -o ro /dev/loop7 /sqfs/mnt   
    1.60 +                                cp -a /sqfs/mnt/. $mnt/slitaz                  
    1.61 +                                umount /sqfs/mnt                               
    1.62 +                                losetup -d /dev/loop7                          
    1.63 +                        done                                                   
    1.64 +                else
    1.65 +			for i in $(ls_r $media/boot/rootfs*gz); do
    1.66 +				${uncpio:-uncpio} $i $mnt/slitaz
    1.67 +			done
    1.68 +		fi
    1.69  		for i in $packages_list; do
    1.70  			tazpkg get-install $i --root=$mnt/slitaz
    1.71  		done
    1.72 @@ -311,7 +330,20 @@
    1.73  
    1.74  EOT
    1.75  	fi
    1.76 -	rm -f /tmp/wait
    1.77 +false &&                                                                          
    1.78 +	[ -s $mnt/boot.ini ] && ! grep -qs tazboot $mnt/boot.ini &&               
    1.79 +	echo "Update boot.ini ..." && unix2dos >> $mnt/boot.ini <<EOT             
    1.80 +C:\\slitaz\\boot\\tazboot.exe="SliTaz"                                                
    1.81 +EOT                                                                               
    1.82 +false &&                                                                          
    1.83 +	grep -qis menuitem $mnt/config.sys && ! grep -qi tazboot $mnt/config.sys &&
    1.84 +	echo "Update config.sys ..." &&                                            
    1.85 +	sed -i 's/menudefault/menuitem SLITAZ, SliTaz\r\n&/' $mnt/config.sys &&    
    1.86 +	unix2dos >> $mnt/config.sys <<EOT                                          
    1.87 +[SLITAZ]                                                                           
    1.88 +install=\\slitaz\\boot\\tazboot.exe                                                
    1.89 +EOT
    1.90 +	rm -f $tmp/wait
    1.91  	[ "$useposixovl" ] && umount $mnt/slitaz
    1.92  	return 0
    1.93  }
    1.94 @@ -349,6 +381,7 @@
    1.95  {
    1.96  	packages_list=
    1.97  	packages_dir=
    1.98 +	[ $0 = /init.exe ] && return
    1.99  	$DIALOG --clear --title " Extra packages " \
   1.100  		--defaultno --yesno \
   1.101  "Do you want to add extra packages ?" 7 70
   1.102 @@ -393,6 +426,11 @@
   1.103  start SliTaz Live with the 'SliTaz RAM boot' menu.\n" 19 70
   1.104  	[ $? -eq 0 ] || return
   1.105  	doinstall
   1.106 +	[ $0 = /init.exe ] || return
   1.107 +	[ -x $mnt/slitaz/sbin/init ] || return
   1.108 +	umount -d $media/cdrom
   1.109 +	umount_proc
   1.110 +	exec chroot $mnt/slitaz /sbin/init
   1.111  }
   1.112  
   1.113  readtazbootconf()
   1.114 @@ -520,7 +558,27 @@
   1.115  To do a traditional installation with disk partitioning,
   1.116  start SliTaz Live with the 'SliTaz RAM boot' menu.\n" 19 70
   1.117  	[ $? -eq 0 ] || return
   1.118 -	doinstall tazusblike
   1.119 +	doinstall tazusblike || return
   1.120 +	[ $0 = /init.exe ] || return
   1.121 +	dotwait
   1.122 +	if [ -d /media/cdrom/fs ]; then
   1.123 +		cp -a /media/cdrom/fs/. /
   1.124 +	else
   1.125 +		for i in $(ls_r /media/cdrom/boot/rootfs*); do
   1.126 +			${uncpio:-uncipo} $i
   1.127 +		done
   1.128 +	fi
   1.129 +	cp /tmp/fs/etc/* /etc 2>/dev/null
   1.130 +	echo "/home=$(getuuid)/slitaz" > /cmdline
   1.131 +	rm -f /tmp/wait
   1.132 +	[ -x /init1 ] || return
   1.133 +	umount -d /media/cdrom
   1.134 +	umount /mnt/slitaz
   1.135 +	rm -f /dev/cdrom
   1.136 +	umount /mnt
   1.137 +	mkdir /mnt/dos
   1.138 +	umount_proc
   1.139 +	exec /init1
   1.140  }
   1.141  
   1.142  installtaz()
   1.143 @@ -755,11 +813,26 @@
   1.144  	[ "$(which zip)" ] && gotposixovl "$1" "$2"
   1.145  }
   1.146  
   1.147 +noinit()
   1.148 +{
   1.149 +	[ $0 = /init.exe ] || menuitem "$@"
   1.150 +}
   1.151 +
   1.152 +initx()
   1.153 +{
   1.154 +	[ $0 = /init.exe ] && menuitem "$@"
   1.155 +}
   1.156 +
   1.157  xfile()
   1.158  {
   1.159  	[ "$(which $1)" ] && menuitem "$@"
   1.160  }
   1.161  
   1.162 +initxfile()
   1.163 +{
   1.164 +	[ $0 = /init.exe ] && xfile "$@"
   1.165 +}
   1.166 +
   1.167  cdfile()
   1.168  {
   1.169  	gotcdfile "$1" && menuitem "$@"
   1.170 @@ -802,6 +875,11 @@
   1.171  	done
   1.172  }
   1.173  
   1.174 +noinitmisspkg()
   1.175 +{
   1.176 +	[ $0 = /init.exe ] || misspkg "$@"
   1.177 +}
   1.178 +
   1.179  missing()
   1.180  {
   1.181  	misspkg install
   1.182 @@ -1323,6 +1401,17 @@
   1.183  		-c %y $media/.|sed 's/ .*//')  $(basename "$ISO")"
   1.184  }
   1.185  
   1.186 +	if [ $0 = /init.exe ]; then
   1.187 +
   1.188 +case "${ISO##*/}$(getarg mode)" in
   1.189 +*install*|*INSTALL*)	install;;
   1.190 +*live*|*LIVE*)		live;;
   1.191 +*text*|*TEXT*)		text;;
   1.192 +esac
   1.193 +dmesg > /tmp/dmesg
   1.194 +
   1.195 +	else
   1.196 +
   1.197  if [ "$1" = "include" ]; then
   1.198  	[ -s "$2" ] && cd $(dirname "$2") && awk -v exe=$0 \
   1.199  	'{ if ($1 == "include") system(exe " include " $2); else print }' <"$2"
   1.200 @@ -1354,10 +1443,17 @@
   1.201  	fi
   1.202  	quit
   1.203  fi
   1.204 +	fi
   1.205  
   1.206  while true; do
   1.207 +	keymap="$(cat /etc/keymap.conf 2>/dev/null)"
   1.208 +	locale="$(sed '/^LANG=/!d;s/.*=//' /etc/locale.conf 2>/dev/null)"
   1.209  	cat > /tmp/dialog$$ <<EOT
   1.210  $DIALOG  --clear --title " $(isotitle) " --menu "" 28 70 30 \
   1.211 +$(initxfile tazkeymap	"tazkeymap"	"Select keyboard (${keymap:-none})") \
   1.212 +$(initxfile tazlocale	"tazlocale"	"Select locale (${locale:-none})") \
   1.213 +$(initx			"live"		"Linux RAM boot (full desktop)") \
   1.214 +$(initx			"text"		"Linux RAM boot") \
   1.215  $(cdfile 'README*'	"readme"	"Show the README file") \
   1.216  $(gotcustomconf		"getcustomconf"	"Get custom config") \
   1.217  $(gotisomd5		"isomd5"	"Check the ISO image") \
   1.218 @@ -1384,14 +1480,18 @@
   1.219  $(cdexe '?pxe*'		"pxe"		"Get SliTaz Web boot DOS/EXE utility") \
   1.220  $(cdfilef '?pxe*'	"fdpxe"		"Create a SliTaz Web boot floppy") \
   1.221  $(cdfilex '?pxe*'	"runpxe"	"Start the SliTaz Web boot utility") \
   1.222 -$(misspkg		"missing"	"Install packages to get more options") \
   1.223 -$(menuitem		"quit"		"Quit this utility")
   1.224 +$(initxfile reboot	"restart"	"Restart the computer") \
   1.225 +$(initxfile poweroff	"stop"		"Power off") \
   1.226 +$(initx			"bootlog"       "Linux boot messages") \
   1.227 +$(initx			"shell"         "Shell prompt") \
   1.228 +$(noinitmisspkg		"missing"	"Install packages to get more options") \
   1.229 +$(noinit		"quit"		"Quit this utility")
   1.230  EOT
   1.231  	exec 3>&1
   1.232  	value=$(. /tmp/dialog$$ 2>&1 1>&3)
   1.233  	retval=$?
   1.234  	exec 3>&-
   1.235  	rm -f /tmp/dialog$$
   1.236 -	[ $retval -eq 0 ] || quit
   1.237 +	[ $retval -ne 0 ] && [ $0 != /init.exe ] && quit
   1.238  	$value
   1.239  done