From 432e5ddeafd71af4775b405ed5ad24d3baca1194 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 9 Jan 2022 18:15:20 +0100 Subject: [PATCH] Add bootloader setting for not loading the src initrd. --- build-aux/iso-grub-cfg.sh | 29 ++++++++++++++++++++++--- share/man/man7/release-iso-bootconfig.7 | 9 +++++++- tix/tix-iso-bootconfig | 6 ++++- tix/tix-iso-bootconfig.8 | 16 ++++++++++++++ 4 files changed, 55 insertions(+), 5 deletions(-) diff --git a/build-aux/iso-grub-cfg.sh b/build-aux/iso-grub-cfg.sh index fb262a33..27ce507a 100755 --- a/build-aux/iso-grub-cfg.sh +++ b/build-aux/iso-grub-cfg.sh @@ -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 } diff --git a/share/man/man7/release-iso-bootconfig.7 b/share/man/man7/release-iso-bootconfig.7 index 8d5d86ec..2ae67e43 100644 --- a/share/man/man7/release-iso-bootconfig.7 +++ b/share/man/man7/release-iso-bootconfig.7 @@ -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 diff --git a/tix/tix-iso-bootconfig b/tix/tix-iso-bootconfig index dce0b1b7..c88a4156 100755 --- a/tix/tix-iso-bootconfig +++ b/tix/tix-iso-bootconfig @@ -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")" diff --git a/tix/tix-iso-bootconfig.8 b/tix/tix-iso-bootconfig.8 index 2765a84d..b223d8ee 100644 --- a/tix/tix-iso-bootconfig.8 +++ b/tix/tix-iso-bootconfig.8 @@ -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