Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 2/2] board/pc/post-build.sh: allow to use grub config file
@ 2023-01-09  7:42 AndreiCherniaev
  2023-10-01 17:08 ` Yann E. MORIN
  0 siblings, 1 reply; 2+ messages in thread
From: AndreiCherniaev @ 2023-01-09  7:42 UTC (permalink / raw)
  To: buildroot

Allow to use grub config file with set timeout not default. Before this set timeout always was 5s and can't be changed, any set timeout from BR2_TARGET_GRUB2_BUILTIN_CONFIG_PC was ignored

Signed-off-by: AndreiCherniaev <cherniaev.andrei@kairo.space>
---
 board/pc/post-build.sh | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/board/pc/post-build.sh b/board/pc/post-build.sh
index c76dee2676..8538faa7eb 100755
--- a/board/pc/post-build.sh
+++ b/board/pc/post-build.sh
@@ -9,7 +9,22 @@ if [ -d "$BINARIES_DIR/efi-part/" ]; then
     cp -f "$BOARD_DIR/grub-efi.cfg" "$BINARIES_DIR/efi-part/EFI/BOOT/grub.cfg"
 else
     cp -f "$BOARD_DIR/grub-bios.cfg" "$TARGET_DIR/boot/grub/grub.cfg"
-
     # Copy grub 1st stage to binaries, required for genimage
     cp -f "$TARGET_DIR/lib/grub/i386-pc/boot.img" "$BINARIES_DIR"
 fi
+
+# When post-build script is runing $BR2_TARGET_GRUB2_BUILTIN_CONFIG_PC is unset, so parce Buildroot .config file again
+GRUB2_BUILTIN_CONFIG_PC="`grep --only-matching --perl-regex "(?<=BR2_TARGET_GRUB2_BUILTIN_CONFIG_PC\=).*" $BR2_CONFIG`"
+# Using the native shell prefix/suffix removal feature (see also qstrip)
+GRUB2_BUILTIN_CONFIG_PC="${GRUB2_BUILTIN_CONFIG_PC%\"}"
+GRUB2_BUILTIN_CONFIG_PC="${GRUB2_BUILTIN_CONFIG_PC#\"}"
+if [ -z "$GRUB2_BUILTIN_CONFIG_PC" ]; then #if user doesn't use his .config for grub
+    # Set time to wait 5 s for keyboard input before booting by default
+    sed -i -e '1 s/^/set default="0"\nset timeout="5"\n\n/;' "$TARGET_DIR/boot/grub/grub.cfg"
+#else if user use his .config for grub
+# to configure bootloader put something like
+#  set default="0"
+#  set timeout="5"
+# to your file located $BR2_TARGET_GRUB2_BUILTIN_CONFIG_PC 
+# More info https://www.gnu.org/software/grub/manual/grub
+fi
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-01 17:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-09  7:42 [Buildroot] [PATCH 2/2] board/pc/post-build.sh: allow to use grub config file AndreiCherniaev
2023-10-01 17:08 ` Yann E. MORIN

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox