You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gensdsk 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/bash
  2. #
  3. # Generate a syslinux floppy that loads a iPXE image
  4. #
  5. # gensdsk foo.sdsk foo.lkrn
  6. #
  7. # the floppy image is the first argument
  8. # followed by list of .lkrn images
  9. #
  10. case $# in
  11. 0|1)
  12. echo Usage: $0 foo.sdsk foo.lkrn ...
  13. exit 1
  14. ;;
  15. esac
  16. case "`mtools -V`" in
  17. Mtools\ version\ 3.9.9*|Mtools\ version\ 3.9.1[0-9]*|[mM]tools\ *\ [4-9].*)
  18. ;;
  19. *)
  20. echo Mtools version 3.9.9 or later is required
  21. exit 1
  22. ;;
  23. esac
  24. img=$1
  25. shift
  26. dir=`mktemp -d bin/sdsk.dir.XXXXXX`
  27. mformat -f 1440 -C -i $img ::
  28. cfg=$dir/syslinux.cfg
  29. cat > $cfg <<EOF
  30. # These default options can be changed in the gensdsk script
  31. TIMEOUT 30
  32. EOF
  33. first=
  34. for f
  35. do
  36. if [ ! -r $f ]
  37. then
  38. echo $f does not exist, skipping 1>&2
  39. continue
  40. fi
  41. # shorten name for 8.3 filesystem
  42. b=$(basename $f)
  43. g=${b%.lkrn}
  44. g=${g//[^a-z0-9]}
  45. g=${g:0:8}.krn
  46. case "$first" in
  47. "")
  48. echo DEFAULT $g
  49. ;;
  50. esac
  51. first=$g
  52. echo LABEL $b
  53. echo "" KERNEL $g
  54. mcopy -m -i $img $f ::$g
  55. done >> $cfg
  56. mcopy -i $img $cfg ::syslinux.cfg
  57. if ! syslinux $img
  58. then
  59. exit 1
  60. fi
  61. rm -fr $dir