From 392149d9c4aa18bfdb66afb72b1fced5d57e87d1 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Mon, 3 Dec 2012 23:18:27 +0100 Subject: [PATCH] [scripts] move GRUB2 Live directory from /boot/grub to /boot/sabayon This is not /boot/grub for a very good reason: Our Live media uses /boot/sabayon instead of /boot/grub and this has also the side effect that we can put /boot/sabayon into the EFI Boot Partition avoiding name clashing. Our /boot/sabayon inside that partition will contain a simple grub.cfg doing two things: 1. set the correct prefix to the real grub boot partition (via set prefix=(hdX,X)/boot/grub 2. load the real grub.cfg file (via configfile (hdX,X)/...) In this way, we can ship a SecureBoot signed grubx64.efi file and have it working with all the partition layouts. The "bootstrap" grub.cfg file is created by our scripts that are sourced by grub-mkconfig. --- boot/core/boot/{grub => sabayon}/grub.cfg | 10 ++++----- remaster/hardenedserver_grub.cfg | 10 ++++----- remaster/minimal_amd64_x86_grub.cfg | 10 ++++----- remaster/minimal_grub.cfg | 10 ++++----- remaster/serverbase_grub.cfg | 10 ++++----- remaster/standard_grub.cfg | 10 ++++----- scripts/_generate_grub_langs.py | 4 ++-- scripts/amd64_x86_pre_iso_script.sh | 2 +- scripts/generic_pre_iso_script.sh | 2 +- scripts/make_grub_efi.sh | 25 ++++++++++++++++++++--- scripts/spinbase_pre_iso_script.sh | 2 +- 11 files changed, 57 insertions(+), 38 deletions(-) rename boot/core/boot/{grub => sabayon}/grub.cfg (91%) diff --git a/boot/core/boot/grub/grub.cfg b/boot/core/boot/sabayon/grub.cfg similarity index 91% rename from boot/core/boot/grub/grub.cfg rename to boot/core/boot/sabayon/grub.cfg index 34806e6..172f628 100644 --- a/boot/core/boot/grub/grub.cfg +++ b/boot/core/boot/sabayon/grub.cfg @@ -3,7 +3,7 @@ set default=0 set fallback=2 set pager=1 -if loadfont /boot/grub/unicode.pf2 ; then +if loadfont /boot/sabayon/unicode.pf2 ; then set gfxmode=auto insmod efi_gop insmod efi_uga @@ -12,9 +12,9 @@ if loadfont /boot/grub/unicode.pf2 ; then insmod gettext fi -if [ -f /boot/grub/default-splash.png ]; then +if [ -f /boot/sabayon/default-splash.png ]; then insmod png - background_image -m stretch /boot/grub/default-splash.png + background_image -m stretch /boot/sabayon/default-splash.png fi if [ x$bootlang = x ]; then @@ -72,14 +72,14 @@ submenu "Advanced Options" { echo "Disabling Kernel Mode Setting..." set modeset_opt="nomodeset" export modeset_opt - configfile /boot/grub/grub.cfg + configfile /boot/sabayon/grub.cfg } menuentry "Disable ACPI" { echo "Disabling ACPI..." set acpi_opt="nomodeset" export acpi_opt - configfile /boot/grub/grub.cfg + configfile /boot/sabayon/grub.cfg } menuentry "Debug mode" { diff --git a/remaster/hardenedserver_grub.cfg b/remaster/hardenedserver_grub.cfg index ef76215..d70c92b 100644 --- a/remaster/hardenedserver_grub.cfg +++ b/remaster/hardenedserver_grub.cfg @@ -3,7 +3,7 @@ set default=0 set fallback=2 set pager=1 -if loadfont /boot/grub/unicode.pf2 ; then +if loadfont /boot/sabayon/unicode.pf2 ; then set gfxmode=auto insmod efi_gop insmod efi_uga @@ -12,9 +12,9 @@ if loadfont /boot/grub/unicode.pf2 ; then insmod gettext fi -if [ -f /boot/grub/default-splash.png ]; then +if [ -f /boot/sabayon/default-splash.png ]; then insmod png - background_image -m stretch /boot/grub/default-splash.png + background_image -m stretch /boot/sabayon/default-splash.png fi if [ x$bootlang = x ]; then @@ -82,14 +82,14 @@ submenu "Advanced Options" { echo "Disabling Kernel Mode Setting..." set modeset_opt="nomodeset" export modeset_opt - configfile /boot/grub/grub.cfg + configfile /boot/sabayon/grub.cfg } menuentry "Disable ACPI" { echo "Disabling ACPI..." set acpi_opt="nomodeset" export acpi_opt - configfile /boot/grub/grub.cfg + configfile /boot/sabayon/grub.cfg } menuentry "Debug mode" { diff --git a/remaster/minimal_amd64_x86_grub.cfg b/remaster/minimal_amd64_x86_grub.cfg index c602e79..3cdbcf2 100644 --- a/remaster/minimal_amd64_x86_grub.cfg +++ b/remaster/minimal_amd64_x86_grub.cfg @@ -3,7 +3,7 @@ set default=0 set fallback=2 set pager=1 -if loadfont /boot/grub/unicode.pf2 ; then +if loadfont /boot/sabayon/unicode.pf2 ; then set gfxmode=auto insmod efi_gop insmod efi_uga @@ -12,9 +12,9 @@ if loadfont /boot/grub/unicode.pf2 ; then insmod gettext fi -if [ -f /boot/grub/default-splash.png ]; then +if [ -f /boot/sabayon/default-splash.png ]; then insmod png - background_image -m stretch /boot/grub/default-splash.png + background_image -m stretch /boot/sabayon/default-splash.png fi if [ x$bootlang = x ]; then @@ -142,14 +142,14 @@ submenu "Advanced Options" { echo "Disabling Kernel Mode Setting..." set modeset_opt="nomodeset" export modeset_opt - configfile /boot/grub/grub.cfg + configfile /boot/sabayon/grub.cfg } menuentry "Disable ACPI" { echo "Disabling ACPI..." set acpi_opt="nomodeset" export acpi_opt - configfile /boot/grub/grub.cfg + configfile /boot/sabayon/grub.cfg } menuentry "Debug mode (x86_64)" { diff --git a/remaster/minimal_grub.cfg b/remaster/minimal_grub.cfg index b23c7ef..7fe0a6e 100644 --- a/remaster/minimal_grub.cfg +++ b/remaster/minimal_grub.cfg @@ -3,7 +3,7 @@ set default=0 set fallback=2 set pager=1 -if loadfont /boot/grub/unicode.pf2 ; then +if loadfont /boot/sabayon/unicode.pf2 ; then set gfxmode=auto insmod efi_gop insmod efi_uga @@ -12,9 +12,9 @@ if loadfont /boot/grub/unicode.pf2 ; then insmod gettext fi -if [ -f /boot/grub/default-splash.png ]; then +if [ -f /boot/sabayon/default-splash.png ]; then insmod png - background_image -m stretch /boot/grub/default-splash.png + background_image -m stretch /boot/sabayon/default-splash.png fi if [ x$bootlang = x ]; then @@ -83,14 +83,14 @@ submenu "Advanced Options" { echo "Disabling Kernel Mode Setting..." set modeset_opt="nomodeset" export modeset_opt - configfile /boot/grub/grub.cfg + configfile /boot/sabayon/grub.cfg } menuentry "Disable ACPI" { echo "Disabling ACPI..." set acpi_opt="nomodeset" export acpi_opt - configfile /boot/grub/grub.cfg + configfile /boot/sabayon/grub.cfg } menuentry "Debug mode" { diff --git a/remaster/serverbase_grub.cfg b/remaster/serverbase_grub.cfg index cd6798e..23e9e48 100644 --- a/remaster/serverbase_grub.cfg +++ b/remaster/serverbase_grub.cfg @@ -3,7 +3,7 @@ set default=0 set fallback=2 set pager=1 -if loadfont /boot/grub/unicode.pf2 ; then +if loadfont /boot/sabayon/unicode.pf2 ; then set gfxmode=auto insmod efi_gop insmod efi_uga @@ -12,9 +12,9 @@ if loadfont /boot/grub/unicode.pf2 ; then insmod gettext fi -if [ -f /boot/grub/default-splash.png ]; then +if [ -f /boot/sabayon/default-splash.png ]; then insmod png - background_image -m stretch /boot/grub/default-splash.png + background_image -m stretch /boot/sabayon/default-splash.png fi if [ x$bootlang = x ]; then @@ -71,14 +71,14 @@ submenu "Advanced Options" { echo "Disabling Kernel Mode Setting..." set modeset_opt="nomodeset" export modeset_opt - configfile /boot/grub/grub.cfg + configfile /boot/sabayon/grub.cfg } menuentry "Disable ACPI" { echo "Disabling ACPI..." set acpi_opt="nomodeset" export acpi_opt - configfile /boot/grub/grub.cfg + configfile /boot/sabayon/grub.cfg } menuentry "Debug mode" { diff --git a/remaster/standard_grub.cfg b/remaster/standard_grub.cfg index 04cd476..eed4312 100644 --- a/remaster/standard_grub.cfg +++ b/remaster/standard_grub.cfg @@ -3,7 +3,7 @@ set default=0 set fallback=2 set pager=1 -if loadfont /boot/grub/unicode.pf2 ; then +if loadfont /boot/sabayon/unicode.pf2 ; then set gfxmode=auto insmod efi_gop insmod efi_uga @@ -12,9 +12,9 @@ if loadfont /boot/grub/unicode.pf2 ; then insmod gettext fi -if [ -f /boot/grub/default-splash.png ]; then +if [ -f /boot/sabayon/default-splash.png ]; then insmod png - background_image -m stretch /boot/grub/default-splash.png + background_image -m stretch /boot/sabayon/default-splash.png fi if [ x$bootlang = x ]; then @@ -101,14 +101,14 @@ submenu "Advanced Options" { echo "Disabling Kernel Mode Setting..." set modeset_opt="nomodeset" export modeset_opt - configfile /boot/grub/grub.cfg + configfile /boot/sabayon/grub.cfg } menuentry "Disable ACPI" { echo "Disabling ACPI..." set acpi_opt="nomodeset" export acpi_opt - configfile /boot/grub/grub.cfg + configfile /boot/sabayon/grub.cfg } menuentry "Debug mode" { diff --git a/scripts/_generate_grub_langs.py b/scripts/_generate_grub_langs.py index 608c12d..488f5d5 100755 --- a/scripts/_generate_grub_langs.py +++ b/scripts/_generate_grub_langs.py @@ -84,7 +84,7 @@ for keymap, lang, name in langs: set bootlang=%(lang)s export bootlang export lang - configfile /boot/grub/grub.cfg + configfile /boot/sabayon/grub.cfg } """ % {'name': name, 'lang': lang,}) @@ -102,7 +102,7 @@ for keymap, lang, name in langs: echo "Switching to: $chosen" set bootkeymap=%(keymap)s export bootkeymap - configfile /boot/grub/grub.cfg + configfile /boot/sabayon/grub.cfg } """ % {'name': name, 'keymap': keymap,}) diff --git a/scripts/amd64_x86_pre_iso_script.sh b/scripts/amd64_x86_pre_iso_script.sh index f4a9eac..9901c4c 100755 --- a/scripts/amd64_x86_pre_iso_script.sh +++ b/scripts/amd64_x86_pre_iso_script.sh @@ -32,7 +32,7 @@ if [ ! -f "${other_iso_path}" ]; then fi isolinux_destination="${CDROOT_DIR}/isolinux/txt.cfg" -grub_destination="${CDROOT_DIR}/boot/grub/grub.cfg" +grub_destination="${CDROOT_DIR}/boot/sabayon/grub.cfg" isolinux_source="${SABAYON_MOLECULE_HOME}/remaster/minimal_amd64_x86_isolinux.cfg" grub_source="${SABAYON_MOLECULE_HOME}/remaster/minimal_amd64_x86_grub.cfg" cp "${isolinux_source}" "${isolinux_destination}" || exit 1 diff --git a/scripts/generic_pre_iso_script.sh b/scripts/generic_pre_iso_script.sh index 547d5b6..f0f5b2c 100755 --- a/scripts/generic_pre_iso_script.sh +++ b/scripts/generic_pre_iso_script.sh @@ -14,7 +14,7 @@ remaster_type="${1}" isolinux_source="${SABAYON_MOLECULE_HOME}/remaster/minimal_isolinux.cfg" grub_source="${SABAYON_MOLECULE_HOME}/remaster/minimal_grub.cfg" isolinux_destination="${CDROOT_DIR}/isolinux/txt.cfg" -grub_destination="${CDROOT_DIR}/boot/grub/grub.cfg" +grub_destination="${CDROOT_DIR}/boot/sabayon/grub.cfg" if [ "${remaster_type}" = "KDE" ] || [ "${remaster_type}" = "GNOME" ]; then isolinux_source="${SABAYON_MOLECULE_HOME}/remaster/standard_isolinux.cfg" diff --git a/scripts/make_grub_efi.sh b/scripts/make_grub_efi.sh index e54c039..92c2fa1 100755 --- a/scripts/make_grub_efi.sh +++ b/scripts/make_grub_efi.sh @@ -11,7 +11,22 @@ export SABAYON_MOLECULE_HOME MOUNT_DIRS=() EFI_BOOT_DIR="${CDROOT_DIR}/efi/boot" -GRUB_BOOT_DIR_PREFIX="/boot/grub" +# This is not /boot/grub for a very good reason: +# Our Live media uses /boot/sabayon instead of /boot/grub +# and this has also the side effect that we can put +# /boot/sabayon into the EFI Boot Partition avoiding +# name clashing. Our /boot/sabayon inside that partition +# will contain a simple grub.cfg doing two things: +# +# 1. set the correct prefix to the real grub boot partition +# (via set prefix=(hdX,X)/boot/grub +# 2. load the real grub.cfg file (via configfile (hdX,X)/...) +# +# In this way, we can ship a SecureBoot signed grubx64.efi +# file and have it working with all the partition layouts. +# The "bootstrap" grub.cfg file is created by our scripts +# that are sourced by grub-mkconfig. +GRUB_BOOT_DIR_PREFIX="/boot/sabayon" GRUB_LOCALE_DIR_PREFIX="${GRUB_BOOT_DIR_PREFIX}/locale" GRUB_BOOT_DIR="${CDROOT_DIR}${GRUB_BOOT_DIR_PREFIX}" GRUB_LOCALE_DIR="${CDROOT_DIR}${GRUB_LOCALE_DIR_PREFIX}" @@ -41,7 +56,9 @@ if [ -d "${x86_64_EFI_DIR}" ]; then -p "${GRUB_BOOT_DIR_PREFIX}" \ -d "${x86_64_EFI_DIR_PREFIX}" \ -o /bootx64.efi \ - -O x86_64-efi ext2 fat lvm part_msdos part_gpt search_fs_uuid normal chain iso9660 \ + -O x86_64-efi ext2 fat lvm part_msdos \ + part_gpt search_fs_uuid normal \ + chain iso9660 configfile loadenv \ || exit 1 mv "${CHROOT_DIR}"/bootx64.efi "${EFI_BOOT_DIR}/" || exit 1 cp -Rp "${x86_64_EFI_DIR}" "${GRUB_BOOT_DIR}/" || exit 1 @@ -52,7 +69,9 @@ if [ -d "${i386_EFI_DIR}" ]; then -p "${GRUB_BOOT_DIR_PREFIX}" \ -d "${i386_EFI_DIR_PREFIX}" \ -o /boota32.efi \ - -O i386-efi ext2 fat lvm part_msdos part_gpt search_fs_uuid normal chain iso9660 \ + -O i386-efi ext2 fat lvm part_msdos \ + part_gpt search_fs_uuid normal \ + chain iso9660 configfile loadenv \ || exit 1 mv "${CHROOT_DIR}"/boota32.efi "${EFI_BOOT_DIR}/" || exit 1 cp -Rp "${i386_EFI_DIR}" "${GRUB_BOOT_DIR}/" || exit 1 diff --git a/scripts/spinbase_pre_iso_script.sh b/scripts/spinbase_pre_iso_script.sh index 0747f14..e8db71b 100755 --- a/scripts/spinbase_pre_iso_script.sh +++ b/scripts/spinbase_pre_iso_script.sh @@ -42,7 +42,7 @@ ver=${RELEASE_VERSION} isolinux_dest="${CDROOT_DIR}/isolinux/txt.cfg" isolinux_dest_txt="${CDROOT_DIR}/isolinux/isolinux.txt" -grub_dest="${CDROOT_DIR}/boot/grub/grub.cfg" +grub_dest="${CDROOT_DIR}/boot/sabayon/grub.cfg" for path in "${isolinux_dest}" "${isolinux_dest_txt}" "${grub_dest}"; do sed -i "s/__VERSION__/${ver}/g" "${path}" || exit 1