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.
This commit is contained in:
parent
366f6a6ba5
commit
8f01688b34
@ -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
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
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"
|
||||
|
Loading…
Reference in New Issue
Block a user