summarylogtreecommitdiffstats
path: root/80_cloverboot
blob: 9e52031dd1ebeb920d8149e95b1a7b1c871ef8e8 (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
#!/usr/bin/env bash
########################################################
# This script generates a Clover entry on grub.cfg.    #
# Based on the 80_plop6boot grub script.               #
########################################################

prefix="/usr"
exec_prefix="${prefix}"

datarootdir="/usr/share"
datadir="${datarootdir}"

if [ -r "${datadir}/grub/grub-mkconfig_lib" ]; then
. "${datadir}/grub/grub-mkconfig_lib"
else
  printf '%s\n' "ERROR: Cannot source file '${datadir}/grub/grub-mkconfig_lib'." > /dev/stderr
  exit 1
fi

CLOVER_EFI_IMAGE="/boot/EFI/CLOVER/CLOVERX64.efi"
CLASS="--class clover --class tool"


if [ -e "${CLOVER_EFI_IMAGE}" ] && is_path_readable_by_grub "${CLOVER_EFI_IMAGE}" ; then
    ## EFI image exists, create menu entry
    echo "Found Clover EFI image: ${CLOVER_EFI_IMAGE}" >&2
    _GRUB_PLOP_HINTS_STRING="$(${grub_probe} --target=hints_string ${CLOVER_EFI_IMAGE})"
    _GRUB_PLOP_FS_UUID="$(${grub_probe} --target=fs_uuid ${CLOVER_EFI_IMAGE})"
    _GRUB_PLOP_REL_PATH="$(make_system_path_relative_to_its_root ${CLOVER_EFI_IMAGE})"
    cat << EOF
if [ "\${grub_platform}" == "efi" ]; then
    menuentry "Clover boot loader" ${CLASS} {
        insmod part_gpt
        insmod fat
        search --fs-uuid --no-floppy --set=root ${_GRUB_PLOP_HINTS_STRING} ${_GRUB_PLOP_FS_UUID}
        chainloader ${_GRUB_PLOP_REL_PATH} ${GRUB_CMDLINE_PLPBT}
    }
fi
EOF
fi