Secure Boot support
[grml-live.git] / etc / grml / fai / config / scripts / GRMLBASE / 45-grub-images
1 #!/bin/bash
2 # Filename:      ${GRML_FAI_CONFIG}/config/scripts/GRMLBASE/45-grub-images
3 # Purpose:       create grub images for use in ISO
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2 or any later version.
7 ################################################################################
8
9 set -e
10 set -u
11
12 TMP_CONFIG="/tmp/grub_config_efi"
13
14 cat > "${target}/${TMP_CONFIG}" <<EOF
15 search.file /conf/bootid.txt root
16 set prefix=(\$root)/boot/grub
17 insmod normal
18 normal
19 echo "E: Could not find root device!"
20 EOF
21
22 ARCHS=(i386-pc)
23 declare -A ADDITIONAL_MODULES
24 ADDITIONAL_MODULES[i386-pc]="biosdisk"
25
26 if ifclass AMD64 ; then
27   if [ -r "${target}"/usr/lib/grub/x86_64-efi/moddep.lst ] ; then
28     ARCHS+=(x86_64-efi)
29     ADDITIONAL_MODULES[x86_64-efi]="efi_gop efi_uga"
30   else
31     echo "/usr/lib/grub/x86_64-efi/moddep.lst could not be found, skipping."
32     echo "NOTE: grub-efi-amd64-bin not installed?"
33   fi
34 fi
35
36 if ifclass I386 ; then
37   if [ -r "${target}"/usr/lib/grub/i386-efi/moddep.lst ] ; then
38     ARCHS+=(i386-efi)
39     ADDITIONAL_MODULES[i386-efi]="efi_gop efi_uga"
40   else
41     echo "/usr/lib/grub/i386-efi/moddep.lst could not be found, skipping."
42     echo "NOTE: grub-efi-ia32 not installed?"
43   fi
44 fi
45
46 for arch in "${ARCHS[@]}" ; do
47   filename=''
48   case "$arch" in
49     i386-pc)    filename=/boot/grub/grub.img ;;
50     x86_64-efi) filename=/boot/bootx64.efi   ;;
51     i386-efi)   filename=/boot/bootia32.efi  ;;
52   esac
53
54   $ROOTCMD grub-mkimage -O $arch -o "$filename" --prefix=/boot/grub/ --config="$TMP_CONFIG" \
55     echo iso9660 part_msdos search_fs_file test \
56     fat ext2 reiserfs xfs btrfs squash4 part_gpt lvm \
57     ${ADDITIONAL_MODULES[$arch]}
58 done
59
60 rm -f "${target}/${TMP_CONFIG}"
61 echo "Generated Grub images"
62
63 ## END OF FILE #################################################################
64 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2