diff --git a/features.in/grub/cfg.in/00defaults.cfg b/features.in/grub/cfg.in/00defaults.cfg index 6b1d4ffb..b0e39401 100644 --- a/features.in/grub/cfg.in/00defaults.cfg +++ b/features.in/grub/cfg.in/00defaults.cfg @@ -14,7 +14,7 @@ if [ -s $pfxfat/grubenv ]; then load_env --file $pfxfat/grubenv set default="${saved_entry}" else - default=@default_id@ + set default=@default_id@ fi function savedefault { if [ -z "${boot_once}" -a -s $pfxfat/grubenv ]; then diff --git a/features.in/grub/config.mk b/features.in/grub/config.mk index 117af348..71d69446 100644 --- a/features.in/grub/config.mk +++ b/features.in/grub/config.mk @@ -9,6 +9,7 @@ ifeq (,$(filter-out i586 x86_64,$(ARCH))) @$(call try,BOOTVGA,normal) endif @$(call set,RELNAME,ALT ($(IMAGE_NAME))) + @$(call xport,GRUB_DEFAULT) # UI is overwritten use/grub/ui/%: use/grub diff --git a/features.in/grub/stage1/scripts.d/01-grub b/features.in/grub/stage1/scripts.d/01-grub index c8558d29..bf92a29d 100755 --- a/features.in/grub/stage1/scripts.d/01-grub +++ b/features.in/grub/stage1/scripts.d/01-grub @@ -29,25 +29,20 @@ local CFG=$1 if [ -n "$GLOBAL_GRUB_DEFAULT" ]; then if [ -n "$(grep -i "$GLOBAL_GRUB_DEFAULT" "$CFG")" ]; then DEFAULT="$GLOBAL_GRUB_DEFAULT" - sed -i '/^default/d' - echo "default=$DEFAULT" >> "$CFG" else echo "error: $GLOBAL_GRUB_DEFAULT missing in $CFG" >&2 exit 1 fi -fi -DEFAULT="$(grep -i '\-\-id ' "$CFG" | head -1 | rev| cut -f2 -d' ' |rev)" -if grep -i '@default_id@' "$CFG"; then - sed -i "s/@default_id@/$DEFAULT/" "$CFG" -fi -if ! grep -i '^\s*\(set\s\+\)\?default=' "$CFG"; then - if [ -n "$DEFAULT" ]; then - echo "default=$DEFAULT" >> "$CFG" - else +elif [ -n "$(grep -i "--id 'linux'" "$CFG")" ]; then + DEFAULT=linux +else + DEFAULT="$(grep -i '\-\-id ' "$CFG" | head -1 | rev| cut -f2 -d' ' |rev)" + if [ -z "$DEFAULT" ]; then echo "error: no DEFAULT or UI directive and cannot guess for $CFG" >&2 exit 1 fi fi +sed -i "s/@default_id@/$DEFAULT/" "$CFG" } default_change "$CFG"