summarylogtreecommitdiffstats
path: root/80_plop6boot
blob: ef9908c529be4300200787b5ac9ab857908ac1ed (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
#!/usr/bin/env bash
########################################################
# This script generates a pbm6 entry on grub.cfg       #
# Based on the 60_memtest86+ 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

PLPBT_LINUX_IMAGE="/boot/plop/linux/pbm6"
PLPBT_EFI_IMAGE="/boot/EFI/plop/pbm6-x64.efi"
CLASS="--class plop --class pbm6 --class tool"

if [ -e "${PLPBT_LINUX_IMAGE}" ] && is_path_readable_by_grub "${PLPBT_LINUX_IMAGE}" ; then
    ## Linux image exists, create menu entry
    echo "Found Plop Boot Manager 6 Linux image: ${PLPBT_LINUX_IMAGE}" >&2
    _GRUB_PLOP_HINTS_STRING="$(${grub_probe} --target=hints_string ${PLPBT_LINUX_IMAGE})"
    _GRUB_PLOP_FS_UUID="$(${grub_probe} --target=fs_uuid ${PLPBT_LINUX_IMAGE})"
    _GRUB_PLOP_REL_PATH="$(make_system_path_relative_to_its_root ${PLPBT_LINUX_IMAGE})"
    cat << EOF
if [ "\${grub_platform}" == "pc" ]; then
  menuentry "Plop Boot Manager 6" ${CLASS} {
      insmod part_gpt
      insmod fat
      search --fs-uuid --no-floppy --set=root ${_GRUB_PLOP_HINTS_STRING} ${_GRUB_PLOP_FS_UUID}
      linux ${_GRUB_PLOP_REL_PATH} ${GRUB_CMDLINE_PLPBT}
  }
fi
EOF
fi

if [ -e "${PLPBT_EFI_IMAGE}" ] && is_path_readable_by_grub "${PLPBT_EFI_IMAGE}" ; then
    ## EFI image exists, create menu entry
    echo "Found Plop Boot Manager 6 EFI image: ${PLPBT_EFI_IMAGE}" >&2
    _GRUB_PLOP_HINTS_STRING="$(${grub_probe} --target=hints_string ${PLPBT_EFI_IMAGE})"
    _GRUB_PLOP_FS_UUID="$(${grub_probe} --target=fs_uuid ${PLPBT_EFI_IMAGE})"
    _GRUB_PLOP_REL_PATH="$(make_system_path_relative_to_its_root ${PLPBT_EFI_IMAGE})"
    cat << EOF
if [ "\${grub_platform}" == "efi" ]; then
    menuentry "Plop Boot Manager 6" ${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