[util] Detect genisoimage as mkisofs replacement
[gpxe.git] / src / util / geniso
blob3804c8e72156e7b88343d203fa8a5340be64fb28
1 #!/bin/bash
3 # Generate a isolinux ISO boot image
5 # geniso foo.iso foo.lkrn
7 # the ISO image is the first argument so that a list of .lkrn images
8 # to include can be specified
10 case $# in
11 0|1)
12 echo Usage: $0 foo.iso foo.lkrn ...
13 exit 1
15 esac
17 # This should be the default location of the isolinux.bin file
18 isolinux_bin=${ISOLINUX_BIN:-util/isolinux.bin}
19 if [ ! -r $isolinux_bin ]
20 then
21 echo $0: $isolinux_bin not found, please install, or set ISOLINUX_BIN in arch/i386/Makefile correctly
22 exit 1
25 # There should either be mkisofs or the compatible genisoimage program
26 mkisofs=`which mkisofs genisoimage | head -n1`
27 if [ -z $mkisofs ]
28 then
29 echo $0: mkisofs or genisoimage not found, please install or set PATH
30 exit 1
33 out=$1
34 shift
35 dir=`mktemp -d bin/iso.dir.XXXXXX`
36 cfg=$dir/isolinux.cfg
37 cp -p $isolinux_bin $dir
38 cat > $cfg <<EOF
39 # These default options can be changed in the geniso script
40 SAY Etherboot ISO boot image generated by geniso
41 TIMEOUT 30
42 EOF
43 first=
44 for f
46 if [ ! -r $f ]
47 then
48 echo $f does not exist, skipping 1>&2
49 continue
51 b=$(basename $f)
52 g=${b%.lkrn}
53 g=${g//[^a-z0-9]}.krn
54 case "$first" in
55 "")
56 echo DEFAULT $g
58 esac
59 first=$g
60 echo LABEL $b
61 echo "" KERNEL $g
62 cp -p $f $dir/$g
63 done >> $cfg
64 $mkisofs -quiet -l -o $out -c boot.cat -b isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table $dir
65 rm -fr $dir