# HG changeset patch # User Pascal Bellard # Date 1418899347 -3600 # Node ID aa3f469a31d7dfa8a6458de79b67417da22b41b6 # Parent c2b42fe954b3057d6add1772ec1a16a6d4a16cbb syslinux/iso2exe: create a vfat partition in usb bootkey (DOS case only) diff -r c2b42fe954b3 -r aa3f469a31d7 syslinux/receipt --- a/syslinux/receipt Wed Dec 17 19:51:54 2014 +0100 +++ b/syslinux/receipt Thu Dec 18 11:42:27 2014 +0100 @@ -29,6 +29,7 @@ sed -i 's/ifcpu64.c32/ifcpu64.c32 md5sum.c32/' com32/modules/Makefile make clean make all 2>&1 | sed 's/NO_WERROR=1/NO_Werror=1/;/syslinux64.exe/d' + echo "make core: LDFLAGS=$LDFLAGS" make -C core make -C com32 ./isohybrid.sh --build diff -r c2b42fe954b3 -r aa3f469a31d7 syslinux/stuff/iso2exe/bootiso.S --- a/syslinux/stuff/iso2exe/bootiso.S Wed Dec 17 19:51:54 2014 +0100 +++ b/syslinux/stuff/iso2exe/bootiso.S Thu Dec 18 11:42:27 2014 +0100 @@ -129,11 +129,11 @@ movw $0x100, %si movw -126(%si), %ax cwd // clear dx - pushw %dx // dos exit + pushw %dx // dos exit() cmpb $0x2F, %al movw $0x3000+EXESTR(help), %ax - jbe abort - int $0x21 + je abort + int $0x21 // get DOS version cmpb $3, %al movb $EXESTR(noDOS3), %al jb abort @@ -172,7 +172,7 @@ popfw // < 286 : flags[12..15] are forced 1 pushfw // = 286 : flags[12..15] are forced 0 popw %bx // > 286 : only flags[15] is forced 0 - popfw // restore flags + popfw // restore flags (IOPL) addb %ah, %bh // test F0 and 00 cases cmpb %ah, %bh movb $EXESTR(no386), %al diff -r c2b42fe954b3 -r aa3f469a31d7 syslinux/stuff/iso2exe/init --- a/syslinux/stuff/iso2exe/init Wed Dec 17 19:51:54 2014 +0100 +++ b/syslinux/stuff/iso2exe/init Thu Dec 18 11:42:27 2014 +0100 @@ -2,6 +2,11 @@ DIALOG=dialog +ddq() +{ + dd $@ 2> /dev/null +} + get() { od -j $1 -N ${3:-2} -t u${3:-2} -An $2 2> /dev/null || @@ -28,6 +33,14 @@ umount /proc } +words2bin() +{ + for i in $@ ; do + printf '\\\\x%02X\\\\x%02X' $(($i&255)) $((($i>>8)&255)) | \ + xargs echo -en + done +} + gettazboot() { echo "Creating $(basename $1) ..." @@ -36,12 +49,9 @@ S=$((32+$L)) P=$((($S+511)/512)) E=$((4096-(32*$P))) - for i in 0x5A4D $(($S%512)) $P 0 2 $E -1 $((${2:-0}-16)) \ - -2 0 256 -16 28 0x6C53 0x5469 0x7A61; do - printf '\\\\x%02X\\\\x%02X' $(($i&255)) $((($i>>8)&255)) | \ - xargs echo -en - done > $1 - dd bs=1 count=$L skip=$(echo $O) if=/mnt/$ISO >> $1 2> /dev/null + words2bin 0x5A4D $(($S%512)) $P 0 2 $E -1 $((${2:-0}-16)) \ + -2 0 256 -16 28 0x6C53 0x5469 0x7A61 > $1 + ddq bs=1 count=$L skip=$(echo $O) if=/mnt/$ISO >> $1 } checkmagic() @@ -82,7 +92,7 @@ tazusbinitfs() { PAD=$(($(stat -c %s $1) % 4)) - [ $PAD -ne 0 ] && dd if=/dev/zero bs=1 count=$((4 - $PAD)) >> $1 + [ $PAD -ne 0 ] && ddq if=/dev/zero bs=1 count=$((4 - $PAD)) >> $1 mkdir -p /tmp/fs/etc /tmp/fs/lib /tmp/fs/home cp -a /etc/locale.conf /tmp/fs/etc 2> /dev/null cp -a /etc/keymap.conf /tmp/fs/etc 2> /dev/null @@ -163,7 +173,7 @@ arg subroot "Change root to directory" mount.posixovl -F /mnt/\$val -- -oallow_other -odefault_permissions -osuid mount --bind /mnt /mnt/\$val/mnt/dos -#mount -o size=0 -t tmpfs tmpfs /mnt/\$val/mnt/dos/\$val +mount -o size=0 -t tmpfs tmpfs /mnt/\$val/mnt/dos/\$val LDSO=\$(ls /mnt/\$val/lib/ld-* | sed q) export LD_LIBRARY_PATH=\$val/lib:\$val/usr/lib:/lib [ "$debug" = "true" ] && sh @@ -195,7 +205,7 @@ return 1 fi echo "Install root filesystem in /slitaz..." - if [ -n "$1" ]; then + if [ "$1" ]; then if [ -d /media/cdrom/fs ]; then ( cd /mnt/slitaz/fs; find | cpio -o -H newc ) | gzip -9 else @@ -308,7 +318,7 @@ cp -a /media/cdrom/fs/. / else for i in $(ls_r /media/cdrom/boot/rootfs*); do - unlzma < $i | (cd / ; cpio -idmu ) + uncpio $i done fi cp /tmp/fs/etc/* /etc @@ -394,7 +404,7 @@ Please insert a blank disk in floppy drive.\n " 12 70 [ $? -eq 0 ] || return - dd if=/media/cdrom/boot/memtest of=/dev/fd0 + ddq if=/media/cdrom/boot/memtest of=/dev/fd0 } pxe() @@ -424,7 +434,7 @@ Please insert a blank disk in floppy drive.\n " 12 70 [ $? -eq 0 ] || return - dd if=/media/cdrom/boot/?pxe of=/dev/fd0 + ddq if=/media/cdrom/boot/?pxe of=/dev/fd0 } gotposixovl() @@ -435,7 +445,7 @@ xfile() { - [ -n "$(which $1)" ] && echo -en "\"$2\" \"$3\"" + [ "$(which $1)" ] && echo -en "\"$2\" \"$3\"" } cdfile() @@ -466,19 +476,20 @@ Please insert a floppy in drive now.\n " 10 70 [ $? -eq 0 ] || return - dd if=/mnt/$ISO of=/dev/fd0 bs=1 count=512 \ + ddq if=/mnt/$ISO of=/dev/fd0 bs=1 count=512 \ skip=$(( $(get 66 /mnt/$ISO) - $sz )) - echo "$ISO" | dd of=/dev/fd0 bs=512 seek=1 count=1 - dd if=/mnt/$ISO of=/dev/fd0 bs=1 count=$sz seek=2 \ + echo "$ISO" | ddq of=/dev/fd0 bs=512 seek=1 count=1 + ddq if=/mnt/$ISO of=/dev/fd0 bs=1 count=$sz seek=2 \ skip=$(( $(get 66 /mnt/$ISO) - $sz + 512 )) } usbdev() { + echo "Wait 5 seconds for USB devices..." sleep 5 DEV="$(grep -l 1 /sys/block/*/removable | \ sed 's|/sys/block/\(.*\)/removable|\1|')" - [ -n "$DEV" ] || return + [ "$DEV" ] || return exec 3>&1 device=`$DIALOG --clear \ --title " Select your USB key " \ @@ -499,14 +510,51 @@ --title " Create a USB boot key " \ --yes-label "Continue" --yesno \ "\nThe USB key will be used like a CD-ROM. You will not be able to write -any data on it.\n\n +any data on the boot partition.\n\n +An extra FAT32 partition will be created with the remaining free space.\n\n You should choose 'USB key read/write installation' to be able to save the package updates or your own configuration and data files.\n\n Please plug your USB stick in now.\n -" 13 70 +" 16 70 [ $? -eq 0 ] || return usbdev || return - dd if=/mnt/$ISO of=$device + + # perform dd in progess bar + max=$(($(stat -c %s /mnt/$ISO)/1024/1024)) + mkfifo /tmp/fifodd + dialog --gauge " The ISO image transfer can be long. Please wait..." \ + 6 70 0 < /tmp/fifodd & + i=0; ddq if=/mnt/$ISO bs=1024k | ( + while ddq bs=1024k count=1 ; do + i=$(($i + 1)) + [ $i -gt $max ] && break + echo $((($i*100)/$max)) > /tmp/fifodd + done ) > $device + + # partition + fat32 format for the remining space + od -j 466 -N 12 -t u2 -An $device | { read dx cx ol oh ll lh + if [ $dx -eq $((0x3F17)) ]; then + cx=$(($cx & 0xFF00)) + ofs=$(($ll+($lh<<16))) + n=$(($(cat /sys/block/${device#/dev/}/size)-$ofs)) + m=$(($cx+($n/8))) + [ $m -gt $((0x3FF00)) ] && m=$((0x3FF00)) + m=$((($m & 0xFF00)+(($m>>16)<<6))) + words2bin 0 $((0x101+$cx)) 0x3F0B $((32+$m)) \ + $ll $lh $(($n & 0xFFFF)) $(($n >> 16)) | \ + ddq bs=1 seek=446 of=$device + if [ "$(which mkdosfs 2> /dev/null)" ]; then + losetup -o $((512*$ofs)) /dev/loop0 $device + mkdosfs -n "SLITAZ BOOT" /dev/loop0 + words2bin $(($ofs & 0xFFFF)) $(($ofs >> 16)) | \ + ddq bs=1 seek=28 of=/dev/loop0 + losetup -d /dev/loop0 + fi + fi ; } + + # kill dialog --gauge + sleep 1 + rm /tmp/fifodd } usbkey() @@ -630,7 +678,7 @@ cat > /tmp/dialog < $TMP/init.exe grep -q mount.posixovl.iso2exe $TMP/init.exe && cp /usr/sbin/mount.posixovl $TMP/bin/mount.posixovl.iso2exe \ - 2> /dev/null && echo "Store mount.posixovl..." + 2> /dev/null && echo "Store mount.posixovl ($(wc -c \ + < /usr/sbin/mount.posixovl) bytes) ..." find $TMP -type f -print0 | xargs -0 chmod +x ( cd $TMP ; find * | cpio -o -H newc ) | \ lzma e $TMP/rootfs.gz -si 2> /dev/null SIZE=$(wc -c < $TMP/rootfs.gz) store 24 $SIZE $1 OFS=$(( $OFS - $SIZE )) - printf "Adding rootfs.gz file at %04X...\n" $OFS + printf "Adding rootfs.gz file at %04X (%d bytes) ...\n" $OFS $SIZE cat $TMP/rootfs.gz | ddq of=$1 bs=1 seek=$OFS conv=notrunc rm -rf $TMP } @@ -41,7 +42,7 @@ add_dosexe() { OFS=$((0x7EE0)) - printf "Adding DOS/EXE at %04X...\n" $OFS + printf "Adding DOS/EXE at %04X (%d bytes) ...\n" $OFS $((0x8000 - $OFS)) $0 --get bootiso.bin 2> /dev/null | \ ddq bs=1 skip=$OFS of=$1 seek=$OFS conv=notrunc } @@ -50,16 +51,16 @@ { SIZE=$($0 --get boot.com | wc -c) OFS=$(( $OFS - $SIZE )) - printf "Adding DOS boot file at %04X...\n" $OFS + printf "Adding DOS boot file at %04X (%d bytes) ...\n" $OFS $SIZE $0 --get boot.com | ddq of=$1 bs=1 seek=$OFS conv=notrunc store 66 $(($OFS+0xC0)) $1 } add_win32exe() { - printf "Adding WIN32 file at %04X...\n" 0 ddq if=/tmp/exe$$ of=$1 conv=notrunc SIZE=$($0 --get win32.exe 2> /dev/null | tee /tmp/exe$$ | wc -c) + printf "Adding WIN32 file at %04X (%d bytes) ...\n" 0 $SIZE ddq if=/tmp/exe$$ of=$1 conv=notrunc printf "Adding bootiso head at %04X...\n" 0 $0 --get bootiso.bin 2> /dev/null > /tmp/exe$$ @@ -73,7 +74,7 @@ store 69 $(($SIZE/512)) $1 8 store 510 $((0xAA55)) $1 rm -f /tmp/exe$$ /tmp/coff$$ - printf "Moving syslinux hybrid boot record at %04X ...\n" $SIZE + printf "Moving syslinux hybrid boot record at %04X (512 bytes) ...\n" $SIZE ddq if=$2 bs=1 count=512 of=$1 seek=$SIZE conv=notrunc OFS=$(($SIZE+512)) } @@ -82,13 +83,14 @@ { SIZE=$($0 --get bootfd.bin 2> /dev/null | wc -c) if [ $SIZE -ne 0 ]; then - OFS=$(( $OFS - $SIZE + 512 )) - printf "Adding floppy bootstrap file at %04X...\n" $OFS + SIZE=$(( $SIZE - 512 )) # sector 2 is data + OFS=$(( $OFS - $SIZE )) + printf "Adding floppy bootstrap file at %04X (%d bytes) ...\n" $OFS $SIZE $0 --get bootfd.bin | \ ddq of=$1 bs=1 count=512 seek=$OFS conv=notrunc $0 --get bootfd.bin | \ ddq of=$1 bs=1 skip=1024 seek=$((512 + $OFS)) conv=notrunc - store 28 $(($SIZE/512 - 1)) $1 8 + store 28 $(($SIZE/512)) $1 8 fi } case "$1" in @@ -206,15 +208,17 @@ ddq if=$1 bs=512 count=1 of=/tmp/hybrid$$ ddq if=$1 bs=512 skip=2 count=20 of=/tmp/tazlito$$ add_win32exe $1 /tmp/hybrid$$ - printf "Moving tazlito data record at %04X ...\n" $OFS + printf "Moving tazlito data record at %04X (512 bytes) ...\n" $OFS ddq if=/tmp/tazlito$$ bs=1 count=512 of=$1 seek=$OFS conv=notrunc rm -f /tmp/tazlito$$ /tmp/hybrid$$ + HOLE=$(($OFS+512)) # keep the largest room for the tazlito info file add_dosexe $1 add_rootfs $1 add_doscom $1 add_fdbootstrap $1 + printf "%d free bytes in %04X..%04X\n" $(($OFS-$HOLE)) $HOLE $OFS store 26 ${RANDOM:-0} $1 i=66 n=0