From ab46f44ebd4835aca619897a4f566ec8ebc412b3 Mon Sep 17 00:00:00 2001 From: Edgar Fouillet Date: Thu, 13 Oct 2022 13:06:22 +0200 Subject: [PATCH] grub: add generation depending on env variables * ELSOS_KBD_LAYOUT can be set to qwerty to set default boot to qwerty * ELSOS_BOOT_TIMEOUT can be set to a number of seconds --- .gitignore | 1 + Makefile | 7 ++++++- grub/{grub.cfg => generate.sh} | 22 +++++++++++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) rename grub/{grub.cfg => generate.sh} (53%) diff --git a/.gitignore b/.gitignore index 7c13ee9..d1fb689 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ *.swp build target +grub/grub.cfg diff --git a/Makefile b/Makefile index 1cf278f..aca3654 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,8 @@ rundd: $(ISO) iso: $(ISO) -$(ISO): $(KERNEL) $(GRUB_CFG) +$(ISO): $(KERNEL) + bash grub/generate.sh mkdir -p build/iso/boot/grub cp $(KERNEL) build/iso/boot/elsos.bin cp $(GRUB_CFG) build/iso/boot/grub @@ -89,3 +90,7 @@ mrproper: clean re: mrproper make all + +reiso: + rm $(ISO) + make iso diff --git a/grub/grub.cfg b/grub/generate.sh similarity index 53% rename from grub/grub.cfg rename to grub/generate.sh index e780387..b08e470 100644 --- a/grub/grub.cfg +++ b/grub/generate.sh @@ -1,4 +1,23 @@ -timeout=2 +#!/bin/bash +cd "$(dirname "$0")" + +GRUB_DEFAULT=0 +GRUB_TIMEOUT=0 +if [ "$ELSOS_KBD_LAYOUT" = "qwerty" ] +then + GRUB_DEFAULT=1 +fi + +if [ -z ${ELSOS_BOOT_TIMEOUT+x} ] +then + GRUB_TIMEOUT=0 +else + GRUB_TIMEOUT=$ELSOS_BOOT_TIMEOUT +fi + +cat > grub.cfg << EOF +default=$GRUB_DEFAULT +timeout=$GRUB_TIMEOUT menuentry "elsOS with serial, azerty" { multiboot2 /boot/elsos.bin serial @@ -19,3 +38,4 @@ menuentry "elsOS, qwerty ansi" { multiboot2 /boot/elsos.bin qwerty boot } +EOF