1
1
#! /usr/bin/env bash
2
2
# This runs *after* user_config. Don't change anything not coming from other variables or meant to be configured by the user.
3
3
function extension_prepare_config__prepare_grub-riscv64() {
4
- display_alert " Prepare config" " ${EXTENSION} " " info"
4
+ display_alert " Extension: ${EXTENSION} : Prepare config" " ${EXTENSION} " " info"
5
5
# Extension configuration defaults.
6
6
declare -g DISTRO_GENERIC_KERNEL=${DISTRO_GENERIC_KERNEL:- no} # if yes, does not build our own kernel, instead, uses generic one from distro
7
7
declare -g UEFI_GRUB_TERMINAL=" ${UEFI_GRUB_TERMINAL:- serial console} " # 'serial' forces grub menu on serial console. empty to not include
@@ -20,7 +20,7 @@ function extension_prepare_config__prepare_grub-riscv64() {
20
20
declare -g UEFI_GRUB_TARGET=" riscv64-efi" # Default for x86_64
21
21
22
22
if [[ " ${DISTRIBUTION} " != " Ubuntu" && " ${BUILDING_IMAGE} " == " yes" ]]; then
23
- exit_with_error " ${DISTRIBUTION} is not supported yet"
23
+ exit_with_error " Extension: ${EXTENSION} : ${DISTRIBUTION} is not supported yet"
24
24
fi
25
25
26
26
add_packages_to_image efibootmgr efivar cloud-initramfs-growroot busybox os-prober " grub-efi-${ARCH} -bin" " grub-efi-${ARCH} "
@@ -32,10 +32,10 @@ pre_umount_final_image__install_grub() {
32
32
33
33
configure_grub
34
34
local chroot_target=" ${MOUNT} "
35
- display_alert " Installing bootloader" " GRUB" " info"
35
+ display_alert " Extension: ${EXTENSION} : Installing bootloader" " GRUB" " info"
36
36
37
37
# RiscV64 specific: actually copy the DTBs to the ESP
38
- display_alert " Copying DTBs to ESP" " ${EXTENSION} " " info"
38
+ display_alert " Extension: ${EXTENSION} : Copying DTBs to ESP" " ${EXTENSION} " " info"
39
39
run_host_command_logged mkdir -pv " ${chroot_target} " /boot/efi/dtb
40
40
run_host_command_logged cp -rpv " ${chroot_target} " /boot/dtb/* " ${chroot_target} " /boot/efi/dtb/
41
41
# RiscV64 specific: @TODO ??? what is this ??
@@ -61,39 +61,39 @@ pre_umount_final_image__install_grub() {
61
61
# shellcheck disable=SC2016 # some wierd escaping going on there.
62
62
chroot_custom " $chroot_target " mkdir -pv ' /dev/disk/by-uuid/"$(grub-probe --target=fs_uuid /)"' " ||" true
63
63
64
- display_alert " Creating GRUB config..." " ${EXTENSION} : grub-mkconfig / update-grub"
64
+ display_alert " Extension: ${EXTENSION} : Creating GRUB config..." " ${EXTENSION} : grub-mkconfig / update-grub"
65
65
chroot_custom " $chroot_target " update-grub || {
66
66
exit_with_error " update-grub failed!"
67
67
}
68
68
69
69
local install_grub_cmdline=" grub-install --target=${UEFI_GRUB_TARGET} --no-nvram --removable" # nvram is global to the host, even across chroot. take care.
70
- display_alert " Installing GRUB EFI..." " ${EXTENSION} : ${UEFI_GRUB_TARGET} "
70
+ display_alert " Extension: ${EXTENSION} : Installing GRUB EFI..." " ${EXTENSION} : ${UEFI_GRUB_TARGET} "
71
71
chroot_custom " $chroot_target " " $install_grub_cmdline " || {
72
- exit_with_error " ${install_grub_cmdline} failed!"
72
+ exit_with_error " Extension: ${EXTENSION} : ${install_grub_cmdline} failed!"
73
73
}
74
74
75
75
# ## Sanity check. The produced "/boot/grub/grub.cfg" should:
76
76
declare -i has_failed_sanity_check=0
77
77
78
78
# - NOT have any mention of `/dev` inside; otherwise something is going to fail
79
79
if grep -q ' /dev' " ${chroot_target} /boot/grub/grub.cfg" ; then
80
- display_alert " GRUB sanity check failed" " grub.cfg contains /dev" " err"
80
+ display_alert " Extension: ${EXTENSION} : GRUB sanity check failed" " grub.cfg contains /dev" " err"
81
81
SHOW_LOG=yes run_host_command_logged grep ' /dev' " ${chroot_target} /boot/grub/grub.cfg" " ||" true
82
82
has_failed_sanity_check=1
83
83
else
84
- display_alert " GRUB config sanity check passed" " no '/dev' found in grub.cfg" " info"
84
+ display_alert " Extension: ${EXTENSION} : GRUB config sanity check passed" " no '/dev' found in grub.cfg" " info"
85
85
fi
86
86
87
87
# - HAVE references to initrd, otherwise going to fail.
88
88
if ! grep -q ' initrd.img' " ${chroot_target} /boot/grub/grub.cfg" ; then
89
- display_alert " GRUB config sanity check failed" " no initrd.img references found in /boot/grub/grub.cfg" " err"
89
+ display_alert " Extension: ${EXTENSION} : GRUB config sanity check failed" " no initrd.img references found in /boot/grub/grub.cfg" " err"
90
90
has_failed_sanity_check=1
91
91
else
92
- display_alert " GRUB config sanity check passed" " initrd.img references found OK in /boot/grub/grub.cfg" " debug"
92
+ display_alert " Extension: ${EXTENSION} : GRUB config sanity check passed" " initrd.img references found OK in /boot/grub/grub.cfg" " debug"
93
93
fi
94
94
95
95
if [[ ${has_failed_sanity_check} -gt 0 ]]; then
96
- exit_with_error " GRUB config sanity check failed, image will be unbootable; see above errors"
96
+ exit_with_error " Extension: ${EXTENSION} : GRUB config sanity check failed, image will be unbootable; see above errors"
97
97
fi
98
98
99
99
# Remove host-side config.
@@ -122,7 +122,7 @@ configure_grub() {
122
122
run_host_command_logged chmod -v +x " ${MOUNT} " /usr/share/desktop-base/grub_background.sh
123
123
fi
124
124
125
- display_alert " GRUB EFI kernel cmdline" " '${GRUB_CMDLINE_LINUX_DEFAULT} ' distro=${UEFI_GRUB_DISTRO_NAME} timeout=${UEFI_GRUB_TIMEOUT} " " "
125
+ display_alert " Extension: ${EXTENSION} : GRUB EFI kernel cmdline" " '${GRUB_CMDLINE_LINUX_DEFAULT} ' distro=${UEFI_GRUB_DISTRO_NAME} timeout=${UEFI_GRUB_TIMEOUT} " " "
126
126
cat << - grubCfgFrag >> "${MOUNT} "/etc/default/grub.d/98-armbian.cfg
127
127
GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} "
128
128
GRUB_TIMEOUT_STYLE=menu # Show the menu with Kernel options (Armbian or -generic)...
0 commit comments