import grubby-8.40-41.el8

This commit is contained in:
CentOS Sources 2020-11-03 06:46:54 -05:00 committed by Andrew Lukoshko
parent 95795ec0f1
commit af0753f6c8
3 changed files with 247 additions and 18 deletions

View File

@ -459,8 +459,8 @@ update_args() {
local add_args=($1) && shift
for arg in ${remove_args[*]}; do
arg="$(echo $arg | sed -e 's/\//\\\//g')"
if [[ $arg = *"="* ]]; then
arg=$(echo $arg | sed -e 's/\//\\\//g')
args="$(echo $args | sed -E "s/(^|[[:space:]])$arg([[:space:]]|$)/ /")"
else
args="$(echo $args | sed -E "s/(^|[[:space:]])$arg(([[:space:]]|$)|([=][^ ]*([$]*)))/ /g")"
@ -468,7 +468,8 @@ update_args() {
done
for arg in ${add_args[*]}; do
arg=${arg%=*}
arg="${arg%%=*}"
arg="$(echo $arg | sed -e 's/\//\\\//g')"
args="$(echo $args | sed -E "s/(^|[[:space:]])$arg(([[:space:]]|$)|([=][^ ]*([$]*)))/ /g")"
done
@ -492,9 +493,22 @@ update_bls_fragment() {
fi
if [[ $param = "ALL" && $bootloader = grub2 ]] && [[ -n $remove_args || -n $add_args ]]; then
local old_args="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")"
opts="$(update_args "${old_args}" "${remove_args}" "${add_args}")"
grub2-editenv "${env}" set kernelopts="${opts}"
local old_args=""
if [[ -z $no_etc_update ]] && [[ -e ${grub_etc_default} ]]; then
old_args="$(source ${grub_etc_default}; echo ${GRUB_CMDLINE_LINUX})"
if [[ -n $old_args ]]; then
opts="$(update_args "${old_args}" "${remove_args}" "${add_args}")"
opts="$(echo "$opts" | sed -e 's/\//\\\//g')"
sed -i -e "s/^GRUB_CMDLINE_LINUX.*/GRUB_CMDLINE_LINUX=\\\"${opts}\\\"/" "${grub_etc_default}"
fi
fi
old_args="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")"
if [[ -n $old_args ]]; then
opts="$(update_args "${old_args}" "${remove_args}" "${add_args}")"
grub2-editenv "${env}" set kernelopts="${opts}"
fi
elif [[ $bootloader = grub2 ]]; then
opts="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")"
fi
@ -544,24 +558,28 @@ set_default_bls() {
}
remove_var_prefix() {
local prefix="$1"
[ -z "${prefix}" ] && return
if [[ -n $remove_kernel && $remove_kernel =~ ^/ ]]; then
remove_kernel="/${remove_kernel##*/}"
remove_kernel="/${remove_kernel##${prefix}/}"
fi
if [[ -n $initrd ]]; then
initrd="/${initrd##*/}"
initrd="/${initrd##${prefix}/}"
fi
if [[ -n $extra_initrd ]]; then
extra_initrd=" /${extra_initrd##*/}"
extra_initrd=" /${extra_initrd##${prefix}/}"
fi
if [[ -n $kernel ]]; then
kernel="/${kernel##*/}"
kernel="/${kernel##${prefix}/}"
fi
if [[ -n $update_kernel && $update_kernel =~ ^/ ]]; then
update_kernel="/${update_kernel##*/}"
update_kernel="/${update_kernel##${prefix}/}"
fi
}
@ -599,6 +617,7 @@ Usage: grubby [OPTION...]
--update-kernel=kernel-path updated information for the specified kernel
--zipl configure zipl bootloader
-b, --bls-directory path to directory containing the BootLoaderSpec fragment files
--no-etc-grub-update don't update the GRUB_CMDLINE_LINUX variable in /etc/default/grub
Help options:
-?, --help Show this help message
@ -610,7 +629,7 @@ OPTS="$(getopt -o c:i:b:? --long help,add-kernel:,args:,bad-image-okay,\
config-file:,copy-default,default-kernel,default-index,default-title,env:,\
grub2,info:,initrd:,extra-initrd:,make-default,remove-args:,\
remove-kernel:,set-default:,set-default-index:,title:,update-kernel:,zipl,\
bls-directory:,add-kernel:,add-multiboot:,mbargs:,mounts:,boot-filesystem:,\
bls-directory:,no-etc-grub-update,add-multiboot:,mbargs:,mounts:,boot-filesystem:,\
bootloader-probe,debug,devtree,devtreedir:,elilo,efi,extlinux,grub,lilo,\
output-file:,remove-mbargs:,remove-multiboot:,silo,yaboot -n ${SCRIPTNAME} -- "$@")"
@ -705,7 +724,11 @@ while [ ${#} -gt 0 ]; do
blsdir="${2}"
shift
;;
--add-kernel|--add-multiboot|--mbargs|--mounts|--boot-filesystem|\
--no-etc-grub-update)
no_etc_update=true
shift
;;
--add-multiboot|--mbargs|--mounts|--boot-filesystem|\
--bootloader-probe|--debug|--devtree|--devtreedir|--elilo|--efi|\
--extlinux|--grub|--lilo|--output-file|--remove-mbargs|--silo|\
--remove-multiboot|--slilo|--yaboot)
@ -750,6 +773,10 @@ if [[ -z $grub_config ]]; then
grub_config="/boot/grub2/grub.cfg"
fi
if [[ -z $grub_etc_default ]]; then
grub_etc_default="/etc/default/grub"
fi
get_bls_values
default_index="$(get_default_index)"
@ -762,9 +789,7 @@ if [[ -n $display_info ]]; then
display_info_values "${display_info}"
fi
if [[ $(get_prefix) == "/boot" ]]; then
remove_var_prefix
fi
remove_var_prefix "$(get_prefix)"
if [[ -n $kernel ]]; then
if [[ $copy_default = "true" ]]; then

179
SOURCES/grubby.8 Normal file
View File

@ -0,0 +1,179 @@
.TH GRUBBY 8 "Wed Apr 29 2020"
.SH NAME
grubby \- command line tool for configuring grub and zipl
.SH SYNOPSIS
\fBgrubby\fR [--add-kernel=\fIkernel-path\fR] [--args=\fIargs\fR]
[--bad-image-okay] [--config-file=\fIpath\fR] [--copy-default]
[--default-kernel] [--default-index] [--default-title]
[--env=\fIpath\fR] [--grub2] [--info=\fIkernel-path\fR]
[--initrd=\fIinitrd-path\fR] [--extra-initrd=\fIinitrd-path\fR]
[--make-default] [--remove-args=\fIargs\fR]
[--remove-kernel=\fIkernel-path\fR] [--set-default=\fIkernel-path\fR]
[--set-default-index=\fientry-index\fR] [--title=\fentry-title\fR]
[--update-kernel=\fIkernel-path\fR] [--zipl] [--bls-directory=\fIpath\fR]
.SH DESCRIPTION
\fBgrubby\fR is a command line tool for updating and displaying information
about the configuration files for the \fBgrub2\fR and \fBzipl\fR boot loaders.
It is primarily designed to be used from scripts which install new kernels and
need to find information about the current boot environment.
On BIOS-based Intel x86 platforms, \fBgrub2\fR is the default bootloader and
the configuration file is in \fB/boot/grub2/grub.cfg\fR. On UEFI-based Intel
x86 platforms, \fBgrub2\fR is the default bootloader, and the configuration
file is in \fB/boot/efi/EFI/redhat/grub.cfg\fR. On PowerPC platforms, systems
based on Power8 and Power9 support \fBgrub2\fR as a bootloader and use a
configuration stored in \fB/boot/grub2/grub.cfg\fR. On s390x platforms the
\fBzipl\fR bootloader use a default configuration in \fB/etc/zipl.conf\fR.
All bootloaders define the boot entries as individual configuration fragments
that are stored by default in \fB/boot/loader/entries\fR. The format for the
config files is specified at \fBhttps://systemd.io/BOOT_LOADER_SPECIFICATION\fR.
The \fBgrubby\fR tool is used to update and display the configuration defined
in the BootLoaderSpec fragment files.
There are a number of ways to specify the kernel used for \fB-\-info\fR,
\fB-\-remove-kernel\fR, and \fB-\-update-kernel\fR. Specificying \fBDEFAULT\fR
or \fBALL\fR selects the default entry and all of the entries, respectively.
Also, the title of a boot entry may be specified by using \fBTITLE=\fItitle\fR
as the argument; all entries with that title are used.
.SH OPTIONS
.TP
\fB-\-add-kernel\fR=\fIkernel-path\fR
Add a new boot entry for the kernel located at \fIkernel-path\fR.
.TP
\fB-\-args\fR=\fIkernel-args\fR
When a new kernel is added, this specifies the command line arguments
which should be passed to the kernel by default (note they are merged
with the arguments of the default entry if \fB-\-copy-default\fR is used).
When \fB-\-update-kernel\fR is used, this specifies new arguments to add
to the argument list. Multiple, space separated arguments may be used. If
an argument already exists the new value replaces the old values. The
\fBroot=\fR kernel argument gets special handling if the configuration
file has special handling for specifying the root filesystem.
.TP
\fB-\-bad-image-okay\fR
When \fBgrubby\fR is looking for an entry to use for something (such
as a default boot entry) it uses sanity checks, such as ensuring that
the kernel exists in the filesystem, to make sure entries that obviously
won't work aren't selected. This option overrides that behavior, and is
designed primarily for testing.
.TP
\fB-\-config-file\fR=\fIpath\fR
Use \fIpath\fR as the configuration file rather then the default.
.TP
\fB-\-copy-default\fR
\fBgrubby\fR will copy as much information (such as kernel arguments and
root device) as possible from the current default kernel. The kernel path
and initrd path will never be copied.
.TP
\fB-\-default-kernel\fR
Display the full path to the current default kernel and exit.
.TP
\fB-\-default-index\fR
Display the numeric index of the current default boot entry and exit.
.TP
\fB-\-default-title\fR
Display the title of the current default boot entry and exit.
.TP
\fB-\-env\fR=\fIpath\fR
Use \fIpath\fR as the grub2 environment block file rather then the default path.
.TP
\fB-\-grub2\fR
Configure \fBgrub2\fR bootloader.
.TP
\fB-\-info\fR=\fIkernel-path\fR
Display information on all boot entries which match \fIkernel-path\fR. If
\fIkernel-path\fR is \fBDEFAULT\fR, then information on the default kernel
is displayed. If \fIkernel-path\fR is \fBALL\fR, then information on all boot
entries are displayed.
.TP
\fB-\-initrd\fR=\fIinitrd-path\fR
Use \fIinitrd-path\fR as the path to an initial ram disk for a new kernel
being added.
.TP
\fB-\-extrainitrd\fR=\fIinitrd-path\fR
Use \fIinitrd-path\fR as the path to an auxiliary init ram disk image to be
added to the boot entry.
.TP
\fB-\-make-default\fR
Make the new kernel entry being added the default entry.
.TP
\fB-\-remove-args\fR=\fIkernel-args\fR
The arguments specified by \fIkernel-args\fR are removed from the kernels
specified by \fB-\-update-kernel\fR. The \fBroot\fR argument gets special
handling for configuration files that support separate root filesystem
configuration.
.TP
\fB-\-remove-kernel\fR=\fIkernel-path\fR
Removes all boot entries which match \fIkernel-path\fR. This may be used
along with -\-add-kernel, in which case the new kernel being added will
never be removed.
.TP
\fB-\-set-default\fR=\fIkernel-path\fR
The first entry which boots the specified kernel is made the default
boot entry.
.TP
\fB-\-set-default-index\fR=\fIentry-index\fR
Makes the given entry number the default boot entry.
.TP
\fB-\-title\fR=\fIentry-title\fR
When a new kernel entry is added \fIentry-title\fR is used as the title
for the entry.
.TP
\fB-\-update-kernel\fR=\fIkernel-path\fR
The entries for kernels matching \fRkernel-path\fR are updated. Currently
the only items that can be updated is the kernel argument list, which is
modified via the \fB-\-args\fR and \fB-\-remove-args\fR options. If the
\fBALL\fR argument is used the variable \fB GRUB_CMDLINE_LINUX\fR in
\fB/etc/default/grub\fR is updated with the latest kernel argument list,
unless the \fB-\-no-etc-grub-update\fR option is used.
.TP
\fB-\-zipl\fR
Configure \fBzipl\fR bootloader.
.TP
\fB-\-bls-directory\fR=\fIpath\fR
Use \fIpath\fR as the directory for the BootLoaderSpec config files rather
than the default \fB/boot/loader/entries\fR.
.TP
\fB-\-no-etc-grub-update\fR
Makes grubby to not update the \fBGRUB_CMDLINE_LINUX\fR variable in
\fB/etc/default/grub\fR when the \fB-\-update-kernel\fR option is
used with the \fBALL\fR argument.
.SH "SEE ALSO"
.BR zipl (8),
.BR mkinitrd (8),
.BR kernel-install (8)
.SH AUTHORS
.nf
Erik Troan
Jeremy Katz
Peter Jones
Javier Martinez
.fi

View File

@ -1,6 +1,6 @@
Name: grubby
Version: 8.40
Release: 38%{?dist}
Release: 41%{?dist}
Summary: Command line tool for updating BootLoaderSpec files
License: GPLv2+
URL: https://github.com/rhinstaller/grubby
@ -13,6 +13,7 @@ Source1: grubby-bls
Source2: grubby.in
Source3: installkernel.in
Source4: installkernel-bls
Source5: grubby.8
Patch0001: 0001-Set-envFile-from-env-when-bootloader-is-not-specifie.patch
Patch0002: 0002-add-README-with-description-of-the-test-suite.patch
Patch0003: 0003-Fix-some-stray-whitespace.patch
@ -120,12 +121,14 @@ make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} sbindir=%{_sbindir} libex
mkdir -p %{buildroot}%{_libexecdir}/{grubby,installkernel}/ %{buildroot}%{_sbindir}/
mv -v %{buildroot}%{_sbindir}/grubby %{buildroot}%{_libexecdir}/grubby/grubby
mv -v %{buildroot}%{_sbindir}/installkernel %{buildroot}%{_libexecdir}/installkernel/installkernel
cp -v %{SOURCE1} %{buildroot}%{_libexecdir}/grubby/
cp -v %{SOURCE4} %{buildroot}%{_libexecdir}/installkernel/
install -m 0755 %{SOURCE1} %{buildroot}%{_libexecdir}/grubby/
install -m 0755 %{SOURCE4} %{buildroot}%{_libexecdir}/installkernel/
sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/grubby,g" %{SOURCE2} \
> %{buildroot}%{_sbindir}/grubby
sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/installkernel,g" %{SOURCE3} \
> %{buildroot}%{_sbindir}/installkernel
rm %{buildroot}%{_mandir}/man8/grubby.8*
install -m 0644 %{SOURCE5} %{buildroot}%{_mandir}/man8/
%package deprecated
Summary: Legacy command line tool for updating bootloader configs
@ -166,6 +169,28 @@ current boot environment.
%{_mandir}/man8/*.8*
%changelog
* Thu May 07 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-41
- grubby-bls: only attempt to update the cmdline if was already set
Related: rhbz#1152027
* Wed May 06 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-40
- Fix installed man page file mode bits
Related: rhbz#1812065
* Wed Apr 29 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-39
- grubby-bls: strip only /boot from paths
Resolves: rhbz#1738238
- Make grubby to also update GRUB_CMDLINE_LINUX in /etc/default/grub
Resolves: rhbz#1152027
- grubby-bls: fix corner case when a kernel param value contains a '='
Resolves: rhbz#1787584
- grubby-bls: update man page to match options in current wrapper script
Resolves: rhbz#1812065
- grubby-bls: always escape the delimiter character used in sed commands
Related: rhbz#1787584
- grubby-bls: add a --no-etc-grub-update option
Related: rhbz#1152027
* Thu Nov 28 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-38
- grubby-bls: don't print rpm-sort error messages
Resolves: rhbz#1731924