Fixed R_386_PC32 relocations
[marionette.git] / tools / make-cd.sh
blob2572718fd3aa4d89e3d2a3d8d53fb1b5cce8a946
1 #!/usr/bin/env sh
2 # Make a Marionette CD image
4 KERNEL=build/kernel/kernel.elf
5 MODS="build/kernel/testmodule.ko"
6 CDDIR=cdrom
7 GRUBDIR=/usr/lib/grub/i386-pc
8 OUTPUT=cdrom.iso
10 # create directory if it doesn't exist - die on failure
11 mkdir_e(){
12 [ -d "$1" ] || mkdir -v "$1" || die "failed to create directory $1"
15 die(){
16 echo $*
17 exit 1
20 [ "$1" == "--help" ] && {
21 echo "Usage: $0"
22 echo "(This command takes no arguments)"
23 echo ""
24 echo "Creates a bootable CD image for Marionette."
25 echo "Requires mkisofs and GRUB"
26 echo ""
27 echo "Please edit this script to alter the settings."
28 echo ""
29 echo "CD-ROM directory: $CDDIR"
30 echo "GRUB files in: $GRUBDIR"
31 echo "Kernel image: $KERNEL"
32 echo "Output ISO image: $OUTPUT"
33 exit 0
36 mkdir_e "$CDDIR"
37 mkdir_e "$CDDIR/boot"
38 mkdir_e "$CDDIR/boot/grub"
40 if [ ! -f "$CDDIR/boot/grub/stage2_eltorito" ]
41 then
42 STAGE2="$GRUBDIR/stage2_eltorito"
43 if [ -f "$STAGE2" -a -r "$STAGE2" ]
44 then
45 cp -v "$GRUBDIR/stage2_eltorito" "$CDDIR/boot/grub/" || die "failed to copy $STAGE2"
46 else
47 # try to download it
48 echo "$STAGE2 does not exist, is not a file, or is not readable. Attempting to download it."
49 wget "http://xlq-experiment.com/marionette/res/stage2_eltorito" -O "$CDDIR/boot/grub/stage2_eltorito" \
50 || die "$STAGE2 does not exist, and I couldn't download it."
54 # install a file into the CD image
55 insfile(){
56 [ -f "$1" ] || die "$1 does not exist. Maybe you forgot to build it?"
57 cp -v "$1" "$CDDIR/boot/" || die "could not install $1"
60 insfile "$KERNEL"
62 for i in $MODS
64 insfile "$i"
65 done
67 cat > "$CDDIR/boot/grub/menu.lst" << EOF
68 default 0
69 timeout 3
71 title Marionette
72 kernel /boot/kernel.elf
73 module /boot/testmodule.ko
75 title Boot from hard disk
76 chainloader (hd0)+1
77 EOF
79 mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 \
80 -boot-info-table -A "Marionette CD" -o "$OUTPUT" "$CDDIR" \
81 || die "failed to create the CD image"
83 echo "Your CD image ($OUTPUT) awaits."