Commit 8f01688b authored by Anton Midyukov's avatar Anton Midyukov

grub: Fix selection of default item

1. Didn't work before because the variable was not exported. 2. Fixed the logic broken by the introduction of support for saving the selected item on the FAT partition.
parent 366f6a6b
...@@ -14,7 +14,7 @@ if [ -s $pfxfat/grubenv ]; then ...@@ -14,7 +14,7 @@ if [ -s $pfxfat/grubenv ]; then
load_env --file $pfxfat/grubenv load_env --file $pfxfat/grubenv
set default="${saved_entry}" set default="${saved_entry}"
else else
default=@default_id@ set default=@default_id@
fi fi
function savedefault { function savedefault {
if [ -z "${boot_once}" -a -s $pfxfat/grubenv ]; then if [ -z "${boot_once}" -a -s $pfxfat/grubenv ]; then
......
...@@ -9,6 +9,7 @@ ifeq (,$(filter-out i586 x86_64,$(ARCH))) ...@@ -9,6 +9,7 @@ ifeq (,$(filter-out i586 x86_64,$(ARCH)))
@$(call try,BOOTVGA,normal) @$(call try,BOOTVGA,normal)
endif endif
@$(call set,RELNAME,ALT ($(IMAGE_NAME))) @$(call set,RELNAME,ALT ($(IMAGE_NAME)))
@$(call xport,GRUB_DEFAULT)
# UI is overwritten # UI is overwritten
use/grub/ui/%: use/grub use/grub/ui/%: use/grub
......
...@@ -29,25 +29,20 @@ local CFG=$1 ...@@ -29,25 +29,20 @@ local CFG=$1
if [ -n "$GLOBAL_GRUB_DEFAULT" ]; then if [ -n "$GLOBAL_GRUB_DEFAULT" ]; then
if [ -n "$(grep -i "$GLOBAL_GRUB_DEFAULT" "$CFG")" ]; then if [ -n "$(grep -i "$GLOBAL_GRUB_DEFAULT" "$CFG")" ]; then
DEFAULT="$GLOBAL_GRUB_DEFAULT" DEFAULT="$GLOBAL_GRUB_DEFAULT"
sed -i '/^default/d'
echo "default=$DEFAULT" >> "$CFG"
else else
echo "error: $GLOBAL_GRUB_DEFAULT missing in $CFG" >&2 echo "error: $GLOBAL_GRUB_DEFAULT missing in $CFG" >&2
exit 1 exit 1
fi fi
fi elif [ -n "$(grep -i "--id 'linux'" "$CFG")" ]; then
DEFAULT="$(grep -i '\-\-id ' "$CFG" | head -1 | rev| cut -f2 -d' ' |rev)" DEFAULT=linux
if grep -i '@default_id@' "$CFG"; then else
sed -i "s/@default_id@/$DEFAULT/" "$CFG" DEFAULT="$(grep -i '\-\-id ' "$CFG" | head -1 | rev| cut -f2 -d' ' |rev)"
fi if [ -z "$DEFAULT" ]; then
if ! grep -i '^\s*\(set\s\+\)\?default=' "$CFG"; then
if [ -n "$DEFAULT" ]; then
echo "default=$DEFAULT" >> "$CFG"
else
echo "error: no DEFAULT or UI directive and cannot guess for $CFG" >&2 echo "error: no DEFAULT or UI directive and cannot guess for $CFG" >&2
exit 1 exit 1
fi fi
fi fi
sed -i "s/@default_id@/$DEFAULT/" "$CFG"
} }
default_change "$CFG" default_change "$CFG"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment