Commit Graph

183 Commits

Author SHA1 Message Date
Josh Boyer
3498276978 Only require s390utils-core
zipl appears to be the only thing grubby needs, and that is provided by s390utils-core.  Change the Requires to that, which allows for a more minimal installation.
2020-10-24 12:33:50 +00:00
Fedora Release Engineering
1ead121a08 - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2020-07-28 00:24:28 +00:00
Javier Martinez Canillas
a5c9c3a138
fix build with rpm-4.16 and correct --extra-initrd option image path
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2020-06-26 10:16:05 +02:00
Javier Martinez Canillas
12e62c4f0a
grubby-bls: don't replace options with kernelopts if values are the same
If the options field in a BLS file has the same value than the kernelopts
variable in grubenv, the options is replaced with the kernelopts variable.

This was done to keep the options in the BLS files in sync when possible,
but having the kernel cmdline as a variable in the grubenv file was proven
to be fragile. Instead, the kernel cmdline will be stored in the BLS files
to make the configuration more robust. This will work even if the grubenv
gets corrupted or is deleted.

Since we want to get rid of the kernelopts variable, don't attempt to use
that in the BLS snippets anymore.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2020-05-13 18:44:59 +02:00
Javier Martinez Canillas
770392fcd0
grubby-bls: only attempt to update cmdline if was already set
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2020-05-07 10:15:39 +02:00
Javier Martinez Canillas
959c481fa9
Fix installed man page file mode bits
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2020-05-06 16:24:55 +02:00
Javier Martinez Canillas
b2ab29059a
grubby-bls: add a --no-etc-grub-update option and a fix for --args
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2020-05-05 12:23:10 +02:00
Javier Martinez Canillas
f24781c87b
grubby-bls: add a --no-etc-grub-update option
The option makes grubby to not update the GRUB_CMDLINE_LINUX variable in
the /etc/default/grub file when the --update-kernel=ALL option is used.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2020-05-05 12:08:02 +02:00
Javier Martinez Canillas
b1eee22db8
grubby-bls: always escape the delimiter character used in sed commands
The forward slash character is used as the delimiter for sed substitutions
so this is escaped before calling sed.

But this was only done before removing parameters from the kernel command
and not when adding it. Use it for all the cases when the parameters are
replaced in the update_args() function.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2020-05-05 12:03:58 +02:00
Javier Martinez Canillas
1621d288b6
grubby-bls: minor style cleanup
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2020-04-30 23:08:02 +02:00
Javier Martinez Canillas
670185c682
Update man page to match current grubby script options and fix a bug
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2020-04-29 18:37:40 +02:00
Javier Martinez Canillas
303821d014
grubby-bls: update man page to match options in current wrapper script
The man page of the old grubby tool is still shipped in the grubby package
but instead there should be a man page that only documents the options for
the wrapper grubby script that is used to manage the BLS config snippets.

Current man page is confusing for users so let's add one that contains the
options that are supported by the wrapper script but no unsupported ones.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2020-04-29 18:37:05 +02:00
Javier Martinez Canillas
f57406f3ab
grubby-bls: fix corner case when a kernel param value contains a '='
If a kernel command line parameter has a '=' character, grubby fails
to update the options field in the BLS snippet, for example:

$ grubby --update-kernel=foo --args="bar=https://test?token="
sed: -e expression #1, char 30: unknown option to `s'

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2020-04-29 18:36:57 +02:00
Javier Martinez Canillas
8c7d866907
Make grubby to also update GRUB_CMDLINE_LINUX in /etc/default/grub
The grubby --update-kernel=ALL option is used to update the kernel command
line parameters for all the boot entries. But the updated cmdline is lost
if the grub2-mkconfig command is executed, since in that case the cmdline
is changed with the value set by GRUB_CMDLINE_LINUX in /etc/default/grub.

To prevent the cmdline set by users to be overridden by mistake, keep the
value of GRUB_CMDLINE_LINUX in sync with the current cmdline.

Related: rhbz#1287854

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2020-03-30 14:25:41 +02:00
Javier Martinez Canillas
5f9558c222
Fix FTBFS and a couple of cleanups
Fix FTBFS
  Resolves: rhbz#1799496
Fix wrong S-o-B tag in patch
Fix warning about using unversioned Obsoletes

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2020-02-10 20:19:29 +01:00
Fedora Release Engineering
03b13cef75 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2020-01-29 03:36:54 +00:00
Javier Martinez Canillas
b5070e2278
grubby-bls: don't update grubenv when generating grub.cfg for ppc64le
Since PowerNV machines can have a Petitboot versions that still don't have
BLS support, grubby re-generates the grub.cfg file on all ppc64le machines.

But this has the side effect that the grubenv file is updated, which will
overwrite any value that was set by grubby itself. To prevent that run the
grub2-mkconfig with the --no-grubenv-update option.

Related: rhbz#1726514

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-11-30 00:29:12 +01:00
Javier Martinez Canillas
3ffa2d2706
Fix logic that checks for kernelopts in BLS files and some cleanups
grubby-bls: don't print rpm-sort error messages
  Resolves: rhbz#1731924
grubby-bls: remove -o option and support -c for ppc64le grub config
  Resolves: rhbz#1758598
grubby-bls: fix logic to check if the kernelopts var is defined in a BLS
  Resolves: rhbz#1726514

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-11-28 12:11:39 +01:00
Javier Martinez Canillas
08153fc1d6
grubby-bls: fix logic to check if the kernelopts var is defined in a BLS
The logic to check if a kernelopts variable is defined in a BLS entry was
wrong and caused grubby to expand the variables even when it was defined.

Resolves: rhbz#1726514

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-11-28 10:52:53 +01:00
Javier Martinez Canillas
5dafc374ee
grubby-bls: remove -o option and support -c for ppc64le grub config
Resolves: rhbz#1758598

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-11-27 17:13:51 +01:00
Javier Martinez Canillas
77a8c0bcac
grubby-bls: don't print rpm-sort error messages
If there are no BLS snippets, an empty array of strings is passed to the
rpm-sort tool and it will print an error that just confuses grubby users.

Resolves: rhbz#1731924

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-11-27 17:13:32 +01:00
Yuval Turgeman
9baffd002d
grubby-bls: strip only /boot from paths
If the /boot directory is a mount point, then the paths of the kernel and
initramfs images paths in the BLS snippet have to be relative to the root
of the boot partition. So the /boot prefix has to be stripped from paths
in this case.

But the function was wrongly stripping the entire path instead of only the
/boot prefix, which prevented having kernels and initrds in subdirectories.

Signed-off-by: Yuval Turgeman <yturgema@redhat.com>
2019-08-06 16:03:53 +02:00
Fedora Release Engineering
4009bc7ed4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2019-07-25 07:49:12 +00:00
Javier Martinez Canillas
b50c79e71c
Add a kernel-install plugin to execute hook scripts in /etc/kernel/
The kernel hook scripts in /etc/kernel/postinst.d and /etc/kernel/prerm.d
were executed by the new-kernel-pkg --rpmposttrans and --remove options.

But with a BLS configuration the new-kernel-pkg script isn't executed and
instead the kernel-install plugins are used. Add a kernel-install plugin
that executes the hooks since packages like dkms and akmod make use of it.

Resolves: rhbz#1696202

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-06-17 18:10:58 +02:00
Igor Gnatenko
7c6e97e809
Rebuild for RPM 4.15
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2019-06-11 00:13:19 +02:00
Igor Gnatenko
7b4b34aa74
Rebuild for RPM 4.15
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2019-06-10 17:42:02 +02:00
Javier Martinez Canillas
73b809baaf
Use mountpoint command to check whether /boot is a mount point
Using grep is wrong and fragile, so let's use the mountpoint command
instead to make it more robust.

Resolves: rhbz#1706091

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-05-03 18:21:23 +02:00
Javier Martinez Canillas
dc24f2cedf
grubby-bls: fix --add-kernel not working when using the --args option
The script prints an error if --args option is used without --update-kernel
but it's also valid to use it with the --add-kernel option.

Resolves: rhbz#1691004

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-03-21 11:29:12 +01:00
Javier Martinez Canillas
8213073fa4
Only switch to BLS config for s390x / zipl
For platforms using GRUB, the switch to BLS should be done in the %post
scriptlet for the grub2-tools package. So only switch to BLS for s390x.

Related: rhbz#1652806

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-03-11 12:55:40 +01:00
Javier Martinez Canillas
6abeb6fc77
grubby-bls: make --update-kernel ALL to update kernelopts var in grubenv
Currently there's no way to update the kernelopts variable defined in the
grubenv by using the grubby wrapper. Updating it with grub2-editenv - set
is tedious and error prone so let's use --update-kernel=ALL option for it.

This command currently iterates over all the BLS entries and update them
individually, but makes more sense to update the kernelopts grubenv var
and only update the BLS entries that don't have the $kernelopts var in
their options field.

If after an update one of these BLS entries have exactly the same params
in their options field than the ones set in $kernelopts, set the options
field to $kernelopts again since the parameters have converged again.

That way the modified BLS entries will only have a custom options field
while its value diverged from the $kernelopts defined in grubenv.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-03-01 16:31:28 +01:00
Javier Martinez Canillas
40d73389b4
grubby-bls: error if args or remove-args is used without update-kernel
The --args and --remove-args options can only be used when the kernel to
update is specified using the --update-kernel option. Print an error if
the latter option is not provided.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-02-14 10:57:13 +01:00
Javier Martinez Canillas
ac9b25b31e
Fix build errors with GCC9 and two more grubby-bls fixes
- Fix GCC warnings about possible string truncations and buffer overflows
- grubby-bls: unset default entry if is the one being removed
- grubby-bls: show absolute path when printing error about incorrect param

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-02-05 20:09:52 +01:00
Javier Martinez Canillas
a77221432e
grubby-bls: unset default entry if is the one being removed
If the default entry is removed, this can't be set as the default anymore
for zipl. Otherwise the zipl tool will fail since it won't exist an IPL
section for the one set as the default.

For grub2, if the saved_entry doesn't exist it will fallback to the first
entry. But still the correct thing to do is to unset the default there.

Resolves: rhbz#1668329

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-02-02 01:12:28 +01:00
Javier Martinez Canillas
f742fa15b3
grubby-bls: show absolute path when printing error about incorrect param
The error message is not printing the absolute path to the images, fix it.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-02-02 01:12:28 +01:00
Fedora Release Engineering
9f336a65dd - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2019-02-01 01:38:17 +00:00
Javier Martinez Canillas
290786e606
Correctly set LDFLAGS and make grubby-bls expand all options variables
- Correctly set LDFLAGS to include hardened flags (pjones)
  Related: rhbz#1654936
- grubby-bls: expand all variables in options field when updating it
  Resolves: rhbz#1660700

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-01-14 09:56:05 +01:00
Javier Martinez Canillas
6b2ae0e335
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>
2018-12-11 16:24:22 +01:00
Javier Martinez Canillas
2ad4f485f1
Another set of mostly grubby-bls fixes
- grubby-bls: also print the absolute path in the --default-kernel option
  Resolves: rhbz#1649778
- grubby-bls: allow to specify the same kernel param multiple times
  Resolves: rhbz#1652486
- grubby-bls: expand kernel options if these are environment variables
  Resolves: rhbz#1649785
- grubby-bls: always generate the BLS snippets when adding new entries
  Resolves: rhbz#1653365
- Improve man page for --info option (jstodola)
  Resolves: rhbz#1651672
- Make the old grubby take precedence over grubby-bls if is installed
  Related: rhbz#165484

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-12-01 02:34:07 +01:00
Javier Martinez Canillas
27cf1e7399
Make the old grubby take precedence over grubby-bls if is installed
Not all bootloaders used in Fedora have BLS support, for example extlinux
doesn't. So when using extlinux the old grubby tool has to be installed.

Currently the grubby-bls wrapper has precedence over the old grubby tool,
which means that even if grubby-deprecated is installed, the wrapper will
executed when calling grubby. Make the old grubby take precedence instead.

Related: rhbz#1654841

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-12-01 02:12:08 +01:00
Javier Martinez Canillas
f1aafa632f
grubby-bls: always generate the BLS snippets when adding new entries
a BLS file is generated at build time and stored in /lib/modules/$kernel
but this default BLS file assumes that /boot is a mount point and so the
kernel and initrd paths are relative to the root of this boot partition.

This is not the case if /boot is not a mount point or if the bootloader
is zipl, since zipl expects the absolute path to be in the BLS snippet.

The kernel-install scripts takes care of this and modifies the BLS file
if needed, but grubby doesn't do that. So instead just generate the BLS
always even if there is one for the kernel version of the added entry.

Resolves: rhbz#1653365

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-12-01 02:02:16 +01:00
Javier Martinez Canillas
b84a214b99
grubby-bls: expand kernel options if these are environment variables
The grub2 bootloader allows the BLS snippets fields to contain environment
variables instead of constants. This is useful for example to define the
kernel command line parameters only once in the grubenv file and set this
variable in the BLS snippets.

But this can be confusing for users when the information is printed by the
grubby script, so expand the variables if they can be looked up in grubenv.

Resolves: rhbz#1649785

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-12-01 02:01:49 +01:00
Javier Martinez Canillas
4b1d63cacd
grubby-bls: allow to specify the same kernel param multiple times
The kernel command line can contain parameters that are specified multiple
times. This is supported by the old grubby tool but ins't supported by the
grubby BLS wrapper. Allow the grubby wrapper to do the same.

Resolves: rhbz#1652486

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-12-01 02:01:22 +01:00
Javier Martinez Canillas
d1dd184403
grubby-bls: also print the absolute path in the --default-kernel option
The absolute path to the kernel and initramfs images is printed by the
--info option, but it's not printed by the --default-kernel option.

Resolves: rhbz#1649778

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-12-01 01:57:07 +01:00
Javier Martinez Canillas
e777519e08
Another batch of grubby-bls fixes
- installkernel-bls: remove unnecessary check for GRUB_ENABLE_BLSCFG=true
  Resolves: rhbz#1647721
- grubby-bls: use title field instead of version for zipl default entry
  Related: rhbz#1645200
- grubby-bls: print the absolute kernel and initramfs images paths
  Resolves: rhbz#1649778
- grubby-bls: make info print the root parameter if is present in cmdline
  Resolves: rhbz#1649791

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-11-21 10:49:59 +01:00
Javier Martinez Canillas
695377d276
grubby-bls: make info print the root parameter if is present in cmdline
The old grubby tool printed the root parameter separated from the other
kernel command line arguments. Make the wrapper have the same behaviour.

Resolves: rhbz#1649791

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-11-21 10:45:49 +01:00
Javier Martinez Canillas
6cdfe45ece
grubby-bls: print the absolute kernel and initramfs images paths
The BLS file "linux" and "initrd" fields expect a relative paths from the
root of the partition that contains the kernel and initramfs. The grubby
tool was printing the value of thse fields and not their full path.

So if there is a partition and /boot is a mount point, he BLS would have:

linux /vmlinuz-4.18.0-38.el8.x86_64
initrd /initramfs-4.18.0-38.el8.x86_64.img

And grubby would print:

kernel="/vmlinuz-4.18.0-38.el8.x86_64"
initrd="/initramfs-4.18.0-38.el8.x86_64.img"

But the old tool used to print the full paths of the images, so should be:

kernel="/boot/vmlinuz-4.18.0-38.el8.x86_64"
initrd="/boot/initramfs-4.18.0-38.el8.x86_64.img"

Resolves: rhbz#1649778

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-11-21 10:45:26 +01:00
Javier Martinez Canillas
791d55400b
grubby-bls: use title field instead of version for zipl default entry
Most bootloaders use the BootLoaderSpec "title" field to name the entries
in their boot menu. The zipl bootloader used the "version" field instead,
since it was wrongly assumed that the zipl boot menu didn't support names
that contained spaces, which are usually present in a BLS "title" field.

But this is not the case, names with space characters are supported by the
IPL and is just a constraint of the section heading in the zipl.conf file.

To be consistent with all the other bootloaders, zipl now uses the "title"
field to populate the boot menu entries from BLS files. So change grubby
to use the "title" field to set the default entry of the "version" field.

Related: rhbz#1645200

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-11-21 10:44:33 +01:00
Javier Martinez Canillas
4925c9ded9
installkernel-bls: remove unnecessary check for GRUB_ENABLE_BLSCFG=true
A BLS configuration is the default and in this case the installkernel-bls
script is used. For a non-BLS configuration the grubby-deprecated package
installs an installkernel that uses the new-kernel-pkg script.

So there is no need to check for GRUB_ENABLE_BLSCFG=true. Also, this check
is wrong for s390x and was causing the installkernel-bls script to no call
kernel-install on this platform.

Resolves: rhbz#1647721

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-11-21 10:43:48 +01:00
Javier Martinez Canillas
f9d8ee1b64
Switch to a BLS configuration on %%post
By default the old grubby tool isn't installed anymore and it's part of
the grubby-deprecated package. Instead the grubby wrapper that modifies
BLS config files is installed for backward compatiblity with old grubby.

So on postinstall the bootloader configuration has to be changed to BLS
since non-BLS bootloader configuration won't be updated anymore without
the old grubby tool and the new-kernel-pkg script.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-11-13 00:39:31 +01:00
Javier Martinez Canillas
d72135ede9
Move old grubby and new-kernel-pkg to grubby-deprecated and default to BLS
Now that Anaconda defaults to a BootLoaderSpec setup on installation, the
the grubby package should also install the grubby BLS wrapper by default.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-11-06 15:16:27 +01:00