Compare commits

...

No commits in common. "a10s" and "c8" have entirely different histories.
a10s ... c8

68 changed files with 17742 additions and 768 deletions

7
.gitignore vendored
View File

@ -1,6 +1 @@
*.tar.bz2 SOURCES/8.40-1.tar.gz
*.tar.gz
clog
*.rpm
.build*log
*/

View File

@ -1,73 +0,0 @@
#!/bin/bash
# set -x
if [[ "$(uname -m)" == arm* || "$(uname -m)" == aarch64 ]]
then
COMMAND="$1"
KERNEL_VERSION="$2"
#BOOT_DIR_ABS="$3"
#KERNEL_IMAGE="$4"
[ -f /etc/u-boot.conf ] && source /etc/u-boot.conf || true
[ -z "$FIRMWAREDT" ] || FirmwareDT=$FIRMWAREDT
if [[ $FirmwareDT == "True" ]]
then
# if we want to use firmware DT we remove symlink to current kernel DT
if [ -h /boot/dtb ]; then
rm -f /boot/dtb
fi
exit 0
fi
# Setup a /boot/dtb -> /boot/dtb-$newest_kernel_version symlink so that
# u-boot can find the correct dtb to load.
#
# If invoked to 'add' a new kernel, find the newest based on `sort`ing
# the kernel versions dtb. If 'remove', then follow basically the same
# procedure but exclude the version currently being removed.
#
# The theory of operation here is that, while newer kernels may add new
# dtb nodes and fields, as upstreaming hw support for some particular
# device progresses, it should never make backward incompatible changes.
# So it should always be safe to use a newer dtb with an older kernel.
list_dtb_versions() {
excluded_version="$1"
for dtbdir in /boot/dtb-*; do
dtbver=${dtbdir#*-}
if [ "$dtbver" != "$excluded_version" ]; then
echo $dtbver
fi
done
}
setup_dtb_link() {
ver=`list_dtb_versions $1 | sort -r --sort=version | head -1`
if [ -h /boot/dtb ]; then
rm -f /boot/dtb
fi
ln -s dtb-$ver /boot/dtb
}
ret=0
case "$COMMAND" in
add)
# If we're adding a kernel we want that version
if [ -h /boot/dtb ]; then
rm -f /boot/dtb
fi
ln -s dtb-$KERNEL_VERSION /boot/dtb
ret=$?
;;
remove)
setup_dtb_link $KERNEL_VERSION
ret=$?
;;
esac
exit $ret
else
# Just exit on non ARM
exit 0
fi

View File

@ -1,33 +0,0 @@
#!/usr/bin/bash
if ! [[ $KERNEL_INSTALL_MACHINE_ID ]]; then
exit 0
fi
COMMAND="$1"
KERNEL_VERSION="$2"
BOOT_DIR_ABS="$3"
# If $BOOT_DIR_ABS exists, some other boot loader is active.
[[ -d "$BOOT_DIR_ABS" ]] && exit 0
run_hooks()
{
local f
local files="$1"
for f in $files ; do
[ -x "$f" ] || continue
"$f" "$KERNEL_VERSION" "/boot/vmlinuz-$KERNEL_VERSION"
done
}
case "$COMMAND" in
add)
run_hooks "/etc/kernel/postinst.d/*[^~] /etc/kernel/postinst.d/$KERNEL_VERSION/*[^~]"
;;
remove)
run_hooks "/etc/kernel/prerm.d/*[^~] /etc/kernel/prerm.d/$KERNEL_VERSION/*[^~]"
;;
*)
exit 0
esac

340
COPYING
View File

@ -1,340 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@ -0,0 +1,30 @@
From b5c0a31ae38c2c42f0dea8c2d7282694f020e976 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 13 Apr 2015 13:57:33 -0700
Subject: [PATCH 01/55] Set envFile from --env when bootloader is not specified
---
grubby.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/grubby.c b/grubby.c
index d4ebb86168d..53fe9250e27 100644
--- a/grubby.c
+++ b/grubby.c
@@ -4423,9 +4423,11 @@ int main(int argc, const char ** argv) {
}
if (!cfi) {
- if (grub2FindConfig(&grub2ConfigType))
+ if (grub2FindConfig(&grub2ConfigType)) {
cfi = &grub2ConfigType;
- else
+ if (envPath)
+ cfi->envFile = envPath;
+ } else
#ifdef __ia64__
cfi = &eliloConfigType;
#elif __powerpc__
--
2.17.1

View File

@ -0,0 +1,91 @@
From 9c9587feca7413b34498064db19d796e1c402b51 Mon Sep 17 00:00:00 2001
From: Alexander Todorov <atodorov@redhat.com>
Date: Thu, 11 Jun 2015 08:45:37 -0400
Subject: [PATCH 02/55] add README with description of the test suite
---
README.rst | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
create mode 100644 README.rst
diff --git a/README.rst b/README.rst
new file mode 100644
index 00000000000..a5743ff2f96
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,72 @@
+grubby is a command line tool for updating and displaying information about
+the configuration files for the grub, lilo, elilo (ia64), yaboot (powerpc)
+and zipl (s390) 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.
+
+
+Testing grubby
+==============
+
+To execute the integrated test suite from inside the source directory run the
+command::
+
+ make test
+
+
+Test Suite Architecture
+------------------------
+
+grubby's test suite is written in Bash. The file `test.sh` contains several
+helper functions and a list of different test scenarios which are exercised
+upon execution. Important functions are:
+
+- oneTest() - test if the configuration generated by the supplied grubby
+ parameters matches a well known configuration file;
+
+- oneDisplayTest() - test grubby features that display some information,
+ checking grubby's output against well known values;
+
+- commandTest() - test if the output of some commands matches the provided
+ text. This function is only used for grub2 testing in a few places.
+
+
+Note: the test suite creates aliases for oneTest() and oneDisplayTest(), which
+are prefixed with the corresponding boot loader name. For example:
+grubTest(). eliloTest(), etc.
+
+The invocation syntax is::
+
+ testFunction config_file results_file --grubby --options
+
+For example the line::
+
+ grubTest grub.1 updargs/g1.1 --update-kernel=DEFAULT --args="root=/dev/hda1"
+
+means execute the command::
+
+ ./grubby --grub --config-file tests/grub.1 --update-kernel=DEFAULT \
+ --args="root=/dev/hda1"
+
+and compare the resulting configuration with the file
+`tests/results/updargs/g1.1`.
+
+
+The line::
+
+ grubDisplayTest grub.1 defaultindex/0 --default-index
+
+means execute::
+
+ ./grubby --grub --config-file tests/grub.1 --default-index
+
+and compare the output with the file `tests/results/defaultindex/0`.
+
+Writing New Test Cases
+----------------------
+
+To write a new test case for grubby you need a config file which matches the
+initial test conditions (either existing one or a new one), provide a
+results file (likely a new one) which contains the expected configuration or
+output and finally add a call to the test function(s) using the desired grubby
+parameters in an appropriate section of `test.sh`.
--
2.17.1

View File

@ -0,0 +1,35 @@
From d4b710802da3d780799f1e01e18b613e77b95bb3 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 24 Jun 2015 09:20:35 -0400
Subject: [PATCH 03/55] Fix some stray whitespace
Signed-off-by: Peter Jones <pjones@redhat.com>
---
README.rst | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.rst b/README.rst
index a5743ff2f96..754454b7bca 100644
--- a/README.rst
+++ b/README.rst
@@ -42,7 +42,7 @@ The invocation syntax is::
For example the line::
grubTest grub.1 updargs/g1.1 --update-kernel=DEFAULT --args="root=/dev/hda1"
-
+
means execute the command::
./grubby --grub --config-file tests/grub.1 --update-kernel=DEFAULT \
@@ -66,7 +66,7 @@ Writing New Test Cases
----------------------
To write a new test case for grubby you need a config file which matches the
-initial test conditions (either existing one or a new one), provide a
+initial test conditions (either existing one or a new one), provide a
results file (likely a new one) which contains the expected configuration or
output and finally add a call to the test function(s) using the desired grubby
parameters in an appropriate section of `test.sh`.
--
2.17.1

View File

@ -0,0 +1,162 @@
From d58e447819e96d84560b16d7632bb7bdf88cc412 Mon Sep 17 00:00:00 2001
From: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
Date: Tue, 16 Jun 2015 10:43:21 -0700
Subject: [PATCH 04/55] grubby: properly handle mixed ' and " and nested quotes
The SLES12 grub2.cfg file on ppc64le by default contains a line like:
submenu "Bootable snapshot #$snapshot_num" {
menuentry "If OK, run 'snapper rollback $snapshot_num' reboot." { true; }
}
On any grubby (tested with 8.40) invocation that updates the config
file, the combination of nested quotes and mixed quotes leads to a
generated file content like:
submenu "Bootable snapshot #$snapshot_num" {
menuentry 'If OK, run snapper rollback $snapshot_num' rollback $snapshot_num' and reboot." { true; }
}
which includes both a change from " to ', but also improperly quoted
strings and trailing characters relative to the string. This actually
leads to a failure to boot from the disk by default when using grubby
(e.g., Autotest) on SLES12 ppc64le. Whether SLES12 should be adding an
entry like this by default or not is probably open to debate, but grubby
should be able to hand this input file.
To fix the issue, three changes were necessary:
1) grub2ExtractTitle needs to check that if the second element starts
with a quote, that the matching element found ends with the same
quote-type (' vs. ")
2) lineWrite needs to output the right kind of quote based upon if the
string to be outputted itself contains quotes. This is not currently
possible in the code, because quotes are stripped out normally by
readConfig, but with the change in 3), that only happens now for the
quotes that actually delineate a string.
3) readConfig needs to check that when it is extracting titles and
determining extras, it uses matching quotes.
With these changes, a simple grubby --set-default=SLES12 (for example),
now produces:
submenu "Bootable snapshot #$snapshot_num" {
menuentry "If OK, run 'snapper rollback $snapshot_num' and reboot." { true; }
}
as expected.
Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
---
grubby.c | 42 +++++++++++++++++++++++++++++++++---------
1 file changed, 33 insertions(+), 9 deletions(-)
diff --git a/grubby.c b/grubby.c
index 53fe9250e27..440c6277935 100644
--- a/grubby.c
+++ b/grubby.c
@@ -451,6 +451,8 @@ char *grub2ExtractTitle(struct singleLine * line) {
* whose last character is also quote (assuming it's the closing one) */
int resultMaxSize;
char * result;
+ /* need to ensure that ' does not match " as we search */
+ char quote_char = *current;
resultMaxSize = sizeOfSingleLine(line);
result = malloc(resultMaxSize);
@@ -464,7 +466,7 @@ char *grub2ExtractTitle(struct singleLine * line) {
current_indent_len = strlen(current_indent);
strncat(result, current_indent, current_indent_len);
- if (!isquote(current[current_len-1])) {
+ if (current[current_len-1] != quote_char) {
strncat(result, current, current_len);
} else {
strncat(result, current, current_len - 1);
@@ -928,10 +930,23 @@ static int lineWrite(FILE * out, struct singleLine * line,
/* Need to handle this, because we strip the quotes from
* menuentry when read it. */
if (line->type == LT_MENUENTRY && i == 1) {
- if(!isquote(*line->elements[i].item))
- fprintf(out, "\'%s\'", line->elements[i].item);
- else
+ if(!isquote(*line->elements[i].item)) {
+ int substring = 0;
+ /* If the line contains nested quotes, we did not strip
+ * the "interna" quotes and we must use the right quotes
+ * again when writing the updated file. */
+ for (int j = i; j < line->numElements; j++) {
+ if (strchr(line->elements[i].item, '\'') != NULL) {
+ substring = 1;
+ fprintf(out, "\"%s\"", line->elements[i].item);
+ break;
+ }
+ }
+ if (!substring)
+ fprintf(out, "\'%s\'", line->elements[i].item);
+ } else {
fprintf(out, "%s", line->elements[i].item);
+ }
fprintf(out, "%s", line->elements[i].indent);
continue;
@@ -1267,6 +1282,8 @@ static struct grubConfig * readConfig(const char * inName,
len = 0;
char *extras;
char *title;
+ /* initially unseen value */
+ char quote_char = '\0';
for (int i = 1; i < line->numElements; i++) {
len += strlen(line->elements[i].item);
@@ -1283,13 +1300,16 @@ static struct grubConfig * readConfig(const char * inName,
for (int i = 0; i < line->numElements; i++) {
if (!strcmp(line->elements[i].item, "menuentry"))
continue;
- if (isquote(*line->elements[i].item))
+ if (isquote(*line->elements[i].item) && quote_char == '\0') {
+ /* ensure we properly pair off quotes */
+ quote_char = *line->elements[i].item;
title = line->elements[i].item + 1;
- else
+ } else {
title = line->elements[i].item;
+ }
len = strlen(title);
- if (isquote(title[len-1])) {
+ if (title[len-1] == quote_char) {
strncat(buf, title,len-1);
break;
} else {
@@ -1300,6 +1320,7 @@ static struct grubConfig * readConfig(const char * inName,
/* get extras */
int count = 0;
+ quote_char = '\0';
for (int i = 0; i < line->numElements; i++) {
if (count >= 2) {
strcat(extras, line->elements[i].item);
@@ -1310,12 +1331,15 @@ static struct grubConfig * readConfig(const char * inName,
continue;
/* count ' or ", there should be two in menuentry line. */
- if (isquote(*line->elements[i].item))
+ if (isquote(*line->elements[i].item) && quote_char == '\0') {
+ /* ensure we properly pair off quotes */
+ quote_char = *line->elements[i].item;
count++;
+ }
len = strlen(line->elements[i].item);
- if (isquote(line->elements[i].item[len -1]))
+ if (line->elements[i].item[len -1] == quote_char)
count++;
/* ok, we get the final ' or ", others are extras. */
--
2.17.1

View File

@ -0,0 +1,34 @@
From 9659e65a9f7ccc2549b75262a4af50ed99cc4bb9 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 11 Nov 2014 10:46:08 -0500
Subject: [PATCH 05/55] Don't put spaces in debug entries on zipl platforms.
Because of course zipl can't handle spaces.
Related: rhbz#1152152
Signed-off-by: Peter Jones <pjones@redhat.com>
---
new-kernel-pkg | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/new-kernel-pkg b/new-kernel-pkg
index b634388a83f..1cdbbb99501 100755
--- a/new-kernel-pkg
+++ b/new-kernel-pkg
@@ -140,7 +140,11 @@ rungrubby() {
if [ "$1" == "--debug" ]; then
[ "$MAKEDEBUG" != "yes" ] && return 0
[ -n "$verbose" ] && echo "- First, making a debug entry."
- declare -x debugtitle=" with debugging"
+ if [ $ARCH = 's390' -o $ARCH = 's390x' ]; then
+ declare -x debugtitle="_with_debugging"
+ else
+ declare -x debugtitle=" with debugging"
+ fi
declare -x debugargs="$DEBUGARG"
shift
else
--
2.17.1

View File

@ -0,0 +1,52 @@
From d9600e2dd1b35a6e74494c8c98ba399d06685041 Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Thu, 27 Feb 2014 10:35:59 +0100
Subject: [PATCH 06/55] Drop SEGV handler
The generated tracebacks are mostly useless without debuginfo (which is likely
not present if the crash is not anticipated) and prevent ABRT from doing a
better job.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
grubby.c | 17 -----------------
1 file changed, 17 deletions(-)
diff --git a/grubby.c b/grubby.c
index 440c6277935..649597ed92b 100644
--- a/grubby.c
+++ b/grubby.c
@@ -4211,21 +4211,6 @@ int addNewKernel(struct grubConfig * config, struct singleEntry * template,
return 0;
}
-static void traceback(int signum)
-{
- void *array[40];
- size_t size;
-
- signal(SIGSEGV, SIG_DFL);
- memset(array, '\0', sizeof (array));
- size = backtrace(array, 40);
-
- fprintf(stderr, "grubby received SIGSEGV! Backtrace (%ld):\n",
- (unsigned long)size);
- backtrace_symbols_fd(array, size, STDERR_FILENO);
- exit(1);
-}
-
int main(int argc, const char ** argv) {
poptContext optCon;
const char * grubConfig = NULL;
@@ -4368,8 +4353,6 @@ int main(int argc, const char ** argv) {
useextlinuxmenu=0;
- signal(SIGSEGV, traceback);
-
int i = 0;
for (int j = 1; j < argc; j++)
i += strlen(argv[j]) + 1;
--
2.17.1

View File

@ -0,0 +1,183 @@
From 1da1f577419e85a4e2d717b73af67b79382ad93e Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 2 Jul 2015 12:34:30 -0400
Subject: [PATCH 07/55] Add a bunch of tests for various
--default-{kernel,title,index}.
... and fix some failures where we see them.
Related: rhbz#1184014
(though I can't actually replicate his failure.)
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grubby.c | 52 ++++++++++++++++++++-------------
test.sh | 10 +++++++
test/results/defaultkernel/g.1 | 1 +
test/results/defaultkernel/l1.1 | 1 +
test/results/defaultkernel/z.1 | 1 +
test/results/defaulttitle/z.1 | 1 +
6 files changed, 45 insertions(+), 21 deletions(-)
create mode 100644 test/results/defaultkernel/g.1
create mode 100644 test/results/defaultkernel/l1.1
create mode 100644 test/results/defaultkernel/z.1
create mode 100644 test/results/defaulttitle/z.1
diff --git a/grubby.c b/grubby.c
index 649597ed92b..0bb486967bf 100644
--- a/grubby.c
+++ b/grubby.c
@@ -428,7 +428,7 @@ char *grub2ExtractTitle(struct singleLine * line) {
/* bail out if line does not start with menuentry */
if (strcmp(line->elements[0].item, "menuentry"))
- return NULL;
+ return NULL;
i = 1;
current = line->elements[i].item;
@@ -437,10 +437,12 @@ char *grub2ExtractTitle(struct singleLine * line) {
/* if second word is quoted, strip the quotes and return single word */
if (isquote(*current) && isquote(current[current_len - 1])) {
char *tmp;
-
- tmp = strdup(current);
- *(tmp + current_len - 1) = '\0';
- return ++tmp;
+
+ tmp = strdup(current+1);
+ if (!tmp)
+ return NULL;
+ tmp[strlen(tmp)-1] = '\0';
+ return tmp;
}
/* if no quotes, return second word verbatim */
@@ -453,11 +455,11 @@ char *grub2ExtractTitle(struct singleLine * line) {
char * result;
/* need to ensure that ' does not match " as we search */
char quote_char = *current;
-
+
resultMaxSize = sizeOfSingleLine(line);
result = malloc(resultMaxSize);
snprintf(result, resultMaxSize, "%s", ++current);
-
+
i++;
for (; i < line->numElements; ++i) {
current = line->elements[i].item;
@@ -4648,27 +4650,35 @@ int main(int argc, const char ** argv) {
struct singleLine * line;
struct singleEntry * entry;
- if (config->defaultImage == -1) return 0;
+ if (config->defaultImage == -1)
+ return 0;
if (config->defaultImage == DEFAULT_SAVED_GRUB2 &&
cfi->defaultIsSaved)
config->defaultImage = 0;
entry = findEntryByIndex(config, config->defaultImage);
- if (!entry) return 0;
+ if (!entry)
+ return 0;
if (!configureGrub2) {
- line = getLineByType(LT_TITLE, entry->lines);
- if (!line) return 0;
- printf("%s\n", line->elements[1].item);
-
- } else {
- char * title;
-
- dbgPrintf("This is GRUB2, default title is embeded in menuentry\n");
- line = getLineByType(LT_MENUENTRY, entry->lines);
- if (!line) return 0;
- title = grub2ExtractTitle(line);
- if (title)
+ char *title;
+ line = getLineByType(LT_TITLE, entry->lines);
+ if (!line)
+ return 0;
+ title = extractTitle(config, line);
+ if (!title)
+ return 0;
printf("%s\n", title);
+ free(title);
+ } else {
+ char * title;
+
+ dbgPrintf("This is GRUB2, default title is embeded in menuentry\n");
+ line = getLineByType(LT_MENUENTRY, entry->lines);
+ if (!line)
+ return 0;
+ title = grub2ExtractTitle(line);
+ if (title)
+ printf("%s\n", title);
}
return 0;
diff --git a/test.sh b/test.sh
index 6379698c6de..96e0087b1e2 100755
--- a/test.sh
+++ b/test.sh
@@ -298,6 +298,9 @@ grubDisplayTest grub.9 defaulttitle/g.9 --default-title
grubDisplayTest grub.10 defaulttitle/g.10 --default-title
grubDisplayTest grub.11 defaulttitle/g.11 --default-title
+testing="GRUB display default kernel"
+grubDisplayTest grub.1 defaultkernel/g.1 --default-kernel
+
testing="LILO default directive"
liloTest lilo.1 default/l1.1 --set-default=/boot/vmlinuz-2.4.18-4
liloTest lilo.1 default/l1.2 --remove-kernel=/boot/vmlinuz-2.4.18-4smp
@@ -305,10 +308,17 @@ liloTest lilo.1 default/l1.3 --add-kernel /boot/kernel --title label \
--copy-default
liloTest lilo.1 default/l1.4 --add-kernel /boot/kernel --title label \
--copy-default --make-default
+liloDisplayTest lilo.1 defaultkernel/l1.1 --default-kernel
testing="Z/IPL default directive"
ziplTest zipl.1 default/z1.1 --add-kernel /boot/new-kernel --title test
ziplTest zipl.1 default/z1.2 --add-kernel /boot/new-kernel --title test --make-default
+testing="Z/IPL display default index"
+ziplDisplayTest zipl.1 defaultindex/0 --default-index
+testing="Z/IPL display default title"
+ziplDisplayTest zipl.1 defaulttitle/z.1 --default-title
+testing="Z/IPL display default kernel"
+ziplDisplayTest zipl.1 defaultkernel/z.1 --default-kernel
testing="GRUB fallback directive"
grubTest grub.5 fallback/g5.1 --remove-kernel=/boot/vmlinuz-2.4.7-ac3 \
diff --git a/test/results/defaultkernel/g.1 b/test/results/defaultkernel/g.1
new file mode 100644
index 00000000000..2c3ac11ead6
--- /dev/null
+++ b/test/results/defaultkernel/g.1
@@ -0,0 +1 @@
+/boot/vmlinuz-2.4.7-2
diff --git a/test/results/defaultkernel/l1.1 b/test/results/defaultkernel/l1.1
new file mode 100644
index 00000000000..fd22b1be2b9
--- /dev/null
+++ b/test/results/defaultkernel/l1.1
@@ -0,0 +1 @@
+/boot/vmlinuz-2.4.18-4smp
diff --git a/test/results/defaultkernel/z.1 b/test/results/defaultkernel/z.1
new file mode 100644
index 00000000000..2c62e98d4d9
--- /dev/null
+++ b/test/results/defaultkernel/z.1
@@ -0,0 +1 @@
+/boot/vmlinuz-2.4.9-37
diff --git a/test/results/defaulttitle/z.1 b/test/results/defaulttitle/z.1
new file mode 100644
index 00000000000..a08e1f35eb7
--- /dev/null
+++ b/test/results/defaulttitle/z.1
@@ -0,0 +1 @@
+linux
--
2.17.1

View File

@ -0,0 +1,28 @@
From 5de1b279749f02a126932f9e03ac62706efde699 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 2 Jul 2015 12:44:51 -0400
Subject: [PATCH 08/55] Emit better systemd debug settings on debug entries.
Resolves: rhbz#1212128
Signed-off-by: Peter Jones <pjones@redhat.com>
---
new-kernel-pkg | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/new-kernel-pkg b/new-kernel-pkg
index 1cdbbb99501..1f6ab39499f 100755
--- a/new-kernel-pkg
+++ b/new-kernel-pkg
@@ -121,7 +121,7 @@ mbkernel="$HYPERVISOR"
mbargs="$HYPERVISOR_ARGS"
adddracutargs=""
addplymouthinitrd=""
-DEBUGARG="systemd.debug"
+DEBUGARG="systemd.log_level=debug systemd.log_target=kmsg"
usage() {
echo "Usage: `basename $0` [-v] [--mkinitrd] [--rminitrd] [--dracut]" >&2
--
2.17.1

View File

@ -0,0 +1,25 @@
From 80e43f6b8c8316075d8f9f6553ad271e168060b1 Mon Sep 17 00:00:00 2001
From: Chris Lumens <clumens@redhat.com>
Date: Wed, 22 Jul 2015 09:13:11 -0400
Subject: [PATCH 09/55] Add a new makefile target that does everything needed
for jenkins.
We should have as much of the logic of how the CI tests are run in source
control as possible, so that's what this target is for. Besides this, jenkins
just runs a "git clean" first.
---
Makefile | 1 +
1 file changed, 1 insertion(+)
diff --git a/Makefile b/Makefile
index ac144046133..ade4421aa25 100644
--- a/Makefile
+++ b/Makefile
@@ -84,3 +84,4 @@ archive:
upload: archive
@scp grubby-$(VERSION).tar.bz2 fedorahosted.org:grubby
+ci: test
--
2.17.1

View File

@ -0,0 +1,41 @@
From ec969de50ea5fa31d98cd00afa6a3f8a43e606a4 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 2 Jul 2015 14:30:09 -0400
Subject: [PATCH 10/55] Make the grub1 "defaultkernel" test more reliable.
Basically just do it twice with various incarnations of
--boot-filesystem={/,/boot}
Related: rhbz#1184014
Signed-off-by: Peter Jones <pjones@redhat.com>
---
test.sh | 3 ++-
test/results/defaultkernel/g.2 | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
create mode 100644 test/results/defaultkernel/g.2
diff --git a/test.sh b/test.sh
index 96e0087b1e2..2985fd62bf9 100755
--- a/test.sh
+++ b/test.sh
@@ -299,7 +299,8 @@ grubDisplayTest grub.10 defaulttitle/g.10 --default-title
grubDisplayTest grub.11 defaulttitle/g.11 --default-title
testing="GRUB display default kernel"
-grubDisplayTest grub.1 defaultkernel/g.1 --default-kernel
+grubDisplayTest grub.1 defaultkernel/g.1 --boot-filesystem=/boot --default-kernel
+grubDisplayTest grub.1 defaultkernel/g.2 --boot-filesystem=/ --default-kernel
testing="LILO default directive"
liloTest lilo.1 default/l1.1 --set-default=/boot/vmlinuz-2.4.18-4
diff --git a/test/results/defaultkernel/g.2 b/test/results/defaultkernel/g.2
new file mode 100644
index 00000000000..d15855e1b57
--- /dev/null
+++ b/test/results/defaultkernel/g.2
@@ -0,0 +1 @@
+/vmlinuz-2.4.7-2
--
2.17.1

View File

@ -0,0 +1,85 @@
From 38d8178482ea7dabf7c4ab8c2973faa2b469e9c7 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 2 Jul 2015 16:26:59 -0400
Subject: [PATCH 11/55] Don't leak from one extractTitle() call.
Found by coverity.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grubby.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/grubby.c b/grubby.c
index 0bb486967bf..70477ba14ee 100644
--- a/grubby.c
+++ b/grubby.c
@@ -1510,13 +1510,14 @@ static struct grubConfig * readConfig(const char * inName,
return cfg;
}
-static void writeDefault(FILE * out, char * indent,
+static void writeDefault(FILE * out, char * indent,
char * separator, struct grubConfig * cfg) {
struct singleEntry * entry;
struct singleLine * line;
int i;
- if (!cfg->defaultImage && cfg->flags == GRUB_CONFIG_NO_DEFAULT) return;
+ if (!cfg->defaultImage && cfg->flags == GRUB_CONFIG_NO_DEFAULT)
+ return;
if (cfg->defaultImage == DEFAULT_SAVED)
fprintf(out, "%sdefault%ssaved\n", indent, separator);
@@ -1540,34 +1541,40 @@ static void writeDefault(FILE * out, char * indent,
fprintf(out, "%sset default=\"%d\"\n", indent,
cfg->defaultImage);
} else {
- fprintf(out, "%sdefault%s%d\n", indent, separator,
+ fprintf(out, "%sdefault%s%d\n", indent, separator,
cfg->defaultImage);
}
} else {
int image = cfg->defaultImage;
entry = cfg->entries;
- while (entry && entry->skip) entry = entry->next;
+ while (entry && entry->skip)
+ entry = entry->next;
i = 0;
while (entry && i < image) {
entry = entry->next;
- while (entry && entry->skip) entry = entry->next;
+ while (entry && entry->skip)
+ entry = entry->next;
i++;
}
- if (!entry) return;
+ if (!entry)
+ return;
line = getLineByType(LT_TITLE, entry->lines);
if (line && line->numElements >= 2)
- fprintf(out, "%sdefault%s%s\n", indent, separator,
+ fprintf(out, "%sdefault%s%s\n", indent, separator,
line->elements[1].item);
- else if (line && (line->numElements == 1) &&
+ else if (line && (line->numElements == 1) &&
cfg->cfi->titleBracketed) {
- fprintf(out, "%sdefault%s%s\n", indent, separator,
- extractTitle(cfg, line));
+ char *title = extractTitle(cfg, line);
+ if (title) {
+ fprintf(out, "%sdefault%s%s\n", indent, separator, title);
+ free(title);
+ }
}
}
}
--
2.17.1

View File

@ -0,0 +1,42 @@
From 3a0171fd435765161406238c8df6f66e859ddd93 Mon Sep 17 00:00:00 2001
From: Don Zickus <dzickus@redhat.com>
Date: Wed, 22 Jul 2015 13:58:53 -0400
Subject: [PATCH 12/55] ppc64le sync grub.cfg changes to disk (#1212114)
After installing a new kernel, if a panic is induced, not all the kernel
pieces are on the disk (most importantly the grub.cfg changes). This can
lead to a hung system on a reboot because the older kernel can not be found.
Address this by forcing all the changes (mainly the fs meta data) to disk
before finishing the kernel package installation.
Tested by 'yum install kernel-...; echo c > /proc/sysrq-trigger'.
Before, the machine would panic and on reboot be stuck without a grub.cfg
to read. After, works as expected.
Resolves: rhbz#1212114
---
new-kernel-pkg | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/new-kernel-pkg b/new-kernel-pkg
index 1f6ab39499f..90652da06b7 100755
--- a/new-kernel-pkg
+++ b/new-kernel-pkg
@@ -927,4 +927,12 @@ fi
# if we mounted the U-Boot directory, unmount it.
[ -n "$mounted" ] && umount $ubootDir
+# make sure changes make it to the disk.
+# if /boot is a mountpoint, force the meta data on disk
+# to by-pass writeback delay.
+# PPC64LE-only to deal with Petitboot issues
+if [ "$ARCH" = "ppc64le" ]; then
+ sync && mountpoint -q /boot &&fsfreeze -f /boot && fsfreeze -u /boot
+fi
+
exit 0
--
2.17.1

View File

@ -0,0 +1,38 @@
From 92adaf4e655c3e6833e6f3b96fe1f5b75f75fd64 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 6 Aug 2015 10:06:13 -0400
Subject: [PATCH 13/55] Make it possible to run "test.sh --verbose" from the
make command line.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
Makefile | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index ade4421aa25..cc7e823959f 100644
--- a/Makefile
+++ b/Makefile
@@ -26,6 +26,10 @@ CC = gcc
RPM_OPT_FLAGS ?= -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector
CFLAGS += $(RPM_OPT_FLAGS) -std=gnu99 -Wall -Werror -Wno-error=unused-function -Wno-unused-function -ggdb
LDFLAGS :=
+VERBOSE_TEST :=
+ifneq ($(VERBOSE_TEST),)
+ VERBOSE_TEST="--verbose"
+endif
grubby_LIBS = -lblkid -lpopt
@@ -39,7 +43,7 @@ debug : clean
test: all
@export TOPDIR=$(TOPDIR)
- @./test.sh
+ @./test.sh $(VERBOSE_TEST)
install: all
mkdir -p $(DESTDIR)$(PREFIX)/sbin
--
2.17.1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,586 @@
From 5c8744420dfc891b2422db8f0be4bad2368f9970 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 6 Aug 2015 10:07:11 -0400
Subject: [PATCH 15/55] Make SET_VARIABLE get handled individually in
GetNextLine()
Resolves: rhbz#1152550
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grubby.c | 119 ++++++++++++++++++++++-----
.gitignore | 2 +
test.sh | 8 ++
test/grub2.16 | 156 +++++++++++++++++++++++++++++++++++
test/results/add/g2-1.16 | 170 +++++++++++++++++++++++++++++++++++++++
5 files changed, 433 insertions(+), 22 deletions(-)
create mode 100644 test/grub2.16
create mode 100644 test/results/add/g2-1.16
diff --git a/grubby.c b/grubby.c
index fe6595b8386..d66c1c5a40a 100644
--- a/grubby.c
+++ b/grubby.c
@@ -75,6 +75,7 @@ struct lineElement {
};
enum lineType_e {
+ LT_UNIDENTIFIED = 0,
LT_WHITESPACE = 1 << 0,
LT_TITLE = 1 << 1,
LT_KERNEL = 1 << 2,
@@ -747,6 +748,33 @@ static char *sdupprintf(const char *format, ...)
return buf;
}
+static inline int
+kwcmp(struct keywordTypes *kw, const char * label, int case_insensitive)
+{
+ int kwl = strlen(kw->key);
+ int ll = strlen(label);
+ int rc;
+ int (*snc)(const char *s1, const char *s2, size_t n) =
+ case_insensitive ? strncasecmp : strncmp;
+ int (*sc)(const char *s1, const char *s2) =
+ case_insensitive ? strcasecmp : strcmp;
+
+ rc = snc(kw->key, label, kwl);
+ if (rc)
+ return rc;
+
+ for (int i = kwl; i < ll; i++) {
+ if (isspace(label[i]))
+ return 0;
+ if (kw->separatorChar && label[i] == kw->separatorChar)
+ return 0;
+ else if (kw->nextChar && label[i] == kw->nextChar)
+ return 0;
+ return sc(kw->key+kwl, label+kwl);
+ }
+ return 0;
+}
+
static enum lineType_e preferredLineType(enum lineType_e type,
struct configFileInfo *cfi)
{
@@ -812,13 +840,8 @@ static enum lineType_e getTypeByKeyword(char *keyword,
struct configFileInfo *cfi)
{
for (struct keywordTypes * kw = cfi->keywords; kw->key; kw++) {
- if (cfi->caseInsensitive) {
- if (!strcasecmp(keyword, kw->key))
- return kw->type;
- } else {
- if (!strcmp(keyword, kw->key))
- return kw->type;
- }
+ if (!kwcmp(kw, keyword, cfi->caseInsensitive))
+ return kw->type;
}
return LT_UNKNOWN;
}
@@ -913,6 +936,7 @@ static int readFile(int fd, char **bufPtr)
static void lineInit(struct singleLine *line)
{
+ line->type = LT_UNIDENTIFIED;
line->indent = NULL;
line->elements = NULL;
line->numElements = 0;
@@ -995,7 +1019,7 @@ static int lineWrite(FILE * out, struct singleLine *line,
if (fprintf(out, "%s", line->elements[i].item) == -1)
return -1;
- if (i < line->numElements - 1)
+ if (i < line->numElements - 1 || line->type == LT_SET_VARIABLE)
if (fprintf(out, "%s", line->elements[i].indent) == -1)
return -1;
}
@@ -1050,6 +1074,8 @@ static int getNextLine(char **bufPtr, struct singleLine *line,
break;
chptr++;
}
+ if (line->type == LT_UNIDENTIFIED)
+ line->type = getTypeByKeyword(start, cfi);
element->item = strndup(start, chptr - start);
start = chptr;
@@ -1115,7 +1141,7 @@ static int getNextLine(char **bufPtr, struct singleLine *line,
line->type = LT_WHITESPACE;
line->numElements = 0;
}
- } else {
+ } else if (line->type == LT_INITRD) {
struct keywordTypes *kw;
kw = getKeywordByType(line->type, cfi);
@@ -1177,6 +1203,39 @@ static int getNextLine(char **bufPtr, struct singleLine *line,
}
}
}
+ } else if (line->type == LT_SET_VARIABLE) {
+ /* and if it's a "set blah=" we need to split it
+ * yet a third way to avoid rhbz# XXX FIXME :/
+ */
+ char *eq;
+ int l;
+ int numElements = line->numElements;
+ struct lineElement *newElements;
+ eq = strchr(line->elements[1].item, '=');
+ if (!eq)
+ return 0;
+ l = eq - line->elements[1].item;
+ if (eq[1] != 0)
+ numElements++;
+ newElements = calloc(numElements,sizeof (*newElements));
+ memcpy(&newElements[0], &line->elements[0],
+ sizeof (newElements[0]));
+ newElements[1].item =
+ strndup(line->elements[1].item, l);
+ newElements[1].indent = "=";
+ *(eq++) = '\0';
+ newElements[2].item = strdup(eq);
+ free(line->elements[1].item);
+ if (line->elements[1].indent)
+ newElements[2].indent = line->elements[1].indent;
+ for (int i = 2; i < line->numElements; i++) {
+ newElements[i+1].item = line->elements[i].item;
+ newElements[i+1].indent =
+ line->elements[i].indent;
+ }
+ free(line->elements);
+ line->elements = newElements;
+ line->numElements = numElements;
}
}
@@ -1282,13 +1341,12 @@ static struct grubConfig *readConfig(const char *inName,
getKeywordByType(LT_DEFAULT, cfi);
if (kwType && line->numElements == 3
&& !strcmp(line->elements[1].item, kwType->key)
- && !is_special_grub2_variable(line->elements[2].
- item)) {
+ && !is_special_grub2_variable(
+ line->elements[2].item)) {
dbgPrintf("Line sets default config\n");
cfg->flags &= ~GRUB_CONFIG_NO_DEFAULT;
defaultLine = line;
}
-
} else if (iskernel(line->type)) {
/* if by some freak chance this is multiboot and the
* "module" lines came earlier in the template, make
@@ -1542,16 +1600,33 @@ static struct grubConfig *readConfig(const char *inName,
}
}
} else if (cfi->defaultIsVariable) {
- char *value = defaultLine->elements[2].item;
- while (*value && (*value == '"' || *value == '\'' ||
- *value == ' ' || *value == '\t'))
- value++;
- cfg->defaultImage = strtol(value, &end, 10);
- while (*end && (*end == '"' || *end == '\'' ||
- *end == ' ' || *end == '\t'))
- end++;
- if (*end)
- cfg->defaultImage = -1;
+ if (defaultLine->numElements == 2) {
+ char *value = defaultLine->elements[1].item + 8;
+ while (*value && (*value == '"' ||
+ *value == '\'' ||
+ *value == ' ' ||
+ *value == '\t'))
+ value++;
+ cfg->defaultImage = strtol(value, &end, 10);
+ while (*end && (*end == '"' || *end == '\'' ||
+ *end == ' ' || *end == '\t'))
+ end++;
+ if (*end)
+ cfg->defaultImage = -1;
+ } else if (defaultLine->numElements == 3) {
+ char *value = defaultLine->elements[2].item;
+ while (*value && (*value == '"' ||
+ *value == '\'' ||
+ *value == ' ' ||
+ *value == '\t'))
+ value++;
+ cfg->defaultImage = strtol(value, &end, 10);
+ while (*end && (*end == '"' || *end == '\'' ||
+ *end == ' ' || *end == '\t'))
+ end++;
+ if (*end)
+ cfg->defaultImage = -1;
+ }
} else if (cfi->defaultSupportSaved &&
!strncmp(defaultLine->elements[1].item, "saved",
5)) {
diff --git a/.gitignore b/.gitignore
index e64d3bc0986..e78a392d601 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
grubby
version.h
*.o
+core.*
+vgcore.*
diff --git a/test.sh b/test.sh
index 2985fd62bf9..cd2d8707b5f 100755
--- a/test.sh
+++ b/test.sh
@@ -543,6 +543,14 @@ if [ "$testgrub2" == "y" ]; then
--copy-default --title "Fedora 21 Rescue" --args=root=/fooooo \
--remove-kernel=wtf --boot-filesystem=/boot/ --efi
+ # a grub2 add with a "set" of the form: set foo="bar=1,2". bz#1152550
+ # has this being emitted as: set foo="bar=1,2"=1,2"
+ # which is wrong.
+ grub2Test grub2.16 add/g2-1.16 \
+ --add-kernel=/boot/vmlinuz-foo \
+ --copy-default --title 'Red Hat Enterprise Linux Server' \
+ --args=root=/dev/mapper/foo--
+
testing="GRUB2 add initrd"
grub2Test grub2.2 add/g2-1.4 --update-kernel=/boot/new-kernel.img \
--initrd=/boot/new-initrd --boot-filesystem=/boot/
diff --git a/test/grub2.16 b/test/grub2.16
new file mode 100644
index 00000000000..136880a61ee
--- /dev/null
+++ b/test/grub2.16
@@ -0,0 +1,156 @@
+#
+# DO NOT EDIT THIS FILE
+#
+# It is automatically generated by grub2-mkconfig using templates
+# from /etc/grub.d and settings from /etc/default/grub
+#
+
+### BEGIN /etc/grub.d/00_header ###
+set pager=1
+
+if [ -s $prefix/grubenv ]; then
+ load_env
+fi
+if [ "${next_entry}" ] ; then
+ set default="${next_entry}"
+ set next_entry=
+ save_env next_entry
+ set boot_once=true
+else
+ set default="${saved_entry}"
+fi
+
+if [ x"${feature_menuentry_id}" = xy ]; then
+ menuentry_id_option="--id"
+else
+ menuentry_id_option=""
+fi
+
+export menuentry_id_option
+
+if [ "${prev_saved_entry}" ]; then
+ set saved_entry="${prev_saved_entry}"
+ save_env saved_entry
+ set prev_saved_entry=
+ save_env prev_saved_entry
+ set boot_once=true
+fi
+
+function savedefault {
+ if [ -z "${boot_once}" ]; then
+ saved_entry="${chosen}"
+ save_env saved_entry
+ fi
+}
+
+function load_video {
+ if [ x$feature_all_video_module = xy ]; then
+ insmod all_video
+ else
+ insmod efi_gop
+ insmod efi_uga
+ insmod ieee1275_fb
+ insmod vbe
+ insmod vga
+ insmod video_bochs
+ insmod video_cirrus
+ fi
+}
+
+serial --speed=115200
+terminal_input serial console
+terminal_output serial console
+if [ x$feature_timeout_style = xy ] ; then
+ set timeout_style=menu
+ set timeout=5
+# Fallback normal timeout code in case the timeout_style feature is
+# unavailable.
+else
+ set timeout=5
+fi
+### END /etc/grub.d/00_header ###
+
+### BEGIN /etc/grub.d/00_tuned ###
+set tuned_params="isolcpus=1,3"
+### END /etc/grub.d/00_tuned ###
+
+### BEGIN /etc/grub.d/01_users ###
+if [ -f ${prefix}/user.cfg ]; then
+ source ${prefix}/user.cfg
+ if [ -n ${GRUB2_PASSWORD} ]; then
+ set superusers="root"
+ export superusers
+ password_pbkdf2 root ${GRUB2_PASSWORD}
+ fi
+fi
+### END /etc/grub.d/01_users ###
+
+### BEGIN /etc/grub.d/10_linux ###
+menuentry 'Red Hat Enterprise Linux Server (3.10.0-297.el7.x86_64) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-296.el7.x86_64-advanced-ae7b3742-9092-4432-9f7f-8abdbf0dc3db' {
+ load_video
+ set gfxpayload=keep
+ insmod gzio
+ insmod part_msdos
+ insmod xfs
+ set root='hd0,msdos1'
+ if [ x$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' cae02b39-f239-4d26-9032-674d261c93d8
+ else
+ search --no-floppy --fs-uuid --set=root cae02b39-f239-4d26-9032-674d261c93d8
+ fi
+ linux16 /vmlinuz-3.10.0-297.el7.x86_64 root=/dev/mapper/rhel_hp--dl380pgen8--02--vm--10-root ro crashkernel=auto rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/root rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/swap console=ttyS0,115200n81 $tuned_params LANG=en_US.UTF-8
+}
+menuentry 'Red Hat Enterprise Linux Server (3.10.0-296.el7.x86_64) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-296.el7.x86_64-advanced-ae7b3742-9092-4432-9f7f-8abdbf0dc3db' {
+ load_video
+ set gfxpayload=keep
+ insmod gzio
+ insmod part_msdos
+ insmod xfs
+ set root='hd0,msdos1'
+ if [ x$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' cae02b39-f239-4d26-9032-674d261c93d8
+ else
+ search --no-floppy --fs-uuid --set=root cae02b39-f239-4d26-9032-674d261c93d8
+ fi
+ linux16 /vmlinuz-3.10.0-296.el7.x86_64 root=/dev/mapper/rhel_hp--dl380pgen8--02--vm--10-root ro crashkernel=auto rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/root rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/swap console=ttyS0,115200n81 $tuned_params
+ initrd16 /initramfs-3.10.0-296.el7.x86_64.img
+}
+menuentry 'Red Hat Enterprise Linux Server (0-rescue-cc21b92886f9ebbd3ed5a494639b7fd7) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-cc21b92886f9ebbd3ed5a494639b7fd7-advanced-ae7b3742-9092-4432-9f7f-8abdbf0dc3db' {
+ load_video
+ insmod gzio
+ insmod part_msdos
+ insmod xfs
+ set root='hd0,msdos1'
+ if [ x$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' cae02b39-f239-4d26-9032-674d261c93d8
+ else
+ search --no-floppy --fs-uuid --set=root cae02b39-f239-4d26-9032-674d261c93d8
+ fi
+ linux16 /vmlinuz-0-rescue-cc21b92886f9ebbd3ed5a494639b7fd7 root=/dev/mapper/rhel_hp--dl380pgen8--02--vm--10-root ro crashkernel=auto rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/root rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/swap console=ttyS0,115200n81 $tuned_params
+ initrd16 /initramfs-0-rescue-cc21b92886f9ebbd3ed5a494639b7fd7.img
+}
+if [ "x$default" = 'Red Hat Enterprise Linux Server (3.10.0-296.el7.x86_64) 7.2 (Maipo)' ]; then default='Advanced options for Red Hat Enterprise Linux Server>Red Hat Enterprise Linux Server (3.10.0-296.el7.x86_64) 7.2 (Maipo)'; fi;
+### END /etc/grub.d/10_linux ###
+
+### BEGIN /etc/grub.d/20_linux_xen ###
+### END /etc/grub.d/20_linux_xen ###
+
+### BEGIN /etc/grub.d/20_ppc_terminfo ###
+### END /etc/grub.d/20_ppc_terminfo ###
+
+### BEGIN /etc/grub.d/30_os-prober ###
+### END /etc/grub.d/30_os-prober ###
+
+### BEGIN /etc/grub.d/40_custom ###
+# This file provides an easy way to add custom menu entries. Simply type the
+# menu entries you want to add after this comment. Be careful not to change
+# the 'exec tail' line above.
+### END /etc/grub.d/40_custom ###
+
+### BEGIN /etc/grub.d/41_custom ###
+if [ -f ${config_directory}/custom.cfg ]; then
+ source ${config_directory}/custom.cfg
+elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
+ source $prefix/custom.cfg;
+fi
+### END /etc/grub.d/41_custom ###
diff --git a/test/results/add/g2-1.16 b/test/results/add/g2-1.16
new file mode 100644
index 00000000000..fc98757f4fc
--- /dev/null
+++ b/test/results/add/g2-1.16
@@ -0,0 +1,170 @@
+#
+# DO NOT EDIT THIS FILE
+#
+# It is automatically generated by grub2-mkconfig using templates
+# from /etc/grub.d and settings from /etc/default/grub
+#
+
+### BEGIN /etc/grub.d/00_header ###
+set pager=1
+
+if [ -s $prefix/grubenv ]; then
+ load_env
+fi
+if [ "${next_entry}" ] ; then
+ set default="${next_entry}"
+ set next_entry=
+ save_env next_entry
+ set boot_once=true
+else
+ set default="${saved_entry}"
+fi
+
+if [ x"${feature_menuentry_id}" = xy ]; then
+ menuentry_id_option="--id"
+else
+ menuentry_id_option=""
+fi
+
+export menuentry_id_option
+
+if [ "${prev_saved_entry}" ]; then
+ set saved_entry="${prev_saved_entry}"
+ save_env saved_entry
+ set prev_saved_entry=
+ save_env prev_saved_entry
+ set boot_once=true
+fi
+
+function savedefault {
+ if [ -z "${boot_once}" ]; then
+ saved_entry="${chosen}"
+ save_env saved_entry
+ fi
+}
+
+function load_video {
+ if [ x$feature_all_video_module = xy ]; then
+ insmod all_video
+ else
+ insmod efi_gop
+ insmod efi_uga
+ insmod ieee1275_fb
+ insmod vbe
+ insmod vga
+ insmod video_bochs
+ insmod video_cirrus
+ fi
+}
+
+serial --speed=115200
+terminal_input serial console
+terminal_output serial console
+if [ x$feature_timeout_style = xy ] ; then
+ set timeout_style=menu
+ set timeout=5
+# Fallback normal timeout code in case the timeout_style feature is
+# unavailable.
+else
+ set timeout=5
+fi
+### END /etc/grub.d/00_header ###
+
+### BEGIN /etc/grub.d/00_tuned ###
+set tuned_params="isolcpus=1,3"
+### END /etc/grub.d/00_tuned ###
+
+### BEGIN /etc/grub.d/01_users ###
+if [ -f ${prefix}/user.cfg ]; then
+ source ${prefix}/user.cfg
+ if [ -n ${GRUB2_PASSWORD} ]; then
+ set superusers="root"
+ export superusers
+ password_pbkdf2 root ${GRUB2_PASSWORD}
+ fi
+fi
+### END /etc/grub.d/01_users ###
+
+### BEGIN /etc/grub.d/10_linux ###
+menuentry 'Red Hat Enterprise Linux Server' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-296.el7.x86_64-advanced-ae7b3742-9092-4432-9f7f-8abdbf0dc3db' {
+ load_video
+ set gfxpayload=keep
+ insmod gzio
+ insmod part_msdos
+ insmod xfs
+ set root='hd0,msdos1'
+ if [ x$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' cae02b39-f239-4d26-9032-674d261c93d8
+ else
+ search --no-floppy --fs-uuid --set=root cae02b39-f239-4d26-9032-674d261c93d8
+ fi
+ linux16 /vmlinuz-foo root=/dev/mapper/foo-- ro crashkernel=auto rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/root rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/swap console=ttyS0,115200n81 $tuned_params LANG=en_US.UTF-8
+}
+menuentry 'Red Hat Enterprise Linux Server (3.10.0-297.el7.x86_64) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-296.el7.x86_64-advanced-ae7b3742-9092-4432-9f7f-8abdbf0dc3db' {
+ load_video
+ set gfxpayload=keep
+ insmod gzio
+ insmod part_msdos
+ insmod xfs
+ set root='hd0,msdos1'
+ if [ x$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' cae02b39-f239-4d26-9032-674d261c93d8
+ else
+ search --no-floppy --fs-uuid --set=root cae02b39-f239-4d26-9032-674d261c93d8
+ fi
+ linux16 /vmlinuz-3.10.0-297.el7.x86_64 root=/dev/mapper/rhel_hp--dl380pgen8--02--vm--10-root ro crashkernel=auto rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/root rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/swap console=ttyS0,115200n81 $tuned_params LANG=en_US.UTF-8
+}
+menuentry 'Red Hat Enterprise Linux Server (3.10.0-296.el7.x86_64) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-296.el7.x86_64-advanced-ae7b3742-9092-4432-9f7f-8abdbf0dc3db' {
+ load_video
+ set gfxpayload=keep
+ insmod gzio
+ insmod part_msdos
+ insmod xfs
+ set root='hd0,msdos1'
+ if [ x$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' cae02b39-f239-4d26-9032-674d261c93d8
+ else
+ search --no-floppy --fs-uuid --set=root cae02b39-f239-4d26-9032-674d261c93d8
+ fi
+ linux16 /vmlinuz-3.10.0-296.el7.x86_64 root=/dev/mapper/rhel_hp--dl380pgen8--02--vm--10-root ro crashkernel=auto rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/root rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/swap console=ttyS0,115200n81 $tuned_params
+ initrd16 /initramfs-3.10.0-296.el7.x86_64.img
+}
+menuentry 'Red Hat Enterprise Linux Server (0-rescue-cc21b92886f9ebbd3ed5a494639b7fd7) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-cc21b92886f9ebbd3ed5a494639b7fd7-advanced-ae7b3742-9092-4432-9f7f-8abdbf0dc3db' {
+ load_video
+ insmod gzio
+ insmod part_msdos
+ insmod xfs
+ set root='hd0,msdos1'
+ if [ x$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' cae02b39-f239-4d26-9032-674d261c93d8
+ else
+ search --no-floppy --fs-uuid --set=root cae02b39-f239-4d26-9032-674d261c93d8
+ fi
+ linux16 /vmlinuz-0-rescue-cc21b92886f9ebbd3ed5a494639b7fd7 root=/dev/mapper/rhel_hp--dl380pgen8--02--vm--10-root ro crashkernel=auto rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/root rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/swap console=ttyS0,115200n81 $tuned_params
+ initrd16 /initramfs-0-rescue-cc21b92886f9ebbd3ed5a494639b7fd7.img
+}
+if [ "x$default" = 'Red Hat Enterprise Linux Server (3.10.0-296.el7.x86_64) 7.2 (Maipo)' ]; then default='Advanced options for Red Hat Enterprise Linux Server>Red Hat Enterprise Linux Server (3.10.0-296.el7.x86_64) 7.2 (Maipo)'; fi;
+### END /etc/grub.d/10_linux ###
+
+### BEGIN /etc/grub.d/20_linux_xen ###
+### END /etc/grub.d/20_linux_xen ###
+
+### BEGIN /etc/grub.d/20_ppc_terminfo ###
+### END /etc/grub.d/20_ppc_terminfo ###
+
+### BEGIN /etc/grub.d/30_os-prober ###
+### END /etc/grub.d/30_os-prober ###
+
+### BEGIN /etc/grub.d/40_custom ###
+# This file provides an easy way to add custom menu entries. Simply type the
+# menu entries you want to add after this comment. Be careful not to change
+# the 'exec tail' line above.
+### END /etc/grub.d/40_custom ###
+
+### BEGIN /etc/grub.d/41_custom ###
+if [ -f ${config_directory}/custom.cfg ]; then
+ source ${config_directory}/custom.cfg
+elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
+ source $prefix/custom.cfg;
+fi
+### END /etc/grub.d/41_custom ###
--
2.17.1

View File

@ -0,0 +1,31 @@
From c014354834f496ade11dda3f6406cbddbee25f75 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 1 Sep 2015 11:02:07 -0400
Subject: [PATCH 16/55] Specify bootloader directory in the test case for
1152550.
Because otherwise it blows up when built in mock without /boot mounted.
Related: rhbz#1152550
Signed-off-by: Peter Jones <pjones@redhat.com>
---
test.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test.sh b/test.sh
index cd2d8707b5f..ba466a50501 100755
--- a/test.sh
+++ b/test.sh
@@ -547,7 +547,7 @@ if [ "$testgrub2" == "y" ]; then
# has this being emitted as: set foo="bar=1,2"=1,2"
# which is wrong.
grub2Test grub2.16 add/g2-1.16 \
- --add-kernel=/boot/vmlinuz-foo \
+ --boot-filesystem=/boot --add-kernel=/boot/vmlinuz-foo \
--copy-default --title 'Red Hat Enterprise Linux Server' \
--args=root=/dev/mapper/foo--
--
2.17.1

View File

@ -0,0 +1,63 @@
From a8fd0f15979d5f4632c337c8bcfbdbae2b957f67 Mon Sep 17 00:00:00 2001
From: marcosfrm <marcosfrm@users.noreply.github.com>
Date: Tue, 6 Oct 2015 08:29:02 -0300
Subject: [PATCH 17/55] Fix dracut cmdline options and conditionalize them to
--add-dracut-args
By default initramfs generated by dracut is HostOnly and has vconsole.conf and locale.conf included. Instead of killing this import section, conditionalize it to --add-dracut-args.
Reference: http://git.kernel.org/cgit/boot/dracut/dracut.git/tree/modules.d/10i18n/parse-i18n.sh
---
new-kernel-pkg | 35 ++++++++++++++---------------------
1 file changed, 14 insertions(+), 21 deletions(-)
diff --git a/new-kernel-pkg b/new-kernel-pkg
index 90652da06b7..997fb1f4987 100755
--- a/new-kernel-pkg
+++ b/new-kernel-pkg
@@ -825,28 +825,21 @@ if [[ ${ARCH} =~ armv[5|7].*l ]]; then
fi
[ -n "$verbose" ] && echo "devtreedir is $devtreedir"
-# add dracut i18n, keyboard and plymouth kernel args if requested
-if [ -n "$dracut" -o -n "$adddracutargs" ]; then
- if [ -r /etc/vconsole.conf ]; then
- . /etc/vconsole.conf
- elif [ -r /etc/sysconfig/keyboard ]; then
- . /etc/sysconfig/keyboard
- fi
+# add dracut kernel args if requested
+if [ -n "$dracut" -a -n "$adddracutargs" ]; then
+ [ -r /etc/vconsole.conf ] && . /etc/vconsole.conf
+ [ -r /etc/locale.conf ] && . /etc/locale.conf
- if [ -r /etc/locale.conf ]; then
- . /etc/locale.conf
- elif [ -r /etc/sysconfig/i18n ]; then
- . /etc/sysconfig/i18n
- fi
-
- for i in SYSFONT SYSFONTACM UNIMAP LANG KEYTABLE; do
- val=$(eval echo \$$i)
- [ -n "$val" ] && kernargs="$kernargs $i=$val"
- done
-
- if [ -n "$KEYBOARDTYPE" -a "$KEYBOARDTYPE" != "pc" ]; then
- kernargs="$kernargs KEYBOARDTYPE=$KEYBOARDTYPE"
- fi
+ while read opt rd_opt; do
+ [ -n "${!opt}" ] && kernargs="$kernargs $rd_opt=\"${!opt}\""
+ done <<< 'KEYMAP rd.vconsole.keymap
+ FONT rd.vconsole.font
+ FONT_MAP rd.vconsole.font.map
+ FONT_UNIMAP rd.vconsole.font.unimap
+ UNICODE rd.vconsole.font.unicode
+ EXT_KEYMAP rd.vconsole.keymap.ext
+ LANG rd.locale.LANG
+ LC_ALL rd.locale.LC_ALL'
fi
# set this as the default if we have the package and it matches
--
2.17.1

View File

@ -0,0 +1,25 @@
From 7ee039e026fe02e01dd4c7fd2b18682b8737697c Mon Sep 17 00:00:00 2001
From: marcosfrm <marcosfrm@users.noreply.github.com>
Date: Tue, 6 Oct 2015 08:40:44 -0300
Subject: [PATCH 18/55] Add missing space
---
new-kernel-pkg | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/new-kernel-pkg b/new-kernel-pkg
index 997fb1f4987..9f56c470b4a 100755
--- a/new-kernel-pkg
+++ b/new-kernel-pkg
@@ -925,7 +925,7 @@ fi
# to by-pass writeback delay.
# PPC64LE-only to deal with Petitboot issues
if [ "$ARCH" = "ppc64le" ]; then
- sync && mountpoint -q /boot &&fsfreeze -f /boot && fsfreeze -u /boot
+ sync && mountpoint -q /boot && fsfreeze -f /boot && fsfreeze -u /boot
fi
exit 0
--
2.17.1

View File

@ -0,0 +1,123 @@
From ae22f8322d2f2dccd19003fccd390fe19f7126c1 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 26 Oct 2015 14:22:39 -0400
Subject: [PATCH 19/55] Always do the "rungrubby --debug" after the normal
kernel on install.
This way the during an update, the right kernel is picked as "default"
for the command line arguments.
Related: rhbz#1212128
Signed-off-by: Peter Jones <pjones@redhat.com>
---
new-kernel-pkg | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/new-kernel-pkg b/new-kernel-pkg
index 9f56c470b4a..9574dbbf10b 100755
--- a/new-kernel-pkg
+++ b/new-kernel-pkg
@@ -243,8 +243,8 @@ install() {
--args=\"root=$rootdevice $kernargs \$debugargs\" \
--remove-kernel=\"TITLE=$title\$debugtitle\""
- rungrubby --debug ${ARGS}
rungrubby ${ARGS} $makedefault
+ rungrubby --debug ${ARGS}
else
[ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby for grub 0.97"
fi
@@ -257,8 +257,8 @@ install() {
${mbargs:+--mbargs=\"$mbargs\"} \
--args=\"root=$rootdevice $kernargs \$debugargs\" \
--remove-kernel=\"TITLE=$title\$debugtitle\""
- rungrubby --debug ${ARGS}
rungrubby ${ARGS} $makedefault
+ rungrubby --debug ${ARGS}
else
[ -n "$verbose" ] && echo "$grub2Config does not exist, not running grubby for grub 2"
fi
@@ -272,8 +272,8 @@ install() {
${mbargs:+--mbargs=\"$mbargs\"} \
--args=\"root=$rootdevice $kernargs \$debugargs\" \
--remove-kernel=\"TITLE=$title\$debugtitle\""
- rungrubby --debug ${ARGS}
rungrubby ${ARGS} $makedefault
+ rungrubby --debug ${ARGS}
else
[ -n "$verbose" ] && echo "$grub2EfiConfig does not exist, not running grubby for grub 2 with UEFI"
fi
@@ -288,8 +288,8 @@ install() {
--args=\"root=$rootdevice $kernargs \$debugargs\" \
--remove-kernel=\"TITLE=$version\""
- rungrubby --debug ${ARGS}
rungrubby ${ARGS} $makedefault
+ rungrubby --debug ${ARGS}
if [ -n "$runLilo" ]; then
[ -n "$verbose" ] && echo "running $lilo"
if [ ! -x $lilo ] ; then
@@ -313,8 +313,8 @@ install() {
--args=\"root=$rootdevice $kernargs \$debugargs\" \
--remove-kernel=\"TITLE=$title\$debugtitle\""
- rungrubby --debug ${ARGS}
rungrubby ${ARGS} $makedefault
+ rungrubby --debug ${ARGS}
else
[ -n "$verbose" ] && echo "$extlinuxConfig does not exist, not running grubby for extlinux"
fi
@@ -480,8 +480,8 @@ update() {
${mbkernel:+--add-multiboot=\"$mbkernel\"} \
--title=\"$title\$debugtitle\""
- rungrubby --debug ${ARGS}
rungrubby ${ARGS}
+ rungrubby --debug ${ARGS}
else
[ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby"
fi
@@ -493,8 +493,8 @@ update() {
${removeargs:+--remove-args=\"$removeargs\"} \
--title=\"$title\$debugtitle\""
- rungrubby --debug ${ARGS}
rungrubby ${ARGS}
+ rungrubby --debug ${ARGS}
else
[ -n "$verbose" ] && echo "$grub2Config does not exist, not running grubby"
fi
@@ -506,8 +506,8 @@ update() {
${removeargs:+--remove-args=\"$removeargs\"} \
--title=\"$title\$debugtitle\""
- rungrubby --debug ${ARGS}
rungrubby ${ARGS}
+ rungrubby --debug ${ARGS}
else
[ -n "$verbose" ] && echo "$grub2EfiConfig does not exist, not running grubby"
fi
@@ -519,8 +519,8 @@ update() {
${removeargs:+--remove-args=\"$removeargs\"} \
--title=\"$title\$debugtitle\""
- rungrubby --debug ${ARGS}
rungrubby ${ARGS}
+ rungrubby --debug ${ARGS}
if [ -n "$runLilo" ]; then
[ -n "$verbose" ] && echo "running $lilo"
@@ -571,8 +571,8 @@ update() {
${removeargs:+--remove-args=\"$removeargs\"} \
--title=\"$title\$debugtitle\""
- rungrubby --debug ${ARGS}
rungrubby ${ARGS}
+ rungrubby --debug ${ARGS}
else
[ -n "$verbose" ] && echo "$extlinuxConfig does not exist, not running grubby"
fi
--
2.17.1

View File

@ -0,0 +1,298 @@
From 8efba98644f9262d74a42fac7ea39d197192443a Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 22 Jun 2016 14:07:49 -0400
Subject: [PATCH 20/55] grubby: add --set-index to specify which position to
add new entries as
This adds an option, "--set-index N", to grubby, and will cause creation
of any new entry to be at a particular zero-indexed position in the
resulting configuration file.
Related: rhbz#1285601
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grubby.c | 26 +++++++++++++++++++++-----
.gitignore | 1 +
grubby.8 | 8 ++++++--
test.sh | 14 ++++++++++++++
test/grub.15 | 19 +++++++++++++++++++
test/results/add/g1.10 | 22 ++++++++++++++++++++++
test/results/add/g1.17 | 19 +++++++++++++++++++
test/results/add/g1.8 | 22 ++++++++++++++++++++++
test/results/add/g1.9 | 22 ++++++++++++++++++++++
9 files changed, 146 insertions(+), 7 deletions(-)
create mode 100644 test/grub.15
create mode 100644 test/results/add/g1.10
create mode 100644 test/results/add/g1.17
create mode 100644 test/results/add/g1.8
create mode 100644 test/results/add/g1.9
diff --git a/grubby.c b/grubby.c
index d66c1c5a40a..54625e7da0a 100644
--- a/grubby.c
+++ b/grubby.c
@@ -4207,9 +4207,9 @@ int addNewKernel(struct grubConfig *config, struct singleEntry *template,
const char *newKernelArgs, const char *newKernelInitrd,
const char **extraInitrds, int extraInitrdCount,
const char *newMBKernel, const char *newMBKernelArgs,
- const char *newDevTreePath)
+ const char *newDevTreePath, int newIndex)
{
- struct singleEntry *new;
+ struct singleEntry *new, *entry, *prev = NULL;
struct singleLine *newLine = NULL, *tmplLine = NULL, *masterLine = NULL;
int needs;
char *chptr;
@@ -4239,9 +4239,20 @@ int addNewKernel(struct grubConfig *config, struct singleEntry *template,
new = malloc(sizeof(*new));
new->skip = 0;
new->multiboot = 0;
- new->next = config->entries;
new->lines = NULL;
- config->entries = new;
+ entry = config->entries;
+ for (unsigned int i = 0; i < newIndex; i++) {
+ if (!entry)
+ break;
+ prev = entry;
+ entry = entry->next;
+ }
+ new->next = entry;
+
+ if (prev)
+ prev->next = new;
+ else
+ config->entries = new;
/* copy/update from the template */
needs = NEED_KERNEL | NEED_TITLE;
@@ -4734,6 +4745,7 @@ int main(int argc, const char **argv)
char *newDevTreePath = NULL;
char *newMBKernel = NULL;
char *newMBKernelArgs = NULL;
+ int newIndex = 0;
char *removeMBKernelArgs = NULL;
char *removeMBKernel = NULL;
char *bootPrefix = NULL;
@@ -4840,6 +4852,9 @@ int main(int argc, const char **argv)
{"set-default-index", 0, POPT_ARG_INT, &defaultIndex, 0,
_("make the given entry index the default entry"),
_("entry-index")},
+ {"set-index", 0, POPT_ARG_INT, &newIndex, 0,
+ _("use the given index when creating a new entry"),
+ _("entry-index")},
{"silo", 0, POPT_ARG_NONE, &configureSilo, 0,
_("configure silo bootloader")},
{"title", 0, POPT_ARG_STRING, &newKernelTitle, 0,
@@ -5255,7 +5270,8 @@ int main(int argc, const char **argv)
if (addNewKernel(config, template, bootPrefix, newKernelPath,
newKernelTitle, newKernelArgs, newKernelInitrd,
(const char **)extraInitrds, extraInitrdCount,
- newMBKernel, newMBKernelArgs, newDevTreePath))
+ newMBKernel, newMBKernelArgs, newDevTreePath,
+ newIndex))
return 1;
if (numEntries(config) == 0) {
diff --git a/.gitignore b/.gitignore
index e78a392d601..1c00ff7c5ed 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@ version.h
*.o
core.*
vgcore.*
+*.tar.*
diff --git a/grubby.8 b/grubby.8
index 355b6eb6908..a4691f8ddb2 100644
--- a/grubby.8
+++ b/grubby.8
@@ -7,12 +7,12 @@ grubby \- command line tool for configuring grub, lilo, elilo, yaboot and zipl
[--bad-image-okay] [--boot-filesystem=\fIbootfs\fR]
[--bootloader-probe] [--config-file \fIpath\fR] [--copy-default]
[--debug] [--default-kernel] [--default-index] [--default-title]
- [--devtree=\fIdevicetree.dtb\fR]
+ [--devtree=\fIdevicetree.dtb\fR] [--set-entry=\fIentry-index\fR]
[--grub] [--lilo] [--yaboot] [--silo] [--zipl]
[--info=\fIkernel-path\fR] [--initrd=\fIinitrd-path\fR]
[--make-default] [-o path] [--version]
[--remove-kernel=\fIkernel-path\fR] [--remove-args=\fIargs\fR]
- [--set-default=\fIkernel-path\fR] [--set-default-index=\fientry-index\fR]
+ [--set-default=\fIkernel-path\fR] [--set-default-index=\fIentry-index\fR]
[--title=entry-title] [--add-multiboot=\fImultiboot-path\fR]
[--mbargs=\fIargs\fR] [--remove-multiboot=\fImultiboot-path\fR]
[--remove-mbargs=\fIargs\fR]
@@ -48,6 +48,10 @@ with that title are used.
\fB-\-add-kernel\fR=\fIkernel-path\fR
Add a new boot entry for the kernel located at \fIkernel-path\fR.
+.TP
+\fB-\-set-entry\fR=\fIentry-index\fR
+Set the position at which to add a new entry created with \fB-\-add-kernel\fR.
+
.TP
\fB-\-args\fR=\fIkernel-args\fR
When a new kernel is added, this specifies the command line arguments
diff --git a/test.sh b/test.sh
index ba466a50501..7d1794c83df 100755
--- a/test.sh
+++ b/test.sh
@@ -485,6 +485,20 @@ grubTest grub.8 add/g8.2 --add-kernel=/boot/new-kernel.img --title='title' \
grubTest grub.11 add/g11.1 --add-kernel=/boot/new-kernel.img --title='title' \
--initrd=/boot/new-initrd --boot-filesystem=/boot --copy-default \
--args='console=tty0 console=ttyS1,9600n81 single'
+grubTest grub.1 add/g1.1 --add-kernel=/boot/new-kernel.img --title='title' \
+ --initrd=/boot/new-initrd --boot-filesystem=/ --set-index 0
+grubTest grub.1 add/g1.17 --add-kernel=/boot/new-kernel.img --title='title' \
+ --initrd=/boot/new-initrd --boot-filesystem=/ --set-index 1
+grubTest grub.1 add/g1.17 --add-kernel=/boot/new-kernel.img --title='title' \
+ --initrd=/boot/new-initrd --boot-filesystem=/ --set-index 2
+grubTest grub.15 add/g1.10 --add-kernel=/boot/new-kernel.img --title='title' \
+ --initrd=/boot/new-initrd --boot-filesystem=/ --set-index 0
+grubTest grub.15 add/g1.8 --add-kernel=/boot/new-kernel.img --title='title' \
+ --initrd=/boot/new-initrd --boot-filesystem=/ --set-index 1
+grubTest grub.15 add/g1.9 --add-kernel=/boot/new-kernel.img --title='title' \
+ --initrd=/boot/new-initrd --boot-filesystem=/ --set-index 2
+grubTest grub.15 add/g1.9 --add-kernel=/boot/new-kernel.img --title='title' \
+ --initrd=/boot/new-initrd --boot-filesystem=/ --set-index 5
testgrub2=n
ARCH=$(uname -m | sed s,i[3456789]86,ia32,)
diff --git a/test/grub.15 b/test/grub.15
new file mode 100644
index 00000000000..e1c5f8a9b52
--- /dev/null
+++ b/test/grub.15
@@ -0,0 +1,19 @@
+# grub.conf generated by anaconda
+#
+# Note that you do not have to rerun grub after making changes to this file
+# NOTICE: You have a /boot partition. This means that
+# all kernel and initrd paths are relative to /boot/, eg.
+# root (hd0,0)
+# kernel /vmlinuz-version ro root=/dev/sda1
+# initrd /initrd-version.img
+#boot=/dev/hda
+default=1
+timeout=10
+splashimage=(hd0,0)/grub/splash.xpm.gz
+title Red Hat Linux (2.4.7-2)
+ root (hd0,0)
+ kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1
+ initrd /initrd-2.4.7-2.img
+title zonk
+ kernel /boot/new-kernel.img
+ initrd /boot/new-initrd
diff --git a/test/results/add/g1.10 b/test/results/add/g1.10
new file mode 100644
index 00000000000..dcdd8a8ce10
--- /dev/null
+++ b/test/results/add/g1.10
@@ -0,0 +1,22 @@
+# grub.conf generated by anaconda
+#
+# Note that you do not have to rerun grub after making changes to this file
+# NOTICE: You have a /boot partition. This means that
+# all kernel and initrd paths are relative to /boot/, eg.
+# root (hd0,0)
+# kernel /vmlinuz-version ro root=/dev/sda1
+# initrd /initrd-version.img
+#boot=/dev/hda
+default=2
+timeout=10
+splashimage=(hd0,0)/grub/splash.xpm.gz
+title title
+ kernel /boot/new-kernel.img
+ initrd /boot/new-initrd
+title Red Hat Linux (2.4.7-2)
+ root (hd0,0)
+ kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1
+ initrd /initrd-2.4.7-2.img
+title zonk
+ kernel /boot/new-kernel.img
+ initrd /boot/new-initrd
diff --git a/test/results/add/g1.17 b/test/results/add/g1.17
new file mode 100644
index 00000000000..6a388228768
--- /dev/null
+++ b/test/results/add/g1.17
@@ -0,0 +1,19 @@
+# grub.conf generated by anaconda
+#
+# Note that you do not have to rerun grub after making changes to this file
+# NOTICE: You have a /boot partition. This means that
+# all kernel and initrd paths are relative to /boot/, eg.
+# root (hd0,0)
+# kernel /vmlinuz-version ro root=/dev/sda1
+# initrd /initrd-version.img
+#boot=/dev/hda
+default=1
+timeout=10
+splashimage=(hd0,0)/grub/splash.xpm.gz
+title Red Hat Linux (2.4.7-2)
+ root (hd0,0)
+ kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1
+ initrd /initrd-2.4.7-2.img
+title title
+ kernel /boot/new-kernel.img
+ initrd /boot/new-initrd
diff --git a/test/results/add/g1.8 b/test/results/add/g1.8
new file mode 100644
index 00000000000..5893a2f5af1
--- /dev/null
+++ b/test/results/add/g1.8
@@ -0,0 +1,22 @@
+# grub.conf generated by anaconda
+#
+# Note that you do not have to rerun grub after making changes to this file
+# NOTICE: You have a /boot partition. This means that
+# all kernel and initrd paths are relative to /boot/, eg.
+# root (hd0,0)
+# kernel /vmlinuz-version ro root=/dev/sda1
+# initrd /initrd-version.img
+#boot=/dev/hda
+default=2
+timeout=10
+splashimage=(hd0,0)/grub/splash.xpm.gz
+title Red Hat Linux (2.4.7-2)
+ root (hd0,0)
+ kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1
+ initrd /initrd-2.4.7-2.img
+title title
+ kernel /boot/new-kernel.img
+ initrd /boot/new-initrd
+title zonk
+ kernel /boot/new-kernel.img
+ initrd /boot/new-initrd
diff --git a/test/results/add/g1.9 b/test/results/add/g1.9
new file mode 100644
index 00000000000..310623d13d2
--- /dev/null
+++ b/test/results/add/g1.9
@@ -0,0 +1,22 @@
+# grub.conf generated by anaconda
+#
+# Note that you do not have to rerun grub after making changes to this file
+# NOTICE: You have a /boot partition. This means that
+# all kernel and initrd paths are relative to /boot/, eg.
+# root (hd0,0)
+# kernel /vmlinuz-version ro root=/dev/sda1
+# initrd /initrd-version.img
+#boot=/dev/hda
+default=2
+timeout=10
+splashimage=(hd0,0)/grub/splash.xpm.gz
+title Red Hat Linux (2.4.7-2)
+ root (hd0,0)
+ kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1
+ initrd /initrd-2.4.7-2.img
+title zonk
+ kernel /boot/new-kernel.img
+ initrd /boot/new-initrd
+title title
+ kernel /boot/new-kernel.img
+ initrd /boot/new-initrd
--
2.17.1

View File

@ -0,0 +1,37 @@
From 0a4d6c3ae61bd6fd6a664b2b55b3e9453cf813ac Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 23 Jun 2016 14:47:35 -0400
Subject: [PATCH 21/55] Fix thinko on --set-index naming.
Related: rhbz#1285601
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grubby.8 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/grubby.8 b/grubby.8
index a4691f8ddb2..f1bfb9336e9 100644
--- a/grubby.8
+++ b/grubby.8
@@ -7,7 +7,7 @@ grubby \- command line tool for configuring grub, lilo, elilo, yaboot and zipl
[--bad-image-okay] [--boot-filesystem=\fIbootfs\fR]
[--bootloader-probe] [--config-file \fIpath\fR] [--copy-default]
[--debug] [--default-kernel] [--default-index] [--default-title]
- [--devtree=\fIdevicetree.dtb\fR] [--set-entry=\fIentry-index\fR]
+ [--devtree=\fIdevicetree.dtb\fR] [--set-index=\fIentry-index\fR]
[--grub] [--lilo] [--yaboot] [--silo] [--zipl]
[--info=\fIkernel-path\fR] [--initrd=\fIinitrd-path\fR]
[--make-default] [-o path] [--version]
@@ -49,7 +49,7 @@ with that title are used.
Add a new boot entry for the kernel located at \fIkernel-path\fR.
.TP
-\fB-\-set-entry\fR=\fIentry-index\fR
+\fB-\-set-index\fR=\fIentry-index\fR
Set the position at which to add a new entry created with \fB-\-add-kernel\fR.
.TP
--
2.17.1

View File

@ -0,0 +1,386 @@
From a23da4b29281ca07b06aab0bb772fedfe1f8ce35 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 24 Jun 2016 16:13:41 -0400
Subject: [PATCH 22/55] Add a test case for a failure rmarshall saw in
--set-index=
Related: rhbz#1285601
Signed-off-by: Peter Jones <pjones@redhat.com>
---
test.sh | 9 ++
test/grub2-support_files/grubenv.3 | 3 +
test/grub2.18 | 154 ++++++++++++++++++++++++++
test/results/add/g2-1.18 | 168 +++++++++++++++++++++++++++++
4 files changed, 334 insertions(+)
create mode 100644 test/grub2-support_files/grubenv.3
create mode 100644 test/grub2.18
create mode 100644 test/results/add/g2-1.18
diff --git a/test.sh b/test.sh
index 7d1794c83df..fb7cd2381d5 100755
--- a/test.sh
+++ b/test.sh
@@ -565,6 +565,15 @@ if [ "$testgrub2" == "y" ]; then
--copy-default --title 'Red Hat Enterprise Linux Server' \
--args=root=/dev/mapper/foo--
+ # copy a stanza and add arguments as well, while using --set-index=
+ testing="GRUB2 add stanza and new args with --set-index="
+ grub2Test grub2.18 add/g2-1.18 --env grubenv.3 \
+ --add-kernel=/boot/vmlinuz-3.10.0-327.22.2.el7.x86_64.debug \
+ --boot-filesystem=/boot --copy-default \
+ --title "Red Hat Enterprise Linux Server (3.10.0-327.22.2.el7.x86_64.debug) 7.2 (Maipo) with debugging" \
+ --args="root=/dev/mapper/rhel_team--area--222-root systemd.log_level=debug systemd.log_target=kmsg" \
+ --set-index=1
+
testing="GRUB2 add initrd"
grub2Test grub2.2 add/g2-1.4 --update-kernel=/boot/new-kernel.img \
--initrd=/boot/new-initrd --boot-filesystem=/boot/
diff --git a/test/grub2-support_files/grubenv.3 b/test/grub2-support_files/grubenv.3
new file mode 100644
index 00000000000..b9a8c798328
--- /dev/null
+++ b/test/grub2-support_files/grubenv.3
@@ -0,0 +1,3 @@
+# GRUB Environment Block
+saved_entry=Red Hat Enterprise Linux Server (3.10.0-327.22.2.el7.x86_64.debug) 7.2 (Maipo) with debugging
+#############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
\ No newline at end of file
diff --git a/test/grub2.18 b/test/grub2.18
new file mode 100644
index 00000000000..529608da773
--- /dev/null
+++ b/test/grub2.18
@@ -0,0 +1,154 @@
+#
+# DO NOT EDIT THIS FILE
+#
+# It is automatically generated by grub2-mkconfig using templates
+# from /etc/grub.d and settings from /etc/default/grub
+#
+
+### BEGIN /etc/grub.d/00_header ###
+set pager=1
+
+if [ -s $prefix/grubenv ]; then
+ load_env
+fi
+if [ "${next_entry}" ] ; then
+ set default="${next_entry}"
+ set next_entry=
+ save_env next_entry
+ set boot_once=true
+else
+ set default="${saved_entry}"
+fi
+
+if [ x"${feature_menuentry_id}" = xy ]; then
+ menuentry_id_option="--id"
+else
+ menuentry_id_option=""
+fi
+
+export menuentry_id_option
+
+if [ "${prev_saved_entry}" ]; then
+ set saved_entry="${prev_saved_entry}"
+ save_env saved_entry
+ set prev_saved_entry=
+ save_env prev_saved_entry
+ set boot_once=true
+fi
+
+function savedefault {
+ if [ -z "${boot_once}" ]; then
+ saved_entry="${chosen}"
+ save_env saved_entry
+ fi
+}
+
+function load_video {
+ if [ x$feature_all_video_module = xy ]; then
+ insmod all_video
+ else
+ insmod efi_gop
+ insmod efi_uga
+ insmod ieee1275_fb
+ insmod vbe
+ insmod vga
+ insmod video_bochs
+ insmod video_cirrus
+ fi
+}
+
+terminal_output console
+if [ x$feature_timeout_style = xy ] ; then
+ set timeout_style=menu
+ set timeout=5
+# Fallback normal timeout code in case the timeout_style feature is
+# unavailable.
+else
+ set timeout=5
+fi
+### END /etc/grub.d/00_header ###
+
+### BEGIN /etc/grub.d/00_tuned ###
+set tuned_params=""
+### END /etc/grub.d/00_tuned ###
+
+### BEGIN /etc/grub.d/01_users ###
+if [ -f ${prefix}/user.cfg ]; then
+ source ${prefix}/user.cfg
+ if [ -n ${GRUB2_PASSWORD} ]; then
+ set superusers="root"
+ export superusers
+ password_pbkdf2 root ${GRUB2_PASSWORD}
+ fi
+fi
+### END /etc/grub.d/01_users ###
+
+### BEGIN /etc/grub.d/10_linux ###
+menuentry 'Red Hat Enterprise Linux Server (3.10.0-327.22.2.el7.x86_64.debug) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-327.el7.x86_64-advanced-91b16928-66bf-4801-8aed-fab3f1a6876c' {
+ load_video
+ set gfxpayload=keep
+ insmod gzio
+ insmod part_msdos
+ insmod xfs
+ set root='hd0,msdos1'
+ if [ x$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 7e972fc0-6cf8-4a58-ace6-1b381e52733d
+ else
+ search --no-floppy --fs-uuid --set=root 7e972fc0-6cf8-4a58-ace6-1b381e52733d
+ fi
+ linux16 /vmlinuz-3.10.0-327.22.2.el7.x86_64.debug root=/dev/mapper/rhel_team--area--222-root ro crashkernel=auto rd.lvm.lv=rhel_team-area-222/root rd.lvm.lv=rhel_team-area-222/swap rhgb quiet LANG=en_US.UTF-8
+}
+menuentry 'Red Hat Enterprise Linux Server (3.10.0-327.el7.x86_64) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-327.el7.x86_64-advanced-91b16928-66bf-4801-8aed-fab3f1a6876c' {
+ load_video
+ set gfxpayload=keep
+ insmod gzio
+ insmod part_msdos
+ insmod xfs
+ set root='hd0,msdos1'
+ if [ x$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 7e972fc0-6cf8-4a58-ace6-1b381e52733d
+ else
+ search --no-floppy --fs-uuid --set=root 7e972fc0-6cf8-4a58-ace6-1b381e52733d
+ fi
+ linux16 /vmlinuz-3.10.0-327.el7.x86_64 root=/dev/mapper/rhel_team--area--222-root ro crashkernel=auto rd.lvm.lv=rhel_team-area-222/root rd.lvm.lv=rhel_team-area-222/swap rhgb quiet LANG=en_US.UTF-8
+ initrd16 /initramfs-3.10.0-327.el7.x86_64.img
+}
+menuentry 'Red Hat Enterprise Linux Server (0-rescue-925cd320373b6a4a9a66a26371afccd2) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-925cd320373b6a4a9a66a26371afccd2-advanced-91b16928-66bf-4801-8aed-fab3f1a6876c' {
+ load_video
+ insmod gzio
+ insmod part_msdos
+ insmod xfs
+ set root='hd0,msdos1'
+ if [ x$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 7e972fc0-6cf8-4a58-ace6-1b381e52733d
+ else
+ search --no-floppy --fs-uuid --set=root 7e972fc0-6cf8-4a58-ace6-1b381e52733d
+ fi
+ linux16 /vmlinuz-0-rescue-925cd320373b6a4a9a66a26371afccd2 root=/dev/mapper/rhel_team--area--222-root ro crashkernel=auto rd.lvm.lv=rhel_team-area-222/root rd.lvm.lv=rhel_team-area-222/swap rhgb quiet
+ initrd16 /initramfs-0-rescue-925cd320373b6a4a9a66a26371afccd2.img
+}
+
+### END /etc/grub.d/10_linux ###
+
+### BEGIN /etc/grub.d/20_linux_xen ###
+### END /etc/grub.d/20_linux_xen ###
+
+### BEGIN /etc/grub.d/20_ppc_terminfo ###
+### END /etc/grub.d/20_ppc_terminfo ###
+
+### BEGIN /etc/grub.d/30_os-prober ###
+### END /etc/grub.d/30_os-prober ###
+
+### BEGIN /etc/grub.d/40_custom ###
+# This file provides an easy way to add custom menu entries. Simply type the
+# menu entries you want to add after this comment. Be careful not to change
+# the 'exec tail' line above.
+### END /etc/grub.d/40_custom ###
+
+### BEGIN /etc/grub.d/41_custom ###
+if [ -f ${config_directory}/custom.cfg ]; then
+ source ${config_directory}/custom.cfg
+elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
+ source $prefix/custom.cfg;
+fi
+### END /etc/grub.d/41_custom ###
diff --git a/test/results/add/g2-1.18 b/test/results/add/g2-1.18
new file mode 100644
index 00000000000..ca5fe2393d5
--- /dev/null
+++ b/test/results/add/g2-1.18
@@ -0,0 +1,168 @@
+#
+# DO NOT EDIT THIS FILE
+#
+# It is automatically generated by grub2-mkconfig using templates
+# from /etc/grub.d and settings from /etc/default/grub
+#
+
+### BEGIN /etc/grub.d/00_header ###
+set pager=1
+
+if [ -s $prefix/grubenv ]; then
+ load_env
+fi
+if [ "${next_entry}" ] ; then
+ set default="${next_entry}"
+ set next_entry=
+ save_env next_entry
+ set boot_once=true
+else
+ set default="${saved_entry}"
+fi
+
+if [ x"${feature_menuentry_id}" = xy ]; then
+ menuentry_id_option="--id"
+else
+ menuentry_id_option=""
+fi
+
+export menuentry_id_option
+
+if [ "${prev_saved_entry}" ]; then
+ set saved_entry="${prev_saved_entry}"
+ save_env saved_entry
+ set prev_saved_entry=
+ save_env prev_saved_entry
+ set boot_once=true
+fi
+
+function savedefault {
+ if [ -z "${boot_once}" ]; then
+ saved_entry="${chosen}"
+ save_env saved_entry
+ fi
+}
+
+function load_video {
+ if [ x$feature_all_video_module = xy ]; then
+ insmod all_video
+ else
+ insmod efi_gop
+ insmod efi_uga
+ insmod ieee1275_fb
+ insmod vbe
+ insmod vga
+ insmod video_bochs
+ insmod video_cirrus
+ fi
+}
+
+terminal_output console
+if [ x$feature_timeout_style = xy ] ; then
+ set timeout_style=menu
+ set timeout=5
+# Fallback normal timeout code in case the timeout_style feature is
+# unavailable.
+else
+ set timeout=5
+fi
+### END /etc/grub.d/00_header ###
+
+### BEGIN /etc/grub.d/00_tuned ###
+set tuned_params=""
+### END /etc/grub.d/00_tuned ###
+
+### BEGIN /etc/grub.d/01_users ###
+if [ -f ${prefix}/user.cfg ]; then
+ source ${prefix}/user.cfg
+ if [ -n ${GRUB2_PASSWORD} ]; then
+ set superusers="root"
+ export superusers
+ password_pbkdf2 root ${GRUB2_PASSWORD}
+ fi
+fi
+### END /etc/grub.d/01_users ###
+
+### BEGIN /etc/grub.d/10_linux ###
+menuentry 'Red Hat Enterprise Linux Server (3.10.0-327.22.2.el7.x86_64.debug) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-327.el7.x86_64-advanced-91b16928-66bf-4801-8aed-fab3f1a6876c' {
+ load_video
+ set gfxpayload=keep
+ insmod gzio
+ insmod part_msdos
+ insmod xfs
+ set root='hd0,msdos1'
+ if [ x$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 7e972fc0-6cf8-4a58-ace6-1b381e52733d
+ else
+ search --no-floppy --fs-uuid --set=root 7e972fc0-6cf8-4a58-ace6-1b381e52733d
+ fi
+ linux16 /vmlinuz-3.10.0-327.22.2.el7.x86_64.debug root=/dev/mapper/rhel_team--area--222-root ro crashkernel=auto rd.lvm.lv=rhel_team-area-222/root rd.lvm.lv=rhel_team-area-222/swap rhgb quiet LANG=en_US.UTF-8
+}
+menuentry 'Red Hat Enterprise Linux Server (3.10.0-327.22.2.el7.x86_64.debug) 7.2 (Maipo) with debugging' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-327.el7.x86_64-advanced-91b16928-66bf-4801-8aed-fab3f1a6876c' {
+ load_video
+ set gfxpayload=keep
+ insmod gzio
+ insmod part_msdos
+ insmod xfs
+ set root='hd0,msdos1'
+ if [ x$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 7e972fc0-6cf8-4a58-ace6-1b381e52733d
+ else
+ search --no-floppy --fs-uuid --set=root 7e972fc0-6cf8-4a58-ace6-1b381e52733d
+ fi
+ linux16 /vmlinuz-3.10.0-327.22.2.el7.x86_64.debug root=/dev/mapper/rhel_team--area--222-root ro crashkernel=auto rd.lvm.lv=rhel_team-area-222/root rd.lvm.lv=rhel_team-area-222/swap rhgb quiet LANG=en_US.UTF-8 systemd.log_level=debug systemd.log_target=kmsg
+}
+menuentry 'Red Hat Enterprise Linux Server (3.10.0-327.el7.x86_64) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-327.el7.x86_64-advanced-91b16928-66bf-4801-8aed-fab3f1a6876c' {
+ load_video
+ set gfxpayload=keep
+ insmod gzio
+ insmod part_msdos
+ insmod xfs
+ set root='hd0,msdos1'
+ if [ x$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 7e972fc0-6cf8-4a58-ace6-1b381e52733d
+ else
+ search --no-floppy --fs-uuid --set=root 7e972fc0-6cf8-4a58-ace6-1b381e52733d
+ fi
+ linux16 /vmlinuz-3.10.0-327.el7.x86_64 root=/dev/mapper/rhel_team--area--222-root ro crashkernel=auto rd.lvm.lv=rhel_team-area-222/root rd.lvm.lv=rhel_team-area-222/swap rhgb quiet LANG=en_US.UTF-8
+ initrd16 /initramfs-3.10.0-327.el7.x86_64.img
+}
+menuentry 'Red Hat Enterprise Linux Server (0-rescue-925cd320373b6a4a9a66a26371afccd2) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-925cd320373b6a4a9a66a26371afccd2-advanced-91b16928-66bf-4801-8aed-fab3f1a6876c' {
+ load_video
+ insmod gzio
+ insmod part_msdos
+ insmod xfs
+ set root='hd0,msdos1'
+ if [ x$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 7e972fc0-6cf8-4a58-ace6-1b381e52733d
+ else
+ search --no-floppy --fs-uuid --set=root 7e972fc0-6cf8-4a58-ace6-1b381e52733d
+ fi
+ linux16 /vmlinuz-0-rescue-925cd320373b6a4a9a66a26371afccd2 root=/dev/mapper/rhel_team--area--222-root ro crashkernel=auto rd.lvm.lv=rhel_team-area-222/root rd.lvm.lv=rhel_team-area-222/swap rhgb quiet
+ initrd16 /initramfs-0-rescue-925cd320373b6a4a9a66a26371afccd2.img
+}
+
+### END /etc/grub.d/10_linux ###
+
+### BEGIN /etc/grub.d/20_linux_xen ###
+### END /etc/grub.d/20_linux_xen ###
+
+### BEGIN /etc/grub.d/20_ppc_terminfo ###
+### END /etc/grub.d/20_ppc_terminfo ###
+
+### BEGIN /etc/grub.d/30_os-prober ###
+### END /etc/grub.d/30_os-prober ###
+
+### BEGIN /etc/grub.d/40_custom ###
+# This file provides an easy way to add custom menu entries. Simply type the
+# menu entries you want to add after this comment. Be careful not to change
+# the 'exec tail' line above.
+### END /etc/grub.d/40_custom ###
+
+### BEGIN /etc/grub.d/41_custom ###
+if [ -f ${config_directory}/custom.cfg ]; then
+ source ${config_directory}/custom.cfg
+elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
+ source $prefix/custom.cfg;
+fi
+### END /etc/grub.d/41_custom ###
--
2.17.1

View File

@ -0,0 +1,46 @@
From f88808a37044c323e35eda49dbc326dcf260439b Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 24 Jun 2016 16:05:45 -0400
Subject: [PATCH 23/55] Ensure command line updates also honor --set-index
Related: rhbz#1285601
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grubby.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/grubby.c b/grubby.c
index 54625e7da0a..d889399449b 100644
--- a/grubby.c
+++ b/grubby.c
@@ -4212,11 +4212,17 @@ int addNewKernel(struct grubConfig *config, struct singleEntry *template,
struct singleEntry *new, *entry, *prev = NULL;
struct singleLine *newLine = NULL, *tmplLine = NULL, *masterLine = NULL;
int needs;
+ char *indexs;
char *chptr;
+ int rc;
if (!newKernelPath)
return 0;
+ rc = asprintf(&indexs, "%d", newIndex);
+ if (rc < 0)
+ return 1;
+
/* if the newKernelTitle is too long silently munge it into something
* we can live with. truncating is first check, then we'll just mess with
* it until it looks better */
@@ -4715,7 +4721,7 @@ int addNewKernel(struct grubConfig *config, struct singleEntry *template,
abort();
}
- if (updateImage(config, "0", prefix, newKernelArgs, NULL,
+ if (updateImage(config, indexs, prefix, newKernelArgs, NULL,
newMBKernelArgs, NULL))
return 1;
--
2.17.1

View File

@ -0,0 +1,67 @@
From fe9bc763507e849caa45926e49c1c324532ced6e Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Thu, 23 Jun 2016 14:41:12 -0400
Subject: [PATCH 24/55] Change debug entry insertion order (rhbz#1285601)
Customer reports indicated that it was confusing to have the debugging
entries before non-debugging entries. Altered the insertion code to use
the --set-index feature on the debug kernels to force them to insert
after the initial non-debugging entry.
Resolves: rhbz#1285601
---
new-kernel-pkg | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/new-kernel-pkg b/new-kernel-pkg
index 9574dbbf10b..64225deb06b 100755
--- a/new-kernel-pkg
+++ b/new-kernel-pkg
@@ -244,7 +244,7 @@ install() {
--remove-kernel=\"TITLE=$title\$debugtitle\""
rungrubby ${ARGS} $makedefault
- rungrubby --debug ${ARGS}
+ rungrubby --debug ${ARGS} --set-index=1
else
[ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby for grub 0.97"
fi
@@ -258,7 +258,7 @@ install() {
--args=\"root=$rootdevice $kernargs \$debugargs\" \
--remove-kernel=\"TITLE=$title\$debugtitle\""
rungrubby ${ARGS} $makedefault
- rungrubby --debug ${ARGS}
+ rungrubby --debug ${ARGS} --set-index=1
else
[ -n "$verbose" ] && echo "$grub2Config does not exist, not running grubby for grub 2"
fi
@@ -273,7 +273,7 @@ install() {
--args=\"root=$rootdevice $kernargs \$debugargs\" \
--remove-kernel=\"TITLE=$title\$debugtitle\""
rungrubby ${ARGS} $makedefault
- rungrubby --debug ${ARGS}
+ rungrubby --debug ${ARGS} --set-index=1
else
[ -n "$verbose" ] && echo "$grub2EfiConfig does not exist, not running grubby for grub 2 with UEFI"
fi
@@ -289,7 +289,7 @@ install() {
--remove-kernel=\"TITLE=$version\""
rungrubby ${ARGS} $makedefault
- rungrubby --debug ${ARGS}
+ rungrubby --debug ${ARGS} --set-index=1
if [ -n "$runLilo" ]; then
[ -n "$verbose" ] && echo "running $lilo"
if [ ! -x $lilo ] ; then
@@ -314,7 +314,7 @@ install() {
--remove-kernel=\"TITLE=$title\$debugtitle\""
rungrubby ${ARGS} $makedefault
- rungrubby --debug ${ARGS}
+ rungrubby --debug ${ARGS} --set-index=1
else
[ -n "$verbose" ] && echo "$extlinuxConfig does not exist, not running grubby for extlinux"
fi
--
2.17.1

View File

@ -0,0 +1,356 @@
From 9073de7c059fcc9fd5ca837068d96cb0246f3c99 Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Fri, 1 Jul 2016 14:03:38 -0400
Subject: [PATCH 25/55] Reorganize grubby man page (#1232168)
Broke the grubby man page into clearer sections and re-organized the
content by general use case for easier reading.
Related: rhbz#1232168
---
grubby.8 | 220 ++++++++++++++++++++++++++++++-------------------------
1 file changed, 120 insertions(+), 100 deletions(-)
diff --git a/grubby.8 b/grubby.8
index f1bfb9336e9..a3033d87254 100644
--- a/grubby.8
+++ b/grubby.8
@@ -1,15 +1,18 @@
.TH GRUBBY 8 "Tue Jan 18 2005"
+
.SH NAME
+
grubby \- command line tool for configuring grub, lilo, elilo, yaboot and zipl
.SH SYNOPSIS
-\fBgrubby\fR [--add-kernel=\fIkernel-path\fR] [--args=\fIargs\fR]
- [--bad-image-okay] [--boot-filesystem=\fIbootfs\fR]
+
+\fBgrubby\fR [--add-kernel=\fIkernel-path\fR] [--args=\fIargs\fR]
+ [--bad-image-okay] [--boot-filesystem=\fIbootfs\fR]
[--bootloader-probe] [--config-file \fIpath\fR] [--copy-default]
[--debug] [--default-kernel] [--default-index] [--default-title]
[--devtree=\fIdevicetree.dtb\fR] [--set-index=\fIentry-index\fR]
[--grub] [--lilo] [--yaboot] [--silo] [--zipl]
- [--info=\fIkernel-path\fR] [--initrd=\fIinitrd-path\fR]
+ [--info=\fIkernel-path\fR] [--initrd=\fIinitrd-path\fR]
[--make-default] [-o path] [--version]
[--remove-kernel=\fIkernel-path\fR] [--remove-args=\fIargs\fR]
[--set-default=\fIkernel-path\fR] [--set-default-index=\fIentry-index\fR]
@@ -18,12 +21,17 @@ grubby \- command line tool for configuring grub, lilo, elilo, yaboot and zipl
[--remove-mbargs=\fIargs\fR]
.SH DESCRIPTION
+
+.SS General Information
+
\fBgrubby\fR is a command line tool for updating and displaying information
about the configuration files for the \fBgrub\fR, \fBlilo\fR, \fBelilo\fR
(ia64), \fByaboot\fR (powerpc) and \fBzipl\fR (s390) 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.
+.SS Architecture Support
+
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
@@ -35,6 +43,8 @@ config stored in \fB/boot/grub2/grub.cfg\fR. The earlier Power7 systems use \fBy
parsing and the configuration file should be in \fB/etc/yaboot.conf\fR. On
s390 platforms the \fBzipl bootloader\fR will read from \fB/etc/zipl.conf\fR.
+.SS Special Arguments
+
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.
@@ -44,13 +54,24 @@ be specified by using \fBTITLE=\fItitle\fR as the argument; all entries
with that title are used.
.SH OPTIONS
+
+.SS Basic Options
+
.TP
\fB-\-add-kernel\fR=\fIkernel-path\fR
Add a new boot entry for the kernel located at \fIkernel-path\fR.
.TP
-\fB-\-set-index\fR=\fIentry-index\fR
-Set the position at which to add a new entry created with \fB-\-add-kernel\fR.
+\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-\-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.
.TP
\fB-\-args\fR=\fIkernel-args\fR
@@ -65,38 +86,11 @@ file has special handling for specifying the root filesystem (like
lilo.conf does).
.TP
-\fB-\-bad-image-okay\fR
-When \fBgrubby\fR is looking for a entry to use for something (such
-as a template or 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-\-boot-filesystem\fR=\fIbootfs\fR
-The \fBgrub\fR boot loader expects file paths listed in it's configuration
-path to be relative to the top of the filesystem they are on, rather then
-relative to the current root filesystem. By default \fBgrubby\fR searches
-the list of currently mounted filesystems to determine this. If this option
-is given \fBgrubby\fR acts as if the specified filesystem was the filesystem
-containing the kernel (this option is designed primarily for testing).
-
-.TP
-\fB-\-bootloader-probe\fR
-\fBgrubby\fR tries to determine if \fBgrub\fR or \fBlilo\fR is currently
-installed. When one of those bootloaders is found the name of that bootloader
-is displayed on stdout. Both could be installed (on different devices), and
-grubby will print out the names of both bootloaders, one per line. The probe
-for \fBgrub\fR requires a commented out boot directive \fBgrub.conf\fR
-identical to the standard directive in the lilo configuration file. If this
-is not present \fBgrubby\fR will assume grub is not installed (note
-that \fBanaconda\fR places this directive in \fBgrub.conf\fR files it creates).
-This option is only available on ia32 platforms.
-
-
-.TP
-\fB-\-config-file\fR=\fIpath\fR
-Use \fIpath\fR as the configuration file rather then the default.
+\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-\-copy-default\fR
@@ -104,10 +98,41 @@ Use \fIpath\fR as the configuration file rather then the default.
root device) as possible from the current default kernel. The kernel path
and initrd path will never be copied.
+.TP
+\fB-\-title\fR=\fIentry-title\fR
+When a new kernel entry is added \fIentry-title\fR is used as the title
+(\fBlilo\fR label) for the entry. If \fIentry-title\fR is longer then maximum
+length allowed by the bootloader (15 for lilo, unlimited for grub and elilo)
+the title is shortened to a (unique) entry.
+
+.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-\-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-\-make-default\fR
+Make the new kernel entry being added the default entry.
+
+.TP
+\fB-\-set-index\fR=\fIentry-index\fR
+Set the position at which to add a new entry created with \fB-\-add-kernel\fR.
+
.TP
\fB-\-debug\fR
Display extra debugging information for failures.
+.SS Display Options
+
.TP
\fB-\-default-kernel\fR
Display the full path to the current default kernel and exit.
@@ -121,9 +146,26 @@ Display the numeric index of the current default boot entry and exit.
Display the title of the current default boot entry and exit.
.TP
-\fB-\-devtree\fR=\fIpath\fR
-Use \fIpath\fR for device tree path in place of the path of any devicetree
-directive found in the template stanza.
+\fB-\-info\fR=\fIkernel-path\fR
+Display information on all boot entries which match \fIkernel-path\fR. I
+
+.TP
+\fB-\-bootloader-probe\fR
+\fBgrubby\fR tries to determine if \fBgrub\fR or \fBlilo\fR is currently
+installed. When one of those bootloaders is found the name of that bootloader
+is displayed on stdout. Both could be installed (on different devices), and
+grubby will print out the names of both bootloaders, one per line. The probe
+for \fBgrub\fR requires a commented out boot directive \fBgrub.conf\fR
+identical to the standard directive in the lilo configuration file. If this
+is not present \fBgrubby\fR will assume grub is not installed (note
+that \fBanaconda\fR places this directive in \fBgrub.conf\fR files it creates).
+This option is only available on ia32 platforms.
+
+.TP
+\fB-\-version\fR
+Display the version of \fBgrubby\fR being run and then exit immediately.
+
+.SS Output Format Options
.TP
\fB-\-elilo\fR
@@ -134,62 +176,10 @@ Use an \fBelilo\fR style configuration file.
Use a \fBgrub\fR style configuration file instead of \fBlilo\fR style. This
is the default on ia32 platforms.
-.TP
-\fB-\-info\fR=\fIkernel-path\fR
-Display information on all boot entries which match \fIkernel-path\fR. I
-
-.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-\-lilo\fR
Use a \fBlilo\fR style configuration file.
-.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
-(\fBlilo\fR label) for the entry. If \fIentry-title\fR is longer then maximum
-length allowed by the bootloader (15 for lilo, unlimited for grub and elilo)
-the title is shortened to a (unique) 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.
-
-.TP
-\fB-\-version\fR
-Display the version of \fBgrubby\fR being run and then exit immediately.
-
.TP
\fB-\-yaboot\fR
Use an \fByaboot\fR style configuration file.
@@ -198,7 +188,35 @@ Use an \fByaboot\fR style configuration file.
\fB-\-zipl\fR
Use an \fBzipl\fR style configuration file.
-.SH MULTIBOOT OPTIONS
+.SS Override Options
+
+.TP
+\fB-\-bad-image-okay\fR
+When \fBgrubby\fR is looking for a entry to use for something (such
+as a template or 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-\-boot-filesystem\fR=\fIbootfs\fR
+The \fBgrub\fR boot loader expects file paths listed in it's configuration
+path to be relative to the top of the filesystem they are on, rather then
+relative to the current root filesystem. By default \fBgrubby\fR searches
+the list of currently mounted filesystems to determine this. If this option
+is given \fBgrubby\fR acts as if the specified filesystem was the filesystem
+containing the kernel (this option is designed primarily for testing).
+
+.TP
+\fB-\-config-file\fR=\fIpath\fR
+Use \fIpath\fR as the configuration file rather then the default.
+
+\fB-\-devtree\fR=\fIpath\fR
+Use \fIpath\fR for device tree path in place of the path of any devicetree
+directive found in the template stanza.
+
+.SS Multiboot Options
+
The Multiboot Specification provides a genreic interface for boot
loaders and operating systems. It is supported by the GRUB bootloader.
@@ -210,34 +228,36 @@ Add a new boot entry for the multiboot kernel located at
.TP
\fB-\-remove-multiboot\fR=\fImultiboot-path\fR
-Removes all boot entries which match \fImultiboot-path\fR.
+Removes all boot entries which match \fImultiboot-path\fR.
.TP
\fB-\-mbargs\fR=\fImultiboot-args\fR
-When a new multiboot kernel is added, this specifies the command line
-arguments which should be passed to that kernel by default
+When a new multiboot kernel is added, this specifies the command line
+arguments which should be passed to that kernel by default
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.
+an argument already exists the new value replaces the old values.
.TP
\fB-\-remove-mbargs\fR=\fImultiboot-args\fR
-The arguments specified by \fImultiboot-args\fR are removed from the
-kernels specified by \fB-\-update-kernel\fR.
-
+The arguments specified by \fImultiboot-args\fR are removed from the
+kernels specified by \fB-\-update-kernel\fR.
.SH "BUGS"
+
The command line syntax is more than a little baroque. This probably
won't be fixed as \fBgrubby\fR is only intended to be called from shell
scripts which can get it right.
.SH "SEE ALSO"
+
.BR grub (8),
.BR lilo (8),
.BR yaboot (8),
.BR mkinitrd (8)
.SH AUTHORS
+
.nf
Erik Troan
Jeremy Katz
--
2.17.1

View File

@ -0,0 +1,369 @@
From e08236e8d15ff0fc581d56efaf4d855c57d6d994 Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Fri, 1 Jul 2016 15:03:13 -0400
Subject: [PATCH 26/55] Update grubby man page contents (#bz1232168)
The grubby man page was missing several options that were added in
previous releases. Added those to the man page as well as updated the
text on others to provide further clarity.
Added an EXAMPLE section containing some basic use cases.
Resolves: rhbz#1232168
---
grubby.8 | 218 +++++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 173 insertions(+), 45 deletions(-)
diff --git a/grubby.8 b/grubby.8
index a3033d87254..64a6984fba0 100644
--- a/grubby.8
+++ b/grubby.8
@@ -2,51 +2,69 @@
.SH NAME
-grubby \- command line tool for configuring grub, lilo, elilo, yaboot and zipl
+grubby \- command line tool used to configure bootloader menu entries across multiple architectures
.SH SYNOPSIS
-\fBgrubby\fR [--add-kernel=\fIkernel-path\fR] [--args=\fIargs\fR]
- [--bad-image-okay] [--boot-filesystem=\fIbootfs\fR]
- [--bootloader-probe] [--config-file \fIpath\fR] [--copy-default]
- [--debug] [--default-kernel] [--default-index] [--default-title]
- [--devtree=\fIdevicetree.dtb\fR] [--set-index=\fIentry-index\fR]
- [--grub] [--lilo] [--yaboot] [--silo] [--zipl]
- [--info=\fIkernel-path\fR] [--initrd=\fIinitrd-path\fR]
- [--make-default] [-o path] [--version]
- [--remove-kernel=\fIkernel-path\fR] [--remove-args=\fIargs\fR]
- [--set-default=\fIkernel-path\fR] [--set-default-index=\fIentry-index\fR]
- [--title=entry-title] [--add-multiboot=\fImultiboot-path\fR]
- [--mbargs=\fIargs\fR] [--remove-multiboot=\fImultiboot-path\fR]
- [--remove-mbargs=\fIargs\fR]
+\fBgrubby\fR [\fIOPTIONS...\fR]
.SH DESCRIPTION
.SS General Information
\fBgrubby\fR is a command line tool for updating and displaying information
-about the configuration files for the \fBgrub\fR, \fBlilo\fR, \fBelilo\fR
-(ia64), \fByaboot\fR (powerpc) and \fBzipl\fR (s390) 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.
+about the configuration files for various architecture specific bootloaders.
+It is primarily designed to be used from scripts which install new kernels
+and need to find information about the current boot environment.
.SS Architecture Support
-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 Intel ia64 platforms,
-\fBelilo\fR mode is used and the default location for the configuration file
-is \fB/boot/efi/EFI/redhat/elilo.conf\fR. On PowerPC platforms, systems based
-on Power8 now support \fBgrub2\fR as a bootloader and store using a default
-config stored in \fB/boot/grub2/grub.cfg\fR. The earlier Power7 systems use \fByaboot\fR
-parsing and the configuration file should be in \fB/etc/yaboot.conf\fR. On
-s390 platforms the \fBzipl bootloader\fR will read from \fB/etc/zipl.conf\fR.
+The \fBgrubby\fR executable has full support for the \fBgrub2\fR
+bootloader on \fBx86_64\fR systems using legacy BIOS or modern
+UEFI firmware and \fBppc64\fR and \fBppc64le\fR hardware using
+OPAL or SLOF as firmware.
+
+Legacy \fBs390\fR and the current \fBs390x\fR architectures
+and their \fBzipl\fR bootloader are fully supported.
+
+Support for \fByaboot\fR has been deprecated as all ppc architecture
+hardware since the Power8 system uses \fBgrub2\fR or petitboot
+which both use the grub2 configuration file format.
+
+Legacy bootloaders \fBLILO\fR, \fBSILO\fR, and \fBELILO\fR
+are deprecated in favor of previously mentioned bootloaders. The
+\fBSILO\fR bootloader should also be considered unsupported.
+
+.SS Default Behavior
+
+The default architecture is chosen at compile time. The grubby executable
+has a series of built in assumptions about what bootloader is being used and
+where its configuration file lives. If no output format option is specified
+on the command line then grubby will use these default settings to first
+search for an existing configuration and, if it is not found, assume that
+it should be placed in the standard location. These default assumptions are
+listed in the table below.
+
+.TS
+allbox;
+lbw6 lbw10 lbw18
+l l l.
+ Arch Bootloader Configuration File
+ x86_64 [BIOS] grub2 /boot/grub2/grub.cfg
+ x86_64 [UEFI] grub2 /boot/efi/EFI/redhat/grub.cfg
+ i386 grub2 /boot/grub2/grub.cfg
+ ia64 elilo /boot/efi/EFI/redhat/elilo.conf
+ ppc [>=Power8] grub2 /boot/grub2/grub.cfg
+ ppc [<=Power7] yaboot /etc/yaboot.conf
+ s390 zipl /etc/zipl.conf
+ s390x zipl /etc/zipl.conf
+.TE
+
.SS Special Arguments
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
+\fB-\-remove-kernel\fR, and \fB-\-update-kernel\fR. Specifying \fBDEFAULT\fR
or \fBALL\fR selects the default entry and all of the entries, respectively.
If a comma separated list of numbers is given, the boot entries indexed
by those numbers are selected. Finally, the title of a boot entry may
@@ -59,12 +77,17 @@ with that title are used.
.TP
\fB-\-add-kernel\fR=\fIkernel-path\fR
-Add a new boot entry for the kernel located at \fIkernel-path\fR.
+Add a new boot entry for the kernel located at \fIkernel-path\fR. A title for
+the boot entry must be set using \fB-\-title\fR. Most invocations should also
+include \fB-\-initrd\fR with memtest86 as a notable exception.
+
+The \fB-\-update-kernel\fR
+option may not be used in the same invocation.
.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
+along with \fB-\-add-kernel\fR, in which case the new kernel being added will
never be removed.
.TP
@@ -110,14 +133,19 @@ the title is shortened to a (unique) entry.
Use \fIinitrd-path\fR as the path to an initial ram disk for a new kernel
being added.
+.TP
+\fB-\-efi\fR
+Use linuxefi and initrdefi when constructing bootloader stanzas instead of linux and initrd.
+
.TP
\fB-\-set-default\fR=\fIkernel-path\fR
The first entry which boots the specified kernel is made the default
-boot entry.
+boot entry. This may not be invoked with \fB-\-set-default-index\fR.
.TP
\fB-\-set-default-index\fR=\fIentry-index\fR
-Makes the given entry number the default boot entry.
+Makes the given entry number the default boot entry. This may not
+be invoked with \fB-\-set-default\fR.
.TP
\fB-\-make-default\fR
@@ -131,8 +159,17 @@ Set the position at which to add a new entry created with \fB-\-add-kernel\fR.
\fB-\-debug\fR
Display extra debugging information for failures.
+.TP
+\fB-i\fR, \fB-\-extra-initrd\fR=\fIinitrd-path\fR
+Use \fIinitrd-path\fR as the path for an auxiliary initrd image.
+
.SS Display Options
+Passing the display option to grubby will cause it to print out the
+requested information about the current bootloader configuration and
+then immediately exit. These options should not be used in any
+script intended to update the bootloader configuration.
+
.TP
\fB-\-default-kernel\fR
Display the full path to the current default kernel and exit.
@@ -159,34 +196,56 @@ for \fBgrub\fR requires a commented out boot directive \fBgrub.conf\fR
identical to the standard directive in the lilo configuration file. If this
is not present \fBgrubby\fR will assume grub is not installed (note
that \fBanaconda\fR places this directive in \fBgrub.conf\fR files it creates).
-This option is only available on ia32 platforms.
+
+\fIThis option is only available on i386 platforms.\fR
.TP
-\fB-\-version\fR
+\fB-v\fR, \fB-\-version\fR
Display the version of \fBgrubby\fR being run and then exit immediately.
.SS Output Format Options
+Sane default options for the current platform are compiled into grubby on
+a per platform basis. These defaults determine the format and layout of
+the generated bootloader configuration file. A different configuration file
+format may be specified on the command line if the system uses a supported
+alternative bootloader.
+
.TP
\fB-\-elilo\fR
-Use an \fBelilo\fR style configuration file.
+Use an \fBelilo\fR style configuration file. This is the default on ia64 platforms. This format is deprecated.
+
+.TP
+\fB-\-extlinux\fR
+Use an \fBextlinux\fR style configuration file. This format is deprecated.
.TP
\fB-\-grub\fR
-Use a \fBgrub\fR style configuration file instead of \fBlilo\fR style. This
-is the default on ia32 platforms.
+Use a \fBgrub\fR style configuration file. This is the default on ia32 platforms.
+
+.TP
+\fB-\-grub2\fR
+Use a \fBgrub2\fR style configuration file. This is the default on \fBx86_64\fR
+architecture as well as the \fBppc64\fR and \fBppc64le\fR architectures
+running on Power8 or later hardware.
.TP
\fB-\-lilo\fR
Use a \fBlilo\fR style configuration file.
+.TP
+\fB-\-silo\fR
+Use a \fBsilo\fR style configuration file. This is the default on SPARC systems. This format is legacy, deprecated, and unsupported.
+
.TP
\fB-\-yaboot\fR
-Use an \fByaboot\fR style configuration file.
+Use a \fByaboot\fR style configuration file. This is the default for
+the \fBppc\fR architecture on on Power7 and earlier hardware.
.TP
\fB-\-zipl\fR
-Use an \fBzipl\fR style configuration file.
+Use a \fBzipl\fR style configuration file. This is the default on the
+legacy s390 and current s390x architectures.
.SS Override Options
@@ -200,7 +259,7 @@ that behavior, and is designed primarily for testing.
.TP
\fB-\-boot-filesystem\fR=\fIbootfs\fR
-The \fBgrub\fR boot loader expects file paths listed in it's configuration
+The \fBgrub\fR boot loader expects file paths listed in its configuration
path to be relative to the top of the filesystem they are on, rather then
relative to the current root filesystem. By default \fBgrubby\fR searches
the list of currently mounted filesystems to determine this. If this option
@@ -208,23 +267,39 @@ is given \fBgrubby\fR acts as if the specified filesystem was the filesystem
containing the kernel (this option is designed primarily for testing).
.TP
-\fB-\-config-file\fR=\fIpath\fR
+\fB-\-env\fR=\fIpath\fR
+Path for the file where grub environment data is stored.
+
+.TP
+\fB-c\fR, \fB-\-config-file\fR=\fIpath\fR
Use \fIpath\fR as the configuration file rather then the default.
-\fB-\-devtree\fR=\fIpath\fR
+.TP
+\fB-o\fR, \fB-\-output-file\fR=\fIfile_path\fR
+The destination path for the updated configuration file. Use "-" to
+send it to stdout.
+
+.TP
+\fB-\-devtree\fR=\fIfile_path\fR
Use \fIpath\fR for device tree path in place of the path of any devicetree
directive found in the template stanza.
+.TP
+\fB-\-devtreedir\fR=\fIfile_path\fR
+Use the specified \fIfile path\fR to load the devicetree definition. This is for
+platforms where a flat file is used instead of firmware to instruct the kernel
+how to communicate with devices.
+
.SS Multiboot Options
-The Multiboot Specification provides a genreic interface for boot
+The Multiboot Specification provides a generic interface for boot
loaders and operating systems. It is supported by the GRUB bootloader.
.TP
\fB-\-add-multiboot\fR=\fImultiboot-path\fR
Add a new boot entry for the multiboot kernel located at
\fImultiboot-path\fR. Note that this is generally accompanied with a
-\fI--add-kernel\fR option.
+\fB--add-kernel\fR option.
.TP
\fB-\-remove-multiboot\fR=\fImultiboot-path\fR
@@ -249,11 +324,63 @@ The command line syntax is more than a little baroque. This probably
won't be fixed as \fBgrubby\fR is only intended to be called from shell
scripts which can get it right.
+.SH EXAMPLE
+
+The following examples assume the following:
+
+.TS
+allbox;
+rbw15 l.
+cfg_file Full path to bootloader config file
+new_kernel Full path to kernel image to be installed
+old_kernel Full path to old kernel image to be removed
+current_kernel Full path to a currently installed kernel
+entry_title Title that appears on bootloader menu
+new_initrd Full path to initrd for a new kernel
+kernel_args Set of arguments for the kernel
+menu_index Index number of a menu entry
+.TE
+
+The examples below quote strings that may have spaces or other whitespace in them. It is also
+perfectly valid to backslash escape these strings if that is more convenient.
+
+.PP
+Add a new kernel entry and copy all options from the current default kernel. This is the behavior
+that most users will want.
+.IP
+\fBgrubby\fR --add-kernel=\fInew_kernel\fR --title="\fIentry_title\fR" --initrd="\fInew_initrd\fR" --copy-default
+.PP
+Add a new kernel entry with custom arguments
+.IP
+\fBgrubby\fR --add-kernel=\fInew_kernel\fR --title="\fIentry_title\fR" --initrd="\fInew_initrd\fR" --args=\fIkernel_args\fR
+.PP
+Remove \fBall menu entries\fR for a specified kernel.
+.IP
+\fBgrubby\fR --remove-kernel=\fIold_kernel\fR
+.PP
+Target a single menu entry to remove without targetting other entries with the same kernel.
+.IP
+\fBgrubby\fR --info=\fIold_kernel\fR
+
+\fBgrubby\fR --remove-kernel=\fImenu_index\fR
+.PP
+Update the arguments for all entries of a specific kernel. New arguments get added while existing arguments get updated values.
+.IP
+\fBgrubby\fR --update-kernel=\fIcurrent_kernel\fR --args="\fIkernel_args\fR"
+.PP
+Remove the arguments for a single entry of a specific kernel.
+.IP
+\fBgrubby\fR --info=\fIcurrent_kernel\fR
+
+\fBgrubby\fR --remove-args=\fImenu_index\fR --args="\fIkernel_args\fR"
+
.SH "SEE ALSO"
.BR grub (8),
.BR lilo (8),
.BR yaboot (8),
+.BR zipl (8),
+.BR dracut (8),
.BR mkinitrd (8)
.SH AUTHORS
@@ -262,4 +389,5 @@ scripts which can get it right.
Erik Troan
Jeremy Katz
Peter Jones
+Robert Marshall
.fi
--
2.17.1

View File

@ -0,0 +1,29 @@
From 850fbd8b0dcc728653993661b92349f3eb2b39a6 Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Tue, 28 Jun 2016 16:26:32 -0400
Subject: [PATCH 27/55] Fix inline help typo (#1232168)
Discovered a typo while synchronizing the inline help with the man pages
and fixed it.
Related: rhbz#1232168
---
grubby.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/grubby.c b/grubby.c
index d889399449b..e2384c55898 100644
--- a/grubby.c
+++ b/grubby.c
@@ -4786,7 +4786,7 @@ int main(int argc, const char **argv)
NULL},
{"boot-filesystem", 0, POPT_ARG_STRING, &bootPrefix, 0,
_
- ("filestystem which contains /boot directory (for testing only)"),
+ ("filesystem which contains /boot directory (for testing only)"),
_("bootfs")},
#if defined(__i386__) || defined(__x86_64__) || defined (__powerpc64__) || defined (__ia64__)
{"bootloader-probe", 0, POPT_ARG_NONE, &bootloaderProbe, 0,
--
2.17.1

View File

@ -0,0 +1,213 @@
From b24cd1c5c8467ac6f7c5680db3a49ef6adc8df21 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 28 Jun 2016 16:50:37 -0400
Subject: [PATCH 28/55] More edits for grubby.8 (#1232168)
- Don't switch between the passive and active voice between the option
descriptions
- keep the same point of view between options ("[it] removes all
entries" vs "remove all entries")
- line wrap everywhere except the example envocations at <80 columns,
not 100.
- consistent use of i386 vs ia32
Signed-off-by: Peter Jones <pjones@redhat.com>
Related: rhbz#1232168
---
grubby.8 | 88 ++++++++++++++++++++++++++++++--------------------------
1 file changed, 48 insertions(+), 40 deletions(-)
diff --git a/grubby.8 b/grubby.8
index 64a6984fba0..690676858ca 100644
--- a/grubby.8
+++ b/grubby.8
@@ -2,11 +2,12 @@
.SH NAME
-grubby \- command line tool used to configure bootloader menu entries across multiple architectures
+grubby \- command line tool used to configure bootloader menu entries across
+multiple architectures
.SH SYNOPSIS
-\fBgrubby\fR [\fIOPTIONS...\fR]
+\fBgrubby\fR [\fIOPTIONS\fR]
.SH DESCRIPTION
@@ -37,13 +38,13 @@ are deprecated in favor of previously mentioned bootloaders. The
.SS Default Behavior
-The default architecture is chosen at compile time. The grubby executable
-has a series of built in assumptions about what bootloader is being used and
-where its configuration file lives. If no output format option is specified
-on the command line then grubby will use these default settings to first
-search for an existing configuration and, if it is not found, assume that
-it should be placed in the standard location. These default assumptions are
-listed in the table below.
+The default bootloader target is primarily determined by the architecture
+for which grubby has been built. Each architecture has a preferred
+bootloader, and each bootloader has its own configuration file. If no
+bootloader is selected on the command line, grubby will use these default
+settings to search for an existing configuration. If no bootloader
+configuration file is found, grubby will use the default value for that
+architecture. These defaults are listed in the table below.
.TS
allbox;
@@ -81,19 +82,18 @@ Add a new boot entry for the kernel located at \fIkernel-path\fR. A title for
the boot entry must be set using \fB-\-title\fR. Most invocations should also
include \fB-\-initrd\fR with memtest86 as a notable exception.
-The \fB-\-update-kernel\fR
-option may not be used in the same invocation.
+The \fB-\-update-kernel\fR option may not be used in the same invocation.
.TP
\fB-\-remove-kernel\fR=\fIkernel-path\fR
-Removes all boot entries which match \fIkernel-path\fR. This may be used
-along with \fB-\-add-kernel\fR, in which case the new kernel being added will
-never be removed.
+Remove all boot entries which match \fIkernel-path\fR. This may be used
+along with \fB-\-add-kernel\fR, in which case the new entry being added will
+not be removed.
.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
+Update the entries for kernels matching \fRkernel-path\fR. Currently
+the only item that can be updated is the kernel argument list, which is
modified via the \fB-\-args\fR and \fB-\-remove-args\fR options.
.TP
@@ -135,7 +135,7 @@ being added.
.TP
\fB-\-efi\fR
-Use linuxefi and initrdefi when constructing bootloader stanzas instead of linux and initrd.
+Use appropriate bootloader commands for EFI on this architecture.
.TP
\fB-\-set-default\fR=\fIkernel-path\fR
@@ -188,16 +188,18 @@ Display information on all boot entries which match \fIkernel-path\fR. I
.TP
\fB-\-bootloader-probe\fR
+Attempt to probe for installed bootloaders. If this option is specified,
\fBgrubby\fR tries to determine if \fBgrub\fR or \fBlilo\fR is currently
-installed. When one of those bootloaders is found the name of that bootloader
-is displayed on stdout. Both could be installed (on different devices), and
-grubby will print out the names of both bootloaders, one per line. The probe
-for \fBgrub\fR requires a commented out boot directive \fBgrub.conf\fR
-identical to the standard directive in the lilo configuration file. If this
-is not present \fBgrubby\fR will assume grub is not installed (note
-that \fBanaconda\fR places this directive in \fBgrub.conf\fR files it creates).
+installed. When one of those bootloaders is found the name of that
+bootloader is displayed on stdout. Both could be installed (on different
+devices), and grubby will print out the names of both bootloaders, one per
+line. The probe for \fBgrub\fR requires a commented out boot directive
+\fBgrub.conf\fR identical to the standard directive in the lilo
+configuration file. If this is not present \fBgrubby\fR will assume grub is
+not installed (note that \fBanaconda\fR places this directive in
+\fBgrub.conf\fR files it creates).
-\fIThis option is only available on i386 platforms.\fR
+\fIThis option is only available on x86 BIOS platforms.\fR
.TP
\fB-v\fR, \fB-\-version\fR
@@ -213,7 +215,8 @@ alternative bootloader.
.TP
\fB-\-elilo\fR
-Use an \fBelilo\fR style configuration file. This is the default on ia64 platforms. This format is deprecated.
+Use an \fBelilo\fR style configuration file. This is the default on ia64
+platforms. This format is deprecated.
.TP
\fB-\-extlinux\fR
@@ -221,13 +224,14 @@ Use an \fBextlinux\fR style configuration file. This format is deprecated.
.TP
\fB-\-grub\fR
-Use a \fBgrub\fR style configuration file. This is the default on ia32 platforms.
+Use a \fBgrub\fR style configuration file. This is the default on the i386
+architecture.
.TP
\fB-\-grub2\fR
-Use a \fBgrub2\fR style configuration file. This is the default on \fBx86_64\fR
-architecture as well as the \fBppc64\fR and \fBppc64le\fR architectures
-running on Power8 or later hardware.
+Use a \fBgrub2\fR style configuration file. This is the default on
+\fBx86_64\fR architecture as well as the \fBppc64\fR and \fBppc64le\fR
+architectures running on Power8 or later hardware.
.TP
\fB-\-lilo\fR
@@ -235,7 +239,8 @@ Use a \fBlilo\fR style configuration file.
.TP
\fB-\-silo\fR
-Use a \fBsilo\fR style configuration file. This is the default on SPARC systems. This format is legacy, deprecated, and unsupported.
+Use a \fBsilo\fR style configuration file. This is the default on SPARC
+systems. This format is legacy, deprecated, and unsupported.
.TP
\fB-\-yaboot\fR
@@ -286,9 +291,9 @@ directive found in the template stanza.
.TP
\fB-\-devtreedir\fR=\fIfile_path\fR
-Use the specified \fIfile path\fR to load the devicetree definition. This is for
-platforms where a flat file is used instead of firmware to instruct the kernel
-how to communicate with devices.
+Use the specified \fIfile path\fR to load the devicetree definition. This is
+for platforms where a flat file is used instead of firmware to instruct the
+kernel how to communicate with devices.
.SS Multiboot Options
@@ -341,12 +346,13 @@ kernel_args Set of arguments for the kernel
menu_index Index number of a menu entry
.TE
-The examples below quote strings that may have spaces or other whitespace in them. It is also
-perfectly valid to backslash escape these strings if that is more convenient.
+The examples below quote strings that may have spaces or other whitespace in
+them. It is also perfectly valid to backslash escape these strings if that
+is more convenient.
.PP
-Add a new kernel entry and copy all options from the current default kernel. This is the behavior
-that most users will want.
+Add a new kernel entry and copy all options from the current default kernel.
+This is the behavior that most users will want.
.IP
\fBgrubby\fR --add-kernel=\fInew_kernel\fR --title="\fIentry_title\fR" --initrd="\fInew_initrd\fR" --copy-default
.PP
@@ -358,13 +364,15 @@ Remove \fBall menu entries\fR for a specified kernel.
.IP
\fBgrubby\fR --remove-kernel=\fIold_kernel\fR
.PP
-Target a single menu entry to remove without targetting other entries with the same kernel.
+Target a single menu entry to remove without targetting other entries with
+the same kernel.
.IP
\fBgrubby\fR --info=\fIold_kernel\fR
\fBgrubby\fR --remove-kernel=\fImenu_index\fR
.PP
-Update the arguments for all entries of a specific kernel. New arguments get added while existing arguments get updated values.
+Update the arguments for all entries of a specific kernel. New arguments get
+added while existing arguments get updated values.
.IP
\fBgrubby\fR --update-kernel=\fIcurrent_kernel\fR --args="\fIkernel_args\fR"
.PP
--
2.17.1

View File

@ -0,0 +1,36 @@
From 79651f6be03752ecaefc9c77e2460e1763f6c0ea Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Fri, 1 Jul 2016 14:24:27 -0400
Subject: [PATCH 29/55] Minor man page changes (#1232168)
Minor wording changes made in the Architecture section after placing the
initial draft up for public comment.
Related: rhbz#1232168
---
grubby.8 | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/grubby.8 b/grubby.8
index 690676858ca..fdf2766fe9a 100644
--- a/grubby.8
+++ b/grubby.8
@@ -29,12 +29,12 @@ Legacy \fBs390\fR and the current \fBs390x\fR architectures
and their \fBzipl\fR bootloader are fully supported.
Support for \fByaboot\fR has been deprecated as all ppc architecture
-hardware since the Power8 system uses \fBgrub2\fR or petitboot
+hardware since the Power8 uses \fBgrub2\fR or petitboot
which both use the grub2 configuration file format.
Legacy bootloaders \fBLILO\fR, \fBSILO\fR, and \fBELILO\fR
-are deprecated in favor of previously mentioned bootloaders. The
-\fBSILO\fR bootloader should also be considered unsupported.
+are deprecated and no longer receiving active support in favor of
+previously mentioned bootloaders.
.SS Default Behavior
--
2.17.1

View File

@ -0,0 +1,66 @@
From 7b34b49d2a08a2636e0319b94d72ab654a30343d Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Thu, 8 Dec 2016 13:39:22 -0500
Subject: [PATCH 30/55] Rename setDefaultImage variables
The variable names in setDefaultImage did not match well with
how they were being used inside the function. Refactored the
variable names as a precursor to refactoring the function.
Related: rhbz#1285601
---
grubby.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/grubby.c b/grubby.c
index e2384c55898..9af8d17b345 100644
--- a/grubby.c
+++ b/grubby.c
@@ -2491,19 +2491,19 @@ void markRemovedImage(struct grubConfig *cfg, const char *image,
entry->skip = 1;
}
-void setDefaultImage(struct grubConfig *config, int hasNew,
- const char *defaultKernelPath, int newIsDefault,
- const char *prefix, int flags, int index)
+void setDefaultImage(struct grubConfig *config, int isUserSpecifiedKernelPath,
+ const char *defaultKernelPath, int newBootEntryIsDefault,
+ const char *prefix, int flags, int newDefaultBootEntryIndex)
{
struct singleEntry *entry, *entry2, *newDefault;
int i, j;
- if (newIsDefault) {
+ if (newBootEntryIsDefault) {
config->defaultImage = 0;
return;
- } else if ((index >= 0) && config->cfi->defaultIsIndex) {
- if (findEntryByIndex(config, index))
- config->defaultImage = index;
+ } else if ((newDefaultBootEntryIndex >= 0) && config->cfi->defaultIsIndex) {
+ if (findEntryByIndex(config, newDefaultBootEntryIndex))
+ config->defaultImage = newDefaultBootEntryIndex;
else
config->defaultImage = -1;
return;
@@ -2531,7 +2531,7 @@ void setDefaultImage(struct grubConfig *config, int hasNew,
if (entry && !entry->skip) {
/* we can preserve the default */
- if (hasNew)
+ if (isUserSpecifiedKernelPath)
config->defaultImage++;
/* count the number of entries erased before this one */
@@ -2540,7 +2540,7 @@ void setDefaultImage(struct grubConfig *config, int hasNew,
if (entry2->skip)
config->defaultImage--;
}
- } else if (hasNew) {
+ } else if (isUserSpecifiedKernelPath) {
config->defaultImage = 0;
} else {
/* Either we just erased the default (or the default line was
--
2.17.1

View File

@ -0,0 +1,198 @@
From 624a75f2d01d986ec78f60319ebc2acd37faada2 Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Tue, 13 Dec 2016 14:36:31 -0500
Subject: [PATCH 31/55] Add index constant definitions instead of open-coded
values.
Added numeric constants NO_DEFAULT_ENTRY and FIRST_ENTRY_INDEX. This
clarifies the intent of various assignment operations throughout the
source file.
Related: rhbz#1285601
---
grubby.c | 44 ++++++++++++++++++++++++--------------------
1 file changed, 24 insertions(+), 20 deletions(-)
diff --git a/grubby.c b/grubby.c
index 9af8d17b345..a717c18999b 100644
--- a/grubby.c
+++ b/grubby.c
@@ -132,6 +132,10 @@ struct singleEntry {
#define NEED_DEVTREE (1 << 6)
#define MAIN_DEFAULT (1 << 0)
+#define FIRST_ENTRY_INDEX 0 /* boot entry index value begin and increment
+ from this initial value */
+#define NO_DEFAULT_ENTRY -1 /* indicates that no specific default boot
+ entry was set or currently exists */
#define DEFAULT_SAVED -2
#define DEFAULT_SAVED_GRUB2 -3
@@ -1612,7 +1616,7 @@ static struct grubConfig *readConfig(const char *inName,
*end == ' ' || *end == '\t'))
end++;
if (*end)
- cfg->defaultImage = -1;
+ cfg->defaultImage = NO_DEFAULT_ENTRY;
} else if (defaultLine->numElements == 3) {
char *value = defaultLine->elements[2].item;
while (*value && (*value == '"' ||
@@ -1625,7 +1629,7 @@ static struct grubConfig *readConfig(const char *inName,
*end == ' ' || *end == '\t'))
end++;
if (*end)
- cfg->defaultImage = -1;
+ cfg->defaultImage = NO_DEFAULT_ENTRY;
}
} else if (cfi->defaultSupportSaved &&
!strncmp(defaultLine->elements[1].item, "saved",
@@ -1635,7 +1639,7 @@ static struct grubConfig *readConfig(const char *inName,
cfg->defaultImage =
strtol(defaultLine->elements[1].item, &end, 10);
if (*end)
- cfg->defaultImage = -1;
+ cfg->defaultImage = NO_DEFAULT_ENTRY;
} else if (defaultLine->numElements >= 2) {
int i = 0;
while ((entry = findEntryByIndex(cfg, i))) {
@@ -1663,7 +1667,7 @@ static struct grubConfig *readConfig(const char *inName,
if (entry) {
cfg->defaultImage = i;
} else {
- cfg->defaultImage = -1;
+ cfg->defaultImage = NO_DEFAULT_ENTRY;
}
}
} else if (cfg->cfi->defaultIsSaved && cfg->cfi->getEnv) {
@@ -1680,7 +1684,7 @@ static struct grubConfig *readConfig(const char *inName,
cfg->defaultImage = index;
}
} else {
- cfg->defaultImage = 0;
+ cfg->defaultImage = FIRST_ENTRY_INDEX;
}
return cfg;
@@ -1700,7 +1704,7 @@ static void writeDefault(FILE * out, char *indent,
fprintf(out, "%sdefault%ssaved\n", indent, separator);
else if (cfg->cfi->defaultIsSaved) {
fprintf(out, "%sset default=\"${saved_entry}\"\n", indent);
- if (cfg->defaultImage >= 0 && cfg->cfi->setEnv) {
+ if (cfg->defaultImage >= FIRST_ENTRY_INDEX && cfg->cfi->setEnv) {
char *title;
entry = findEntryByIndex(cfg, cfg->defaultImage);
line = getLineByType(LT_MENUENTRY, entry->lines);
@@ -1713,7 +1717,7 @@ static void writeDefault(FILE * out, char *indent,
"saved_entry", title);
}
}
- } else if (cfg->defaultImage > -1) {
+ } else if (cfg->defaultImage >= FIRST_ENTRY_INDEX) {
if (cfg->cfi->defaultIsIndex) {
if (cfg->cfi->defaultIsVariable) {
fprintf(out, "%sset default=\"%d\"\n", indent,
@@ -2417,7 +2421,7 @@ struct singleEntry *findTemplate(struct grubConfig *cfg, const char *prefix,
}
}
}
- } else if (cfg->defaultImage > -1) {
+ } else if (cfg->defaultImage >= FIRST_ENTRY_INDEX) {
entry = findEntryByIndex(cfg, cfg->defaultImage);
if (entry && suitableImage(entry, prefix, skipRemoved, flags)) {
if (indexPtr)
@@ -2499,20 +2503,20 @@ void setDefaultImage(struct grubConfig *config, int isUserSpecifiedKernelPath,
int i, j;
if (newBootEntryIsDefault) {
- config->defaultImage = 0;
+ config->defaultImage = FIRST_ENTRY_INDEX;
return;
} else if ((newDefaultBootEntryIndex >= 0) && config->cfi->defaultIsIndex) {
if (findEntryByIndex(config, newDefaultBootEntryIndex))
config->defaultImage = newDefaultBootEntryIndex;
else
- config->defaultImage = -1;
+ config->defaultImage = NO_DEFAULT_ENTRY;
return;
} else if (defaultKernelPath) {
i = 0;
if (findEntryByPath(config, defaultKernelPath, prefix, &i)) {
config->defaultImage = i;
} else {
- config->defaultImage = -1;
+ config->defaultImage = NO_DEFAULT_ENTRY;
return;
}
}
@@ -2524,7 +2528,7 @@ void setDefaultImage(struct grubConfig *config, int isUserSpecifiedKernelPath,
/* default is set to saved, we don't want to change it */
return;
- if (config->defaultImage > -1)
+ if (config->defaultImage >= FIRST_ENTRY_INDEX)
entry = findEntryByIndex(config, config->defaultImage);
else
entry = NULL;
@@ -2541,7 +2545,7 @@ void setDefaultImage(struct grubConfig *config, int isUserSpecifiedKernelPath,
config->defaultImage--;
}
} else if (isUserSpecifiedKernelPath) {
- config->defaultImage = 0;
+ config->defaultImage = FIRST_ENTRY_INDEX;
} else {
/* Either we just erased the default (or the default line was
* bad to begin with) and didn't put a new one in. We'll use
@@ -2550,7 +2554,7 @@ void setDefaultImage(struct grubConfig *config, int isUserSpecifiedKernelPath,
findTemplate(config, prefix, &config->defaultImage, 1,
flags);
if (!newDefault)
- config->defaultImage = -1;
+ config->defaultImage = NO_DEFAULT_ENTRY;
}
}
@@ -5175,11 +5179,11 @@ int main(int argc, const char **argv)
struct singleEntry *entry;
char *rootspec;
- if (config->defaultImage == -1)
+ if (config->defaultImage == NO_DEFAULT_ENTRY)
return 0;
if (config->defaultImage == DEFAULT_SAVED_GRUB2 &&
cfi->defaultIsSaved)
- config->defaultImage = 0;
+ config->defaultImage = FIRST_ENTRY_INDEX;
entry = findEntryByIndex(config, config->defaultImage);
if (!entry)
return 0;
@@ -5202,11 +5206,11 @@ int main(int argc, const char **argv)
struct singleLine *line;
struct singleEntry *entry;
- if (config->defaultImage == -1)
+ if (config->defaultImage == NO_DEFAULT_ENTRY)
return 0;
if (config->defaultImage == DEFAULT_SAVED_GRUB2 &&
cfi->defaultIsSaved)
- config->defaultImage = 0;
+ config->defaultImage = FIRST_ENTRY_INDEX;
entry = findEntryByIndex(config, config->defaultImage);
if (!entry)
return 0;
@@ -5236,11 +5240,11 @@ int main(int argc, const char **argv)
return 0;
} else if (displayDefaultIndex) {
- if (config->defaultImage == -1)
+ if (config->defaultImage == NO_DEFAULT_ENTRY)
return 0;
if (config->defaultImage == DEFAULT_SAVED_GRUB2 &&
cfi->defaultIsSaved)
- config->defaultImage = 0;
+ config->defaultImage = FIRST_ENTRY_INDEX;
printf("%i\n", config->defaultImage);
return 0;
--
2.17.1

View File

@ -0,0 +1,50 @@
From 12ae8096bd3099b81fded8c30be1a8050ed7e68c Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Thu, 8 Dec 2016 16:52:45 -0500
Subject: [PATCH 32/55] Track configuration modifications
The setDefaultImage function had a subtle dependency on being run before
addNewKernel is invoked. Added the ability to track invocation to
prevent them from being so tightly coupled.
Related: rhbz#1285601
---
grubby.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/grubby.c b/grubby.c
index a717c18999b..1f712ec1391 100644
--- a/grubby.c
+++ b/grubby.c
@@ -678,6 +678,8 @@ struct grubConfig {
int fallbackImage; /* just like defaultImage */
int flags;
struct configFileInfo *cfi;
+ int isModified; /* assumes only one entry added
+ per invocation of grubby */
};
blkid_cache blkid;
@@ -1297,6 +1299,7 @@ static struct grubConfig *readConfig(const char *inName,
cfg->theLines = NULL;
cfg->entries = NULL;
cfg->fallbackImage = 0;
+ cfg->isModified = 0;
/* copy everything we have */
while (*head) {
@@ -4726,8 +4729,10 @@ int addNewKernel(struct grubConfig *config, struct singleEntry *template,
}
if (updateImage(config, indexs, prefix, newKernelArgs, NULL,
- newMBKernelArgs, NULL))
+ newMBKernelArgs, NULL)) {
+ config->isModified = 1;
return 1;
+ }
return 0;
}
--
2.17.1

View File

@ -0,0 +1,65 @@
From 5ec8c855f307a89f08013c832bd7e121c8f83327 Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Thu, 15 Dec 2016 21:47:28 -0500
Subject: [PATCH 33/55] Fix some test cases where the resulting default index
is wrong
Fix two issues with tests where removing a kernel or adding a boot entry
at a user specified index had the wrong default index selected in the
expected output.
One of these issues is the --set-index test cases for grub 1, which
expect --make-default is implied where it should not be.
The third is a removal test, where the default index in the result data
is off by one when we've removed 2 entries keyed off of the kernel
filesystem path.
This change causes these test cases to fail.
Resolves: rhbz#1285601
---
test/results/add/g1.17 | 2 +-
test/results/add/g1.9 | 2 +-
test/results/remove/g7.1 | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/results/add/g1.17 b/test/results/add/g1.17
index 6a388228768..eda4e93329d 100644
--- a/test/results/add/g1.17
+++ b/test/results/add/g1.17
@@ -7,7 +7,7 @@
# kernel /vmlinuz-version ro root=/dev/sda1
# initrd /initrd-version.img
#boot=/dev/hda
-default=1
+default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Linux (2.4.7-2)
diff --git a/test/results/add/g1.9 b/test/results/add/g1.9
index 310623d13d2..8976e762d74 100644
--- a/test/results/add/g1.9
+++ b/test/results/add/g1.9
@@ -7,7 +7,7 @@
# kernel /vmlinuz-version ro root=/dev/sda1
# initrd /initrd-version.img
#boot=/dev/hda
-default=2
+default=1
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Linux (2.4.7-2)
diff --git a/test/results/remove/g7.1 b/test/results/remove/g7.1
index ea1a6fbaec9..611d7a16685 100644
--- a/test/results/remove/g7.1
+++ b/test/results/remove/g7.1
@@ -1,4 +1,4 @@
-default=1
+default=0
timeout=10
splashimage=(hd0,5)/boot/grub/splash.xpm.gz
--
2.17.1

View File

@ -0,0 +1,197 @@
From ff38bf8209faf54c25e15b1fcec4184fee1f39e9 Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Tue, 13 Dec 2016 18:20:15 -0500
Subject: [PATCH 34/55] Don't assume --make-default just because --set-index
was passed.
grubby previously made the assumption that every time a new
boot entry gets added using --set-index, it should be the default. Due
to this behavior, it also masked an logic error that prevented the
selection of the proper index in cases where it was necessary to
dynamically pick a new default boot entry, or to keep the existing
default boot entry when its position in the config file moved.
Resolves: rhbz#1285601
---
grubby.c | 138 ++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 97 insertions(+), 41 deletions(-)
diff --git a/grubby.c b/grubby.c
index 1f712ec1391..fcca6364887 100644
--- a/grubby.c
+++ b/grubby.c
@@ -2498,66 +2498,121 @@ void markRemovedImage(struct grubConfig *cfg, const char *image,
entry->skip = 1;
}
-void setDefaultImage(struct grubConfig *config, int isUserSpecifiedKernelPath,
+void setDefaultImage(struct grubConfig *config, int isAddingBootEntry,
const char *defaultKernelPath, int newBootEntryIsDefault,
- const char *prefix, int flags, int newDefaultBootEntryIndex)
+ const char *prefix, int flags,
+ int newDefaultBootEntryIndex, int newBootEntryIndex)
{
- struct singleEntry *entry, *entry2, *newDefault;
- int i, j;
+ struct singleEntry *bootEntry, *newDefault;
+ int indexToVerify, firstKernelEntryIndex, currentLookupIndex;
+ /* handle the two cases where the user explictly picks the default
+ * boot entry index as it would exist post-modification */
+
+ /* Case 1: user chose to make the latest boot entry the default */
if (newBootEntryIsDefault) {
- config->defaultImage = FIRST_ENTRY_INDEX;
+ config->defaultImage = newBootEntryIndex;
return;
- } else if ((newDefaultBootEntryIndex >= 0) && config->cfi->defaultIsIndex) {
- if (findEntryByIndex(config, newDefaultBootEntryIndex))
+ }
+
+ /* Case 2: user picked an arbitrary index as the default boot entry */
+ if (newDefaultBootEntryIndex >= FIRST_ENTRY_INDEX
+ && config->cfi->defaultIsIndex) {
+ indexToVerify = newDefaultBootEntryIndex;
+
+ /* user chose to make latest boot entry the default */
+ if (newDefaultBootEntryIndex == newBootEntryIndex) {
+ config->defaultImage = newBootEntryIndex;
+ return;
+ }
+
+ /* the user picks the default index based on the
+ * order of the bootloader configuration after
+ * modification; ensure we are checking for the
+ * existence of the correct entry */
+ if (newBootEntryIndex < newDefaultBootEntryIndex) {
+ if (!config->isModified)
+ indexToVerify--;
+ }
+
+ /* verify the user selected index will exist */
+ if (findEntryByIndex(config, indexToVerify)) {
config->defaultImage = newDefaultBootEntryIndex;
- else
- config->defaultImage = NO_DEFAULT_ENTRY;
- return;
- } else if (defaultKernelPath) {
- i = 0;
- if (findEntryByPath(config, defaultKernelPath, prefix, &i)) {
- config->defaultImage = i;
} else {
config->defaultImage = NO_DEFAULT_ENTRY;
- return;
}
- }
- /* defaultImage now points to what we'd like to use, but before any
- * order changes */
- if ((config->defaultImage == DEFAULT_SAVED) ||
- (config->defaultImage == DEFAULT_SAVED_GRUB2))
- /* default is set to saved, we don't want to change it */
return;
+ }
- if (config->defaultImage >= FIRST_ENTRY_INDEX)
- entry = findEntryByIndex(config, config->defaultImage);
- else
- entry = NULL;
+ /* handle cases where the index value may shift */
- if (entry && !entry->skip) {
- /* we can preserve the default */
- if (isUserSpecifiedKernelPath)
+ /* check validity of existing default or first-entry-found
+ selection */
+ if (defaultKernelPath) {
+ /* user requested first-entry-found */
+ if (!findEntryByPath(config, defaultKernelPath,
+ prefix, &firstKernelEntryIndex)) {
+ /* don't change default if can't find match */
+ config->defaultImage = NO_DEFAULT_ENTRY;
+ return;
+ }
+
+ config->defaultImage = firstKernelEntryIndex;
+
+ /* this is where we start looking for decrement later */
+ currentLookupIndex = config->defaultImage;
+
+ if (isAddingBootEntry && !config->isModified &&
+ (newBootEntryIndex < config->defaultImage)) {
+ /* increment because new entry added before default */
config->defaultImage++;
-
- /* count the number of entries erased before this one */
- for (j = 0; j < config->defaultImage; j++) {
- entry2 = findEntryByIndex(config, j);
- if (entry2->skip)
- config->defaultImage--;
}
- } else if (isUserSpecifiedKernelPath) {
- config->defaultImage = FIRST_ENTRY_INDEX;
} else {
- /* Either we just erased the default (or the default line was
- * bad to begin with) and didn't put a new one in. We'll use
- * the first valid image. */
+ /* use pre-existing default entry */
+ currentLookupIndex = config->defaultImage;
+
+ if (isAddingBootEntry
+ && (newBootEntryIndex <= config->defaultImage)) {
+ config->defaultImage++;
+
+ if (config->isModified) {
+ currentLookupIndex++;
+ }
+ }
+ }
+
+ /* sanity check - is this entry index valid? */
+ bootEntry = findEntryByIndex(config, currentLookupIndex);
+
+ if ((bootEntry && bootEntry->skip) || !bootEntry) {
+ /* entry is to be skipped or is invalid */
+ if (isAddingBootEntry) {
+ config->defaultImage = newBootEntryIndex;
+ return;
+ }
newDefault =
findTemplate(config, prefix, &config->defaultImage, 1,
flags);
- if (!newDefault)
+ if (!newDefault) {
config->defaultImage = NO_DEFAULT_ENTRY;
+ }
+
+ return;
+ }
+
+ currentLookupIndex--;
+
+ /* decrement index by the total number of entries deleted */
+
+ for (indexToVerify = currentLookupIndex;
+ indexToVerify >= FIRST_ENTRY_INDEX; indexToVerify--) {
+
+ bootEntry = findEntryByIndex(config, indexToVerify);
+
+ if (bootEntry && bootEntry->skip) {
+ config->defaultImage--;
+ }
}
}
@@ -5265,7 +5320,8 @@ int main(int argc, const char **argv)
markRemovedImage(config, removeKernelPath, bootPrefix);
markRemovedImage(config, removeMBKernel, bootPrefix);
setDefaultImage(config, newKernelPath != NULL, defaultKernel,
- makeDefault, bootPrefix, flags, defaultIndex);
+ makeDefault, bootPrefix, flags, defaultIndex,
+ newIndex);
setFallbackImage(config, newKernelPath != NULL);
if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs,
removeArgs, newMBKernelArgs, removeMBKernelArgs))
--
2.17.1

View File

@ -0,0 +1,32 @@
From 8836f04b716c9ca56b518627c3d8064f18f9c33d Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Thu, 15 Dec 2016 21:53:31 -0500
Subject: [PATCH 35/55] Clarify --set-default-index in the man page.
This changes the man page to say that the index value provided with
--set-default-index applies to the boot entry list after modifications.
Resolves: rhbz#1285601
---
grubby.8 | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/grubby.8 b/grubby.8
index fdf2766fe9a..1e8f140c4df 100644
--- a/grubby.8
+++ b/grubby.8
@@ -144,8 +144,9 @@ boot entry. This may not be invoked with \fB-\-set-default-index\fR.
.TP
\fB-\-set-default-index\fR=\fIentry-index\fR
-Makes the given entry number the default boot entry. This may not
-be invoked with \fB-\-set-default\fR.
+Makes the given entry number the default boot entry. This may not be invoked
+with \fB-\-set-default\fR. The given value represents the index in the
+post-modification boot entry list.
.TP
\fB-\-make-default\fR
--
2.17.1

View File

@ -0,0 +1,261 @@
From 2d19bc931b0b2a70abc18f6d15dddbf547cafd94 Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Thu, 22 Dec 2016 17:40:52 -0500
Subject: [PATCH 36/55] Add multi-entry removal test (#1285601)
Test what happens to the default entry set in the grub environment after
removing the first two boot entries.
Related: rhbz#1285601
---
test.sh | 7 ++
test/grub2-support_files/grubenv.4 | 3 +
test/grub2.19 | 112 +++++++++++++++++++++++++++++
test/results/remove/g2.19 | 88 +++++++++++++++++++++++
4 files changed, 210 insertions(+)
create mode 100644 test/grub2-support_files/grubenv.4
create mode 100644 test/grub2.19
create mode 100644 test/results/remove/g2.19
diff --git a/test.sh b/test.sh
index fb7cd2381d5..1ef9eca535d 100755
--- a/test.sh
+++ b/test.sh
@@ -565,6 +565,13 @@ if [ "$testgrub2" == "y" ]; then
--copy-default --title 'Red Hat Enterprise Linux Server' \
--args=root=/dev/mapper/foo--
+ grub2Test grub2.19 remove/g2.19 --env grubenv.4 \
+ --remove-kernel=/boot/vmlinuz-2.6.38.2-9.fc15.x86_64 \
+ --boot-filesystem=/boot/
+ commandTest "saved_default output" \
+ "grub2-editenv test/grub2-support_files/env_temp list" \
+ "saved_entry=Linux, with Fedora 2.6.38.8-32.fc15.x86_64"
+
# copy a stanza and add arguments as well, while using --set-index=
testing="GRUB2 add stanza and new args with --set-index="
grub2Test grub2.18 add/g2-1.18 --env grubenv.3 \
diff --git a/test/grub2-support_files/grubenv.4 b/test/grub2-support_files/grubenv.4
new file mode 100644
index 00000000000..13116382feb
--- /dev/null
+++ b/test/grub2-support_files/grubenv.4
@@ -0,0 +1,3 @@
+# GRUB Environment Block
+saved_entry=Linux, with Fedora 2.6.38.8-32.fc15.x86_64
+################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
diff --git a/test/grub2.19 b/test/grub2.19
new file mode 100644
index 00000000000..be07b3ea6b3
--- /dev/null
+++ b/test/grub2.19
@@ -0,0 +1,112 @@
+#
+# DO NOT EDIT THIS FILE
+#
+# It is automatically generated by grub2-mkconfig using templates
+# from /etc/grub.d and settings from /etc/default/grub
+#
+
+### BEGIN /etc/grub.d/00_header ###
+if [ -s $prefix/grubenv ]; then
+ load_env
+fi
+if [ "${next_entry}" ] ; then
+ set default="${next_entry}"
+ set next_entry=
+ save_env next_entry
+ set boot_once=true
+else
+ set default="${saved_entry}"
+fi
+
+if [ x"${feature_menuentry_id}" = xy ]; then
+ menuentry_id_option="--id"
+else
+ menuentry_id_option=""
+fi
+
+export menuentry_id_option
+
+if [ "${prev_saved_entry}" ]; then
+ set saved_entry="${prev_saved_entry}"
+ save_env saved_entry
+ set prev_saved_entry=
+ save_env prev_saved_entry
+ set boot_once=true
+fi
+
+function savedefault {
+ if [ -z "${boot_once}" ]; then
+ saved_entry="${chosen}"
+ save_env saved_entry
+ fi
+}
+
+function load_video {
+ insmod vbe
+ insmod vga
+ insmod video_bochs
+ insmod video_cirrus
+}
+
+set timeout=5
+### END /etc/grub.d/00_header ###
+
+### BEGIN /etc/grub.d/10_linux ###
+menuentry 'First Title To Remove' --class gnu-linux --class gnu --class os {
+ load_video
+ set gfxpayload=keep
+ insmod part_msdos
+ insmod ext2
+ set root='(hd0,msdos1)'
+ search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed
+ echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...'
+ linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb
+ echo 'Loading initial ramdisk ...'
+ initrd /initramfs-2.6.38.2-9.fc15.x86_64.img
+}
+menuentry 'Second Title To Remove' --class gnu-linux --class gnu --class os {
+ load_video
+ set gfxpayload=keep
+ insmod part_msdos
+ insmod ext2
+ set root='(hd0,msdos1)'
+ search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed
+ echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...'
+ linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb
+ echo 'Loading initial ramdisk ...'
+ initrd /initramfs-2.6.38.2-9.fc15.x86_64.img
+}
+menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os {
+ load_video
+ set gfxpayload=keep
+ insmod part_msdos
+ insmod ext2
+ set root='(hd0,msdos1)'
+ search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed
+ echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...'
+ linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb
+ echo 'Loading initial ramdisk ...'
+ initrd /initramfs-2.6.38.8-32.fc15.x86_64.img
+}
+### END /etc/grub.d/10_linux ###
+
+### BEGIN /etc/grub.d/20_linux_xen ###
+### END /etc/grub.d/20_linux_xen ###
+
+### BEGIN /etc/grub.d/30_os-prober ###
+### END /etc/grub.d/30_os-prober ###
+
+### BEGIN /etc/grub.d/40_custom ###
+# This file provides an easy way to add custom menu entries. Simply type the
+# menu entries you want to add after this comment. Be careful not to change
+# the 'exec tail' line above.
+### END /etc/grub.d/40_custom ###
+
+### BEGIN /etc/grub.d/41_custom ###
+if [ -f $prefix/custom.cfg ]; then
+ source $prefix/custom.cfg;
+fi
+### END /etc/grub.d/41_custom ###
+
+### BEGIN /etc/grub.d/90_persistent ###
+### END /etc/grub.d/90_persistent ###
diff --git a/test/results/remove/g2.19 b/test/results/remove/g2.19
new file mode 100644
index 00000000000..f65edd5ac29
--- /dev/null
+++ b/test/results/remove/g2.19
@@ -0,0 +1,88 @@
+#
+# DO NOT EDIT THIS FILE
+#
+# It is automatically generated by grub2-mkconfig using templates
+# from /etc/grub.d and settings from /etc/default/grub
+#
+
+### BEGIN /etc/grub.d/00_header ###
+if [ -s $prefix/grubenv ]; then
+ load_env
+fi
+if [ "${next_entry}" ] ; then
+ set default="${next_entry}"
+ set next_entry=
+ save_env next_entry
+ set boot_once=true
+else
+ set default="${saved_entry}"
+fi
+
+if [ x"${feature_menuentry_id}" = xy ]; then
+ menuentry_id_option="--id"
+else
+ menuentry_id_option=""
+fi
+
+export menuentry_id_option
+
+if [ "${prev_saved_entry}" ]; then
+ set saved_entry="${prev_saved_entry}"
+ save_env saved_entry
+ set prev_saved_entry=
+ save_env prev_saved_entry
+ set boot_once=true
+fi
+
+function savedefault {
+ if [ -z "${boot_once}" ]; then
+ saved_entry="${chosen}"
+ save_env saved_entry
+ fi
+}
+
+function load_video {
+ insmod vbe
+ insmod vga
+ insmod video_bochs
+ insmod video_cirrus
+}
+
+set timeout=5
+### END /etc/grub.d/00_header ###
+
+### BEGIN /etc/grub.d/10_linux ###
+menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os {
+ load_video
+ set gfxpayload=keep
+ insmod part_msdos
+ insmod ext2
+ set root='(hd0,msdos1)'
+ search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed
+ echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...'
+ linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb
+ echo 'Loading initial ramdisk ...'
+ initrd /initramfs-2.6.38.8-32.fc15.x86_64.img
+}
+### END /etc/grub.d/10_linux ###
+
+### BEGIN /etc/grub.d/20_linux_xen ###
+### END /etc/grub.d/20_linux_xen ###
+
+### BEGIN /etc/grub.d/30_os-prober ###
+### END /etc/grub.d/30_os-prober ###
+
+### BEGIN /etc/grub.d/40_custom ###
+# This file provides an easy way to add custom menu entries. Simply type the
+# menu entries you want to add after this comment. Be careful not to change
+# the 'exec tail' line above.
+### END /etc/grub.d/40_custom ###
+
+### BEGIN /etc/grub.d/41_custom ###
+if [ -f $prefix/custom.cfg ]; then
+ source $prefix/custom.cfg;
+fi
+### END /etc/grub.d/41_custom ###
+
+### BEGIN /etc/grub.d/90_persistent ###
+### END /etc/grub.d/90_persistent ###
--
2.17.1

View File

@ -0,0 +1,40 @@
From 46843e71656264d98ceda79985e5d341a8d58aa7 Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Thu, 22 Dec 2016 17:52:14 -0500
Subject: [PATCH 37/55] Fix findTemplate index logic (#1285601)
The fallback case where findTemplate has to look for the first entry
contained a logic flaw that could return an incorrect index. This
discovered index should be reduced by one for each boot entry that will
be skipped in the final output. The flaw occurred because the index
variable was used for the loop upper bound at the same time as it was
being decremented within the actual loop body. The loop would thus fail
to examine a number of boot entries equal to the total number of
iterations the loop performed.
Related: rhbz#1285601
---
grubby.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/grubby.c b/grubby.c
index fcca6364887..692c351ccb6 100644
--- a/grubby.c
+++ b/grubby.c
@@ -2436,8 +2436,11 @@ struct singleEntry *findTemplate(struct grubConfig *cfg, const char *prefix,
index = 0;
while ((entry = findEntryByIndex(cfg, index))) {
if (suitableImage(entry, prefix, skipRemoved, flags)) {
- int j;
- for (j = 0; j < index; j++) {
+ int j, unmodifiedIndex;
+
+ unmodifiedIndex = index;
+
+ for (j = 0; j < unmodifiedIndex; j++) {
entry2 = findEntryByIndex(cfg, j);
if (entry2->skip)
index--;
--
2.17.1

View File

@ -0,0 +1,43 @@
From d3c64808b6fc4794e2c58b1812315914966afea9 Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Thu, 22 Dec 2016 17:56:44 -0500
Subject: [PATCH 38/55] Write correct default to environment (#1285601)
grubby writes the title of the default boot entry to the bootloader
environment. The title lookup did not correctly account for the offset
required if some boot entries were marked for removal.
Related: rhbz#1285601
---
grubby.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/grubby.c b/grubby.c
index 692c351ccb6..9edb26d0ded 100644
--- a/grubby.c
+++ b/grubby.c
@@ -1709,7 +1709,20 @@ static void writeDefault(FILE * out, char *indent,
fprintf(out, "%sset default=\"${saved_entry}\"\n", indent);
if (cfg->defaultImage >= FIRST_ENTRY_INDEX && cfg->cfi->setEnv) {
char *title;
- entry = findEntryByIndex(cfg, cfg->defaultImage);
+ int trueIndex, currentIndex;
+
+ trueIndex = 0;
+ currentIndex = 0;
+
+ while ((entry = findEntryByIndex(cfg, currentIndex))) {
+ if (!entry->skip) {
+ if (trueIndex == cfg->defaultImage) {
+ break;
+ }
+ trueIndex++;
+ }
+ currentIndex++;
+ }
line = getLineByType(LT_MENUENTRY, entry->lines);
if (!line)
line = getLineByType(LT_TITLE, entry->lines);
--
2.17.1

View File

@ -0,0 +1,29 @@
From d124974021199ddee0d1af1b2c7866f533c2f23a Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Mon, 27 Feb 2017 15:59:53 -0500
Subject: [PATCH 39/55] Initialize variable for ppc environment (#1285601)
Building on PPC does not default the value of an uninitialized integer
to zero which caused test failures.
Related: rhbz#1285601
---
grubby.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/grubby.c b/grubby.c
index 9edb26d0ded..9ccad2735dd 100644
--- a/grubby.c
+++ b/grubby.c
@@ -2566,6 +2566,8 @@ void setDefaultImage(struct grubConfig *config, int isAddingBootEntry,
/* check validity of existing default or first-entry-found
selection */
if (defaultKernelPath) {
+ /* we must initialize this */
+ firstKernelEntryIndex = 0;
/* user requested first-entry-found */
if (!findEntryByPath(config, defaultKernelPath,
prefix, &firstKernelEntryIndex)) {
--
2.17.1

View File

@ -0,0 +1,64 @@
From a8367596ca63156509eed0b332a077247765b811 Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Tue, 28 Feb 2017 18:31:56 -0500
Subject: [PATCH 40/55] Fix initial saved_entry read issue (#1285601)
If a system has never had a kernel upgrade/rollback then grubby
does not read saved_entry properly. Added a guard to catch
saved_entry and read it to pick the proper index in these cases.
Resolves: rhbz#1285601
---
grubby.c | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/grubby.c b/grubby.c
index 9ccad2735dd..974b81c7864 100644
--- a/grubby.c
+++ b/grubby.c
@@ -2522,6 +2522,9 @@ void setDefaultImage(struct grubConfig *config, int isAddingBootEntry,
struct singleEntry *bootEntry, *newDefault;
int indexToVerify, firstKernelEntryIndex, currentLookupIndex;
+ /* initialize */
+ currentLookupIndex = FIRST_ENTRY_INDEX;
+
/* handle the two cases where the user explictly picks the default
* boot entry index as it would exist post-modification */
@@ -2587,8 +2590,30 @@ void setDefaultImage(struct grubConfig *config, int isAddingBootEntry,
config->defaultImage++;
}
} else {
- /* use pre-existing default entry */
- currentLookupIndex = config->defaultImage;
+ /* check to see if the default is stored in the environment */
+ if (config->defaultImage < FIRST_ENTRY_INDEX) {
+ if (config->defaultImage == DEFAULT_SAVED || config->defaultImage == DEFAULT_SAVED_GRUB2)
+ {
+ if (config->cfi->defaultIsSaved) {
+ if (config->cfi->getEnv) {
+ char *defaultTitle = config->cfi->getEnv(config->cfi, "saved_entry");
+
+ if (defaultTitle) {
+ if (isnumber(defaultTitle)) {
+ currentLookupIndex = atoi(defaultTitle);
+ } else {
+ findEntryByTitle(config, defaultTitle, &currentLookupIndex);
+ }
+ /* set the default Image to an actual index */
+ config->defaultImage = currentLookupIndex;
+ }
+ }
+ }
+ }
+ } else {
+ /* use pre-existing default entry from the file*/
+ currentLookupIndex = config->defaultImage;
+ }
if (isAddingBootEntry
&& (newBootEntryIndex <= config->defaultImage)) {
--
2.17.1

View File

@ -0,0 +1,74 @@
From 4d48c517db42b6d7f30d7d2441863704bd01eb11 Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Tue, 14 Mar 2017 22:55:27 -0400
Subject: [PATCH 41/55] Add s390/s390x --info test (#1285601)
Running the --info grubby option on s390/s390x platforms always returned
the (null) value. Added a test to look at --info and ensure it comes out
as a user would expect.
Resolves: rhbz#1285601
---
test.sh | 2 ++
test/results/info/z2.1 | 6 ++++++
test/zipl.2 | 22 ++++++++++++++++++++++
3 files changed, 30 insertions(+)
create mode 100644 test/results/info/z2.1
create mode 100644 test/zipl.2
diff --git a/test.sh b/test.sh
index 1ef9eca535d..afa4f705b2b 100755
--- a/test.sh
+++ b/test.sh
@@ -320,6 +320,8 @@ testing="Z/IPL display default title"
ziplDisplayTest zipl.1 defaulttitle/z.1 --default-title
testing="Z/IPL display default kernel"
ziplDisplayTest zipl.1 defaultkernel/z.1 --default-kernel
+testing="Z/IPL display entry information"
+ziplDisplayTest zipl.2 info/z2.1 --info=1
testing="GRUB fallback directive"
grubTest grub.5 fallback/g5.1 --remove-kernel=/boot/vmlinuz-2.4.7-ac3 \
diff --git a/test/results/info/z2.1 b/test/results/info/z2.1
new file mode 100644
index 00000000000..e5ce3a1a61f
--- /dev/null
+++ b/test/results/info/z2.1
@@ -0,0 +1,6 @@
+index=1
+kernel=/boot/vmlinuz-3.10.0-514.6.2.el7.s390x
+args="crashkernel=auto rd.dasd=0.0.0120 rd.dasd=0.0.0121 rd.dasd=0.0.0122 rd.dasd=0.0.0123 rd.lvm.lv=rhel_ibm-z-68/root rd.lvm.lv=rhel_ibm-z-68/swap rd.znet=qeth,0.0.8000,0.0.8001,0.0.8002,layer2=1,portname=z-68,portno=0 LANG=en_US.UTF-8 systemd.log_level=debug systemd.log_target=kmsg"
+root=/dev/mapper/rhel_ibm--z--68-root
+initrd=/boot/initramfs-3.10.0-514.6.2.el7.s390x.img
+title=3.10.0-514.6.2.el7.s390x_with_debugging
diff --git a/test/zipl.2 b/test/zipl.2
new file mode 100644
index 00000000000..f064b2a36d5
--- /dev/null
+++ b/test/zipl.2
@@ -0,0 +1,22 @@
+[defaultboot]
+defaultauto
+prompt=1
+timeout=5
+default=3.10.0-514.6.2.el7.s390x_with_debugging
+target=/boot
+[3.10.0-514.6.2.el7.s390x]
+ image=/boot/vmlinuz-3.10.0-514.6.2.el7.s390x
+ parameters="root=/dev/mapper/rhel_ibm--z--68-root crashkernel=auto rd.dasd=0.0.0120 rd.dasd=0.0.0121 rd.dasd=0.0.0122 rd.dasd=0.0.0123 rd.lvm.lv=rhel_ibm-z-68/root rd.lvm.lv=rhel_ibm-z-68/swap rd.znet=qeth,0.0.8000,0.0.8001,0.0.8002,layer2=1,portname=z-68,portno=0 LANG=en_US.UTF-8"
+ ramdisk=/boot/initramfs-3.10.0-514.6.2.el7.s390x.img
+[3.10.0-514.6.2.el7.s390x_with_debugging]
+ image=/boot/vmlinuz-3.10.0-514.6.2.el7.s390x
+ parameters="root=/dev/mapper/rhel_ibm--z--68-root crashkernel=auto rd.dasd=0.0.0120 rd.dasd=0.0.0121 rd.dasd=0.0.0122 rd.dasd=0.0.0123 rd.lvm.lv=rhel_ibm-z-68/root rd.lvm.lv=rhel_ibm-z-68/swap rd.znet=qeth,0.0.8000,0.0.8001,0.0.8002,layer2=1,portname=z-68,portno=0 LANG=en_US.UTF-8 systemd.log_level=debug systemd.log_target=kmsg"
+ ramdisk=/boot/initramfs-3.10.0-514.6.2.el7.s390x.img
+[linux]
+ image=/boot/vmlinuz-3.10.0-514.el7.s390x
+ ramdisk=/boot/initramfs-3.10.0-514.el7.s390x.img
+ parameters="root=/dev/mapper/rhel_ibm--z--68-root crashkernel=auto rd.dasd=0.0.0120 rd.dasd=0.0.0121 rd.dasd=0.0.0122 rd.dasd=0.0.0123 rd.lvm.lv=rhel_ibm-z-68/root rd.lvm.lv=rhel_ibm-z-68/swap rd.znet=qeth,0.0.8000,0.0.8001,0.0.8002,layer2=1,portname=z-68,portno=0 LANG=en_US.UTF-8"
+[linux-0-rescue-196fd0394b7442a6838686745f03fd04]
+ image=/boot/vmlinuz-0-rescue-196fd0394b7442a6838686745f03fd04
+ ramdisk=/boot/initramfs-0-rescue-196fd0394b7442a6838686745f03fd04.img
+ parameters="root=/dev/mapper/rhel_ibm--z--68-root crashkernel=auto rd.dasd=0.0.0120 rd.dasd=0.0.0121 rd.dasd=0.0.0122 rd.dasd=0.0.0123 rd.lvm.lv=rhel_ibm-z-68/root rd.lvm.lv=rhel_ibm-z-68/swap rd.znet=qeth,0.0.8000,0.0.8001,0.0.8002,layer2=1,portname=z-68,portno=0"
--
2.17.1

View File

@ -0,0 +1,59 @@
From 8d81aeffcb1c2f9706dfe625a2f9f5e61f8a5c63 Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Tue, 14 Mar 2017 15:20:53 -0400
Subject: [PATCH 42/55] Fix --info for s390x/s390 (#1285601)
The --info flag for grubby on s390/s390x always returned (null). Fixed
codepath to use extractTitle where necessary and get the actual title.
Related: rhbz#1285601
---
grubby.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/grubby.c b/grubby.c
index 974b81c7864..9bf051dfed4 100644
--- a/grubby.c
+++ b/grubby.c
@@ -2684,7 +2684,7 @@ void setFallbackImage(struct grubConfig *config, int hasNew)
}
}
-void displayEntry(struct singleEntry *entry, const char *prefix, int index)
+void displayEntry(struct grubConfig *config, struct singleEntry *entry, const char *prefix, int index)
{
struct singleLine *line;
char *root = NULL;
@@ -2780,7 +2780,14 @@ void displayEntry(struct singleEntry *entry, const char *prefix, int index)
line = getLineByType(LT_TITLE, entry->lines);
if (line) {
- printf("title=%s\n", line->elements[1].item);
+ char *entryTitle;
+ /* if we can extractTitle, then it's a zipl config and
+ * if not then we go ahead with what's existed prior */
+ entryTitle = extractTitle(config, line);
+ if (!entryTitle) {
+ entryTitle=line->elements[1].item;
+ }
+ printf("title=%s\n", entryTitle);
} else {
char *title;
line = getLineByType(LT_MENUENTRY, entry->lines);
@@ -3196,11 +3203,11 @@ int displayInfo(struct grubConfig *config, char *kernel, const char *prefix)
printf("lba\n");
}
- displayEntry(entry, prefix, i);
+ displayEntry(config, entry, prefix, i);
i++;
while ((entry = findEntryByPath(config, kernel, prefix, &i))) {
- displayEntry(entry, prefix, i);
+ displayEntry(config, entry, prefix, i);
i++;
}
--
2.17.1

View File

@ -0,0 +1,59 @@
From 6d2322507be50c828c400a6de0cd48bf30dfa1b1 Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Tue, 14 Mar 2017 22:39:20 -0400
Subject: [PATCH 43/55] Add s390/s390x set-default-index test (#1285601)
Adds a test to ensure set-default-index actually works for s390 and
s390x platforms.
Related: rhbz#1285601
---
test.sh | 2 ++
test/results/default/z2.1 | 22 ++++++++++++++++++++++
2 files changed, 24 insertions(+)
create mode 100644 test/results/default/z2.1
diff --git a/test.sh b/test.sh
index afa4f705b2b..aaa6e9323a6 100755
--- a/test.sh
+++ b/test.sh
@@ -314,6 +314,8 @@ liloDisplayTest lilo.1 defaultkernel/l1.1 --default-kernel
testing="Z/IPL default directive"
ziplTest zipl.1 default/z1.1 --add-kernel /boot/new-kernel --title test
ziplTest zipl.1 default/z1.2 --add-kernel /boot/new-kernel --title test --make-default
+testing="Z/IPL default index directive"
+ziplTest zipl.2 default/z2.1 --set-default-index=0
testing="Z/IPL display default index"
ziplDisplayTest zipl.1 defaultindex/0 --default-index
testing="Z/IPL display default title"
diff --git a/test/results/default/z2.1 b/test/results/default/z2.1
new file mode 100644
index 00000000000..93e7491e00a
--- /dev/null
+++ b/test/results/default/z2.1
@@ -0,0 +1,22 @@
+[defaultboot]
+defaultauto
+prompt=1
+timeout=5
+default=3.10.0-514.6.2.el7.s390x
+target=/boot
+[3.10.0-514.6.2.el7.s390x]
+ image=/boot/vmlinuz-3.10.0-514.6.2.el7.s390x
+ parameters="root=/dev/mapper/rhel_ibm--z--68-root crashkernel=auto rd.dasd=0.0.0120 rd.dasd=0.0.0121 rd.dasd=0.0.0122 rd.dasd=0.0.0123 rd.lvm.lv=rhel_ibm-z-68/root rd.lvm.lv=rhel_ibm-z-68/swap rd.znet=qeth,0.0.8000,0.0.8001,0.0.8002,layer2=1,portname=z-68,portno=0 LANG=en_US.UTF-8"
+ ramdisk=/boot/initramfs-3.10.0-514.6.2.el7.s390x.img
+[3.10.0-514.6.2.el7.s390x_with_debugging]
+ image=/boot/vmlinuz-3.10.0-514.6.2.el7.s390x
+ parameters="root=/dev/mapper/rhel_ibm--z--68-root crashkernel=auto rd.dasd=0.0.0120 rd.dasd=0.0.0121 rd.dasd=0.0.0122 rd.dasd=0.0.0123 rd.lvm.lv=rhel_ibm-z-68/root rd.lvm.lv=rhel_ibm-z-68/swap rd.znet=qeth,0.0.8000,0.0.8001,0.0.8002,layer2=1,portname=z-68,portno=0 LANG=en_US.UTF-8 systemd.log_level=debug systemd.log_target=kmsg"
+ ramdisk=/boot/initramfs-3.10.0-514.6.2.el7.s390x.img
+[linux]
+ image=/boot/vmlinuz-3.10.0-514.el7.s390x
+ ramdisk=/boot/initramfs-3.10.0-514.el7.s390x.img
+ parameters="root=/dev/mapper/rhel_ibm--z--68-root crashkernel=auto rd.dasd=0.0.0120 rd.dasd=0.0.0121 rd.dasd=0.0.0122 rd.dasd=0.0.0123 rd.lvm.lv=rhel_ibm-z-68/root rd.lvm.lv=rhel_ibm-z-68/swap rd.znet=qeth,0.0.8000,0.0.8001,0.0.8002,layer2=1,portname=z-68,portno=0 LANG=en_US.UTF-8"
+[linux-0-rescue-196fd0394b7442a6838686745f03fd04]
+ image=/boot/vmlinuz-0-rescue-196fd0394b7442a6838686745f03fd04
+ ramdisk=/boot/initramfs-0-rescue-196fd0394b7442a6838686745f03fd04.img
+ parameters="root=/dev/mapper/rhel_ibm--z--68-root crashkernel=auto rd.dasd=0.0.0120 rd.dasd=0.0.0121 rd.dasd=0.0.0122 rd.dasd=0.0.0123 rd.lvm.lv=rhel_ibm-z-68/root rd.lvm.lv=rhel_ibm-z-68/swap rd.znet=qeth,0.0.8000,0.0.8001,0.0.8002,layer2=1,portname=z-68,portno=0"
--
2.17.1

View File

@ -0,0 +1,32 @@
From 9b6266cdec60130435e9ba61af855e370ec31f1a Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Tue, 14 Mar 2017 22:25:02 -0400
Subject: [PATCH 44/55] Fix setDefaultImage for s390/s390x (#1285601)
The setDefaultImage routine has never actually supported s390/s390x when
picking an arbitrary index because a zipl config never has the property
defaultIsIndex set to 1. Eliminating the extraneous check resolved the
issue on s390/s390x and does not appear to break other platforms.
Related: rhbz#1285601
---
grubby.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/grubby.c b/grubby.c
index 9bf051dfed4..5202485a541 100644
--- a/grubby.c
+++ b/grubby.c
@@ -2535,8 +2535,7 @@ void setDefaultImage(struct grubConfig *config, int isAddingBootEntry,
}
/* Case 2: user picked an arbitrary index as the default boot entry */
- if (newDefaultBootEntryIndex >= FIRST_ENTRY_INDEX
- && config->cfi->defaultIsIndex) {
+ if (newDefaultBootEntryIndex >= FIRST_ENTRY_INDEX) {
indexToVerify = newDefaultBootEntryIndex;
/* user chose to make latest boot entry the default */
--
2.17.1

View File

@ -0,0 +1,78 @@
From 7d48cb09b85b81f707565db6d35b1ba0d247b6b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@fedoraproject.org>
Date: Fri, 23 Jun 2017 23:56:50 +0200
Subject: [PATCH 45/55] Be more thorough about flushing our config file when
writing.
Add missing fclose() at the end of writeConfig
Use fflush(out) + fsync(fileno(out) on temporary file
fsync() the destination directory after rename
---
grubby.c | 41 ++++++++++++++++++++++++++++++++++-------
1 file changed, 34 insertions(+), 7 deletions(-)
diff --git a/grubby.c b/grubby.c
index 5202485a541..11ee64a02b9 100644
--- a/grubby.c
+++ b/grubby.c
@@ -1789,6 +1789,7 @@ static int writeConfig(struct grubConfig *cfg, char *outName,
int needs = MAIN_DEFAULT;
struct stat sb;
int i;
+ int rc = 0;
if (!strcmp(outName, "-")) {
out = stdout;
@@ -1903,16 +1904,42 @@ static int writeConfig(struct grubConfig *cfg, char *outName,
}
if (tmpOutName) {
- if (rename(tmpOutName, outName)) {
+ /* write userspace buffers */
+ if (fflush(out))
+ rc = 1;
+
+ /* purge the write-back cache with fsync() */
+ if (fsync(fileno(out)))
+ rc = 1;
+
+ if (fclose(out))
+ rc = 1;
+
+ if (rc == 0 && rename(tmpOutName, outName)) {
+ unlink(tmpOutName);
+ rc = 1;
+ }
+
+ /* fsync() the destination directory after rename */
+ if (rc == 0) {
+ int dirfd;
+
+ dirfd = open(dirname(strdupa(outName)), O_RDONLY);
+ if (dirfd < 0)
+ rc = 1;
+ else if (fsync(dirfd))
+ rc = 1;
+
+ if (dirfd >= 0)
+ close(dirfd);
+ }
+
+ if (rc == 1)
fprintf(stderr,
- _("grubby: error moving %s to %s: %s\n"),
- tmpOutName, outName, strerror(errno));
- unlink(outName);
- return 1;
- }
+ _("grubby: error flushing data: %m\n"));
}
- return 0;
+ return rc;
}
static int numEntries(struct grubConfig *cfg)
--
2.17.1

View File

@ -0,0 +1,168 @@
From 92d22c7cb9a100a601b9a28cb78b8fbde9dac9a8 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 27 Sep 2017 11:28:00 -0400
Subject: [PATCH 46/55] Fix incorrect test case and --remove-args with a value.
Currently we have this test case:
grubTest grub.3 updargs/g3.4 --update-kernel=ALL --remove-args="hdd=foobar"
This fails to notice that the actual argument in grub.3 is hdd=ide-scsi,
and removes it anyway, and the data in g3.4 supports that behavior.
This is clearly wrong, and so this patch introduces updargs/g3.5, which
leaves hdd=ide-scsi intact, and fixes the code so that it won't modify
the command line in that case.
Resolves: rhbz#1476273
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grubby.c | 71 ++++++++++++++++++++++++++++++++-------
test.sh | 2 +-
test/results/updargs/g3.5 | 16 +++++++++
3 files changed, 76 insertions(+), 13 deletions(-)
create mode 100644 test/results/updargs/g3.5
diff --git a/grubby.c b/grubby.c
index 11ee64a02b9..9af04dea01b 100644
--- a/grubby.c
+++ b/grubby.c
@@ -3563,23 +3563,67 @@ static void removeElement(struct singleLine *line, int removeHere)
line->numElements--;
}
-int argMatch(const char *one, const char *two)
+static int argNameMatch(const char *one, const char *two)
{
char *first, *second;
+ char *chptra, *chptrb;
+ int rc;
+
+ first = strcpy(alloca(strlen(one) + 1), one);
+ second = strcpy(alloca(strlen(two) + 1), two);
+
+ chptra = strchr(first, '=');
+ if (chptra)
+ *chptra = '\0';
+
+ chptrb = strchr(second, '=');
+ if (chptrb)
+ *chptrb = '\0';
+
+ rc = strcmp(first, second);
+
+ if (chptra)
+ *chptra = '=';
+ if (chptrb)
+ *chptrb = '=';
+
+ return rc;
+}
+
+static int argHasValue(const char *arg)
+{
char *chptr;
+ chptr = strchr(arg, '=');
+ if (chptr)
+ return 1;
+ return 0;
+}
+
+static int argValueMatch(const char *one, const char *two)
+{
+ char *first, *second;
+ char *chptra, *chptrb;
+
first = strcpy(alloca(strlen(one) + 1), one);
second = strcpy(alloca(strlen(two) + 1), two);
- chptr = strchr(first, '=');
- if (chptr)
- *chptr = '\0';
+ chptra = strchr(first, '=');
+ if (chptra)
+ chptra += 1;
- chptr = strchr(second, '=');
- if (chptr)
- *chptr = '\0';
+ chptrb = strchr(second, '=');
+ if (chptrb)
+ chptrb += 1;
- return strcmp(first, second);
+ if (!chptra && !chptrb)
+ return 0;
+ else if (!chptra)
+ return *chptrb - 0;
+ else if (!chptrb)
+ return 0 - *chptra;
+ else
+ return strcmp(chptra, chptrb);
}
int updateActualImage(struct grubConfig *cfg, const char *image,
@@ -3723,7 +3767,7 @@ int updateActualImage(struct grubConfig *cfg, const char *image,
}
if (usedElements[i])
continue;
- if (!argMatch(line->elements[i].item, *arg)) {
+ if (!argNameMatch(line->elements[i].item, *arg)) {
usedElements[i] = 1;
break;
}
@@ -3782,9 +3826,12 @@ int updateActualImage(struct grubConfig *cfg, const char *image,
!strcmp(line->elements[i].item, "--"))
/* reached the end of hyper args, stop here */
break;
- if (!argMatch(line->elements[i].item, *arg)) {
- removeElement(line, i);
- break;
+ if (!argNameMatch(line->elements[i].item, *arg)) {
+ if (!argHasValue(*arg) ||
+ !argValueMatch(line->elements[i].item, *arg)) {
+ removeElement(line, i);
+ break;
+ }
}
}
/* handle removing LT_ROOT line too */
diff --git a/test.sh b/test.sh
index aaa6e9323a6..a97ada94d22 100755
--- a/test.sh
+++ b/test.sh
@@ -386,7 +386,7 @@ grubTest grub.3 updargs/g3.2 --update-kernel=DEFAULT \
--args "root=/dev/hdd1 hdd=notide-scsi"
grubTest grub.3 updargs/g3.4 --update-kernel=ALL --remove-args="hdd"
grubTest grub.3 updargs/g3.4 --update-kernel=ALL --remove-args="hdd=ide-scsi"
-grubTest grub.3 updargs/g3.4 --update-kernel=ALL --remove-args="hdd=foobar"
+grubTest grub.3 updargs/g3.5 --update-kernel=ALL --remove-args="hdd=foobar"
grubTest grub.3 updargs/g3.7 --update-kernel=ALL \
--remove-args="hdd root ro"
grubTest grub.7 updargs/g7.2 --boot-filesystem=/ \
diff --git a/test/results/updargs/g3.5 b/test/results/updargs/g3.5
new file mode 100644
index 00000000000..7d50bb87d84
--- /dev/null
+++ b/test/results/updargs/g3.5
@@ -0,0 +1,16 @@
+#boot=/dev/hda
+timeout=10
+splashimage=(hd0,1)/grub/splash.xpm.gz
+title Red Hat Linux (2.4.7-2smp)
+ root (hd0,1)
+ kernel /vmlinuz-2.4.7-2smp ro root=/dev/hda5 hdd=ide-scsi
+ initrd /initrd-2.4.7-2smp.img
+title Red Hat Linux-up (2.4.7-2)
+ root (hd0,1)
+ kernel /vmlinuz-2.4.7-2 ro root=/dev/hda5 hdd=ide-scsi
+ initrd /initrd-2.4.7-2.img
+title DOS
+ rootnoverify (hd0,0)
+ chainloader +1
+
+
--
2.17.1

View File

@ -0,0 +1,59 @@
From 19b47a3eab1b4fc490e007caaa9597595f15f496 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 31 Jan 2018 13:06:48 -0500
Subject: [PATCH 47/55] grubby: Make sure configure$BOOTLOADER variables are
set correctly.
When we've chosen a bootloader because it's default for a platform, and
we've already determined it's not overridden by the command line, set
the configure$BOOTLOADER variable to 1 so that our checks for which
bootloader are selected work correctly.
Resolves: rhbz#1340893
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grubby.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/grubby.c b/grubby.c
index 9af04dea01b..c1b4104892c 100644
--- a/grubby.c
+++ b/grubby.c
@@ -5151,22 +5151,27 @@ int main(int argc, const char **argv)
if (!cfi) {
if (grub2FindConfig(&grub2ConfigType)) {
cfi = &grub2ConfigType;
+ configureGrub2 = 1;
if (envPath)
cfi->envFile = envPath;
- } else
+ } else {
#ifdef __ia64__
cfi = &eliloConfigType;
-#elif __powerpc__
+ configureLilo = 1;
+#elif defined(__powerpc__)
cfi = &yabootConfigType;
-#elif __sparc__
+ configureYaboot = 1;
+#elif defined(__sparc__)
cfi = &siloConfigType;
-#elif __s390__
+ configureSilo = 1;
+#elif defined(__s390__) || defined(__s390x__)
cfi = &ziplConfigType;
-#elif __s390x__
- cfi = &ziplConfigtype;
+ configureZipl = 1;
#else
cfi = &grubConfigType;
+ configureGrub = 1;
#endif
+ }
}
if (!grubConfig) {
--
2.17.1

View File

@ -0,0 +1,237 @@
From 7a09f286922ab14df7a07e50d81e197bedd6d20d Mon Sep 17 00:00:00 2001
From: Dennis Gilmore <dennis@ausil.us>
Date: Wed, 30 Aug 2017 14:03:45 -0500
Subject: [PATCH 48/55] remove the old crufty u-boot support
Fedora has only supported extlinux.conf for a few releases now
as a result it should be the only way we boot systems. Remove
the no longer needed uboot file
Signed-off-by: Dennis Gilmore <dennis@ausil.us>
---
new-kernel-pkg | 116 -------------------------------------------------
uboot | 43 ------------------
2 files changed, 159 deletions(-)
delete mode 100644 uboot
diff --git a/new-kernel-pkg b/new-kernel-pkg
index 64225deb06b..0fe6caab51a 100755
--- a/new-kernel-pkg
+++ b/new-kernel-pkg
@@ -37,7 +37,6 @@ else
fi
[ -f /etc/sysconfig/kernel ] && . /etc/sysconfig/kernel
-[ -f /etc/sysconfig/uboot ] && . /etc/sysconfig/uboot
cfgGrub2=""
cfgGrub2Efi=""
@@ -50,7 +49,6 @@ grubConfig=""
grub2Config=""
grub2EfiConfig=""
extlinuxConfig=""
-ubootScript="/boot/boot.scr"
ARCH=$(uname -m)
@@ -84,13 +82,6 @@ elif [[ ${ARCH} =~ armv[5|7].*l ]] ; then
liloConfig=""
bootPrefix=/boot
extlinuxConfig=$(readlink -f /etc/extlinux.conf 2>/dev/null)
- ubootDir=${UBOOT_DIR:-"/boot"}
- ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"}
- ubootKList=${UBOOT_KLIST:-"klist.txt"}
- ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"}
- ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"}
- ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"}
- ubootAddress=${UBOOT_IMGADDR:-"0x00008000"}
mounted=""
liloFlag=""
isx86=""
@@ -386,53 +377,6 @@ remove() {
[ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby"
fi
- if [ -n "$cfguBoot" ]; then
- [ -n "$verbose" ] && echo "removing $version from $ubootDir..."
-
- if [ -f $ubootDir/$ubootKList ]; then
- tmpKList=`mktemp $ubootDir/$ubootKList.XXXX`
- curversion=`tail -n1 $ubootDir/$ubootKList`
- sed "/$version$/d" $ubootDir/$ubootKList > $tmpKList
- newversion=`tail -n1 $tmpKList`
- if [ -f $ubootDir/uImage-$newversion ] && [ -f $ubootDir/uInitrd-$newversion ]; then
- if [ "$curversion" != "$newversion" ]; then
- cp -fp $ubootDir/uImage-$newversion $ubootDir/${ubootDefaultImage}
- if [ $? -ne 0 ]; then
- [ -n "$verbose" ] && echo "copy uImage-$newversion error, default kernel not replaced!" && exit
- fi
- cp -fp $ubootDir/uInitrd-$newversion $ubootDir/${ubootDefaultInitrd}
- if [ $? -ne 0 ]; then
- [ -n "$verbose" ] && echo "copy uInitrd-$newversion error, default Initrd not replaced!" && exit
- fi
- fi
-
- [ -n "$verbose" ] && echo "removing uImage-$version"
- if [ -f $ubootDir/uImage-$version ]; then
- rm -f $ubootDir/uImage-$version
- else
- [ -n "$verbose" ] && echo "uImage-$version did not exist!"
- fi
-
- [ -n "$verbose" ] && echo "removing uInitrd-$version"
- if [ -f $ubootDir/uInitrd-$version ]; then
- rm -f $ubootDir/uInitrd-$version
- else
- [ -n "$verbose" ] && echo "uInitrd-$version did not exist!"
- fi
-
- mv $tmpKList $ubootDir/$ubootKList
- [ -x /sbin/a-b-c ] && /sbin/a-b-c
- else
- [ -n "$verbose" ] && echo "uImage $newversion does not exist!"
- [ -f $tmpKList ] && rm -f $tmpKList
- fi
- else
- [ -n "$verbose" ] && echo "No previous kernel version. U-Boot images not removed!"
- fi
- else
- [ -n "$verbose" ] && echo "$ubootScript does not exist, not modifying $ubootDir"
- fi
-
if [ -n "$cfgExtlinux" ]; then
[ -n "$verbose" ] && echo "removing $version from $extlinuxConfig"
$grubby --extlinux -c $extlinuxConfig \
@@ -534,36 +478,6 @@ update() {
[ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby"
fi
- if [ -n "$cfguBoot" ]; then
- [ -n "$verbose" ] && echo "adding $version to $ubootDir..."
-
- [ -n "$verbose" ] && echo "creating uImage-$version"
- mkimage -A arm -O linux -T kernel -C none -a $ubootAddress \
- -e $ubootAddress -n $version \
- -d $kernelImage $ubootDir/uImage-$version
-
- [ -n "$verbose" ] && echo "creating uInitrd-$version"
- mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \
- -n initramfs -d $initrdfile $ubootDir/uInitrd-$version
-
- if [ -f $ubootDir/uImage-$version ] && [ -f $ubootDir/uInitrd-$version ]; then
- cp -fp $ubootDir/uImage-$version $ubootDir/${ubootDefaultImage}
- if [ $? -ne 0 ]; then
- [ -n "$verbose" ] && echo "copy uImage-$version error, kernel not installed!" && exit
- fi
- cp -fp $ubootDir/uInitrd-$version $ubootDir/${ubootDefaultInitrd}
- if [ $? -ne 0 ]; then
- [ -n "$verbose" ] && echo "copy uInitrd-$version error, kernel not installed!" && exit
- fi
- echo $version >> $ubootDir/$ubootKList
- [ -x /sbin/a-b-c ] && /sbin/a-b-c
- else
- [ -n "$verbose" ] && echo "cannot make $version the default"
- fi
- else
- [ -n "$verbose" ] && echo "$ubootScript does not exist, not setting up $ubootDir"
- fi
-
if [ -n "$cfgExtlinux" ]; then
[ -n "$verbose" ] && echo "updating $version from $extlinuxConfig"
ARGS="--extlinux -c $extlinuxConfig --update-kernel=$kernelImage \
@@ -874,33 +788,6 @@ fi
[ -n "$liloConfig" ] && [ -f "$liloConfig" ] && cfgLilo=1;
[ -n "$extlinuxConfig" ] && [ -f "$extlinuxConfig" ] && cfgExtlinux=1;
-# if we have a U-Boot directory, but no boot script, check if the directory
-# is mounted. If not, mount it, and then check if a boot script exists.
-if [ -n "$ubootDir" ]; then
- if [ -f "$ubootScript" ]; then
- cfguBoot=1
- else
- mountEntry=`mount | grep $ubootDir`
- if [ -z "$mountEntry" ]; then
- mount $ubootDevice $ubootDir
- mounted=1
- fi
- [ -f "$ubootScript" ] && cfguBoot=1;
- fi
-fi
-
-# if we're using U-Boot, check if the default load address should change
-if [ -n "$cfguBoot" -a -z "$UBOOT_IMGADDR" ]; then
- [[ $version =~ .([^.]*)$ ]]
- platform=${BASH_REMATCH[1]}
- # A few platforms use an alternate kernel load address
- if [ "$platform" = "omap" ]; then
- ubootAddress=0x80008000
- elif [ "$platform" = "imx" ]; then
- ubootAddress=0x90008000
- fi
-fi
-
# if we have a lilo config on an x86 box, see if the default boot loader
# is lilo to determine if it should be run
if [ -n "$cfgLilo" -a -n "$isx86" ]; then
@@ -917,9 +804,6 @@ elif [ "$mode" == "--rpmposttrans" ]; then
rpmposttrans
fi
-# if we mounted the U-Boot directory, unmount it.
-[ -n "$mounted" ] && umount $ubootDir
-
# make sure changes make it to the disk.
# if /boot is a mountpoint, force the meta data on disk
# to by-pass writeback delay.
diff --git a/uboot b/uboot
deleted file mode 100644
index 07d8671822f..00000000000
--- a/uboot
+++ /dev/null
@@ -1,43 +0,0 @@
-# Settings for uBoot setup in /sbin/new-kernel-pkg
-#
-# Default values are provided below (as comments)
-#
-# WARNING: These values affect where grubby installs and removes
-# uBoot kernel images. Changing these _after_ kernels have
-# been installed may cause removing a kernel image to fail.
-
-# directory where uBoot images and scripts are found
-#UBOOT_DIR=/boot
-
-# Override the load address when running mkimage on the kernel.
-# OMAP such as Beagleboard and Pandaboard: Use 0x80008000
-# Tegra such as Trimslice: Use 0x00008000
-# IMX such as Efika mx51 smarttop: Use 0x90008000
-# Kirkwood such as Dreamplug, Guruplug, Sheevaplug: Use 0x00008000
-# If left undefined grubby will use defults for Tegra or OMAP depending
-# upon the contents of /proc/cpuinfo.
-#UBOOT_IMGADDR=0x0x00008000
-
-# name of the text file containing the list of installed kernel versions
-# NOTE: The versions are in order of installation. The last entry should
-# always be the default boot kernel version.
-#UBOOT_KLIST=klist.txt
-
-# device partition where uBoot images reside; mounted on $UBOOT_DIR
-#UBOOT_DEVICE=mmcblk0p1
-
-
-# NOTE: Both of the following files are automatically overwritte
-# when a kernel package is installed or removed.
-
-# default kernel uImage file name
-#UBOOT_UIMAGE=uImage
-
-# default initrd uInitrd file name
-#UBOOT_UINITRD=uInitrd
-
-# defualt for platform shipping an onboard dtb.
-#SHIPSDTB=no
-
-# option to tell new-kernel-pkg a specific dtb file to load in extlinux.conf
-#dtbfile=foo.dtb
--
2.17.1

View File

@ -0,0 +1,148 @@
From bd789c1aa159fb4992904e7c529789d7defbe332 Mon Sep 17 00:00:00 2001
From: Nathaniel McCallum <npmccallum@redhat.com>
Date: Fri, 2 Mar 2018 14:59:32 -0500
Subject: [PATCH 49/55] Change return type in getRootSpecifier()
Rather than returning a new allocation of the prefix, just return the
length of the prefix. This change accomplishes a couple things. First,
it reduces some memory leaks since the return value was often never
freed. Second, it simplifies the caller who is usually only interested
in the length of the prefix.
---
grubby.c | 57 ++++++++++++++++++++++++++------------------------------
1 file changed, 26 insertions(+), 31 deletions(-)
diff --git a/grubby.c b/grubby.c
index c1b4104892c..1fe850a3ddf 100644
--- a/grubby.c
+++ b/grubby.c
@@ -698,7 +698,7 @@ static int lineWrite(FILE * out, struct singleLine *line,
struct configFileInfo *cfi);
static int getNextLine(char **bufPtr, struct singleLine *line,
struct configFileInfo *cfi);
-static char *getRootSpecifier(char *str);
+static size_t getRootSpecifier(const char *str);
static void requote(struct singleLine *line, struct configFileInfo *cfi);
static void insertElement(struct singleLine *line,
const char *item, int insertHere,
@@ -2122,7 +2122,7 @@ int suitableImage(struct singleEntry *entry, const char *bootPrefix,
char *fullName;
int i;
char *dev;
- char *rootspec;
+ size_t rs;
char *rootdev;
if (skipRemoved && entry->skip) {
@@ -2150,12 +2150,11 @@ int suitableImage(struct singleEntry *entry, const char *bootPrefix,
fullName = alloca(strlen(bootPrefix) +
strlen(line->elements[1].item) + 1);
- rootspec = getRootSpecifier(line->elements[1].item);
- int rootspec_offset = rootspec ? strlen(rootspec) : 0;
+ rs = getRootSpecifier(line->elements[1].item);
int hasslash = endswith(bootPrefix, '/') ||
- beginswith(line->elements[1].item + rootspec_offset, '/');
+ beginswith(line->elements[1].item + rs, '/');
sprintf(fullName, "%s%s%s", bootPrefix, hasslash ? "" : "/",
- line->elements[1].item + rootspec_offset);
+ line->elements[1].item + rs);
if (access(fullName, R_OK)) {
notSuitablePrintf(entry, 0, "access to %s failed\n", fullName);
return 0;
@@ -2247,7 +2246,6 @@ struct singleEntry *findEntryByPath(struct grubConfig *config,
struct singleLine *line;
int i;
char *chptr;
- char *rootspec = NULL;
enum lineType_e checkType = LT_KERNEL;
if (isdigit(*kernel)) {
@@ -2352,14 +2350,10 @@ struct singleEntry *findEntryByPath(struct grubConfig *config,
if (line && line->type != LT_MENUENTRY &&
line->numElements >= 2) {
- rootspec =
- getRootSpecifier(line->elements[1].
- item);
- if (!strcmp
- (line->elements[1].item +
- ((rootspec !=
- NULL) ? strlen(rootspec) : 0),
- kernel + strlen(prefix)))
+ if (!strcmp(line->elements[1].item +
+ getRootSpecifier(
+ line->elements[1].item),
+ kernel + strlen(prefix)))
break;
}
if (line->type == LT_MENUENTRY &&
@@ -3268,12 +3262,12 @@ struct singleLine *addLineTmpl(struct singleEntry *entry,
type & (LT_HYPER | LT_KERNEL | LT_MBMODULE | LT_INITRD |
LT_KERNEL_EFI | LT_INITRD_EFI | LT_KERNEL_16 |
LT_INITRD_16)) {
- char *rootspec =
- getRootSpecifier(tmplLine->elements[1].item);
- if (rootspec != NULL) {
+ size_t rs = getRootSpecifier(tmplLine->elements[1].item);
+ if (rs > 0) {
free(newLine->elements[1].item);
- newLine->elements[1].item =
- sdupprintf("%s%s", rootspec, val);
+ newLine->elements[1].item = sdupprintf(
+ "%.*s%s", (int) rs,
+ tmplLine->elements[1].item, val);
}
}
}
@@ -4325,17 +4319,19 @@ int checkForElilo(struct grubConfig *config)
return 1;
}
-static char *getRootSpecifier(char *str)
+static size_t getRootSpecifier(const char *str)
{
- char *idx, *rootspec = NULL;
+ size_t rs = 0;
if (*str == '(') {
- idx = rootspec = strdup(str);
- while (*idx && (*idx != ')') && (!isspace(*idx)))
- idx++;
- *(++idx) = '\0';
+ for (; str[rs] != ')' && !isspace(str[rs]); rs++) {
+ if (!str[rs])
+ return rs;
+ }
+ rs++;
}
- return rootspec;
+
+ return rs;
}
static char *getInitrdVal(struct grubConfig *config,
@@ -5365,7 +5361,7 @@ int main(int argc, const char **argv)
if (displayDefault) {
struct singleLine *line;
struct singleEntry *entry;
- char *rootspec;
+ size_t rs;
if (config->defaultImage == NO_DEFAULT_ENTRY)
return 0;
@@ -5384,9 +5380,8 @@ int main(int argc, const char **argv)
if (!line)
return 0;
- rootspec = getRootSpecifier(line->elements[1].item);
- printf("%s%s\n", bootPrefix, line->elements[1].item +
- ((rootspec != NULL) ? strlen(rootspec) : 0));
+ rs = getRootSpecifier(line->elements[1].item);
+ printf("%s%s\n", bootPrefix, line->elements[1].item + rs);
return 0;
--
2.17.1

View File

@ -0,0 +1,208 @@
From 9c6e5cd813d0c064e2805cdb4c6726d32b49d3e1 Mon Sep 17 00:00:00 2001
From: Nathaniel McCallum <npmccallum@redhat.com>
Date: Fri, 2 Mar 2018 08:40:18 -0500
Subject: [PATCH 50/55] Add btrfs subvolume support for grub2
In order to find the subvolume prefix from a given path, we parse
/proc/mounts. In cases where /proc/mounts doesn't contain the
filesystem, the caller can use the --mounts option to specify his own
mounts file.
Btrfs subvolumes are already supported by grub2 and by grub2-mkconfig.
Fixes #22
---
grubby.c | 146 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 142 insertions(+), 4 deletions(-)
diff --git a/grubby.c b/grubby.c
index 1fe850a3ddf..396041a1187 100644
--- a/grubby.c
+++ b/grubby.c
@@ -68,6 +68,8 @@ int isEfi = 0;
char *saved_command_line = NULL;
+const char *mounts = "/proc/mounts";
+
/* comments get lumped in with indention */
struct lineElement {
char *item;
@@ -2115,6 +2117,129 @@ static int endswith(const char *s, char c)
return s[slen] == c;
}
+typedef struct {
+ const char *start;
+ size_t chars;
+} field;
+
+static int iscomma(int c)
+{
+ return c == ',';
+}
+
+static int isequal(int c)
+{
+ return c == '=';
+}
+
+static field findField(const field *in, typeof(isspace) *isdelim, field *out)
+{
+ field nxt = {};
+ size_t off = 0;
+
+ while (off < in->chars && isdelim(in->start[off]))
+ off++;
+
+ if (off == in->chars)
+ return nxt;
+
+ out->start = &in->start[off];
+ out->chars = 0;
+
+ while (off + out->chars < in->chars && !isdelim(out->start[out->chars]))
+ out->chars++;
+
+ nxt.start = out->start + out->chars;
+ nxt.chars = in->chars - off - out->chars;
+ return nxt;
+}
+
+static int fieldEquals(const field *in, const char *str)
+{
+ return in->chars == strlen(str) &&
+ strncmp(in->start, str, in->chars) == 0;
+}
+
+/* Parse /proc/mounts to determine the subvolume prefix. */
+static size_t subvolPrefix(const char *str)
+{
+ FILE *file = NULL;
+ char *line = NULL;
+ size_t prfx = 0;
+ size_t size = 0;
+
+ file = fopen(mounts, "r");
+ if (!file)
+ return 0;
+
+ for (ssize_t s; (s = getline(&line, &size, file)) >= 0; ) {
+ field nxt = { line, s };
+ field dev = {};
+ field path = {};
+ field type = {};
+ field opts = {};
+ field opt = {};
+
+ nxt = findField(&nxt, isspace, &dev);
+ if (!nxt.start)
+ continue;
+
+ nxt = findField(&nxt, isspace, &path);
+ if (!nxt.start)
+ continue;
+
+ nxt = findField(&nxt, isspace, &type);
+ if (!nxt.start)
+ continue;
+
+ nxt = findField(&nxt, isspace, &opts);
+ if (!nxt.start)
+ continue;
+
+ if (!fieldEquals(&type, "btrfs"))
+ continue;
+
+ /* We have found a btrfs mount point. */
+
+ nxt = opts;
+ while ((nxt = findField(&nxt, iscomma, &opt)).start) {
+ field key = {};
+ field val = {};
+
+ opt = findField(&opt, isequal, &key);
+ if (!opt.start)
+ continue;
+
+ opt = findField(&opt, isequal, &val);
+ if (!opt.start)
+ continue;
+
+ if (!fieldEquals(&key, "subvol"))
+ continue;
+
+ /* We have found a btrfs subvolume mount point. */
+
+ if (strncmp(val.start, str, val.chars))
+ continue;
+
+ if (val.start[val.chars - 1] != '/' &&
+ str[val.chars] != '/')
+ continue;
+
+ /* The subvolume mount point matches our input. */
+
+ if (prfx < val.chars)
+ prfx = val.chars;
+ }
+ }
+
+ dbgPrintf("%s(): str: '%s', prfx: '%s'\n", __FUNCTION__, str, prfx);
+
+ fclose(file);
+ free(line);
+ return prfx;
+}
+
int suitableImage(struct singleEntry *entry, const char *bootPrefix,
int skipRemoved, int flags)
{
@@ -3262,12 +3387,22 @@ struct singleLine *addLineTmpl(struct singleEntry *entry,
type & (LT_HYPER | LT_KERNEL | LT_MBMODULE | LT_INITRD |
LT_KERNEL_EFI | LT_INITRD_EFI | LT_KERNEL_16 |
LT_INITRD_16)) {
- size_t rs = getRootSpecifier(tmplLine->elements[1].item);
+ const char *prfx = tmplLine->elements[1].item;
+ size_t rs = getRootSpecifier(prfx);
+ if (isinitrd(tmplLine->type)) {
+ for (struct singleLine *l = entry->lines;
+ rs == 0 && l; l = l->next) {
+ if (iskernel(l->type)) {
+ prfx = l->elements[1].item;
+ rs = getRootSpecifier(prfx);
+ break;
+ }
+ }
+ }
if (rs > 0) {
free(newLine->elements[1].item);
newLine->elements[1].item = sdupprintf(
- "%.*s%s", (int) rs,
- tmplLine->elements[1].item, val);
+ "%.*s%s", (int) rs, prfx, val);
}
}
}
@@ -4331,7 +4466,7 @@ static size_t getRootSpecifier(const char *str)
rs++;
}
- return rs;
+ return rs + subvolPrefix(str + rs);
}
static char *getInitrdVal(struct grubConfig *config,
@@ -4963,6 +5098,9 @@ int main(int argc, const char **argv)
{"mbargs", 0, POPT_ARG_STRING, &newMBKernelArgs, 0,
_("default arguments for the new multiboot kernel or "
"new arguments for multiboot kernel being updated"), NULL},
+ {"mounts", 0, POPT_ARG_STRING, &mounts, 0,
+ _("path to fake /proc/mounts file (for testing only)"),
+ _("mounts")},
{"bad-image-okay", 0, 0, &badImageOkay, 0,
_
("don't sanity check images in boot entries (for testing only)"),
--
2.17.1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,24 @@
From be8c1d611186d1fc35c50d417ba7b43ce25c6054 Mon Sep 17 00:00:00 2001
From: Rafael dos Santos <rdossant@redhat.com>
Date: Tue, 29 May 2018 15:15:24 +0200
Subject: [PATCH 52/55] Use system LDFLAGS
---
Makefile | 1 +
1 file changed, 1 insertion(+)
diff --git a/Makefile b/Makefile
index cc7e823959f..65cd28295aa 100644
--- a/Makefile
+++ b/Makefile
@@ -25,6 +25,7 @@ OBJECTS = grubby.o log.o
CC = gcc
RPM_OPT_FLAGS ?= -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector
CFLAGS += $(RPM_OPT_FLAGS) -std=gnu99 -Wall -Werror -Wno-error=unused-function -Wno-unused-function -ggdb
+LDFLAGS := $(RPM_LD_FLAGS)
LDFLAGS :=
VERBOSE_TEST :=
ifneq ($(VERBOSE_TEST),)
--
2.17.1

View File

@ -0,0 +1,36 @@
From b4d5d14bef6861212f55148bbe6939a41700a54c Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 18 Jul 2018 13:41:02 -0400
Subject: [PATCH 53/55] Honor sbindir
Signed-off-by: Peter Jones <pjones@redhat.com>
---
Makefile | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 65cd28295aa..44fc12f0c1b 100644
--- a/Makefile
+++ b/Makefile
@@ -47,14 +47,14 @@ test: all
@./test.sh $(VERBOSE_TEST)
install: all
- mkdir -p $(DESTDIR)$(PREFIX)/sbin
+ mkdir -p $(DESTDIR)$(PREFIX)$(sbindir)
mkdir -p $(DESTDIR)/$(mandir)/man8
- install -m 755 new-kernel-pkg $(DESTDIR)$(PREFIX)/sbin
+ install -m 755 new-kernel-pkg $(DESTDIR)$(PREFIX)$(sbindir)
install -m 644 new-kernel-pkg.8 $(DESTDIR)/$(mandir)/man8
- install -m 755 installkernel $(DESTDIR)$(PREFIX)/sbin
+ install -m 755 installkernel $(DESTDIR)$(PREFIX)$(sbindir)
install -m 644 installkernel.8 $(DESTDIR)/$(mandir)/man8
if [ -f grubby ]; then \
- install -m 755 grubby $(DESTDIR)$(PREFIX)/sbin ; \
+ install -m 755 grubby $(DESTDIR)$(PREFIX)$(sbindir) ; \
install -m 644 grubby.8 $(DESTDIR)/$(mandir)/man8 ; \
fi
--
2.17.1

View File

@ -0,0 +1,48 @@
From f8482113065878c0ace605fbca296fc7601c47cc Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Tue, 31 Jul 2018 17:43:53 +0200
Subject: [PATCH 54/55] Make installkernel to use kernel-install scripts on BLS
configuration
The kernel make install target executes the arch/$ARCH/boot/install.sh
that in turns executes the distro specific installkernel script. This
script always uses new-kernel-pkg to install the kernel images.
But on a BootLoaderSpec setup, the kernel-install scripts must be used
instead. Check if the system uses a BLS setup, and call kernel-install
add in that case instead of new-kernel-pkg.
Reported-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
installkernel | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/installkernel b/installkernel
index b887929c179..68dcfac16d2 100755
--- a/installkernel
+++ b/installkernel
@@ -20,6 +20,8 @@
# Author(s): tyson@rwii.com
#
+[[ -f /etc/default/grub ]] && . /etc/default/grub
+
usage() {
echo "Usage: `basename $0` <kernel_version> <bootimage> <mapfile>" >&2
exit 1
@@ -77,6 +79,11 @@ cp $MAPFILE $INSTALL_PATH/System.map-$KERNEL_VERSION
ln -fs ${RELATIVE_PATH}$INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION $LINK_PATH/$KERNEL_NAME
ln -fs ${RELATIVE_PATH}$INSTALL_PATH/System.map-$KERNEL_VERSION $LINK_PATH/System.map
+if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ] || [ ! -f /sbin/new-kernel-pkg ]; then
+ kernel-install add $KERNEL_VERSION $INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION
+ exit $?
+fi
+
if [ -n "$cfgLoader" ] && [ -x /sbin/new-kernel-pkg ]; then
if [ -n "$(which dracut 2>/dev/null)" ]; then
new-kernel-pkg --mkinitrd --dracut --host-only --depmod --install --kernel-name $KERNEL_NAME $KERNEL_VERSION
--
2.17.1

View File

@ -0,0 +1,419 @@
From 4e0e028b21070f956b144bd530230d01b9015d73 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 12 Oct 2018 16:39:37 -0400
Subject: [PATCH 55/55] Add /usr/libexec/rpm-sort
Signed-off-by: Peter Jones <pjones@redhat.com>
---
rpm-sort.c | 355 +++++++++++++++++++++++++++++++++++++++++++++++++++++
Makefile | 9 +-
.gitignore | 1 +
3 files changed, 363 insertions(+), 2 deletions(-)
create mode 100644 rpm-sort.c
diff --git a/rpm-sort.c b/rpm-sort.c
new file mode 100644
index 00000000000..f19635645ba
--- /dev/null
+++ b/rpm-sort.c
@@ -0,0 +1,355 @@
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <assert.h>
+#include <argp.h>
+#include <rpm/rpmlib.h>
+#include <err.h>
+
+typedef enum {
+ RPMNVRCMP,
+ VERSNVRCMP,
+ RPMVERCMP,
+ STRVERSCMP,
+} comparitors;
+
+static comparitors comparitor = RPMNVRCMP;
+
+static inline void *xmalloc(size_t sz)
+{
+ void *ret = malloc(sz);
+
+ assert(sz == 0 || ret != NULL);
+ return ret;
+}
+
+static inline void *xrealloc(void *p, size_t sz)
+{
+ void *ret = realloc(p, sz);
+
+ assert(sz == 0 || ret != NULL);
+ return ret;
+}
+
+static inline char *xstrdup(const char * const s)
+{
+ void *ret = strdup(s);
+
+ assert(s == NULL || ret != NULL);
+ return ret;
+}
+
+static size_t
+read_file (const char *input, char **ret)
+{
+ FILE *in;
+ size_t s;
+ size_t sz = 2048;
+ size_t offset = 0;
+ char *text;
+
+ if (!strcmp(input, "-"))
+ in = stdin;
+ else
+ in = fopen(input, "r");
+
+ text = xmalloc (sz);
+
+ if (!in)
+ err(1, "cannot open `%s'", input);
+
+ while ((s = fread (text + offset, 1, sz - offset, in)) != 0)
+ {
+ offset += s;
+ if (sz - offset == 0)
+ {
+ sz += 2048;
+ text = xrealloc (text, sz);
+ }
+ }
+
+ text[offset] = '\0';
+ *ret = text;
+
+ if (in != stdin)
+ fclose(in);
+
+ return offset + 1;
+}
+
+/* returns name/version/release */
+/* NULL string pointer returned if nothing found */
+static void
+split_package_string (char *package_string, char **name,
+ char **version, char **release)
+{
+ char *package_version, *package_release;
+
+ /* Release */
+ package_release = strrchr (package_string, '-');
+
+ if (package_release != NULL)
+ *package_release++ = '\0';
+
+ *release = package_release;
+
+ /* Version */
+ package_version = strrchr(package_string, '-');
+
+ if (package_version != NULL)
+ *package_version++ = '\0';
+
+ *version = package_version;
+ /* Name */
+ *name = package_string;
+
+ /* Bubble up non-null values from release to name */
+ if (*name == NULL)
+ {
+ *name = (*version == NULL ? *release : *version);
+ *version = *release;
+ *release = NULL;
+ }
+ if (*version == NULL)
+ {
+ *version = *release;
+ *release = NULL;
+ }
+}
+
+static int
+cmprpmversp(const void *p1, const void *p2)
+{
+ return rpmvercmp(*(char * const *)p1, *(char * const *)p2);
+}
+
+static int
+cmpstrversp(const void *p1, const void *p2)
+{
+ return strverscmp(*(char * const *)p1, *(char * const *)p2);
+}
+
+/*
+ * package name-version-release comparator for qsort
+ * expects p, q which are pointers to character strings (char *)
+ * which will not be altered in this function
+ */
+static int
+package_version_compare (const void *p, const void *q)
+{
+ char *local_p, *local_q;
+ char *lhs_name, *lhs_version, *lhs_release;
+ char *rhs_name, *rhs_version, *rhs_release;
+ int vercmpflag = 0;
+ int (*cmp)(const char *s1, const char *s2);
+
+ switch(comparitor)
+ {
+ default: /* just to shut up -Werror=maybe-uninitialized */
+ case RPMNVRCMP:
+ cmp = rpmvercmp;
+ break;
+ case VERSNVRCMP:
+ cmp = strverscmp;
+ break;
+ case RPMVERCMP:
+ return cmprpmversp(p, q);
+ break;
+ case STRVERSCMP:
+ return cmpstrversp(p, q);
+ break;
+ }
+
+ local_p = alloca (strlen (*(char * const *)p) + 1);
+ local_q = alloca (strlen (*(char * const *)q) + 1);
+
+ /* make sure these allocated */
+ assert (local_p);
+ assert (local_q);
+
+ strcpy (local_p, *(char * const *)p);
+ strcpy (local_q, *(char * const *)q);
+
+ split_package_string (local_p, &lhs_name, &lhs_version, &lhs_release);
+ split_package_string (local_q, &rhs_name, &rhs_version, &rhs_release);
+
+ /* Check Name and return if unequal */
+ vercmpflag = cmp ((lhs_name == NULL ? "" : lhs_name),
+ (rhs_name == NULL ? "" : rhs_name));
+ if (vercmpflag != 0)
+ return vercmpflag;
+
+ /* Check version and return if unequal */
+ vercmpflag = cmp ((lhs_version == NULL ? "" : lhs_version),
+ (rhs_version == NULL ? "" : rhs_version));
+ if (vercmpflag != 0)
+ return vercmpflag;
+
+ /* Check release and return the version compare value */
+ vercmpflag = cmp ((lhs_release == NULL ? "" : lhs_release),
+ (rhs_release == NULL ? "" : rhs_release));
+
+ return vercmpflag;
+}
+
+static void
+add_input (const char *filename, char ***package_names, size_t *n_package_names)
+{
+ char *orig_input_buffer = NULL;
+ char *input_buffer;
+ char *position_of_newline;
+ char **names = *package_names;
+ char **new_names = NULL;
+ size_t n_names = *n_package_names;
+
+ if (!*package_names)
+ new_names = names = xmalloc (sizeof (char *) * 2);
+
+ if (read_file (filename, &orig_input_buffer) < 2)
+ {
+ if (new_names)
+ free (new_names);
+ if (orig_input_buffer)
+ free (orig_input_buffer);
+ return;
+ }
+
+ input_buffer = orig_input_buffer;
+ while (input_buffer && *input_buffer &&
+ (position_of_newline = strchrnul (input_buffer, '\n')))
+ {
+ size_t sz = position_of_newline - input_buffer;
+ char *new;
+
+ if (sz == 0)
+ {
+ input_buffer = position_of_newline + 1;
+ continue;
+ }
+
+ new = xmalloc (sz+1);
+ strncpy (new, input_buffer, sz);
+ new[sz] = '\0';
+
+ names = xrealloc (names, sizeof (char *) * (n_names + 1));
+ names[n_names] = new;
+ n_names++;
+
+ /* move buffer ahead to next line */
+ input_buffer = position_of_newline + 1;
+ if (*position_of_newline == '\0')
+ input_buffer = NULL;
+ }
+
+ free (orig_input_buffer);
+
+ *package_names = names;
+ *n_package_names = n_names;
+}
+
+static char *
+help_filter (int key, const char *text, void *input __attribute__ ((unused)))
+{
+ return (char *)text;
+}
+
+static struct argp_option options[] = {
+ { "comparitor", 'c', "COMPARITOR", 0, "[rpm-nvr-cmp|vers-nvr-cmp|rpmvercmp|strverscmp]", 0},
+ { 0, }
+};
+
+struct arguments
+{
+ size_t ninputs;
+ size_t input_max;
+ char **inputs;
+};
+
+static error_t
+argp_parser (int key, char *arg, struct argp_state *state)
+{
+ struct arguments *arguments = state->input;
+ switch (key)
+ {
+ case 'c':
+ if (!strcmp(arg, "rpm-nvr-cmp") || !strcmp(arg, "rpmnvrcmp"))
+ comparitor = RPMNVRCMP;
+ else if (!strcmp(arg, "vers-nvr-cmp") || !strcmp(arg, "versnvrcmp"))
+ comparitor = VERSNVRCMP;
+ else if (!strcmp(arg, "rpmvercmp"))
+ comparitor = RPMVERCMP;
+ else if (!strcmp(arg, "strverscmp"))
+ comparitor = STRVERSCMP;
+ else
+ err(1, "Invalid comparitor \"%s\"", arg);
+ break;
+ case ARGP_KEY_ARG:
+ assert (arguments->ninputs < arguments->input_max);
+ arguments->inputs[arguments->ninputs++] = xstrdup (arg);
+ break;
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+ return 0;
+}
+
+static struct argp argp = {
+ options, argp_parser, "[INPUT_FILES]",
+ "Sort a list of strings in RPM version sort order.",
+ NULL, help_filter, NULL
+};
+
+int
+main (int argc, char *argv[])
+{
+ struct arguments arguments;
+ char **package_names = NULL;
+ size_t n_package_names = 0;
+ int i;
+
+ memset (&arguments, 0, sizeof (struct arguments));
+ arguments.input_max = argc+1;
+ arguments.inputs = xmalloc ((arguments.input_max + 1)
+ * sizeof (arguments.inputs[0]));
+ memset (arguments.inputs, 0, (arguments.input_max + 1)
+ * sizeof (arguments.inputs[0]));
+
+ /* Parse our arguments */
+ if (argp_parse (&argp, argc, argv, 0, 0, &arguments) != 0)
+ errx(1, "%s", "Error in parsing command line arguments\n");
+
+ /* If there's no inputs in argv, add one for stdin */
+ if (!arguments.ninputs)
+ {
+ arguments.ninputs = 1;
+ arguments.inputs[0] = xmalloc (2);
+ strcpy(arguments.inputs[0], "-");
+ }
+
+ for (i = 0; i < arguments.ninputs; i++)
+ add_input(arguments.inputs[i], &package_names, &n_package_names);
+
+ if (package_names == NULL || n_package_names < 1)
+ errx(1, "Invalid input");
+
+ qsort (package_names, n_package_names, sizeof (char *),
+ package_version_compare);
+
+ /* send sorted list to stdout */
+ for (i = 0; i < n_package_names; i++)
+ {
+ fprintf (stdout, "%s\n", package_names[i]);
+ free (package_names[i]);
+ }
+
+ free (package_names);
+ for (i = 0; i < arguments.ninputs; i++)
+ free (arguments.inputs[i]);
+
+ free (arguments.inputs);
+
+ return 0;
+}
diff --git a/Makefile b/Makefile
index 44fc12f0c1b..8eeec80da21 100644
--- a/Makefile
+++ b/Makefile
@@ -34,7 +34,7 @@ endif
grubby_LIBS = -lblkid -lpopt
-all: grubby
+all: grubby rpm-sort
debug : clean
$(MAKE) CFLAGS="${CFLAGS} -DDEBUG=1" all
@@ -57,12 +57,17 @@ install: all
install -m 755 grubby $(DESTDIR)$(PREFIX)$(sbindir) ; \
install -m 644 grubby.8 $(DESTDIR)/$(mandir)/man8 ; \
fi
+ install -m 755 -d $(DESTDIR)$(PREFIX)$(libexecdir)/grubby/
+ install -m 755 rpm-sort $(DESTDIR)$(PREFIX)$(libexecdir)/grubby/rpm-sort
grubby:: $(OBJECTS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(grubby_LIBS)
+rpm-sort::rpm-sort.o
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lrpm
+
clean:
- rm -f *.o grubby *~
+ rm -f *.o grubby rpm-sort *~
GITTAG = $(VERSION)-1
diff --git a/.gitignore b/.gitignore
index 1c00ff7c5ed..bcaf1494f61 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
grubby
+rpm-sort
version.h
*.o
core.*
--
2.17.1

View File

@ -0,0 +1,30 @@
From e15806969cbae83a94068d99e4f1d295dab95eac Mon Sep 17 00:00:00 2001
From: Jan Stodola <jstodola@redhat.com>
Date: Tue, 20 Nov 2018 15:02:19 +0100
Subject: [PATCH] Improve man page for --info option
1) commit 941d4a0b removed description of --info DEFAULT
2) Add description of --info ALL
---
grubby.8 | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/grubby.8 b/grubby.8
index 1e8f140c4df..8b98433960c 100644
--- a/grubby.8
+++ b/grubby.8
@@ -185,7 +185,10 @@ Display the title of the current default boot entry and exit.
.TP
\fB-\-info\fR=\fIkernel-path\fR
-Display information on all boot entries which match \fIkernel-path\fR. I
+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-\-bootloader-probe\fR
--
2.19.1

View File

@ -92,7 +92,7 @@ get_bls_values() {
bls="${bls%.conf}" bls="${bls%.conf}"
bls="${bls##*/}" bls="${bls##*/}"
echo "${bls}" echo "${bls}"
done | sort -Vr 2>/dev/null)) || : done | /usr/libexec/grubby/rpm-sort -c rpmnvrcmp 2>/dev/null | tac)) || :
for bls in "${files[@]}" ; do for bls in "${files[@]}" ; do
blspath="${blsdir}/${bls}.conf" blspath="${blsdir}/${bls}.conf"
@ -429,7 +429,7 @@ add_bls_fragment() {
fi fi
if [[ -n $extra_initrd ]]; then if [[ -n $extra_initrd ]]; then
append_bls_value "${bls_target}" "initrd" " ${extra_initrd}" append_bls_value "${bls_target}" "initrd" "${extra_initrd}"
fi fi
if [[ $MAKEDEBUG = "yes" ]]; then if [[ $MAKEDEBUG = "yes" ]]; then
@ -521,6 +521,10 @@ update_bls_fragment() {
if [[ $param != "ALL" || "$(has_kernelopts "$i")" = "false" ]]; then if [[ $param != "ALL" || "$(has_kernelopts "$i")" = "false" ]]; then
set_bls_value "${bls_file[$i]}" "options" "${new_args}" set_bls_value "${bls_file[$i]}" "options" "${new_args}"
fi fi
if [[ $bootloader = grub2 && "$(has_kernelopts "$i")" = "false" && $opts = $new_args ]]; then
set_bls_value "${bls_file[$i]}" "options" "\$kernelopts"
fi
fi fi
if [[ -n $initrd ]]; then if [[ -n $initrd ]]; then
@ -581,7 +585,7 @@ remove_var_prefix() {
fi fi
if [[ -n $extra_initrd ]]; then if [[ -n $extra_initrd ]]; then
extra_initrd="/${extra_initrd##${prefix}/}" extra_initrd=" /${extra_initrd##${prefix}/}"
fi fi
if [[ -n $kernel ]]; then if [[ -n $kernel ]]; then
@ -595,32 +599,7 @@ remove_var_prefix() {
update_grubcfg() update_grubcfg()
{ {
# Older ppc64le OPAL firmware (petitboot version < 1.8.0) don't have BLS support if [[ $arch = 'ppc64' || $arch = 'ppc64le' ]]; then
# so grub2-mkconfig has to be run to generate a config with menuentry commands.
if [ "${arch}" = "ppc64le" ] && [ -d /sys/firmware/opal ]; then
RUN_MKCONFIG="true"
petitboot_path="/sys/firmware/devicetree/base/ibm,firmware-versions/petitboot"
if test -e ${petitboot_path}; then
read -r -d '' petitboot_version < ${petitboot_path}
petitboot_version="$(echo ${petitboot_version//v})"
if test -n ${petitboot_version}; then
major_version="$(echo ${petitboot_version} | cut -d . -f1)"
minor_version="$(echo ${petitboot_version} | cut -d . -f2)"
re='^[0-9]+$'
if [[ $major_version =~ $re ]] && [[ $minor_version =~ $re ]] &&
([[ ${major_version} -gt 1 ]] ||
[[ ${major_version} -eq 1 &&
${minor_version} -ge 8 ]]); then
RUN_MKCONFIG="false"
fi
fi
fi
fi
if [[ $RUN_MKCONFIG = "true" ]]; then
grub2-mkconfig --no-grubenv-update -o "${grub_config}" >& /dev/null grub2-mkconfig --no-grubenv-update -o "${grub_config}" >& /dev/null
fi fi
} }
@ -655,12 +634,12 @@ Usage: grubby [OPTION...]
--no-etc-grub-update don't update the GRUB_CMDLINE_LINUX variable in /etc/default/grub --no-etc-grub-update don't update the GRUB_CMDLINE_LINUX variable in /etc/default/grub
Help options: Help options:
-h, --help Show this help message -?, --help Show this help message
EOF EOF
} }
OPTS="$(getopt -o hc:i:b:? --long help,add-kernel:,args:,bad-image-okay,\ 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:,\ config-file:,copy-default,default-kernel,default-index,default-title,env:,\
grub2,info:,initrd:,extra-initrd:,make-default,remove-args:,\ grub2,info:,initrd:,extra-initrd:,make-default,remove-args:,\
remove-kernel:,set-default:,set-default-index:,title:,update-kernel:,zipl,\ remove-kernel:,set-default:,set-default-index:,title:,update-kernel:,zipl,\
@ -722,7 +701,7 @@ while [ ${#} -gt 0 ]; do
shift shift
;; ;;
--extra-initrd|-i) --extra-initrd|-i)
extra_initrd="${2}" extra_initrd=" /${2}"
shift shift
;; ;;
--make-default) --make-default)

View File

@ -19,10 +19,13 @@ 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 It is primarily designed to be used from scripts which install new kernels and
need to find information about the current boot environment. need to find information about the current boot environment.
On BIOS-based Intel x86, PowerPC and UEFI-based platforms, \fBgrub2\fR is the On BIOS-based Intel x86 platforms, \fBgrub2\fR is the default bootloader and
default bootloader and the configuration file is in \fB/boot/grub2/grub.cfg\fR. the configuration file is in \fB/boot/grub2/grub.cfg\fR. On UEFI-based Intel
On s390x platforms, the \fBzipl\fR bootloader use a default configuration in x86 platforms, \fBgrub2\fR is the default bootloader, and the configuration
\fB/etc/zipl.conf\fR. 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 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 that are stored by default in \fB/boot/loader/entries\fR. The format for the
@ -145,8 +148,7 @@ 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 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 \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, \fB/etc/default/grub\fR is updated with the latest kernel argument list,
unless the \fB-\-no-etc-grub-update\fR option is used or the file does not unless the \fB-\-no-etc-grub-update\fR option is used.
exist (e.g., on s390x).
.TP .TP
\fB-\-zipl\fR \fB-\-zipl\fR

8
SOURCES/grubby.in Normal file
View File

@ -0,0 +1,8 @@
#!/bin/bash
if [[ -x @@LIBEXECDIR@@/grubby-bls ]] ; then
exec @@LIBEXECDIR@@/grubby-bls "${@}"
elif [[ -x @@LIBEXECDIR@@/grubby ]] ; then
exec @@LIBEXECDIR@@/grubby "${@}"
fi
echo "Grubby is not installed correctly." >>/dev/stderr
exit 1

83
SOURCES/installkernel-bls Executable file
View File

@ -0,0 +1,83 @@
#! /bin/sh
#
# /sbin/installkernel
#
# Copyright 2007-2008 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Author(s): tyson@rwii.com
#
usage() {
echo "Usage: `basename $0` <kernel_version> <bootimage> <mapfile>" >&2
exit 1
}
cfgLoader=
if [ -z "$INSTALL_PATH" -o "$INSTALL_PATH" == "/boot" ]; then
INSTALL_PATH=/boot
cfgLoader=1
fi
LINK_PATH=/boot
RELATIVE_PATH=`echo "$INSTALL_PATH/" | sed "s|^$LINK_PATH/||"`
KERNEL_VERSION=$1
BOOTIMAGE=$2
MAPFILE=$3
ARCH=$(uname -m)
if [ $ARCH = 'ppc64' -o $ARCH = 'ppc' ]; then
KERNEL_NAME=vmlinux
else
KERNEL_NAME=vmlinuz
fi
if [ -z "$KERNEL_VERSION" -o -z "$BOOTIMAGE" -o -z "$MAPFILE" ]; then
usage
fi
if [ -f $INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION ]; then
mv $INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION \
$INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION.old;
fi
if [ ! -L $INSTALL_PATH/$KERNEL_NAME ]; then
if [ -e $INSTALLPATH/$KERNEL_NAME ]; then
mv $INSTALL_PATH/$KERNEL_NAME $INSTALL_PATH/$KERNEL_NAME.old
fi
fi
if [ -f $INSTALL_PATH/System.map-$KERNEL_VERSION ]; then
mv $INSTALL_PATH/System.map-$KERNEL_VERSION \
$INSTALL_PATH/System.map-$KERNEL_VERSION.old;
fi
if [ ! -L $INSTALL_PATH/System.map ]; then
if [ -e $INSTALLPATH/System.map ]; then
mv $INSTALL_PATH/System.map $INSTALL_PATH/System.map.old
fi
fi
ln -sf ${RELATIVE_PATH}$INSTALL_PATH/System.map-$KERNEL_VERSION $LINK_PATH/System.map
cat $BOOTIMAGE > $INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION
cp $MAPFILE $INSTALL_PATH/System.map-$KERNEL_VERSION
ln -fs ${RELATIVE_PATH}$INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION $LINK_PATH/$KERNEL_NAME
ln -fs ${RELATIVE_PATH}$INSTALL_PATH/System.map-$KERNEL_VERSION $LINK_PATH/System.map
if [ -n "$cfgLoader" ]; then
kernel-install add $KERNEL_VERSION $INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION
exit $?
fi

8
SOURCES/installkernel.in Normal file
View File

@ -0,0 +1,8 @@
#!/bin/bash
if [[ -x @@LIBEXECDIR@@/installkernel ]] ; then
exec @@LIBEXECDIR@@/installkernel "${@}"
elif [[ -x @@LIBEXECDIR@@/installkernel-bls ]] ; then
exec @@LIBEXECDIR@@/installkernel-bls "${@}"
fi
echo "installkernel is not installed correctly." >>/dev/stderr
exit 1

View File

@ -1,274 +1,269 @@
# What? No.
%define __brp_mangle_shebangs %{nil}
Name: grubby Name: grubby
Version: 8.40 Version: 8.40
Release: 76%{?dist} Release: 49%{?dist}
Summary: Command line tool for updating bootloader configs Summary: Command line tool for updating BootLoaderSpec files
License: GPL-2.0-or-later License: GPLv2+
URL: https://github.com/rhinstaller/grubby
# we only pull git snaps at the moment
# git clone git@github.com:rhinstaller/grubby.git
# git archive --format=tar --prefix=grubby-%%{version}/ HEAD |bzip2 > grubby-%%{version}.tar.bz2
# Source0: %%{name}-%%{version}.tar.bz2
Source0: https://github.com/rhboot/grubby/archive/%{version}-1.tar.gz
Source1: grubby-bls Source1: grubby-bls
# Source2: rpm-sort.c Source2: grubby.in
Source3: COPYING Source3: installkernel.in
Source5: 95-kernel-hooks.install Source4: installkernel-bls
Source6: 10-devicetree.install Source5: grubby.8
Source7: 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
Patch0004: 0004-grubby-properly-handle-mixed-and-and-nested-quotes.patch
Patch0005: 0005-Don-t-put-spaces-in-debug-entries-on-zipl-platforms.patch
Patch0006: 0006-Drop-SEGV-handler.patch
Patch0007: 0007-Add-a-bunch-of-tests-for-various-default-kernel-titl.patch
Patch0008: 0008-Emit-better-systemd-debug-settings-on-debug-entries.patch
Patch0009: 0009-Add-a-new-makefile-target-that-does-everything-neede.patch
Patch0010: 0010-Make-the-grub1-defaultkernel-test-more-reliable.patch
Patch0011: 0011-Don-t-leak-from-one-extractTitle-call.patch
Patch0012: 0012-ppc64le-sync-grub.cfg-changes-to-disk-1212114.patch
Patch0013: 0013-Make-it-possible-to-run-test.sh-verbose-from-the-mak.patch
Patch0014: 0014-Lindent-dammit.patch
Patch0015: 0015-Make-SET_VARIABLE-get-handled-individually-in-GetNex.patch
Patch0016: 0016-Specify-bootloader-directory-in-the-test-case-for-11.patch
Patch0017: 0017-Fix-dracut-cmdline-options-and-conditionalize-them-t.patch
Patch0018: 0018-Add-missing-space.patch
Patch0019: 0019-Always-do-the-rungrubby-debug-after-the-normal-kerne.patch
Patch0020: 0020-grubby-add-set-index-to-specify-which-position-to-ad.patch
Patch0021: 0021-Fix-thinko-on-set-index-naming.patch
Patch0022: 0022-Add-a-test-case-for-a-failure-rmarshall-saw-in-set-i.patch
Patch0023: 0023-Ensure-command-line-updates-also-honor-set-index.patch
Patch0024: 0024-Change-debug-entry-insertion-order-rhbz-1285601.patch
Patch0025: 0025-Reorganize-grubby-man-page-1232168.patch
Patch0026: 0026-Update-grubby-man-page-contents-bz1232168.patch
Patch0027: 0027-Fix-inline-help-typo-1232168.patch
Patch0028: 0028-More-edits-for-grubby.8-1232168.patch
Patch0029: 0029-Minor-man-page-changes-1232168.patch
Patch0030: 0030-Rename-setDefaultImage-variables.patch
Patch0031: 0031-Add-index-constant-definitions-instead-of-open-coded.patch
Patch0032: 0032-Track-configuration-modifications.patch
Patch0033: 0033-Fix-some-test-cases-where-the-resulting-default-inde.patch
Patch0034: 0034-Don-t-assume-make-default-just-because-set-index-was.patch
Patch0035: 0035-Clarify-set-default-index-in-the-man-page.patch
Patch0036: 0036-Add-multi-entry-removal-test-1285601.patch
Patch0037: 0037-Fix-findTemplate-index-logic-1285601.patch
Patch0038: 0038-Write-correct-default-to-environment-1285601.patch
Patch0039: 0039-Initialize-variable-for-ppc-environment-1285601.patch
Patch0040: 0040-Fix-initial-saved_entry-read-issue-1285601.patch
Patch0041: 0041-Add-s390-s390x-info-test-1285601.patch
Patch0042: 0042-Fix-info-for-s390x-s390-1285601.patch
Patch0043: 0043-Add-s390-s390x-set-default-index-test-1285601.patch
Patch0044: 0044-Fix-setDefaultImage-for-s390-s390x-1285601.patch
Patch0045: 0045-Be-more-thorough-about-flushing-our-config-file-when.patch
Patch0046: 0046-Fix-incorrect-test-case-and-remove-args-with-a-value.patch
Patch0047: 0047-grubby-Make-sure-configure-BOOTLOADER-variables-are-.patch
Patch0048: 0048-remove-the-old-crufty-u-boot-support.patch
Patch0049: 0049-Change-return-type-in-getRootSpecifier.patch
Patch0050: 0050-Add-btrfs-subvolume-support-for-grub2.patch
Patch0051: 0051-Add-tests-for-btrfs-support.patch
Patch0052: 0052-Use-system-LDFLAGS.patch
Patch0053: 0053-Honor-sbindir.patch
Patch0054: 0054-Make-installkernel-to-use-kernel-install-scripts-on-.patch
Patch0055: 0055-Add-usr-libexec-rpm-sort.patch
Patch0056: 0056-Improve-man-page-for-info-option.patch
BuildRequires: gcc BuildRequires: gcc
BuildRequires: glib2-devel BuildRequires: pkgconfig glib2-devel popt-devel
BuildRequires: libblkid-devel BuildRequires: libblkid-devel git-core sed make
BuildRequires: make # for make test / getopt:
BuildRequires: pkgconfig BuildRequires: util-linux-ng
BuildRequires: popt-devel
BuildRequires: rpm-devel BuildRequires: rpm-devel
BuildRequires: sed %ifarch aarch64 i686 x86_64 %{power64}
%ifarch aarch64 x86_64 %{power64}
BuildRequires: grub2-tools-minimal BuildRequires: grub2-tools-minimal
Requires: grub2-tools-minimal Requires: grub2-tools-minimal
Requires: grub2-tools Requires: grub2-tools
%endif %endif
%ifarch s390 s390x %ifarch s390 s390x
Requires: s390utils-core Requires: s390utils-base
%endif %endif
Requires: findutils Requires: findutils
Requires: util-linux Requires: util-linux
ExcludeArch: %{ix86}
Conflicts: uboot-tools < 2021.01-0.1.rc2
Obsoletes: %{name}-bls < %{version}-%{release}
Obsoletes: %{name}-deprecated < %{version}-%{release}
%description %description
This package provides a grubby compatibility script that manages This package provides a grubby compatibility script that manages
BootLoaderSpec files and is meant to be backward compatible with BootLoaderSpec files and is meant to only be used for legacy compatibility
the previous grubby tool. users with existing grubby users.
%prep %prep
# Make sure the license can be found in mock %setup -q -n grubby-%{version}-1
cp %{SOURCE3} . || true
git init
git config user.email "noone@example.com"
git config user.name "no one"
git add .
git commit -a -q -m "%{version} baseline"
git branch start
git am %{patches} </dev/null
git config --unset user.email
git config --unset user.name
%build %build
%set_build_flags %set_build_flags
make %{?_smp_mflags} LDFLAGS="${LDFLAGS}"
%ifnarch aarch64 %{arm}
%check
make test
%endif
%install %install
mkdir -p %{buildroot}%{_sbindir}/ make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} sbindir=%{_sbindir} libexecdir=%{_libexecdir}
install -T -m 0755 %{SOURCE1} %{buildroot}%{_sbindir}/grubby
install -D -m 0755 -t %{buildroot}%{_prefix}/lib/kernel/install.d/ %{SOURCE5} mkdir -p %{buildroot}%{_libexecdir}/{grubby,installkernel}/ %{buildroot}%{_sbindir}/
install -D -m 0755 -t %{buildroot}%{_prefix}/lib/kernel/install.d/ %{SOURCE6} mv -v %{buildroot}%{_sbindir}/grubby %{buildroot}%{_libexecdir}/grubby/grubby
mv -v %{buildroot}%{_sbindir}/installkernel %{buildroot}%{_libexecdir}/installkernel/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/
mkdir -p %{buildroot}%{_mandir}/man8 %package deprecated
install -m 0644 %{SOURCE7} %{buildroot}%{_mandir}/man8/ Summary: Legacy command line tool for updating bootloader configs
Conflicts: %{name} <= 8.40-13
%post %description deprecated
if [ "$1" = 2 ]; then This package provides deprecated, legacy grubby. This is for temporary
arch=$(uname -m) compatibility only.
[[ $arch == "s390x" ]] && \
zipl-switch-to-blscfg --backup-suffix=.rpmsave &>/dev/null || : grubby is a command line tool for updating and displaying information about
fi the configuration files for the grub, lilo, elilo (ia64), yaboot (powerpc)
and zipl (s390) 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.
%files %files
%{!?_licensedir:%global license %%doc}
%license COPYING %license COPYING
%dir %{_libexecdir}/grubby
%dir %{_libexecdir}/installkernel
%attr(0755,root,root) %{_libexecdir}/grubby/grubby-bls
%attr(0755,root,root) %{_libexecdir}/grubby/rpm-sort
%attr(0755,root,root) %{_sbindir}/grubby %attr(0755,root,root) %{_sbindir}/grubby
%attr(0755,root,root) %{_prefix}/lib/kernel/install.d/10-devicetree.install %attr(0755,root,root) %{_libexecdir}/installkernel/installkernel-bls
%attr(0755,root,root) %{_prefix}/lib/kernel/install.d/95-kernel-hooks.install %attr(0755,root,root) %{_sbindir}/installkernel
%{_mandir}/man8/grubby.8* %{_mandir}/man8/[gi]*.8*
%files deprecated
%{!?_licensedir:%global license %%doc}
%license COPYING
%dir %{_libexecdir}/grubby
%dir %{_libexecdir}/installkernel
%attr(0755,root,root) %{_libexecdir}/grubby/grubby
%attr(0755,root,root) %{_libexecdir}/installkernel/installkernel
%attr(0755,root,root) %{_sbindir}/grubby
%attr(0755,root,root) %{_sbindir}/installkernel
%attr(0755,root,root) %{_sbindir}/new-kernel-pkg
%{_mandir}/man8/*.8*
%changelog %changelog
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 8.40-76 * Wed Jan 10 2024 Marta Lewandowska <mlewando@redhat.com> - 8.40-49
- Bump release for June 2024 mass rebuild
* Wed Jan 24 2024 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-75
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Sat Jan 20 2024 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-74
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Wed Jan 10 2024 Marta Lewandowska <mlewando@redhat.com> - 8.40-73
- Do not overwrite all vars that start with GRUB_CMDLINE_LINUX - Do not overwrite all vars that start with GRUB_CMDLINE_LINUX
- Resolves: #RHEL-12853
* Mon Sep 11 2023 Zbigniew Jedrzejewski-Szmek <zbyszek@in.waw.pl> - 8.40-72 * Tue Feb 21 2023 Marta Lewandowska <mlewando@redhat.com> - 8.40-48
- Drop installkernel so that it can be provided by systemd - Apply Marta's default args fix
- Resolves: #1900829
* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-71 * Mon Oct 10 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-47
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild - Backport fedora/rhel9 initial cmdline population
- Resolves: #2129740
* Tue Feb 21 2023 Marta Lewandowska <mlewando@redhat.com> - 8.40-70 * Thu Oct 06 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-46
- remove root= when not copying default - Fix quoting of opts in grubby-bls
- Resolves: #2129740
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-69 * Thu Aug 11 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-44
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild - Write to /etc/kernel/cmdline on non-s390x also
- Resolves: #1978226
* Tue Nov 01 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-68 * Thu Aug 11 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-44
- Drop custom rpm-sort - Write to /etc/kernel/cmdline on s390x and only s390x
- See-also: https://github.com/rpm-software-management/rpm/pull/2249 - Resolves: #1978226
* Tue Oct 04 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-67 * Fri Jun 03 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-43
- Apply Marta's copy-default args fix
* Mon Aug 22 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-66
- Give up and just pull the config from BLS
- Suggested-by: Bojan Smojver <bojan@rexursive.com>
* Wed Aug 17 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-65
- Mark package as obsoleting -deprecated
- Resolves: #2117817
* Tue Aug 02 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-64
- Handle updating /etc/kernel/cmdline
* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-63
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Tue Jul 19 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-62
- Clarify that grub files aren't used on s390x in man page
* Wed Jun 22 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-61
- Revert previous change
* Tue May 31 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-60
- Additionally write to /etc/kernel/cmdline - Additionally write to /etc/kernel/cmdline
- Resolves: #1978226
* Wed Apr 27 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-59 * Wed Jun 09 2021 Javier Martinez Canillas <javierm@redhat.com> - 8.40-42
- Remove upstream and layers of indirection around -bls
* Thu Mar 10 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-58
- Remove grubby-deprecated
* Mon Feb 07 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-57
- grubby-bls: wire up -h (help)
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-56
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-55
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Wed Jun 23 2021 Javier Martinez Canillas <javierm@redhat.com> - 8.40-54
- Clarify package description
Resolves: rhbz#1913299
- Update man page to not mention the GRUB config in the ESP anymore
Resolves: rhbz#1958458
* Wed Jun 09 2021 Javier Martinez Canillas <javierm@redhat.com> - 8.40-53
- grubby-bls: expand only the kernelopts variable - grubby-bls: expand only the kernelopts variable
Resolves: rhbz#1819666
* Mon Apr 26 2021 Javier Martinez Canillas <javierm@redhat.com> - 8.40-52 * Thu May 07 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-41
- grubby-bs: Fix changing kernel cmdline params not working on ppc64le - grubby-bls: only attempt to update the cmdline if was already set
Related: rhbz#1152027
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-51 * Wed May 06 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-40
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Wed Dec 30 2020 Tom Stellard <tstellar@redhat.com> - 8.40-50
- Use make_build macro instead of plain make
- https://docs.fedoraproject.org/en-US/packaging-guidelines/#_parallel_make
* Fri Nov 20 2020 Peter Robinson <pbrobinson@fedoraproject.org> - 8.40-49
- Add device tree kernel install option
* Mon Oct 26 2020 Josh Boyer <jwb@redhat.com> - 8.40-48
- Only require s390utils-core, not s390utils-base
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-47
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Fri Jun 26 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-46
- fix build with rpm-4.16
- grubby-bls: fix --extra-initrd option not adding the correct path
* Wed May 13 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-45
- grubby-bls: don't replace options with kernelopts if values are the same
* Wed May 06 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-44
- Fix installed man page file mode bits - Fix installed man page file mode bits
Related: rhbz#1812065
* Tue May 05 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-43 * Wed Apr 29 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-39
- grubby-bls: always escape the delimiter character used in sed commands - grubby-bls: strip only /boot from paths
- grubby-bls: add a --no-etc-grub-update option Resolves: rhbz#1738238
* Wed Apr 29 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-42
- grubby-bls: fix corner case when a kernel param value contains a '='
- grubby-bls: update man page to match options in current wrapper script
* Mon Mar 30 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-41
- Make grubby to also update GRUB_CMDLINE_LINUX in /etc/default/grub - Make grubby to also update GRUB_CMDLINE_LINUX in /etc/default/grub
Related: rhbz#1287854 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
* Mon Feb 10 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-40 * Thu Nov 28 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-38
- Fix FTBFS
Resolves: rhbz#1799496
- Fix wrong S-o-B tag in patch
- Fix warning about using unversioned Obsoletes
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-39
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Fri Nov 29 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-38
- grubby-bls: don't update grubenv when generating grub.cfg for ppc64le
Related: rhbz#1726514
* Thu Nov 28 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-37
- grubby-bls: don't print rpm-sort error messages - grubby-bls: don't print rpm-sort error messages
Resolves: rhbz#1731924 Resolves: rhbz#1731924
- grubby-bls: remove -o option and support -c for ppc64le grub config - grubby-bls: remove -o option and support -c for ppc64le grub config
Resolves: rhbz#1758598 Resolves: rhbz#1758598
- grubby-bls: fix logic to check if the kernelopts var is defined in a BLS - grubby-bls: fix logic to check if the kernelopts var is defined in a BLS
Resolves: rhbz#1726514 Resolves: rhbz#1726514
- grubby-bls: don't update grubenv when generating grub.cfg for ppc64le
Related: rhbz#1726514
* Tue Aug 06 2019 Yuval Turgeman <yturgema@redhat.com> - 8.40-36 * Mon May 20 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-37
- grubby-bls: strip only /boot from paths - grubby-bls: unset default entry if is the one being removed
Resolves: rhbz#1668329
- grubby-bls: error if args or remove-args is used without update-kernel
Related: rhbz#1690765
- grubby-bls: make --update-kernel ALL to update kernelopts var in grubenv
Resolves: rhbz#1690765
- grubby-bls: fix --add-kernel not working when using the --args option
Related: rhbz#1690765
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-35 * Mon May 06 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-36
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild - grubby-bls: show absolute path when printing error about incorrect param
Related: rhbz#1706091
* Mon Jun 17 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-34 * Fri May 03 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-35
- Add a kernel-install plugin to execute hook scripts in /etc/kernel/
Resolves: rhbz#1696202
* Mon Jun 10 22:13:19 CET 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 8.40-33
- Rebuild for RPM 4.15
* Mon Jun 10 15:42:02 CET 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 8.40-32
- Rebuild for RPM 4.15
* Fri May 03 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-31
- Use mountpoint command to check whether /boot is a mount point - Use mountpoint command to check whether /boot is a mount point
Resolves: rhbz#1706091 Resolves: rhbz#1706091
* Thu Mar 21 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-30 * Wed Dec 19 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-34
- grubby-bls: fix --add-kernel not working when using the --args option
Resolves: rhbz#1691004
* Mon Mar 11 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-29
- Only switch to BLS config for s390x / zipl
Related: rhbz#1652806
* Fri Mar 01 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-28
- grubby-bls: make --update-kernel ALL to update kernelopts var in grubenv
* Thu Feb 14 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-27
- grubby-bls: error if args or remove-args is used without update-kernel
* Tue Feb 05 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-26
- 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
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-25
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Mon Jan 14 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-24
- Correctly set LDFLAGS to include hardened flags (pjones)
Related: rhbz#1654936
- grubby-bls: expand all variables in options field when updating it - grubby-bls: expand all variables in options field when updating it
Resolves: rhbz#1660700 Resolves: rhbz#1660700
* Tue Dec 11 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-23 * Tue Dec 18 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-33
- Correctly set LDFLAGS to include hardened flags (pjones)
Related: rhbz#1654936
* Tue Dec 04 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-32
- grubby-bls: lookup default entry by either id or title on grub2 - grubby-bls: lookup default entry by either id or title on grub2
Related: rhbz#1654936 Related: rhbz#1654936
* Fri Nov 30 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-22 * Fri Nov 23 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-31
- 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 - grubby-bls: allow to specify the same kernel param multiple times
Resolves: rhbz#1652486 Resolves: rhbz#1652486
- grubby-bls: expand kernel options if these are environment variables - grubby-bls: expand kernel options if these are environment variables
@ -277,80 +272,91 @@ fi
Resolves: rhbz#1653365 Resolves: rhbz#1653365
- Improve man page for --info option (jstodola) - Improve man page for --info option (jstodola)
Resolves: rhbz#1651672 Resolves: rhbz#1651672
- Make the old grubby take precedence over grubby-bls if is installed
Related: rhbz#165484
* Wed Nov 21 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-21 * Tue Nov 20 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-30
- installkernel-bls: remove unnecessary check for GRUB_ENABLE_BLSCFG=true - grubby-bls: also print the absolute path in the --default-kernel option
Resolves: rhbz#1647721 Resolves: rhbz#1649778
- grubby-bls: use title field instead of version for zipl default entry
Related: rhbz#1645200 * Mon Nov 19 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-29
- grubby-bls: print the absolute kernel and initramfs images paths - grubby-bls: print the absolute kernel and initramfs images paths
Resolves: rhbz#1649778 Resolves: rhbz#1649778
- grubby-bls: make info print the root parameter if is present in cmdline - grubby-bls: make info print the root parameter if is present in cmdline
Resolves: rhbz#1649791 Resolves: rhbz#1649791
* Tue Nov 13 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-20 * Mon Nov 12 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-28
- Switch to a BLS configuration on %%post - grubby-bls: use title field instead of version for zipl default entry
Related: rhbz#1645200
* Tue Nov 06 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-19 * Thu Nov 08 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-27
- Make the temporary config wrapper be what "grubby" contains, and put - installkernel-bls: remove unnecessary check for GRUB_ENABLE_BLSCFG=true
traditional grubby in grubby-deprecated (pjones) Resolves: rhbz#1647721
- Re-enable debuginfo generation (pjones)
Related: rhbz#1619344 * Mon Nov 05 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-26
- Install installkernel-bls here as well, not just in the grub2 package, - grubby-bls: only compare using relative paths if /boot is a mount point
since s390x doesn't have grubby packages (pjones) Resolves: rhbz#1642078
Related: rhbz#1619344
- Make grubby-bls execute grub2-mkconfig on ppc64 * Wed Oct 31 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-25
Resolves: rhbz#1636039 - grubby-bls: fix --default-* options for s390x
Resolves: rhbz#1644608
* Fri Oct 26 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-24
- grubby-bls: allow to add many BLS entries for the same kernel image
Resolves: rhbz#1634752
* Fri Oct 19 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-23
- grubby-bls: use ~debug instead of -debug as suffix to sort correctly
Related: rhbz#1638103
* Fri Oct 19 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-22
- grubby-bls: grubby-bls: use id instead of title to get the default entry
Resolves: rhbz#1638103
* Wed Oct 17 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-21
- grubby-bls: escape delimiter character before replacing the options field
Resolves: rhbz#1640017
* Tue Oct 16 2018 Peter Jones <pjones@redhat.com> - 8.40-20
- Add missing patches from RHEL-7 for grubby-deprecated.
Resolves: rhbz#1561919
- grubby-bls: make a copy of the cmdline if is modified for an entry
Resolves: rhbz#1629054
* Mon Oct 15 2018 Peter Jones <pjones@redhat.com> - 8.40-19
- grubby-bls: Make grubby-bls sort everything the same way grub2 does
Resolves: rhbz#1638103
- grubby-bls: Consistently use the filename as the bls id
Related: rhbz#1638103
- grubby-bls: check if entry exists before attempting to print its info
Resolves: rhbz#1634712
* Thu Oct 11 2018 Peter Jones <pjones@redhat.com> - 8.40-18
- grubby-bls: make "id" be the filename, and include it in --info=ALL
Related: rhbz#1638103
* Fri Oct 05 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-17
- grubby-bls should only check if kernel exists and not if was installed - grubby-bls should only check if kernel exists and not if was installed
Resolves: rhbz#1634740 Resolves: rhbz#1634740
- Use ! instead of , as sed delimiter in grubby-bls script - Use ! instead of , as sed delimiter in grubby-bls script
Resolves: rhbz#1634744 Resolves: rhbz#1634744
- Print information about the entry set as default - Print information about the entry set as default
Resolves: rhbz#1636180 Resolves: rhbz#1636180
- grubby-bls: make "id" be the filename, and include it in --info=ALL (pjones)
Related: rhbz#1638103
- grubby-bls: Make grubby-bls sort everything the same way grub2 does (pjones)
Resolves: rhbz#1638103
- grubby-bls: Consistently use the filename as the bls id
Related: rhbz#1638103
- grubby-bls: check if entry exists before attempting to print its info
Resolves: rhbz#1634712
- grubby-bls: make a copy of the cmdline if is modified for an entry
Resolves: rhbz#1629054
- grubby-bls: escape delimiter character before replacing the options field
Resolves: rhbz#1640017
- grubby-bls: grubby-bls: use id instead of title to get the default entry
Resolves: rhbz#1638103
- grubby-bls: use ~debug instead of -debug as suffix to sort correctly
Related: rhbz#1638103
- grubby-bls: allow to add many BLS entries for the same kernel image
Resolves: rhbz#1634752
- grubby-bls: fix --default-* options for s390x
Resolves: rhbz#1644608
- grubby-bls: only compare using relative paths if /boot is a mount point
Resolves: rhbz#1642078
* Fri Aug 10 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-18 * Thu Oct 04 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-16
- Make installkernel to use kernel-install scripts on BLS configuration - Make grubby-bls execute grub2-mkconfig on ppc64
Resolves: rhbz#1636039
* Tue Jul 24 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-17 * Fri Sep 28 2018 Peter Jones <pjones@redhat.com> - 8.40-15
- Fix grubby wrapper paths - Install installkernel-bls here as well, not just in the grub2 package,
Resolves: rhbz#1607981 since s390x doesn't have grubby packages.
Related: rhbz#1619344
* Tue Jul 24 2018 Peter Jones <pjones@redhat.com> - 8.40-16 * Fri Sep 28 2018 Peter Jones <pjones@redhat.com> - 8.40-14
- Fix permissions on /usr/sbin/grubby - Re-enable debuginfo generation.
Related: rhbz#1619344
* Fri Jul 13 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-15 * Fri Aug 31 2018 Peter Jones <pjones@redhat.com> - 8.40-13
- Add a grubby-bls package that conflicts with grubby - Make the temporary config wrapper be what "grubby" contains, and put
traditional grubby in grubby-deprecated.
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-14
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Thu Jun 14 2018 Peter Jones <pjones@redhat.com> - 8.40-13
- Use standard Fedora linker flags (rhbz#1543502) (rdossant)
- Switch zipl config to BLS configuration on %%postun for s390x (javierm)
* Tue Apr 10 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-12 * Tue Apr 10 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-12
- Use .rpmsave as backup suffix when switching to BLS configuration - Use .rpmsave as backup suffix when switching to BLS configuration

View File

@ -1,6 +0,0 @@
--- !Policy
product_versions:
- rhel-10
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: rtt.gating.functional}

View File