See if what people are seeing in 1141414 is actually 957681

Related: rhbz#957681
  Related: rhbz#1141414
This commit is contained in:
Peter Jones 2014-09-26 13:30:13 -04:00
parent 271f511622
commit 0370b222f6
10 changed files with 1552 additions and 1 deletions

View File

@ -0,0 +1,41 @@
From 4dbf9c7e15420eb06540bb426bf36c434787e344 Mon Sep 17 00:00:00 2001
From: Yannick Brosseau <scientist@fb.com>
Date: Thu, 3 Jul 2014 13:55:19 -0700
Subject: [PATCH 1/9] Don't go past the last element of indexVars in
findEntryByPath
We add a chance of creating an infinite loop, because we
were reading memory past the last element of indexVars set to -1.
This issue was only apparent with -O2, probably because the way the
memory was initialized.
Signed-off-by: Yannick Brosseau <scientist@fb.com>
---
grubby.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/grubby.c b/grubby.c
index 88a1f08..db91364 100644
--- a/grubby.c
+++ b/grubby.c
@@ -1959,11 +1959,13 @@ struct singleEntry * findEntryByPath(struct grubConfig * config,
}
indexVars[i + 1] = -1;
-
+
i = 0;
if (index) {
- while (i < *index) i++;
- if (indexVars[i] == -1) return NULL;
+ while (i < *index) {
+ i++;
+ if (indexVars[i] == -1) return NULL;
+ }
}
entry = findEntryByIndex(config, indexVars[i]);
--
1.9.3

View File

@ -0,0 +1,452 @@
From 98cab84501f86bd98f12653c11f4ecc632139399 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 8 Jul 2014 14:37:21 -0400
Subject: [PATCH 2/9] Add bls test harness bits.
This expects that there are bls config files and that grubby knows how
to deal with them, which isn't at all true, and so the test case
currently fails because test/grub2.15 doesn't provide any kernel stanzas
whatsoever.
Maybe I should add a dummy there, but... I'd rather leave this failing
here.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
test.sh | 105 +++++++++++++++++++
...724b7a981ebb5b8495b9ea-3.8.0-2.fc19.x86_64.conf | 8 ++
...724b7a981ebb5b8495b9ea-3.8.1-2.fc19.x86_64.conf | 8 ++
...981ebb5b8495b9ea-tboot-3.8.0-2.fc19.x86_64.conf | 10 ++
...981ebb5b8495b9ea-tboot-3.8.1-2.fc19.x86_64.conf | 10 ++
test/grub2.15 | 112 +++++++++++++++++++++
test/results/grub2.15 | 112 +++++++++++++++++++++
7 files changed, 365 insertions(+)
create mode 100644 test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-3.8.0-2.fc19.x86_64.conf
create mode 100644 test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-3.8.1-2.fc19.x86_64.conf
create mode 100644 test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-tboot-3.8.0-2.fc19.x86_64.conf
create mode 100644 test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-tboot-3.8.1-2.fc19.x86_64.conf
create mode 100644 test/grub2.15
create mode 100644 test/results/grub2.15
diff --git a/test.sh b/test.sh
index 864a8ce..e7be15f 100755
--- a/test.sh
+++ b/test.sh
@@ -163,6 +163,102 @@ for b in $(./grubby --help | \
eval "${b}DisplayTest() { [[ \"$b\" == \$opt_bootloader ]] && oneDisplayTest --$b \"\$@\"; }"
done
+grub2BlsTest() {
+ declare blsdir=$(mktemp -d) cmpdir=$(mktemp -d)
+
+ declare blspairs=""
+ while [ -n "$1" ]; do
+ if [ "$1" == "--blspair" ]; then
+ blsin=$(echo $2 | sed 's/\(.*\),.*/\1/')
+ blsout=$(echo $2 | sed 's/[^,]*,\(.*\)/\1/')
+ [ -n "$blsin" ] && cp "test/grub2-support_files/$blsin" ${blsdir}/
+ [ -n "$blsout" ] && cp "test/grub2-support_files/$blsout" ${cmpdir}/
+ blspairs="${blspairs} $2"
+ shift 2
+ else
+ break
+ fi
+ done
+
+ typeset mode=$1 cfg=test/$2 correct=test/results/$3
+ shift 3
+
+ local ENV_FILE=""
+ if [ "$mode" == "--grub2" ]; then
+ ENV_FILE="test/grub2-support_files/env_temp"
+ if [ "$1" == "--env" ]; then
+ cp "test/grub2-support_files/$2" "$ENV_FILE"
+ shift 2
+ else
+ cp "test/grub2-support_files/grubenv.0" "$ENV_FILE"
+ fi
+ ENV_FILE="--env=$ENV_FILE"
+ fi
+
+ declare outfile=$(mktemp)
+ echo "$testing ... $mode bls $cfg $correct"
+ runme=( ./grubby "$mode" --bad-image-okay $ENV_FILE -c "$cfg" -o - --blsdir="${blsdir}" "$@" )
+ declare -i old_fail=$fail
+ if "${runme[@]}" 2>&1 | cmp "$correct" > /dev/null; then
+ (( pass++ ))
+ if $opt_verbose; then
+ echo -------------------------------------------------------------
+ echo -n "PASS: "
+ printf "%q " "${runme[@]}"; echo
+ "${runme[@]}" 2>&1 | diff -U30 "$cfg" -
+ echo
+ fi
+ else
+ (( fail++ ))
+ echo -------------------------------------------------------------
+ echo -n "FAIL: "
+ printf "%q " "${runme[@]}"; echo
+ "${runme[@]}" 2>&1 | diff -U30 "$correct" -
+ echo
+ fi
+
+ for pair in ${blspairs} ; do
+ blsin=$(echo $pair | sed 's/\(.*\),.*/\1/')
+ blsout=$(echo $pair | sed 's/[^,]*,\(.*\)/\1/')
+
+ if [ -z "${blsout}" -a -f ${blsdir}/${blsin} ]; then
+ (( fail++ ))
+ echo -------------------------------------------------------------
+ echo -n "FAIL: "
+ printf "%q " "${runme[@]}"; echo
+ diff -U30 /dev/null ${blsdir}/${blsin}
+ elif [ -n "${blsout}" ] && ! cmp ${blsdir}/${blsout} ${cmpdir}/${blsout} >/dev/null ; then
+ (( fail++ ))
+ echo -------------------------------------------------------------
+ echo -n "FAIL: "
+ printf "%q " "${runme[@]}"; echo
+ diff -U30 "${cmpdir}/${blsout}" "${blsdir}/${blsout}"
+ else
+ (( pass++ ))
+ if $opt_verbose; then
+ echo -------------------------------------------------------------
+ echo -n "PASS: "
+ printf "%q " "${runme[@]}"; echo
+ diff -U30 "${cmpdir}/${blsout}" "${blsdir}/${blsout}"
+ fi
+ fi
+ done
+
+ if [ $old_fail -eq $fail ]; then
+ (( pass++ ))
+ if $opt_verbose; then
+ echo -------------------------------------------------------------
+ echo -n "PASS: "
+ printf "%q " "${runme[@]}"; echo
+ "${runme[@]}" 2>&1 | diff -U30 "$cfg" -
+ echo
+ fi
+ fi
+
+ rm -rvf ${blsdir}/ ${cmpdir}/
+}
+
+
#----------------------------------------------------------------------
# Main
#----------------------------------------------------------------------
@@ -533,6 +629,15 @@ if [ "$testgrub2" == "y" ]; then
grub2Test grub2.2 add/g2-1.4 --update-kernel=/boot/new-kernel.img \
--initrd=/boot/new-initrd --boot-filesystem=/boot/
+ testing="GRUB2 add bls kernel+initrd"
+ grub2BlsTest \
+ --blspair 6a9857a393724b7a981ebb5b8495b9ea-3.8.0-2.fc19.x86_64.conf,6a9857a393724b7a981ebb5b8495b9ea-3.8.0-2.fc19.x86_64.conf \
+ --blspair ,6a9857a393724b7a981ebb5b8495b9ea-3.8.1-2.fc19.x86_64.conf \
+ --grub2 grub2.15 grub2.15 \
+ --add-kernel=/boot/new-kernel.img \
+ --title=title --initrd=/boot/new-initrd --boot-filesystem=/boot/ \
+ --copy-default
+
testing="GRUB2 display default index"
grub2DisplayTest grub2.1 defaultindex/0 --default-index
grub2DisplayTest grub2.2 defaultindex/0 --default-index
diff --git a/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-3.8.0-2.fc19.x86_64.conf b/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-3.8.0-2.fc19.x86_64.conf
new file mode 100644
index 0000000..e36a1fd
--- /dev/null
+++ b/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-3.8.0-2.fc19.x86_64.conf
@@ -0,0 +1,8 @@
+# /boot/org/freedesktop/bls/entries/6a9857a393724b7a981ebb5b8495b9ea-3.8.0-2.fc19.x86_64.conf
+title Fedora 19 (Rawhide)
+version 3.8.0-2.fc19.x86_64
+machine-id 6a9857a393724b7a981ebb5b8495b9ea
+filesystem 6d3376e4-fc93-4509-95ec-a21d68011da2
+linux /boot/vmlinux-3.8.0-2.fc19.x86_64
+options root=UUID=6d3376e4-fc93-4509-95ec-a21d68011da2
+initrd /boot/initrd-3.8.0-2.fc19.x86_64
diff --git a/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-3.8.1-2.fc19.x86_64.conf b/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-3.8.1-2.fc19.x86_64.conf
new file mode 100644
index 0000000..382d1af
--- /dev/null
+++ b/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-3.8.1-2.fc19.x86_64.conf
@@ -0,0 +1,8 @@
+# /boot/org/freedesktop/bls/entries/6a9857a393724b7a981ebb5b8495b9ea-3.8.1-2.fc19.x86_64.conf
+title Fedora 19 (Rawhide)
+version 3.8.1-2.fc19.x86_64
+machine-id 6a9857a393724b7a981ebb5b8495b9ea
+filesystem 6d3376e4-fc93-4509-95ec-a21d68011da2
+linux /boot/vmlinux-3.8.1-2.fc19.x86_64
+options root=UUID=6d3376e4-fc93-4509-95ec-a21d68011da2
+initrd /boot/initrd-3.8.1-2.fc19.x86_64
diff --git a/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-tboot-3.8.0-2.fc19.x86_64.conf b/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-tboot-3.8.0-2.fc19.x86_64.conf
new file mode 100644
index 0000000..05c0910
--- /dev/null
+++ b/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-tboot-3.8.0-2.fc19.x86_64.conf
@@ -0,0 +1,10 @@
+# /boot/org/freedesktop/bls/entries/6a9857a393724b7a981ebb5b8495b9ea-tboot-3.8.0-2.fc19.x86_64.conf
+title Fedora 19 (tboot) (Rawhide)
+version 3.8.0-2.fc19.x86_64
+machine-id 6a9857a393724b7a981ebb5b8495b9ea
+filesystem 6d3376e4-fc93-4509-95ec-a21d68011da2
+multiboot /boot/tboot.gz
+ options logging=serial,vga,memory
+linux /boot/vmlinux-3.8.0-2.fc19.x86_64
+options root=UUID=6d3376e4-fc93-4509-95ec-a21d68011da2
+initrd /boot/initrd-3.8.0-2.fc19.x86_64
diff --git a/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-tboot-3.8.1-2.fc19.x86_64.conf b/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-tboot-3.8.1-2.fc19.x86_64.conf
new file mode 100644
index 0000000..db17a93
--- /dev/null
+++ b/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-tboot-3.8.1-2.fc19.x86_64.conf
@@ -0,0 +1,10 @@
+# /boot/org/freedesktop/bls/entries/6a9857a393724b7a981ebb5b8495b9ea-tboot-3.8.1-2.fc19.x86_64.conf
+title Fedora 19 (tboot) (Rawhide)
+version 3.8.1-2.fc19.x86_64
+machine-id 6a9857a393724b7a981ebb5b8495b9ea
+filesystem 6d3376e4-fc93-4509-95ec-a21d68011da2
+multiboot /boot/tboot.gz
+ options logging=serial,vga,memory
+linux /boot/vmlinux-3.8.1-2.fc19.x86_64
+options root=UUID=6d3376e4-fc93-4509-95ec-a21d68011da2
+initrd /boot/initrd-3.8.1-2.fc19.x86_64
diff --git a/test/grub2.15 b/test/grub2.15
new file mode 100644
index 0000000..0be2d74
--- /dev/null
+++ b/test/grub2.15
@@ -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 {
+ 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
+}
+
+if [ x$feature_default_font_path = xy ] ; then
+ font=unicode
+else
+insmod part_gpt
+insmod btrfs
+set root='hd0,gpt4'
+if [ x$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 5a2ca487-30f7-4fa5-96bd-abe38b68ceb3
+else
+ search --no-floppy --fs-uuid --set=root 5a2ca487-30f7-4fa5-96bd-abe38b68ceb3
+fi
+ font="/root/usr/share/grub/unicode.pf2"
+fi
+
+if loadfont $font ; then
+ set gfxmode=auto
+ load_video
+ insmod gfxterm
+ set locale_dir=$prefix/locale
+ set lang=en_US
+ insmod gettext
+fi
+terminal_output gfxterm
+set timeout=5
+### END /etc/grub.d/00_header ###
+
+### BEGIN /etc/grub.d/10_blscfg ###
+
+bls_import
+
+### END /etc/grub.d/10_blscfg ###
+
+### 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/grub2.15 b/test/results/grub2.15
new file mode 100644
index 0000000..0be2d74
--- /dev/null
+++ b/test/results/grub2.15
@@ -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 {
+ 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
+}
+
+if [ x$feature_default_font_path = xy ] ; then
+ font=unicode
+else
+insmod part_gpt
+insmod btrfs
+set root='hd0,gpt4'
+if [ x$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 5a2ca487-30f7-4fa5-96bd-abe38b68ceb3
+else
+ search --no-floppy --fs-uuid --set=root 5a2ca487-30f7-4fa5-96bd-abe38b68ceb3
+fi
+ font="/root/usr/share/grub/unicode.pf2"
+fi
+
+if loadfont $font ; then
+ set gfxmode=auto
+ load_video
+ insmod gfxterm
+ set locale_dir=$prefix/locale
+ set lang=en_US
+ insmod gettext
+fi
+terminal_output gfxterm
+set timeout=5
+### END /etc/grub.d/00_header ###
+
+### BEGIN /etc/grub.d/10_blscfg ###
+
+bls_import
+
+### END /etc/grub.d/10_blscfg ###
+
+### 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 ###
--
1.9.3

View File

@ -0,0 +1,37 @@
From 2f35781fde88a99dec22407057b1a46343bc00cc Mon Sep 17 00:00:00 2001
From: Junxiao Bi <junxiao.bi@oracle.com>
Date: Wed, 14 May 2014 16:44:21 +0800
Subject: [PATCH 3/9] grubby: fix initrd updating when multiboot exist
When using the following command to add an initrd for the kernel.
grubby --update-kernel=/boot/vmlinuz-2.6.32-431.17.1.el6.x86_64.debug
--initrd /boot/initramfs-2.6.32-431.17.1.el6.x86_64.debug.img
--add-multiboot=/boot/tboot.gz
The multiboot image /boot/tboot.gz is used as the key to search the
configure entry in grub.conf, this is wrong. There may be other kernels
also configure multiboot with the same name tboot.gz, if there index are
smaller than the target one, then that will make the initrd added to the
wrong kernel. Fix it to use kernel name as the search key.
Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
Reviewed-by: John Haxby <john.haxby@oracle.com>
---
grubby.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/grubby.c b/grubby.c
index db91364..118cb84 100644
--- a/grubby.c
+++ b/grubby.c
@@ -3311,7 +3311,7 @@ int addMBInitrd(struct grubConfig * cfg, const char *newMBKernel,
if (!image) return 0;
- for (; (entry = findEntryByPath(cfg, newMBKernel, prefix, &index)); index++) {
+ for (; (entry = findEntryByPath(cfg, image, prefix, &index)); index++) {
kernelLine = getLineByType(LT_MBMODULE, entry->lines);
if (!kernelLine) continue;
--
1.9.3

View File

@ -0,0 +1,46 @@
From 338b08cb67a369069475f327b0fce74b506e5c46 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 12 Sep 2014 15:50:05 -0400
Subject: [PATCH 4/9] Tell a slightly better fib about default bootloader
config paths.
It's not going to be right everywhere, but... whatever.
Resolves: rhbz#1001664
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grubby.8 | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/grubby.8 b/grubby.8
index c2b0155..bd5ccb8 100644
--- a/grubby.8
+++ b/grubby.8
@@ -19,16 +19,18 @@ grubby \- command line tool for configuring grub, lilo, elilo, yaboot and zipl
.SH DESCRIPTION
\fBgrubby\fR is a command line tool for updating and displaying information
-about the configuration files for the \fBgrub\fR, \fBlilo\fR, \fBelilo\fR
+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.
-On Intel x86 platforms, \fBgrub\fR is the default bootloader and the
-configuration file is in \fB/boot/grub/grub.conf\fR. On Intel ia64 platforms,
-\fBelilo\fR mode is used and the default location for the configuration file
-is \fB/boot/grub/grub.conf\fR. On PowerPC platforms, \fByaboot\fR parsing
-is used and the configuration file should be in \fB/etc/yaboot.conf\fR.
+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, \fByaboot\fR
+parsing is used and the configuration file should be in \fB/etc/yaboot.conf\fR.
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
--
1.9.3

View File

@ -0,0 +1,35 @@
From f631d090d3a78327e6d2642465be6ab559dd7f4e Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 15 Sep 2014 14:31:01 -0400
Subject: [PATCH 5/9] Make findTemplate actually return the saved default.
Really not sure why this wasn't returning here before; going into the
loop below is just going to clobber all that it's done.
Related: rhbz#957681
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grubby.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/grubby.c b/grubby.c
index 118cb84..baf646b 100644
--- a/grubby.c
+++ b/grubby.c
@@ -2119,8 +2119,12 @@ struct singleEntry * findTemplate(struct grubConfig * cfg, const char * prefix,
} else {
entry = findEntryByTitle(cfg, defTitle, &index);
}
- if (entry)
+ if (entry && suitableImage(entry, prefix, skipRemoved, flags)) {
cfg->defaultImage = index;
+ if (indexPtr)
+ *indexPtr = index;
+ return entry;
+ }
}
}
} else if (cfg->defaultImage > -1) {
--
1.9.3

View File

@ -0,0 +1,106 @@
From 5c3bc267ba244478284c7879c7197aad168766e6 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 15 Sep 2014 15:18:48 -0400
Subject: [PATCH 6/9] Support filtering --update-kernel= by title as well.
If there are two entries with the same kernel, we need to match the
title to uniquely identify one.
Related: rhbz#957681
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grubby.c | 40 +++++++++++++++++++++++++++++++++++-----
1 file changed, 35 insertions(+), 5 deletions(-)
diff --git a/grubby.c b/grubby.c
index baf646b..855464a 100644
--- a/grubby.c
+++ b/grubby.c
@@ -3308,7 +3308,8 @@ int updateImage(struct grubConfig * cfg, const char * image,
}
int addMBInitrd(struct grubConfig * cfg, const char *newMBKernel,
- const char * image, const char * prefix, const char * initrd) {
+ const char * image, const char * prefix, const char * initrd,
+ const char * title) {
struct singleEntry * entry;
struct singleLine * line, * kernelLine, *endLine = NULL;
int index = 0;
@@ -3319,6 +3320,20 @@ int addMBInitrd(struct grubConfig * cfg, const char *newMBKernel,
kernelLine = getLineByType(LT_MBMODULE, entry->lines);
if (!kernelLine) continue;
+ /* if title is supplied, the entry's title must match it. */
+ if (title) {
+ line = getLineByType(LT_TITLE|LT_MENUENTRY, entry->lines);
+ char *linetitle = extractTitle(line);
+
+ if (!linetitle)
+ continue;
+ if (strcmp(title, linetitle)) {
+ free(linetitle);
+ continue;
+ }
+ free(linetitle);
+ }
+
if (prefix) {
int prefixLen = strlen(prefix);
if (!strncmp(initrd, prefix, prefixLen))
@@ -3344,7 +3359,7 @@ int addMBInitrd(struct grubConfig * cfg, const char *newMBKernel,
}
int updateInitrd(struct grubConfig * cfg, const char * image,
- const char * prefix, const char * initrd) {
+ const char * prefix, const char * initrd, const char * title) {
struct singleEntry * entry;
struct singleLine * line, * kernelLine, *endLine = NULL;
int index = 0;
@@ -3355,6 +3370,20 @@ int updateInitrd(struct grubConfig * cfg, const char * image,
kernelLine = getLineByType(LT_KERNEL|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines);
if (!kernelLine) continue;
+ /* if title is supplied, the entry's title must match it. */
+ if (title) {
+ line = getLineByType(LT_TITLE|LT_MENUENTRY, entry->lines);
+ char *linetitle = extractTitle(line);
+
+ if (!linetitle)
+ continue;
+ if (strcmp(title, linetitle)) {
+ free(linetitle);
+ continue;
+ }
+ free(linetitle);
+ }
+
line = getLineByType(LT_INITRD|LT_INITRD_EFI|LT_INITRD_16, entry->lines);
if (line)
removeLine(entry, line);
@@ -4413,7 +4442,7 @@ int main(int argc, const char ** argv) {
if (newKernelPath && !newKernelTitle) {
fprintf(stderr, _("grubby: kernel title must be specified\n"));
return 1;
- } else if (!newKernelPath && (newKernelTitle || copyDefault ||
+ } else if (!newKernelPath && (copyDefault ||
(newKernelInitrd && !updateKernelPath)||
makeDefault || extraInitrdCount > 0)) {
fprintf(stderr, _("grubby: kernel path expected\n"));
@@ -4635,11 +4664,12 @@ int main(int argc, const char ** argv) {
if (updateKernelPath && newKernelInitrd) {
if (newMBKernel) {
if (addMBInitrd(config, newMBKernel, updateKernelPath,
- bootPrefix, newKernelInitrd))
+ bootPrefix, newKernelInitrd,
+ newKernelTitle))
return 1;
} else {
if (updateInitrd(config, updateKernelPath, bootPrefix,
- newKernelInitrd))
+ newKernelInitrd, newKernelTitle))
return 1;
}
}
--
1.9.3

View File

@ -0,0 +1,310 @@
From c3b1511221a5f542ae8b5691bcc5049249b9d29f Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 15 Sep 2014 15:20:34 -0400
Subject: [PATCH 7/9] Conditionally create debug entries when installing
kernels.
If /etc/sysconfig/kernel has MAKEDEBUG set to "yes", create non-default
entries that have systemd.debug set.
Resolves: rhbz#957681
Signed-off-by: Peter Jones <pjones@redhat.com>
---
new-kernel-pkg | 190 ++++++++++++++++++++++++++++++++++++---------------------
1 file changed, 119 insertions(+), 71 deletions(-)
diff --git a/new-kernel-pkg b/new-kernel-pkg
index d9a9b67..70f6118 100755
--- a/new-kernel-pkg
+++ b/new-kernel-pkg
@@ -50,6 +50,7 @@ grubConfig=""
grub2Config=""
grub2EfiConfig=""
extlinuxConfig=""
+ubootScript="/boot/boot.scr"
ARCH=$(uname -m)
@@ -120,6 +121,7 @@ mbkernel="$HYPERVISOR"
mbargs="$HYPERVISOR_ARGS"
adddracutargs=""
addplymouthinitrd=""
+DEBUGARG="systemd.debug"
usage() {
echo "Usage: `basename $0` [-v] [--mkinitrd] [--rminitrd] [--dracut]" >&2
@@ -134,6 +136,41 @@ usage() {
exit 1
}
+rungrubby() {
+ if [ "$1" == "--debug" ]; then
+ [ "$MAKEDEBUG" != "yes" ] && return 0
+ [ -n "$verbose" ] && echo "- First, making a debug entry."
+ declare -x debugtitle=" with debugging"
+ declare -x debugargs="$DEBUGARG"
+ shift
+ else
+ [ -n "$verbose" ] && echo "- Making a normal entry."
+ fi
+ $(eval $grubby $@)
+ export -n debugargs
+ export -n debugtitle
+ unset debugargs
+ unset debugtitle
+}
+
+set_title() {
+ if [ -n "$banner" ]; then
+ if [ $ARCH = 's390' -o $ARCH = 's390x' ]; then
+ title=$(echo $banner | sed 's/ /_/g')
+ else
+ title="$banner ($version)"
+ fi
+ elif [ $ARCH = 's390' -o $ARCH = 's390x' ]; then
+ title=$(echo $version | sed 's/ /_/g')
+ elif [ -f /etc/os-release ]; then
+ . /etc/os-release
+ title="$NAME ($version) $VERSION"
+ elif [ -f /etc/redhat-release ]; then
+ title="$(sed 's/ release.*$//' < /etc/redhat-release) ($version)"
+ else
+ title="Red Hat Linux ($version)"
+ fi
+}
install() {
# XXX kernel should be able to be specified also (or work right on ia64)
@@ -184,57 +221,49 @@ install() {
cfgLilo=""
fi
-
- if [ -n "$banner" ]; then
- if [ $ARCH = 's390' -o $ARCH = 's390x' ]; then
- title=$(echo $banner | sed 's/ /_/g')
- else
- title="$banner ($version)"
- fi
- elif [ $ARCH = 's390' -o $ARCH = 's390x' ]; then
- title=$(echo $version | sed 's/ /_/g')
- elif [ -f /etc/os-release ]; then
- . /etc/os-release
- title="$NAME ($version) $VERSION"
- elif [ -f /etc/redhat-release ]; then
- title="$(sed 's/ release.*$//' < /etc/redhat-release) ($version)"
- else
- title="Red Hat Linux ($version)"
- fi
-
+ set_title
if [ -n "$cfgGrub" ]; then
[ -n "$verbose" ] && echo "adding $version to $grubConfig"
- $grubby --grub -c $grubConfig \
- --add-kernel=$kernelImage \
- $INITRD --copy-default $makedefault --title "$title" \
- ${mbkernel:+--add-multiboot="$mbkernel"} ${mbargs:+--mbargs="$mbargs"} \
- --args="root=$rootdevice $kernargs" --remove-kernel="TITLE=$title"
+ ARGS="--grub -c $grubConfig --add-kernel=$kernelImage $INITRD \
+ ${mbkernel:+--add-multiboot=\"$mbkernel\"} \
+ ${mbargs:+--mbargs=\"$mbargs\"} \
+ --title=\"$title\$debugtitle\" --copy-default \
+ --args=\"root=$rootdevice $kernargs \$debugargs\" \
+ --remove-kernel=\"TITLE=$title\$debugtitle\""
+
+ rungrubby --debug ${ARGS}
+ rungrubby ${ARGS} $makedefault
else
[ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby for grub 0.97"
fi
if [ -n "$cfgGrub2" ]; then
[ -n "$verbose" ] && echo "adding $version to $grub2Config"
- $grubby --grub2 -c $grub2Config \
- --add-kernel=$kernelImage \
- $INITRD --copy-default $makedefault --title "$title" \
- ${mbkernel:+--add-multiboot="$mbkernel"} \
- ${mbargs:+--mbargs="$mbargs"} \
- --args="root=$rootdevice $kernargs" --remove-kernel="TITLE=$title"
+ ARGS="--grub2 -c $grub2Config --add-kernel=$kernelImage $INITRD \
+ --copy-default --title \"$title\$debugtitle\" \
+ ${mbkernel:+--add-multiboot=\"$mbkernel\"} \
+ ${mbargs:+--mbargs=\"$mbargs\"} \
+ --args=\"root=$rootdevice $kernargs \$debugargs\" \
+ --remove-kernel=\"TITLE=$title\$debugtitle\""
+ rungrubby --debug ${ARGS}
+ rungrubby ${ARGS} $makedefault
else
[ -n "$verbose" ] && echo "$grub2Config does not exist, not running grubby for grub 2"
fi
if [ -n "$cfgGrub2Efi" ]; then
[ -n "$verbose" ] && echo "adding $version to $grub2EfiConfig"
- $grubby --grub2 -c $grub2EfiConfig --efi \
- --add-kernel=$kernelImage $DEVTREE \
- $INITRD --copy-default $makedefault --title "$title" \
- ${mbkernel:+--add-multiboot="$mbkernel"} \
- ${mbargs:+--mbargs="$mbargs"} \
- --args="root=$rootdevice $kernargs" --remove-kernel="TITLE=$title"
+ ARGS="--grub2 -c $grub2EfiConfig --efi \
+ --add-kernel=$kernelImage $DEVTREE $INITRD \
+ --copy-default --title \"$title\$debugtitle\" \
+ ${mbkernel:+--add-multiboot=\"$mbkernel\"} \
+ ${mbargs:+--mbargs=\"$mbargs\"} \
+ --args=\"root=$rootdevice $kernargs \$debugargs\" \
+ --remove-kernel=\"TITLE=$title\$debugtitle\""
+ rungrubby --debug ${ARGS}
+ rungrubby ${ARGS} $makedefault
else
[ -n "$verbose" ] && echo "$grub2EfiConfig does not exist, not running grubby for grub 2 with UEFI"
fi
@@ -242,12 +271,15 @@ install() {
if [ -n "$cfgLilo" ]; then
[ -n "$verbose" ] && echo "adding $version to $liloConfig"
- $grubby --add-kernel=$kernelImage $INITRD \
- --copy-default $makedefault --title "$title" \
- ${mbkernel:+--add-multiboot="$mbkernel"} ${mbargs:+--mbargs="$mbargs"} \
- --args="root=$rootdevice $kernargs" --remove-kernel="TITLE=$version" \
- --$liloFlag
+ ARGS="--$liloFlag --add-kernel=$kernelImage $INITRD \
+ --copy-default --title \"$title\$debugtitle\" \
+ ${mbkernel:+--add-multiboot=\"$mbkernel\"} \
+ ${mbargs:+--mbargs=\"$mbargs\"} \
+ --args=\"root=$rootdevice $kernargs \$debugargs\" \
+ --remove-kernel=\"TITLE=$version\""
+ rungrubby --debug ${ARGS}
+ rungrubby ${ARGS} $makedefault
if [ -n "$runLilo" ]; then
[ -n "$verbose" ] && echo "running $lilo"
if [ ! -x $lilo ] ; then
@@ -263,11 +295,15 @@ install() {
if [ -n "$cfgExtlinux" ]; then
[ -n "$verbose" ] && echo "adding $version to $extlinuxConfig"
- $grubby --extlinux -c $extlinuxConfig \
- --add-kernel=$kernelImage \
- $INITRD --copy-default $makedefault --title "$title" \
- ${mbkernel:+--add-multiboot="$mbkernel"} ${mbargs:+--mbargs="$mbargs"} \
- --args="root=$rootdevice $kernargs" --remove-kernel="TITLE=$title"
+ ARGS="--extlinux -c $extlinuxConfig --add-kernel=$kernelImage \
+ $INITRD --copy-default --title \"$title\$debugtitle\" \
+ ${mbkernel:+--add-multiboot=\"$mbkernel\"} \
+ ${mbargs:+--mbargs=\"$mbargs\"} \
+ --args=\"root=$rootdevice $kernargs \$debugargs\" \
+ --remove-kernel=\"TITLE=$title\$debugtitle\""
+
+ rungrubby --debug ${ARGS}
+ rungrubby ${ARGS} $makedefault
else
[ -n "$verbose" ] && echo "$extlinuxConfig does not exist, not running grubby for extlinux"
fi
@@ -401,6 +437,8 @@ update() {
return
fi
+ set_title
+
INITRD=""
if [ -f $initrdfile ]; then
[ -n "$verbose" ] && echo "found $initrdfile and using it with grubby"
@@ -413,45 +451,53 @@ update() {
if [ -n "$cfgGrub" ]; then
[ -n "$verbose" ] && echo "updating $version from $grubConfig"
- $grubby --grub -c $grubConfig \
- --update-kernel=$kernelImage \
- $INITRD \
- ${kernargs:+--args="$kernargs"} \
- ${removeargs:+--remove-args="$removeargs"} \
- ${mbkernel:+--add-multiboot="$mbkernel"}
+ ARGS="--grub -c $grubConfig --update-kernel=$kernelImage $INITRD \
+ ${kernargs:+--args=\"$kernargs\"} \
+ ${removeargs:+--remove-args=\"$removeargs\"} \
+ ${mbkernel:+--add-multiboot=\"$mbkernel\"} \
+ --title=\"$title\$debugtitle\""
+
+ rungrubby --debug ${ARGS}
+ rungrubby ${ARGS}
else
[ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby"
fi
if [ -n "$cfgGrub2" ]; then
[ -n "$verbose" ] && echo "updating $version from $grub2Config"
- $grubby --grub2 -c $grub2Config \
- --update-kernel=$kernelImage \
- $INITRD \
- ${kernargs:+--args="$kernargs"} \
- ${removeargs:+--remove-args="$removeargs"}
+ ARGS="--grub2 -c $grub2Config --update-kernel=$kernelImage $INITRD \
+ ${kernargs:+--args=\"$kernargs\"} \
+ ${removeargs:+--remove-args=\"$removeargs\"} \
+ --title=\"$title\$debugtitle\""
+
+ rungrubby --debug ${ARGS}
+ rungrubby ${ARGS}
else
[ -n "$verbose" ] && echo "$grub2Config does not exist, not running grubby"
fi
if [ -n "$cfgGrub2Efi" ]; then
[ -n "$verbose" ] && echo "updating $version from $grub2EfiConfig"
- $grubby --grub2 -c $grub2EfiConfig --efi \
- --update-kernel=$kernelImage \
- $INITRD \
- ${kernargs:+--args="$kernargs"} \
- ${removeargs:+--remove-args="$removeargs"}
+ ARGS="--grub2 -c $grub2EfiConfig --efi --update-kernel=$kernelImage \
+ $INITRD ${kernargs:+--args=\"$kernargs\"} \
+ ${removeargs:+--remove-args=\"$removeargs\"} \
+ --title=\"$title\$debugtitle\""
+
+ rungrubby --debug ${ARGS}
+ rungrubby ${ARGS}
else
[ -n "$verbose" ] && echo "$grub2EfiConfig does not exist, not running grubby"
fi
if [ -n "$cfgLilo" ]; then
[ -n "$verbose" ] && echo "updating $version from $liloConfig"
- $grubby --update-kernel=$kernelImage \
- $INITRD \
- ${kernargs:+--args="$kernargs"} \
- ${removeargs:+--remove-args="$removeargs"} \
- --$liloFlag
+ ARGS="--$liloFlag --update-kernel=$kernelImage $INITRD \
+ ${kernargs:+--args=\"$kernargs\"} \
+ ${removeargs:+--remove-args=\"$removeargs\"} \
+ --title=\"$title\$debugtitle\""
+
+ rungrubby --debug ${ARGS}
+ rungrubby ${ARGS}
if [ -n "$runLilo" ]; then
[ -n "$verbose" ] && echo "running $lilo"
@@ -497,11 +543,13 @@ update() {
if [ -n "$cfgExtlinux" ]; then
[ -n "$verbose" ] && echo "updating $version from $extlinuxConfig"
- $grubby --extlinux -c $extlinuxConfig \
- --update-kernel=$kernelImage \
- $INITRD \
- ${kernargs:+--args="$kernargs"} \
- ${removeargs:+--remove-args="$removeargs"}
+ ARGS="--extlinux -c $extlinuxConfig --update-kernel=$kernelImage \
+ $INITRD ${kernargs:+--args=\"$kernargs\"} \
+ ${removeargs:+--remove-args=\"$removeargs\"} \
+ --title=\"$title\$debugtitle\""
+
+ rungrubby --debug ${ARGS}
+ rungrubby ${ARGS}
else
[ -n "$verbose" ] && echo "$extlinuxConfig does not exist, not running grubby"
fi
--
1.9.3

View File

@ -0,0 +1,446 @@
From 4b927a16d3a1a8356f4ceb78c7388ca3cb6a5d87 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 15 Sep 2014 16:49:26 -0400
Subject: [PATCH 8/9] Revert "Add bls test harness bits."
This wasn't supposed to be pushed to master yet. woops.
This reverts commit 98cab84501f86bd98f12653c11f4ecc632139399.
---
test.sh | 105 -------------------
...724b7a981ebb5b8495b9ea-3.8.0-2.fc19.x86_64.conf | 8 --
...724b7a981ebb5b8495b9ea-3.8.1-2.fc19.x86_64.conf | 8 --
...981ebb5b8495b9ea-tboot-3.8.0-2.fc19.x86_64.conf | 10 --
...981ebb5b8495b9ea-tboot-3.8.1-2.fc19.x86_64.conf | 10 --
test/grub2.15 | 112 ---------------------
test/results/grub2.15 | 112 ---------------------
7 files changed, 365 deletions(-)
delete mode 100644 test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-3.8.0-2.fc19.x86_64.conf
delete mode 100644 test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-3.8.1-2.fc19.x86_64.conf
delete mode 100644 test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-tboot-3.8.0-2.fc19.x86_64.conf
delete mode 100644 test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-tboot-3.8.1-2.fc19.x86_64.conf
delete mode 100644 test/grub2.15
delete mode 100644 test/results/grub2.15
diff --git a/test.sh b/test.sh
index e7be15f..864a8ce 100755
--- a/test.sh
+++ b/test.sh
@@ -163,102 +163,6 @@ for b in $(./grubby --help | \
eval "${b}DisplayTest() { [[ \"$b\" == \$opt_bootloader ]] && oneDisplayTest --$b \"\$@\"; }"
done
-grub2BlsTest() {
- declare blsdir=$(mktemp -d) cmpdir=$(mktemp -d)
-
- declare blspairs=""
- while [ -n "$1" ]; do
- if [ "$1" == "--blspair" ]; then
- blsin=$(echo $2 | sed 's/\(.*\),.*/\1/')
- blsout=$(echo $2 | sed 's/[^,]*,\(.*\)/\1/')
- [ -n "$blsin" ] && cp "test/grub2-support_files/$blsin" ${blsdir}/
- [ -n "$blsout" ] && cp "test/grub2-support_files/$blsout" ${cmpdir}/
- blspairs="${blspairs} $2"
- shift 2
- else
- break
- fi
- done
-
- typeset mode=$1 cfg=test/$2 correct=test/results/$3
- shift 3
-
- local ENV_FILE=""
- if [ "$mode" == "--grub2" ]; then
- ENV_FILE="test/grub2-support_files/env_temp"
- if [ "$1" == "--env" ]; then
- cp "test/grub2-support_files/$2" "$ENV_FILE"
- shift 2
- else
- cp "test/grub2-support_files/grubenv.0" "$ENV_FILE"
- fi
- ENV_FILE="--env=$ENV_FILE"
- fi
-
- declare outfile=$(mktemp)
- echo "$testing ... $mode bls $cfg $correct"
- runme=( ./grubby "$mode" --bad-image-okay $ENV_FILE -c "$cfg" -o - --blsdir="${blsdir}" "$@" )
- declare -i old_fail=$fail
- if "${runme[@]}" 2>&1 | cmp "$correct" > /dev/null; then
- (( pass++ ))
- if $opt_verbose; then
- echo -------------------------------------------------------------
- echo -n "PASS: "
- printf "%q " "${runme[@]}"; echo
- "${runme[@]}" 2>&1 | diff -U30 "$cfg" -
- echo
- fi
- else
- (( fail++ ))
- echo -------------------------------------------------------------
- echo -n "FAIL: "
- printf "%q " "${runme[@]}"; echo
- "${runme[@]}" 2>&1 | diff -U30 "$correct" -
- echo
- fi
-
- for pair in ${blspairs} ; do
- blsin=$(echo $pair | sed 's/\(.*\),.*/\1/')
- blsout=$(echo $pair | sed 's/[^,]*,\(.*\)/\1/')
-
- if [ -z "${blsout}" -a -f ${blsdir}/${blsin} ]; then
- (( fail++ ))
- echo -------------------------------------------------------------
- echo -n "FAIL: "
- printf "%q " "${runme[@]}"; echo
- diff -U30 /dev/null ${blsdir}/${blsin}
- elif [ -n "${blsout}" ] && ! cmp ${blsdir}/${blsout} ${cmpdir}/${blsout} >/dev/null ; then
- (( fail++ ))
- echo -------------------------------------------------------------
- echo -n "FAIL: "
- printf "%q " "${runme[@]}"; echo
- diff -U30 "${cmpdir}/${blsout}" "${blsdir}/${blsout}"
- else
- (( pass++ ))
- if $opt_verbose; then
- echo -------------------------------------------------------------
- echo -n "PASS: "
- printf "%q " "${runme[@]}"; echo
- diff -U30 "${cmpdir}/${blsout}" "${blsdir}/${blsout}"
- fi
- fi
- done
-
- if [ $old_fail -eq $fail ]; then
- (( pass++ ))
- if $opt_verbose; then
- echo -------------------------------------------------------------
- echo -n "PASS: "
- printf "%q " "${runme[@]}"; echo
- "${runme[@]}" 2>&1 | diff -U30 "$cfg" -
- echo
- fi
- fi
-
- rm -rvf ${blsdir}/ ${cmpdir}/
-}
-
-
#----------------------------------------------------------------------
# Main
#----------------------------------------------------------------------
@@ -629,15 +533,6 @@ if [ "$testgrub2" == "y" ]; then
grub2Test grub2.2 add/g2-1.4 --update-kernel=/boot/new-kernel.img \
--initrd=/boot/new-initrd --boot-filesystem=/boot/
- testing="GRUB2 add bls kernel+initrd"
- grub2BlsTest \
- --blspair 6a9857a393724b7a981ebb5b8495b9ea-3.8.0-2.fc19.x86_64.conf,6a9857a393724b7a981ebb5b8495b9ea-3.8.0-2.fc19.x86_64.conf \
- --blspair ,6a9857a393724b7a981ebb5b8495b9ea-3.8.1-2.fc19.x86_64.conf \
- --grub2 grub2.15 grub2.15 \
- --add-kernel=/boot/new-kernel.img \
- --title=title --initrd=/boot/new-initrd --boot-filesystem=/boot/ \
- --copy-default
-
testing="GRUB2 display default index"
grub2DisplayTest grub2.1 defaultindex/0 --default-index
grub2DisplayTest grub2.2 defaultindex/0 --default-index
diff --git a/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-3.8.0-2.fc19.x86_64.conf b/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-3.8.0-2.fc19.x86_64.conf
deleted file mode 100644
index e36a1fd..0000000
--- a/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-3.8.0-2.fc19.x86_64.conf
+++ /dev/null
@@ -1,8 +0,0 @@
-# /boot/org/freedesktop/bls/entries/6a9857a393724b7a981ebb5b8495b9ea-3.8.0-2.fc19.x86_64.conf
-title Fedora 19 (Rawhide)
-version 3.8.0-2.fc19.x86_64
-machine-id 6a9857a393724b7a981ebb5b8495b9ea
-filesystem 6d3376e4-fc93-4509-95ec-a21d68011da2
-linux /boot/vmlinux-3.8.0-2.fc19.x86_64
-options root=UUID=6d3376e4-fc93-4509-95ec-a21d68011da2
-initrd /boot/initrd-3.8.0-2.fc19.x86_64
diff --git a/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-3.8.1-2.fc19.x86_64.conf b/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-3.8.1-2.fc19.x86_64.conf
deleted file mode 100644
index 382d1af..0000000
--- a/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-3.8.1-2.fc19.x86_64.conf
+++ /dev/null
@@ -1,8 +0,0 @@
-# /boot/org/freedesktop/bls/entries/6a9857a393724b7a981ebb5b8495b9ea-3.8.1-2.fc19.x86_64.conf
-title Fedora 19 (Rawhide)
-version 3.8.1-2.fc19.x86_64
-machine-id 6a9857a393724b7a981ebb5b8495b9ea
-filesystem 6d3376e4-fc93-4509-95ec-a21d68011da2
-linux /boot/vmlinux-3.8.1-2.fc19.x86_64
-options root=UUID=6d3376e4-fc93-4509-95ec-a21d68011da2
-initrd /boot/initrd-3.8.1-2.fc19.x86_64
diff --git a/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-tboot-3.8.0-2.fc19.x86_64.conf b/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-tboot-3.8.0-2.fc19.x86_64.conf
deleted file mode 100644
index 05c0910..0000000
--- a/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-tboot-3.8.0-2.fc19.x86_64.conf
+++ /dev/null
@@ -1,10 +0,0 @@
-# /boot/org/freedesktop/bls/entries/6a9857a393724b7a981ebb5b8495b9ea-tboot-3.8.0-2.fc19.x86_64.conf
-title Fedora 19 (tboot) (Rawhide)
-version 3.8.0-2.fc19.x86_64
-machine-id 6a9857a393724b7a981ebb5b8495b9ea
-filesystem 6d3376e4-fc93-4509-95ec-a21d68011da2
-multiboot /boot/tboot.gz
- options logging=serial,vga,memory
-linux /boot/vmlinux-3.8.0-2.fc19.x86_64
-options root=UUID=6d3376e4-fc93-4509-95ec-a21d68011da2
-initrd /boot/initrd-3.8.0-2.fc19.x86_64
diff --git a/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-tboot-3.8.1-2.fc19.x86_64.conf b/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-tboot-3.8.1-2.fc19.x86_64.conf
deleted file mode 100644
index db17a93..0000000
--- a/test/grub2-support_files/6a9857a393724b7a981ebb5b8495b9ea-tboot-3.8.1-2.fc19.x86_64.conf
+++ /dev/null
@@ -1,10 +0,0 @@
-# /boot/org/freedesktop/bls/entries/6a9857a393724b7a981ebb5b8495b9ea-tboot-3.8.1-2.fc19.x86_64.conf
-title Fedora 19 (tboot) (Rawhide)
-version 3.8.1-2.fc19.x86_64
-machine-id 6a9857a393724b7a981ebb5b8495b9ea
-filesystem 6d3376e4-fc93-4509-95ec-a21d68011da2
-multiboot /boot/tboot.gz
- options logging=serial,vga,memory
-linux /boot/vmlinux-3.8.1-2.fc19.x86_64
-options root=UUID=6d3376e4-fc93-4509-95ec-a21d68011da2
-initrd /boot/initrd-3.8.1-2.fc19.x86_64
diff --git a/test/grub2.15 b/test/grub2.15
deleted file mode 100644
index 0be2d74..0000000
--- a/test/grub2.15
+++ /dev/null
@@ -1,112 +0,0 @@
-#
-# 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 {
- 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
-}
-
-if [ x$feature_default_font_path = xy ] ; then
- font=unicode
-else
-insmod part_gpt
-insmod btrfs
-set root='hd0,gpt4'
-if [ x$feature_platform_search_hint = xy ]; then
- search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 5a2ca487-30f7-4fa5-96bd-abe38b68ceb3
-else
- search --no-floppy --fs-uuid --set=root 5a2ca487-30f7-4fa5-96bd-abe38b68ceb3
-fi
- font="/root/usr/share/grub/unicode.pf2"
-fi
-
-if loadfont $font ; then
- set gfxmode=auto
- load_video
- insmod gfxterm
- set locale_dir=$prefix/locale
- set lang=en_US
- insmod gettext
-fi
-terminal_output gfxterm
-set timeout=5
-### END /etc/grub.d/00_header ###
-
-### BEGIN /etc/grub.d/10_blscfg ###
-
-bls_import
-
-### END /etc/grub.d/10_blscfg ###
-
-### 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/grub2.15 b/test/results/grub2.15
deleted file mode 100644
index 0be2d74..0000000
--- a/test/results/grub2.15
+++ /dev/null
@@ -1,112 +0,0 @@
-#
-# 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 {
- 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
-}
-
-if [ x$feature_default_font_path = xy ] ; then
- font=unicode
-else
-insmod part_gpt
-insmod btrfs
-set root='hd0,gpt4'
-if [ x$feature_platform_search_hint = xy ]; then
- search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 5a2ca487-30f7-4fa5-96bd-abe38b68ceb3
-else
- search --no-floppy --fs-uuid --set=root 5a2ca487-30f7-4fa5-96bd-abe38b68ceb3
-fi
- font="/root/usr/share/grub/unicode.pf2"
-fi
-
-if loadfont $font ; then
- set gfxmode=auto
- load_video
- insmod gfxterm
- set locale_dir=$prefix/locale
- set lang=en_US
- insmod gettext
-fi
-terminal_output gfxterm
-set timeout=5
-### END /etc/grub.d/00_header ###
-
-### BEGIN /etc/grub.d/10_blscfg ###
-
-bls_import
-
-### END /etc/grub.d/10_blscfg ###
-
-### 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 ###
--
1.9.3

View File

@ -0,0 +1,62 @@
From 65d2f744f9546dd0ef24d4579ca722afadf41c52 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 25 Sep 2014 13:24:15 -0400
Subject: [PATCH 9/9] Always error check getLineByType()
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grubby.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/grubby.c b/grubby.c
index 855464a..27b4547 100644
--- a/grubby.c
+++ b/grubby.c
@@ -2369,9 +2369,11 @@ void displayEntry(struct singleEntry * entry, const char * prefix, int index) {
} else {
char * title;
line = getLineByType(LT_MENUENTRY, entry->lines);
- title = grub2ExtractTitle(line);
- if (title)
- printf("title=%s\n", title);
+ if (!line) {
+ title = grub2ExtractTitle(line);
+ if (title)
+ printf("title=%s\n", title);
+ }
}
for (j = 0, line = entry->lines; line; line = line->next) {
@@ -3322,9 +3324,13 @@ int addMBInitrd(struct grubConfig * cfg, const char *newMBKernel,
/* if title is supplied, the entry's title must match it. */
if (title) {
+ char *linetitle;
+
line = getLineByType(LT_TITLE|LT_MENUENTRY, entry->lines);
- char *linetitle = extractTitle(line);
+ if (!line)
+ continue;
+ linetitle = extractTitle(line);
if (!linetitle)
continue;
if (strcmp(title, linetitle)) {
@@ -3372,9 +3378,13 @@ int updateInitrd(struct grubConfig * cfg, const char * image,
/* if title is supplied, the entry's title must match it. */
if (title) {
+ char *linetitle;
+
line = getLineByType(LT_TITLE|LT_MENUENTRY, entry->lines);
- char *linetitle = extractTitle(line);
+ if (!line)
+ continue;
+ linetitle = extractTitle(line);
if (!linetitle)
continue;
if (strcmp(title, linetitle)) {
--
1.9.3

View File

@ -1,6 +1,6 @@
Name: grubby Name: grubby
Version: 8.35 Version: 8.35
Release: 4%{?dist} Release: 5%{?dist}
Summary: Command line tool for updating bootloader configs Summary: Command line tool for updating bootloader configs
Group: System Environment/Base Group: System Environment/Base
License: GPLv2+ License: GPLv2+
@ -9,6 +9,15 @@ URL: http://git.fedorahosted.org/git/grubby.git
# git clone git://git.fedorahosted.org/git/grubby.git # git clone git://git.fedorahosted.org/git/grubby.git
# git archive --format=tar --prefix=grubby-%{version}/ HEAD |bzip2 > grubby-%{version}.tar.bz2 # git archive --format=tar --prefix=grubby-%{version}/ HEAD |bzip2 > grubby-%{version}.tar.bz2
Source0: %{name}-%{version}.tar.bz2 Source0: %{name}-%{version}.tar.bz2
Patch0001: 0001-Don-t-go-past-the-last-element-of-indexVars-in-findE.patch
Patch0002: 0002-Add-bls-test-harness-bits.patch
Patch0003: 0003-grubby-fix-initrd-updating-when-multiboot-exist.patch
Patch0004: 0004-Tell-a-slightly-better-fib-about-default-bootloader-.patch
Patch0005: 0005-Make-findTemplate-actually-return-the-saved-default.patch
Patch0006: 0006-Support-filtering-update-kernel-by-title-as-well.patch
Patch0007: 0007-Conditionally-create-debug-entries-when-installing-k.patch
Patch0008: 0008-Revert-Add-bls-test-harness-bits.patch
Patch0009: 0009-Always-error-check-getLineByType.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: pkgconfig glib2-devel popt-devel BuildRequires: pkgconfig glib2-devel popt-devel
@ -41,6 +50,8 @@ git config user.name "no one"
git add . git add .
git commit -a -q -m "%{version} baseline" git commit -a -q -m "%{version} baseline"
git am %{patches} </dev/null git am %{patches} </dev/null
grub config --unset user.email
grub config --unset user.name
%build %build
make %{?_smp_mflags} make %{?_smp_mflags}
@ -76,6 +87,11 @@ rm -rf $RPM_BUILD_ROOT
%endif %endif
%changelog %changelog
* Fri Sep 26 2014 Peter Jones <pjones@redhat.com> - 8.35-5
- See if what people are seeing in 1141414 is actually 957681
Related: rhbz#957681
Related: rhbz#1141414
* Sat Aug 16 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 8.35-4 * Sat Aug 16 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 8.35-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild