From 99ae54c84c76cd9c0916c697541927299af37cdb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 24 Nov 2023 06:32:00 +0100 Subject: [PATCH] env_init, grub list & split --- grub.cfg.sh | 66 +++++++++++++++++++++++++++++++----------- live/main.sh | 1 + live/menu/cmd.sh | 1 + live/menu/env.sh | 1 + live/menu/gfx.sh | 1 + live/menu/pause.sh | 1 + live/menu/scan.sh | 1 + live/menu/set.sh | 19 ++++++------ live/source/menu.sh | 1 - readme.md | 2 ++ readme/grub.md | 70 +++++++++++++++++++++++++++++---------------- 11 files changed, 112 insertions(+), 52 deletions(-) diff --git a/grub.cfg.sh b/grub.cfg.sh index 3db2e81..5d2675d 100644 --- a/grub.cfg.sh +++ b/grub.cfg.sh @@ -34,10 +34,19 @@ function grub_init { } function grub_list_const { - echo -n "\ - cpu-platform | ${grub_cpu}-${grub_platform} - cmdpath | ${cmdpath} -" + target="${1}" + setparams \ +" cpu-platform | ${grub_cpu}-${grub_platform}" \ +" cmdpath | ${cmdpath}" + for entry in "${@}" ; do + if [ "${target}" == 'menu' ] ; then + menuentry "${entry}" { nop } + else + echo "${entry}" + fi + done + unset entry + unset target } function grub_list_info { @@ -57,20 +66,38 @@ function grub_list_info { } function grub_list_vars { - echo -n "\ - root | ${root} - prefix | ${prefix} -check_signatures | ${check_signatures} -" + target="${1}" + setparams \ +" root | ${root}" \ +" prefix | ${prefix}" \ +"check_signatures | ${check_signatures}" + for entry in "${@}" ; do + if [ "${target}" == 'menu' ] ; then + menuentry "${entry}" { nop } + else + echo "${entry}" + fi + done + unset entry + unset target list_trusted } function grub_list_xtra { - echo -n "\ - env | ${env} - live | ${live} - data | ${data} -" + target="${1}" + setparams \ +" env | ${env}" \ +" live | ${live}" \ +" data | ${data}" + for entry in "${@}" ; do + if [ "${target}" == 'menu' ] ; then + menuentry "${entry}" { nop } + else + echo "${entry}" + fi + done + unset entry + unset target } function grub_main { @@ -107,9 +134,14 @@ function grub_pause { } function grub_split { - echo -n "\ - --- -" + target="${1}" + setparams \ +' ---' + if [ "${target}" == 'menu' ] ; then + menuentry "${1}" { nop } + else + echo "${1}" + fi } grub_main diff --git a/live/main.sh b/live/main.sh index e8909da..7d5f959 100644 --- a/live/main.sh +++ b/live/main.sh @@ -1,3 +1,4 @@ +env_init menu_init default='scan' diff --git a/live/menu/cmd.sh b/live/menu/cmd.sh index b995d77..eece47c 100644 --- a/live/menu/cmd.sh +++ b/live/menu/cmd.sh @@ -1,3 +1,4 @@ +env_init menu_init menuentry 'halt' { halt } diff --git a/live/menu/env.sh b/live/menu/env.sh index 45cb61e..b7dce0f 100644 --- a/live/menu/env.sh +++ b/live/menu/env.sh @@ -1,3 +1,4 @@ +env_init menu_init "${env} → ${env_mod}" menuentry 'list file' { diff --git a/live/menu/gfx.sh b/live/menu/gfx.sh index 7c75aee..f16ed2d 100644 --- a/live/menu/gfx.sh +++ b/live/menu/gfx.sh @@ -1,3 +1,4 @@ +env_init menu_init menuentry 'list' { diff --git a/live/menu/pause.sh b/live/menu/pause.sh index f6a23df..f698ba0 100644 --- a/live/menu/pause.sh +++ b/live/menu/pause.sh @@ -1,3 +1,4 @@ +env_init menu_init menu_item 0 ' 0' diff --git a/live/menu/scan.sh b/live/menu/scan.sh index a05e604..5096cdb 100644 --- a/live/menu/scan.sh +++ b/live/menu/scan.sh @@ -1,3 +1,4 @@ +env_init menu_init "${scan}" scan "${scan}" diff --git a/live/menu/set.sh b/live/menu/set.sh index 603ff36..e390f89 100644 --- a/live/menu/set.sh +++ b/live/menu/set.sh @@ -1,17 +1,18 @@ +env_init menu_init default='split' -menuentry "cmdpath: ${cmdpath}" { nop } -menuentry "grub_cpu: ${grub_cpu} → grub_platform: ${grub_platform}" { nop } -menu_split -menuentry "check_signatures: ${check_signatures} → pager: ${pager}" { nop } -menuentry "prefix: ${prefix} → root: ${root}" { nop } +grub_list_const 'menu' +grub_split 'menu' +grub_list_vars 'menu' +grub_split 'menu' +grub_list_xtra 'menu' menu_split 'split' -menuentry "esp: ${esp} → data: ${data}" { nop } -menuentry "env: ${env} → env_mod: ${env_mod}" { nop } -menuentry "live: ${live}" { nop } -menu_split menu_swap "check_squashfs | ${check_squashfs}" 'check_squashfs' 'enforce' 'no' menu_swap " live_from | ${live_from}" 'live_from' 'ram' 'media' menuentry " pause | ${pause}" { menu 'pause' } +menu_split +menuentry "esp: ${esp}" { nop } +menuentry "env_mod: ${env_mod}" { nop } +menuentry "pager: ${pager}" { nop } diff --git a/live/source/menu.sh b/live/source/menu.sh index cc8ebfc..2b5f782 100644 --- a/live/source/menu.sh +++ b/live/source/menu.sh @@ -25,7 +25,6 @@ function menu_exit { } function menu_init { - env_init if [ "${menu}" ] ; then if [ "${1}" ] ; then menuentry "→ ${menu} → ${1}" { nop } diff --git a/readme.md b/readme.md index 5a3c114..cc68b0f 100644 --- a/readme.md +++ b/readme.md @@ -210,6 +210,8 @@ bash /media/ssd/esp/bios/setup.sh /dev/sda * [ ] try -mount-opts +* refactor grub list_{const,vars,xtra} & split + ### Python … diff --git a/readme/grub.md b/readme/grub.md index b928792..2b54c9a 100644 --- a/readme/grub.md +++ b/readme/grub.md @@ -43,7 +43,6 @@ * rmmod * sha256sum * sha512sum -* sleep * background_color * background_image @@ -54,7 +53,6 @@ * cryptomount * date * echo -* eval * export * halt * initrd @@ -78,7 +76,6 @@ * normal * normal_exit * probe -* read * reboot * regexp * save_env @@ -93,11 +90,49 @@ * trust * unset * verify_detached + +### x86_64-efi-signed + +#### allowed + +* sleep + +#### denied + +* eval +* read * videoinfo ## Variables * biosnum +* icondir +* net_default_interface +* pxe_blksize +* pxe_default_gateway +* superusers + +* config_directory +* config_file + +* debug +* default +* fallback +* gfxmode +* gfxpayload +* gfxterm_font +* menu_color_highlight +* menu_color_normal +* theme +* timeout +* timeout_style + +### Function + +* ? + +### Persistent + * feature_200_final * feature_all_video_module * feature_chainloader_bpb @@ -108,43 +143,28 @@ * feature_ntldr * feature_platform_search_hint * feature_timeout_style -* icondir -* net_default_interface * net_default_ip * net_default_mac * net_default_server -* pxe_blksize -* pxe_default_gateway * pxe_default_server -* superusers +* secondary_locale_dir -* chosen -* config_directory -* config_file - -* ? * check_signatures +* chosen * cmdpath * (hd?,*)/efi/boot/bootx64.efi * (hd?) * color_highlight * color_normal -* debug -* default -* fallback -* gfxmode -* gfxpayload -* gfxterm_font * grub_cpu * grub_platform * lang * locale_dir -* menu_color_highlight -* menu_color_normal * pager * prefix * root -* secondary_locale_dir -* theme -* timeout -* timeout_style + +#### x86_64-efi-signed + +* lockdown +* shim_lock