summaryrefslogtreecommitdiff
path: root/src/grub-efi.sh
blob: 611e85f1b00e22bd90ceb71064d6293238b4ca7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
. samizdat-paths.sh

linux_kernel_commandline='boot=samizdat components quiet nbdroot=192.168.10.1/samizdat.btrfs nbddev=/dev/nbd0 ip=dhcp'

grub_config()
{
    cat <<EOF
insmod echo
echo GRUB

insmod normal
insmod keystatus

insmod linux
insmod iso9660

insmod part_acorn
insmod part_amiga
insmod part_apple
insmod part_bsd
insmod part_dvh
insmod part_gpt
insmod part_msdos
insmod part_plan
insmod part_sun
insmod part_sunpc

echo Loading vmlinuz...

linux /linux/vmlinuz ${linux_kernel_commandline}

echo Loading initrd.img...
initrd /linux/initrd.img

echo Booting.
echo
boot

EOF
}

real_destdir=$samizdat_grub_efi_dir
[ "$real_destdir" ] || exit 1
destdir=$real_destdir.tmp

set -e
rm -r "${destdir}" 2>/dev/null || true
mkdir -p "${destdir}"/grub/i386-pc/
cp -r /usr/lib/grub/i386-pc/*  "${destdir}"/grub/i386-pc/
rm "${destdir}"/grub/i386-pc/*.img || true

grub_config > "${destdir}"/load_cfg

grub-mkimage -O i386-pc -d /usr/lib/grub/i386-pc/ -o "${destdir}"/core.img -c "${destdir}"/load_cfg  --prefix=/grub iso9660 biosdisk
cat /usr/lib/grub/i386-pc/cdboot.img "${destdir}"/core.img > "${destdir}"/grub/i386-pc/eltorito.img
cat /usr/lib/grub/i386-pc/boot.img "${destdir}"/core.img > "${destdir}"/embedded.img

rm -r "$real_destdir" 2>/dev/null || true
mv -T "$destdir" "$real_destdir"