wok diff syslinux/stuff/iso2exe/init @ rev 16041
syslinux/iso2exe: fix 'a la umsdos' install
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Mar 09 14:09:57 2014 +0000 (2014-03-09) |
parents | d814ca840c3c |
children | 8d64ce80ab95 |
line diff
1.1 --- a/syslinux/stuff/iso2exe/init Fri Mar 07 10:50:10 2014 +0000 1.2 +++ b/syslinux/stuff/iso2exe/init Sun Mar 09 14:09:57 2014 +0000 1.3 @@ -13,6 +13,21 @@ 1.4 sed "/$1=/!d;s/.*$1=\\([^ ]*\\).*/\\1/" /proc/cmdline 1.5 } 1.6 1.7 +mount_proc() 1.8 +{ 1.9 + mount -t proc /proc /proc 1.10 + mount -t sysfs /sys /sys 1.11 + udevd --daemon 2> /dev/null && udevadm trigger && sleep 5 1.12 +} 1.13 + 1.14 +umount_proc() 1.15 +{ 1.16 + killall udevd 2> /dev/null 1.17 + umount /sys/fs/fuse/connections 2> /dev/null 1.18 + umount /sys 1.19 + umount /proc 1.20 +} 1.21 + 1.22 gettazboot() 1.23 { 1.24 echo "Creating $(basename $1) ..." 1.25 @@ -61,7 +76,7 @@ 1.26 getuuid() 1.27 { 1.28 dev=$(mount | sed '/ \/mnt /!d;s/ .*//;s|/dev/||;q') 1.29 - blkid | sed "/$dev:/!d;s/.*UUID=.\\([^ ]*\\)\".*/\\1/" 1.30 + blkid | sed "/$dev:/!d;s/.* UUID=.\\([^ ]*\\)\".*/\\1/" 1.31 } 1.32 1.33 mkinitrd() 1.34 @@ -70,7 +85,7 @@ 1.35 for i in bin lib dev proc tmp mnt etc ; do 1.36 mkdir -p /tmp/fs/$i 1.37 done 1.38 - for i in /dev/console /dev/null /dev/tty /dev/tty1 /dev/fuse \ 1.39 + for i in /dev/console /dev/null /dev/tty /dev/tty1 /dev/tty2 /dev/fuse \ 1.40 /dev/hd* /dev/sd* ; do 1.41 cp -a $i /tmp/fs$i 1.42 done 1.43 @@ -84,6 +99,10 @@ 1.44 [ -e /tmp/fs/bin/${i%,} ] || ln -s busybox /tmp/fs/bin/${i%,} 1.45 done 1.46 ln -s /proc/mounts /tmp/fs/etc/mtab 1.47 + sed 's/ .*//' /proc/modules | while read mod ; do 1.48 + find /lib/modules/ | grep $mod.ko | \ 1.49 + sed 's|.*|cp & /tmp/fs/lib|' | sh 1.50 + done 1.51 cat > /tmp/fs/init <<EOT 1.52 #!/bin/sh 1.53 1.54 @@ -95,14 +114,17 @@ 1.55 } 1.56 1.57 mount -t proc /proc /proc 1.58 + arg debug "shell" && debug=true && set -x 1.59 +for i in /lib/*.ko* ; do insmod \$i ; done; sleep 2 1.60 arg mount "Mount device" 1.61 mount \$( (blkid /dev/?d* || blkid) | grep \$val | sed 's/:.*//;q') /mnt 1.62 arg subroot "Change root to directory" 1.63 -mount.posixovl -F /mnt/\$val 1.64 +mount.posixovl -F /mnt/\$val -- -oallow_other -odefault_permissions -osuid 1.65 mount --bind /mnt /mnt/\$val/mnt/dos 1.66 LDSO=\$(ls /mnt/\$val/lib/ld-* | sed q) 1.67 +export LD_LIBRARY_PATH=\$val/lib:\$val/usr/lib:/lib 1.68 + [ "$debug" = "true" ] && sh 1.69 umount /proc 1.70 -export LD_LIBRARY_PATH=\$val/lib:\$val/usr/lib:/lib 1.71 exec /bin/switch_root /mnt \${LDSO#/mnt/} \$val/usr/sbin/chroot \$val /sbin/init 1.72 EOT 1.73 chmod +x /tmp/fs/init 1.74 @@ -115,16 +137,26 @@ 1.75 [ -s /lib/squashfs.ko* ] 1.76 } 1.77 1.78 +ls_r() 1.79 +{ 1.80 + ls -r $@ 2> /dev/null || ls $@ 1.81 +} 1.82 + 1.83 doinstall() 1.84 { 1.85 mkdir -p /mnt/slitaz/boot /mnt/slitaz/mnt/dos 1.86 - mount.posixovl -F /mnt/slitaz || return 1.87 - echo "Install root filesystem..." 1.88 + if ! mount.posixovl -F /mnt/slitaz -- \ 1.89 + -oallow_other -odefault_permissions -osuid; then 1.90 + echo "Can't install SliTaz. Abort." 1.91 + sleep 5 1.92 + return 1 1.93 + fi 1.94 + echo "Install root filesystem in /slitaz..." 1.95 if [ -n "$1" ]; then 1.96 if [ -d /media/cdrom/fs ]; then 1.97 ( cd /mnt/slitaz/fs; find | cpio -o -H newc ) | gzip -9 1.98 else 1.99 - ls -r /media/cdrom/boot/rootfs* | xargs cat 1.100 + ls_r /media/cdrom/boot/rootfs* | xargs cat 1.101 fi > /mnt/slitaz/boot/rootfs.gz 1.102 mkdir /mnt/slitaz/home 1.103 initrd=rootfs.gz 1.104 @@ -137,13 +169,13 @@ 1.105 [ -s $(basename $i) ] && continue 1.106 cpio -i $i 1.107 done 1.108 - for i in $(ls -r /media/cdrom/boot/rootfs*); do 1.109 + for i in $(ls_r /media/cdrom/boot/rootfs*); do 1.110 mount -o loop,ro $i /sqfs/mnt 1.111 cp -a /sqfs/mnt/. /mnt/slitaz 1.112 umount -d /sqfs/mnt 1.113 done 1.114 else 1.115 - for i in $(ls -r /media/cdrom/boot/rootfs*); do 1.116 + for i in $(ls_r /media/cdrom/boot/rootfs*); do 1.117 uncpio $i /mnt/slitaz 1.118 done 1.119 fi 1.120 @@ -159,24 +191,29 @@ 1.121 done 1.122 gettazboot /mnt/slitaz/boot/tazboot.exe 1.123 unix2dos > /mnt/slitaz/boot/tazboot.cmd <<EOT 1.124 -kernel=\\slitaz\\boot\\bzimage 1.125 -initrd=\\slitaz\\boot\\$initrd 1.126 +kernel=/slitaz/boot/bzimage 1.127 +initrd=/slitaz/boot/$initrd 1.128 rw root=/dev/null $extraargs autologin 1.129 EOT 1.130 unix2dos /mnt/slitaz/boot/he* /mnt/slitaz/boot/opt* \ 1.131 /mnt/slitaz/boot/README 1.132 [ -d /mnt/slitaz/usr/sbin -a ! -x /mnt/slitaz/usr/sbin/mount.posixovl ] && 1.133 cp $(which mount.posixovl) /mnt/slitaz/usr/sbin 1.134 - ! grep -qs tazboot /mnt/boot.ini && unix2dos >> /mnt/boot.ini <<EOT 1.135 +false && 1.136 + ! grep -qs tazboot /mnt/boot.ini && echo "Update boot.ini ..." && 1.137 + unix2dos >> /mnt/boot.ini <<EOT 1.138 C:\\slitaz\\boot\\tazboot.exe="SliTaz" 1.139 EOT 1.140 - grep -qs menuitem /mnt/config.sys && !grep -q tazboot /mnt/config.sys && 1.141 - sed -i 's/menudefault=/menuitem=slitaz,SliTaz\n&/' /mnt/config.sys && 1.142 - cat >> /mnt/config.sys <<EOT 1.143 -[slitaz] 1.144 -device=\\slitaz\\boot\\tazboot.exe 1.145 + grep -qs menuitem /mnt/config.sys && ! grep -q tazboot /mnt/config.sys && 1.146 + echo "Update config.sys ..." && 1.147 + sed -i 's/menudefault=/menuitem=slitaz,SliTaz\r\n&/' /mnt/config.sys && 1.148 + echo -e "[slitaz]\r" >> /mnt/config.sys && 1.149 + echo "Update autoexec.bat ..." && 1.150 + unix2dos >> /mnt/autoexec.bat <<EOT 1.151 +:slitaz 1.152 +\\slitaz\\boot\\tazboot.exe 1.153 EOT 1.154 - unix2dos /mnt/config.sys 2> /dev/null 1.155 + return 0 1.156 } 1.157 1.158 install() 1.159 @@ -195,10 +232,10 @@ 1.160 start SliTaz Live with 'SliTaz RAM boot' menu.\n 1.161 " 19 70 1.162 [ $? -eq 0 ] || return 1.163 - doinstall 1.164 - [ -x /sbin/init ] || return 1.165 + doinstall || return 1.166 + [ -x /mnt/slitaz/sbin/init ] || return 1.167 umount -d /media/cdrom 1.168 - umount /proc 1.169 + umount_proc 1.170 exec chroot /mnt/slitaz /sbin/init 1.171 } 1.172 1.173 @@ -218,11 +255,11 @@ 1.174 start SliTaz Live with 'SliTaz RAM boot' menu.\n 1.175 " 19 70 1.176 [ $? -eq 0 ] || return 1.177 - doinstall tazusblike 1.178 + doinstall tazusblike || return 1.179 if [ -d /media/cdrom/fs ]; then 1.180 zcat /mnt/slitaz/boot/rootfs.gz | cpio -idmu 1.181 else 1.182 - for i in $(ls -r /media/cdrom/boot/rootfs*); do 1.183 + for i in $(ls_r /media/cdrom/boot/rootfs*); do 1.184 ( zcat $i 2> /dev/null || unlzma -c $i ) | cpio -idmu 1.185 done 1.186 fi 1.187 @@ -230,7 +267,7 @@ 1.188 umount -d /media/cdrom 1.189 mount --move /mnt /mnt/dos 1.190 ln -s /mnt/dos/slitaz/home /home 1.191 - umount /proc 1.192 + umount_proc 1.193 exec /sbin/init 1.194 } 1.195 1.196 @@ -338,6 +375,12 @@ 1.197 dd if=/media/cdrom/boot/?pxe of=/dev/fd0 1.198 } 1.199 1.200 +gotposixovl() 1.201 +{ 1.202 + mount.posixovl 2>&1 | grep -qi usage && 1.203 + echo -en "\"$1\" \"$2\"" 1.204 +} 1.205 + 1.206 xfile() 1.207 { 1.208 [ -n "$(which $1)" ] && echo -en "\"$2\" \"$3\"" 1.209 @@ -481,14 +524,14 @@ 1.210 umount_loram 1.211 umount -d /media/cdrom 1.212 umount /mnt 1.213 - umount /proc 1.214 + umount_proc 1.215 exec /init 1.216 } 1.217 1.218 live() 1.219 { 1.220 n=0 1.221 - for i in $(ls -r /media/cdrom/boot/rootfs*); do 1.222 + for i in $(ls_r /media/cdrom/boot/rootfs* 2> /dev/null); do 1.223 [ $((n++)) -eq 0 ] || uncpio $i 1.224 done 1.225 text 1.226 @@ -516,16 +559,16 @@ 1.227 BIN=bin/mount.posixovl 1.228 [ -x /usr/s$BIN ] || mv /bin/mount.posixovl.iso2exe \ 1.229 /usr/s$BIN 2> /dev/null || mv /bin/mount.posixovl.iso2exe /$BIN 1.230 -mount -t proc /proc /proc 1.231 +mount_proc 1.232 ISO="$(getarg iso | sed 's/.://;s|\\|/|g')" 1.233 getiso 1.234 mount_loram 1.235 -case "$(basename $ISO | tr [A-Z] [a-z])$(getarg mode)" in 1.236 +case "${ISO##*/}$(getarg mode)" in 1.237 *install*) install ;; 1.238 *live*) live ;; 1.239 *text*) text ;; 1.240 esac 1.241 -which $DIALOG || live 1.242 +which $DIALOG 2> /dev/null || live 1.243 dmesg > /tmp/dmesg 1.244 1.245 while true; do 1.246 @@ -533,16 +576,16 @@ 1.247 $DIALOG --clear \ 1.248 --title " Welcome to SliTaz " \ 1.249 --menu "" 21 70 15 \ 1.250 - "live" "SliTaz RAM boot" \ 1.251 +$(cdfile boot/bzImage "live" "SliTaz RAM boot") \ 1.252 "text" "SliTaz RAM boot (text mode only)" \ 1.253 $(cdfile README "readme" "Show the README file") \ 1.254 $(cdfile md5sum "md5" "Check ISO files") \ 1.255 -$(xfile mount.posixovl "install" "Hard disk installation (UMSDOS way)") \ 1.256 -$(xfile mount.posixovl "installtaz" "Hard disk installation (TAZUSB way)") \ 1.257 +$(gotposixovl "install" "Hard disk installation (UMSDOS way)") \ 1.258 +$(gotposixovl "installtaz" "Hard disk installation (TAZUSB way)") \ 1.259 $(xfile tazusb "usbkey" "USB key read/write installation") \ 1.260 - "usbbootkey" "USB boot key (read only)" \ 1.261 +$(cdfile boot/bzImage "usbbootkey" "USB boot key (read only)") \ 1.262 $(fddata "fdbootstrap" "Floppy bootstrap") \ 1.263 - "tazboot" "Get tazboot.exe Linux loader" \ 1.264 +$(cdfile boot/bzImage "tazboot" "Get tazboot.exe Linux loader") \ 1.265 $(cdexe boot/memtest "memtest" "Get Memtest86") \ 1.266 $(cdfile boot/memtest "fdmemtest" "Create a Memtest86 boot floppy") \ 1.267 $(cdexe boot/gpxe "pxe" "Get SliTaz Web boot utility") \