[build] Add syslinux floppy image type .sdsk
[gpxe.git] / src / util / genliso
blob17823841563bc08fe0976ae9339df3e2b2634e3d
1 #!/bin/bash
3 # Generate a legacy floppy emulation ISO boot image
5 # genliso foo.liso foo.lkrn bar.lkrn ...
7 # The .liso image filename is the first argument followed by
8 # a list of .lkrn images include in .liso image
10 case $# in
11 0|1)
12 echo Usage: $0 foo.liso foo.lkrn ...
13 exit 1
15 esac
17 case "`mtools -V`" in
18 Mtools\ version\ 3.9.9*|Mtools\ version\ 3.9.1[0-9]*|Mtools\ version\ 4.*)
21 echo Mtools version 3.9.9 or later is required
22 exit 1
24 esac
26 out=$1
27 shift
29 dir=bin/liso.dir
30 mkdir -p $dir
32 img=$dir/boot.img
33 mformat -f 1440 -C -i $img ::
35 cfg=bin/syslinux.cfg
36 cat > $cfg <<EOF
37 # These default options can be changed in the genliso script
38 SAY gPXE ISO boot image generated by genliso
39 TIMEOUT 30
40 EOF
42 first=
43 for f
45 if [ ! -r $f ]
46 then
47 echo $f does not exist, skipping 1>&2
48 continue
50 # shorten name for 8.3 filesystem
51 b=$(basename $f)
52 g=${b%.lkrn}
53 g=${g//[^a-z0-9]}
54 g=${g:0:8}.krn
55 case "$first" in
56 "")
57 echo DEFAULT $g
59 esac
60 first=$g
61 echo LABEL $b
62 echo "" KERNEL $g
63 mcopy -m -i $img $f ::$g
64 done >> $cfg
66 mcopy -i $img $cfg ::syslinux.cfg
68 if ! syslinux $img
69 then
70 exit 1
73 mkisofs -o $out -c boot.cat -b boot.img $dir
75 rm -fr $dir