grubby-bls: lookup default entry by either id or title on grub2

There is a grub2-set-default script that can be used to set the default
entry. It can take an entry id, title or index as a parameter so grubby
should be able to also lookup a default entry using the title on grub2.

Related: rhbz#1654936

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2018-12-11 16:21:45 +01:00
parent 2ad4f485f1
commit 6b2ae0e335
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69
2 changed files with 6 additions and 14 deletions

View File

@ -125,25 +125,13 @@ get_default_index() {
index="$default"
fi
# GRUB2 and zipl use different fields to set the default entry
if [[ $bootloader = "grub2" ]]; then
id="$default"
else
title="$default"
fi
for i in ${!bls_file[@]}; do
if [[ $i -eq $index ]]; then
echo $i
return
fi
if [[ $bootloader = "grub2" && $id = ${bls_id[$i]} ]]; then
echo $i
return
fi
if [[ $bootloader = "zipl" && $title = ${bls_title[$i]} ]]; then
if [[ $default = ${bls_id[$i]} || $default = ${bls_title[$i]} ]]; then
echo $i
return
fi

View File

@ -1,6 +1,6 @@
Name: grubby
Version: 8.40
Release: 22%{?dist}
Release: 23%{?dist}
Summary: Command line tool for updating bootloader configs
License: GPLv2+
URL: https://github.com/rhinstaller/grubby
@ -130,6 +130,10 @@ current boot environment.
%{_mandir}/man8/*.8*
%changelog
* Tue Dec 11 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-23
- grubby-bls: lookup default entry by either id or title on grub2
Related: rhbz#1654936
* Fri Nov 30 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-22
- grubby-bls: also print the absolute path in the --default-kernel option
Resolves: rhbz#1649778