Add bootloader setting for not loading the src initrd.

This commit is contained in:
Jonas 'Sortie' Termansen 2022-01-09 18:15:20 +01:00
parent 31e3a20bca
commit 432e5ddeaf
4 changed files with 55 additions and 5 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh
# Copyright (c) 2018 Jonas 'Sortie' Termansen.
# Copyright (c) 2018, 2022 Jonas 'Sortie' Termansen.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@ -182,6 +182,7 @@ if [ -e /boot/random.seed ]; then
else
no_random_seed=--no-random-seed
fi
set enable_src=true
export version
export machine
@ -190,6 +191,7 @@ export menu_title
export timeout
export default
export no_random_seed
export enable_src
EOF
if [ -n "$ports" ]; then
@ -285,13 +287,22 @@ cat << EOF
echo done
fi
EOF
# TODO: Make loading of the /src initrd optional.
for initrd in $system_initrd $src_initrd $live_initrd $overlay_initrd; do
cat << EOF
if [ "$initrd" = "$src_initrd" ]; then
cat << EOF
if \$enable_src; then
echo -n "Loading /$initrd ($(human_size $initrd)) ... "
module /$initrd
echo done
fi
EOF
else
cat << EOF
echo -n "Loading /$initrd ($(human_size $initrd)) ... "
module /$initrd
echo done
EOF
fi
done
cat << EOF
hook_initrd_post
@ -393,6 +404,18 @@ menu_title="\$base_menu_title - Advanced Options"
hook_advanced_menu_pre
if "\$enable_src"; then
menuentry "Disable loading source code" {
enable_src=false
configfile /boot/grub/advanced.cfg
}
else
menuentry "Enable loading source code" {
enable_src=true
configfile /boot/grub/advanced.cfg
}
fi
menuentry "Select binary packages..." {
configfile /boot/grub/tix.cfg
}

View File

@ -260,6 +260,11 @@ If the selected menu option itself is a submenu, it can be appended with a
.Sy '>'
and another selection to pick a default menu option in that submenu, and so on.
(Default: 0)
.It Sy enable_src
Whether to load the source code initrd containing
.Pa /src .
(Default:
.Sy true )
.It Sy machine
The machine type this release was built for.
.It Sy menu_title
@ -346,7 +351,9 @@ command line.
.Pp
Load
.Pa /boot/system.initrd.xz ,
.Pa /boot/src.initrd.xz ,
.Pa /boot/src.initrd.xz
(if
.Sy $enable_src ) ,
.Pa /boot/live.initrd.xz ,
and
.Pa /boot/overlay.initrd.xz

View File

@ -1,5 +1,5 @@
#!/bin/sh
# Copyright (c) 2017, 2018 Jonas 'Sortie' Termansen.
# Copyright (c) 2017, 2018, 2022 Jonas 'Sortie' Termansen.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@ -22,6 +22,7 @@ append_title="modified by $(id -un)@$(hostname)"
default=
directory=
enable_append_title=true
enable_src=
liveconfig=
operand=1
random_seed=false
@ -49,7 +50,9 @@ for argument do
--default=*) default=$parameter ;;
--default) previous_option=default ;;
--disable-append-title) enable_append_title=false ;;
--disable-src) enable_src=false ;;
--enable-append-title) enable_append_title=true ;;
--enable-src) enable_src=true ;;
--liveconfig=*) liveconfig=$parameter ;;
--liveconfig) previous_option=liveconfig ;;
--random-seed) random_seed=true ;;
@ -121,6 +124,7 @@ mkdir -p -- "$directory/boot/grub"
if [ -n "$timeout" ]; then
printf 'timeout="%s"\n' "$timeout"
fi
print_enable_default_bool "$enable_src" src src
if $enable_append_title; then
printf "base_menu_title=\"\$base_menu_title - \"'%s'\n" \
"$(printf '%s\n' "$append_title" | sed "s/'/'\\\\''/g")"

View File

@ -9,7 +9,9 @@
.Op Fl \-append-title Ns = Ns Ar text
.Op Fl \-default Ns = Ns Ar default-boot-menu-option
.Op Fl \-disable-append-title
.Op Fl \-disable-src
.Op Fl \-enable-append-title
.Op Fl \-enable-src
.Op Fl \-liveconfig Ns = Ns Ar liveconfig-directory
.Op Fl \-random-seed
.Op Fl \-timeout Ns = Ns Ar boot-menu-timeout
@ -86,6 +88,13 @@ GRUB variable.
Don't append anything to the bootloader menu title by appending to the
.Sy base_menu_title
GRUB variable.
.It Fl \-disable-src
Disable loading the source code in
.Pa /src
by setting
.Sy enable_src
GRUB variable to
.Sy false .
.It Fl \-enable-append-title
Enable appending " - " followed by the value set with
.Fl \-append-title
@ -94,6 +103,13 @@ to the bootloader menu title by appending to the
GRUB variable.
This option is on by default and can be disabled with
.Fl \-disable-append-title .
.It Fl \-enable-src
Enable loading the source code in
.Pa /src
by setting
.Sy enable_src
GRUB variable to
.Sy true .
.It Fl \-liveconfig Ns = Ns Ar liveconfig-directory
Overlay the
.Ar liveconfig-directory