Commit Graph

14 Commits

Author SHA1 Message Date
Javier Martinez Canillas 9a80bb6f8e
grubby-bls: allow to add many BLS entries for the same kernel image
The BLS files name convention used is ${MACHINE_ID}-${KERNEL_VERSION}.conf
but this means that there can only be a single entry for a given kernel.

Allow the grubby wrapper to add many entries for the same kernel image,
since the old grubby tool was able to do that. To differentiate from the
original BLS entry and to specify that it's a customized entry, add a
[[:digit:]]~custom suffix after the kernel version number.

This will also sort the custom entries before the original entry, that's
also what the old grubby tool did.

Resolves: rhbz#1634752

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-11-02 00:55:03 +01:00
Javier Martinez Canillas 1c345197a4
grubby-bls: use ~debug instead of -debug as suffix to sort correctly
For the debug BLS entries a -debug suffix was added so they are sorted after
the kernel entries, but that only works with version sort and not rpm sort.

So instead use ~debug prefix so rpm sort algorithm could sort it correctly.

Related: rhbz#1638103

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-10-23 15:51:23 +02:00
Javier Martinez Canillas db3ffac800
grubby-bls: use id instead of title to get the default entry
The wrapper is using the title before to store the default entry, but we
are now using the entry id for grub2, so make the wrapper query the id.

Resolves: rhbz#1638103

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-10-23 15:51:16 +02:00
Javier Martinez Canillas 7d53b5e0a6
grubby-bls: escape delimiter character before replacing the options field
The ! character was used as the delimiter, but this doesn't work when the
param uses this character, for example "memmap=1G!1G".

Resolves: rhbz#1640017

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-10-23 15:50:49 +02:00
Javier Martinez Canillas 84881fb396
grubby-bls: make a copy of the cmdline if is modified for an entry
The BLS entries use a global kernel command line parameters that's set as
kernelopts variable in the grubenv file. But users may want to have custom
parameters for some entries, so make a copy of the current kernelopts and
set the "options" field value to the modified parameters.

Resolves: rhbz#1629054

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-10-23 15:49:19 +02:00
Peter Jones a5e56a6e7d
Make grubby-bls sort everything correctly, including spaces.
Related: rhbz#1638103
2018-10-23 15:49:19 +02:00
Javier Martinez Canillas b40ea5be18
grubby-bls: check if entry exists before attempting to print its info
The grubby --info option didn't check if an entry existed for a kernel and
printed wrong information about it. Fix this and also for --update-kernel
and --set-default options that have the same issue.

Resolves: rhbz#1634712

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-10-23 15:35:52 +02:00
Javier Martinez Canillas cf425061aa
grubby-bls: set saved_entry to id instead of title on set-default
The grubby wrapper sets the saved_entry in grubenv to the entry title
field since that's done by grubby. But for BLS the id is the filename
without the .conf extension, this saved_entry is set to this when a
new kernel is installed.

So for consistency also use the entry id for the --set-default option.

Related: rhbz#1638103

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-10-23 15:35:13 +02:00
Peter Jones 4aa091811b
grubby-bls: make "id" be the filename, and include it in --info=ALL
Related: rhbz#1638103
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-10-23 15:08:30 +02:00
Javier Martinez Canillas 33ab171b28
Print information about the entry set as default by grubby-bls script
This information can be useful for users to know what's the BLS entry
that was set as the default.

Resolves: rhbz#1636180

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-10-23 15:06:54 +02:00
Javier Martinez Canillas 28952a66c8
Use ! instead of , as sed delimiter in grubby-bls script
The script uses sed to modify the options field in the BLS entries, but it
is using a ',' character as the sed delimiter. It's total valid to have a
kernel command line parameter that contains that character, for example:

$ grubby --add-kernel=/boot/vmlinuz --args="console=ttyS0,115200n81" \
  --initrd=/boot/initrd.img --make-default --title=install
sed: -e expression #1, char 42: unknown option to `s'

Fix this by using a different delimiter that won't be present in a cmdline.

Resolves: rhbz#1634744

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-10-23 15:06:49 +02:00
Javier Martinez Canillas f9880644e6
grubby-bls should only check if kernel exists and not if was installed
When a new BLS entry is added, the script checks if the kernel image exists
and also if it was installed from a rpm package. But the latter isn't really
needed, it should be valid to just copy a kernel image and add a BLS entry.

Resolves: rhbz#1634740

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-10-23 15:06:45 +02:00
Javier Martinez Canillas b8c8cdcf6c
Make grubby-bls execute grub2-mkconfig on ppc64
When booting an ppc64 machine on bare-metal (PowerNV) the OPAL firmware
interface is used. The firmware contains the Petitboot boot-loader that
can be used to parse the BootLoaderSpec (BLS) snippets in a BLS setup.

But machines could have an older version of Petitboot that doesn't have
BLS support, so on ppc64 machines can't be assumed that just modifying
the BLS files is enough for those changes to be reflected in the boot
menu. Instead, grub2-mkconfig is executed so the BLS can be parsed and
produce a grub config file that can be used by any Petitboot version.

Resolves: rhbz#1636039

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-10-23 15:06:40 +02:00
Javier Martinez Canillas 19db5c489a
Add grubby-bls package
Add a grubby wrapper script that allows to manage BootLoaderSpec files by
using the same command line options supported by the grubby tool. This is
provided for backward compatibility for grubby users that swtich to BLS.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-07-13 20:05:41 +02:00