diff mbox series

[2/2] board/pc/post-build.sh: allow to use grub config file

Message ID 20230109074202.12012-2-cherniaev.andrei@kairo.space
State Rejected
Headers show
Series None | expand

Commit Message

AndreiCherniaev Jan. 9, 2023, 7:42 a.m. UTC
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(-)

Comments

Yann E. MORIN Oct. 1, 2023, 5:08 p.m. UTC | #1
Andrei, All,

Sorry to come back so alte on that patch...

On 2023-01-09 16:42 +0900, AndreiCherniaev spake thusly:
> 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

Please properly format your commit log, wrapped at ~72 chars wide lines.

The files in board/ are meant to be used with the defconfigs in
Buildroot, and together are meant as examples and startkng point for
frther custmisations.

We can't add support for everything up to the kitchen sink in those
scripts; we want to keep them simple so that it is easy to see what they
are doing on how they can be extended.

It is your responsibility to adapt those files to match your use-case,
potentially duplicating them on hyour side to create a new board
definition.

As such, I've maked this patch as rejected.

Regards,
Yann E. MORIN.

> 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
diff mbox series

Patch

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