The previous fix was completely not right, so fix it a different way.

Resolves: rhbz#1249668

Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
Peter Jones 2015-08-03 15:08:50 -04:00
parent 7b98965227
commit ea2871d57a
7 changed files with 38 additions and 32 deletions

View File

@ -1,4 +1,4 @@
From 6656c53125c328613529a52b3dcdf479d49ec475 Mon Sep 17 00:00:00 2001
From b9f953dc0a2297fab25b968dce4f7320d022c3e1 Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Mon, 16 Mar 2015 14:14:19 -0400
Subject: [PATCH 69/74] Use Distribution Package Sort for grub2-mkconfig
@ -10,24 +10,14 @@ starting with the most recent. Added an option for rpm-based systems to
use the rpm-sort library to sort kernels instead.
Resolves rhbz#1124074
And then later we discovered that was wrong and did:
Reverse rpmvercmp return value (#1229329)
RPM sort was returning kernels sorted from oldest to newest
instead of newest to oldest. Flipped the sign on the return
value to switch the order.
Resolves: rhbz#1229329
---
.gitignore | 1 +
Makefile.util.def | 16 +++
configure.ac | 29 +++++
util/grub-mkconfig_lib.in | 8 +-
util/grub-mkconfig_lib.in | 11 +-
util/grub-rpm-sort.8 | 12 ++
util/grub-rpm-sort.c | 281 ++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 346 insertions(+), 1 deletion(-)
6 files changed, 349 insertions(+), 1 deletion(-)
create mode 100644 util/grub-rpm-sort.8
create mode 100644 util/grub-rpm-sort.c
@ -71,7 +61,7 @@ index 591c5e5..f28d73d 100644
name = grub-mkconfig;
common = util/grub-mkconfig.in;
diff --git a/configure.ac b/configure.ac
index 357c94e..64791d1 100644
index 357c94e..4f26f6c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,6 +65,7 @@ grub_TRANSFORM([grub-mkrelpath])
@ -97,7 +87,7 @@ index 357c94e..64791d1 100644
+AC_ARG_ENABLE([rpm-sort],
+ [AS_HELP_STRING([--enable-rpm-sort],
+ [enable native rpm sorting of kernels in grub (default=guessed)])])
+if test x"$enable_rpm-sort" = xno ; then
+if test x"$enable_rpm_sort" = xno ; then
+ rpm_sort_excuse="explicitly disabled"
+fi
+
@ -125,23 +115,33 @@ index 357c94e..64791d1 100644
if test x$host_kernel = xkfreebsd; then
AC_CHECK_LIB([geom], [geom_gettree], [],
diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in
index 10fabee..954844d 100644
index 10fabee..9c410ea 100644
--- a/util/grub-mkconfig_lib.in
+++ b/util/grub-mkconfig_lib.in
@@ -213,6 +213,12 @@ version_sort ()
@@ -33,6 +33,9 @@ fi
if test "x$grub_mkrelpath" = x; then
grub_mkrelpath="${bindir}/@grub_mkrelpath@"
fi
+if test "x$grub_rpm_sort" = x; then
+ grub_rpm_sort="${sbindir}/@grub_rpm_sort@"
+fi
if which gettext >/dev/null 2>/dev/null; then
:
@@ -213,6 +216,12 @@ version_sort ()
esac
}
+if [ "x$RPMLIB" = x ]; then
+ kernel_sort=version_sort
+if [ "x$grub_rpm_sort" != x -a -x "$grub_rpm_sort" ]; then
+ kernel_sort="$grub_rpm_sort"
+else
+ kernel_sort="${sbindir}/grub-rpm-sort"
+ kernel_sort=version_sort
+fi
+
version_test_numeric ()
{
version_test_numeric_a="$1"
@@ -229,7 +235,7 @@ version_test_numeric ()
@@ -229,7 +238,7 @@ version_test_numeric ()
version_test_numeric_a="$version_test_numeric_b"
version_test_numeric_b="$version_test_numeric_c"
fi
@ -170,7 +170,7 @@ index 0000000..8ce2148
+.BR "info grub"
diff --git a/util/grub-rpm-sort.c b/util/grub-rpm-sort.c
new file mode 100644
index 0000000..4bbba1f
index 0000000..f33bd1e
--- /dev/null
+++ b/util/grub-rpm-sort.c
@@ -0,0 +1,281 @@
@ -293,19 +293,19 @@ index 0000000..4bbba1f
+ vercmpflag = rpmvercmp ((lhs_name == NULL ? "" : lhs_name),
+ (rhs_name == NULL ? "" : rhs_name));
+ if (vercmpflag != 0)
+ return -vercmpflag;
+ return vercmpflag;
+
+ /* Check version and return if unequal */
+ vercmpflag = rpmvercmp ((lhs_version == NULL ? "" : lhs_version),
+ (rhs_version == NULL ? "" : rhs_version));
+ if (vercmpflag != 0)
+ return -vercmpflag;
+ return vercmpflag;
+
+ /* Check release and return the version compare value */
+ vercmpflag = rpmvercmp ((lhs_release == NULL ? "" : lhs_release),
+ (rhs_release == NULL ? "" : rhs_release));
+
+ return -vercmpflag;
+ return vercmpflag;
+}
+
+static void

View File

@ -1,4 +1,4 @@
From 9e6914a17245c7a9499c58b5b8c578526f201004 Mon Sep 17 00:00:00 2001
From 05a8c8724027ddf9cefc0a8be5e2046174f2c38d Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Thu, 25 Jun 2015 11:13:11 -0400
Subject: [PATCH 70/74] Add friendly grub2 password config tool (#985962)
@ -65,7 +65,7 @@ index f28d73d..bc13d4a 100644
common = util/grub-mkconfig_lib.in;
installdir = noinst;
diff --git a/configure.ac b/configure.ac
index 64791d1..add5473 100644
index 4f26f6c..8545b9d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,6 +65,7 @@ grub_TRANSFORM([grub-mkrelpath])

View File

@ -1,4 +1,4 @@
From 77d0a87d5c1d1864f9a8409cde6fbd29d11bd996 Mon Sep 17 00:00:00 2001
From 05c9156ed3cee62e6aa8f955b96998b5d9302425 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 7 Jul 2015 12:00:26 -0400
Subject: [PATCH 71/74] Make "exit" take a return code.

View File

@ -1,4 +1,4 @@
From 9466b1c5194e6c7d388349fa2691e288b4523bc3 Mon Sep 17 00:00:00 2001
From a8b6f41df623cd777e41e0f6d44e25617f8388c9 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 7 Jul 2015 12:04:28 -0400
Subject: [PATCH 72/74] Add some __unused__ where gcc 5.x is more picky about

View File

@ -1,4 +1,4 @@
From 6afbd577549250cdd954dfc12f03a6a4e7d3b906 Mon Sep 17 00:00:00 2001
From 62b86cdfaf57a098ba7c6d8b08df161aa294e7a3 Mon Sep 17 00:00:00 2001
From: Matthew Garrett <mjg59@coreos.com>
Date: Tue, 14 Jul 2015 16:58:51 -0700
Subject: [PATCH 73/74] Fix race in EFI validation

View File

@ -1,4 +1,4 @@
From 530c5e9d5b84fd87daed817fd11415486bcfd9a6 Mon Sep 17 00:00:00 2001
From e433d768dd3d11e93a53e7df8d6c0171b8316b1e Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 22 Jul 2015 11:21:01 -0400
Subject: [PATCH 74/74] Mark po/exclude.pot as binary so git won't try to diff

View File

@ -45,7 +45,7 @@
Name: grub2
Epoch: 1
Version: 2.02
Release: 0.19%{?dist}
Release: 0.20%{?dist}
Summary: Bootloader with support for Linux, Multiboot and more
Group: System Environment/Base
@ -140,6 +140,8 @@ Patch0073: 0073-Fix-race-in-EFI-validation.patch
Patch0074: 0074-Mark-po-exclude.pot-as-binary-so-git-won-t-try-to-di.patch
# And these are:
# git checkout debuginfo
# git format-patch fedora-23..
@ -594,6 +596,10 @@ fi
%{_datarootdir}/grub/themes/starfield
%changelog
* Mon Aug 03 2015 Peter Jones <pjones@redhat.com> - 2.02-0.20
- The previous fix was completely not right, so fix it a different way.
Resolves: rhbz#1249668
* Fri Jul 31 2015 Peter Jones <pjones@redhat.com> - 2.02-0.19
- Fix grub2-mkconfig's sort to put kernels in the right order.
Related: rhbz#1124074