wok-current rev 4513

syslinux: add isohybrid (shell version)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Nov 26 16:44:48 2009 +0100 (2009-11-26)
parents a8ca1e0896fe
children 4ab9080e26aa
files syslinux-extra/receipt syslinux/receipt syslinux/stuff/tools/isohybrid.sh
line diff
     1.1 --- a/syslinux-extra/receipt	Wed Nov 25 10:51:12 2009 +0000
     1.2 +++ b/syslinux-extra/receipt	Thu Nov 26 16:44:48 2009 +0100
     1.3 @@ -12,15 +12,15 @@
     1.4  # Rules to gen a SliTaz package suitable for Tazpkg.
     1.5  genpkg_rules()
     1.6  {
     1.7 -    mkdir -p $fs/usr/share/boot
     1.8 +    mkdir -p $fs/usr/share/boot $fs/usr/bin $fs/bin
     1.9      lzma e $src/memdisk/memdisk $fs/usr/share/boot/memdisk.lzma 2> /dev/null
    1.10      cp -a $src/mbr/mbr.bin $fs/usr/share/boot
    1.11      lzma e $src/core/pxelinux.0 $fs/usr/share/boot/pxelinux.0.lzma 2> /dev/null
    1.12      #lzma e $src/com32/menu/vesamenu.c32 $fs/usr/share/boot/vesamenu.c32.lzma
    1.13      #lzma e $src/com32/modules/mboot.c32 $fs/usr/share/boot/mboot.c32.lzma
    1.14      cp $src/com32/modules/sdi.c32 $fs/usr/share/boot/
    1.15 -    mkdir -p $fs/bin
    1.16      cp -a $src/linux/syslinux-nomtools $fs/bin/syslinux
    1.17      cp -a $src/extlinux/extlinux $fs/bin
    1.18 +    cp -a $src/isohybrid.sh $fs/usr/bin/isohybrid
    1.19      chown root.root $fs/usr/share/boot/* $fs/bin/*
    1.20  }
     2.1 --- a/syslinux/receipt	Wed Nov 25 10:51:12 2009 +0000
     2.2 +++ b/syslinux/receipt	Thu Nov 26 16:44:48 2009 +0100
     2.3 @@ -16,11 +16,13 @@
     2.4  compile_rules()
     2.5  {
     2.6      cd $src
     2.7 +    cp ../stuff/tools/isohybrid.sh .
     2.8      cp ../stuff/tools/keytab-lilo.pl .
     2.9      cp ../stuff/extra/ifmem.c com32/modules
    2.10      grep -q ifmem.c32 com32/modules/Makefile ||
    2.11  	sed -i 's/ifcpu64.c32/ifcpu64.c32 ifmem.c32/' com32/modules/Makefile
    2.12      make -C com32
    2.13 +    ./isohybrid.sh --build
    2.14      for i in /usr/share/kbd/keymaps/i386/*/*.map.gz; do
    2.15          [ "$(basename $(dirname $i))" = "include" ] && continue
    2.16          j=$(basename $i)
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/syslinux/stuff/tools/isohybrid.sh	Thu Nov 26 16:44:48 2009 +0100
     3.3 @@ -0,0 +1,86 @@
     3.4 +#!/bin/sh
     3.5 +
     3.6 +build="--build"
     3.7 +if [ "$1" == "$build" ]; then
     3.8 +	cat  >> $0 <<EOM
     3.9 +$(uuencode -m mbr/isohdpfx.bin -)
    3.10 +EOT
    3.11 +EOM
    3.12 +	sed -i "/$build/{NNNNNNNNNd}" $0
    3.13 +	exit
    3.14 +fi
    3.15 +
    3.16 +if [ -z "$1" ]; then
    3.17 +	cat << EOT
    3.18 +usage: $0 isoimage
    3.19 +EOT
    3.20 +	exit 1
    3.21 +fi
    3.22 +iso=$1
    3.23 +heads=64	# zipdrive-style geometry
    3.24 +sectors=32
    3.25 +partype=23	# "Windows hidden IFS"
    3.26 +
    3.27 +readiso()
    3.28 +{
    3.29 +	dd if=$iso bs=2k skip=$1 count=1 2> /dev/null | \
    3.30 +	dd bs=1 skip=$2 count=$3 2> /dev/null
    3.31 +}
    3.32 +
    3.33 +# read a 32 bits data
    3.34 +readlong()
    3.35 +{
    3.36 +	readiso $1 $2 4  | hexdump -e '"" 1/4 "%d" "\n"'
    3.37 +}
    3.38 +
    3.39 +# write a 32 bits data
    3.40 +storelong()
    3.41 +{
    3.42 +	printf "00000  %02X %02X %02X %02X \n" \
    3.43 +		$(( $2 & 255 )) $(( ($2>>8) & 255 )) \
    3.44 +		$(( ($2>>16) & 255 )) $(( ($2>>24) & 255 )) | \
    3.45 +	hexdump -R | dd bs=1 conv=notrunc of=$iso seek=$(( $1 )) 2> /dev/null
    3.46 +}
    3.47 +
    3.48 +setmbr()
    3.49 +{
    3.50 +	uudecode | dd of=$iso conv=notrunc 2> /dev/null
    3.51 +	storelong 432 $(( $lba * 4 ))
    3.52 +	storelong 440 $(( ($RANDOM << 16) + $RANDOM ))
    3.53 +	storelong 446 $(( 0x80 + ( 1 << 16) ))
    3.54 +	esect=$(( $sectors + ((($cylinders -1) & 0x300) >> 2) ))
    3.55 +	ecyl=$(( ($cylinders - 1) & 0xff ))
    3.56 +	storelong 450 $(( $partype + (($heads - 1) << 8) + ($esect << 16) + ($ecyl <<24) ))
    3.57 +	storelong 458 $(( $cylinders * $heads * $sectors ))
    3.58 +	storelong 510 $(( 0xAA55 ))
    3.59 +}
    3.60 +
    3.61 +if [ "$(readiso 17 7 23)" != "EL TORITO SPECIFICATION" ]; then
    3.62 +	echo "$iso: no boot record found.";
    3.63 +	exit 1
    3.64 +fi
    3.65 +catalog=$(readlong 17 71)
    3.66 +if [ "$(readiso $catalog 0 32 | md5sum | awk '{ print $1 }')" != \
    3.67 +     "788e7bfdad52cc6aae525725f24a7f89" ]; then
    3.68 +	echo "$iso: invalid boot catalog.";
    3.69 +	exit 1
    3.70 +fi
    3.71 +lba=$(readlong $catalog 40)
    3.72 +if [ $(readlong $lba 64) -ne 1886961915 ]; then
    3.73 +	echo "$iso: bootloader does not have a isolinux.bin hybrid signature.";
    3.74 +	exit 1
    3.75 +fi
    3.76 +size=$(stat -c "%s" $iso)
    3.77 +pad=$(( $size % (512 * $heads * $sectors) ))
    3.78 +[ $pad -eq 0 ] || pad=$((  (512 * $heads * $sectors) - $pad ))
    3.79 +[ $pad -eq 0 ] || dd if=/dev/zero bs=512 count=$(( $pad / 512 )) >> $iso 2> /dev/null
    3.80 +cylinders=$(( ($size + $pad) / (512 * $heads * $sectors) ))
    3.81 +if [ $cylinders -gt 1024 ]; then
    3.82 +	cat 1>&2 <<EOT
    3.83 +Warning: more than 1024 cylinders ($cylinders).
    3.84 +Not all BIOSes will be able to boot this device.
    3.85 +EOT
    3.86 +	cylinders=1024
    3.87 +fi
    3.88 +
    3.89 +setmbr <<EOT