Accepting request 132054 from devel:openSUSE:Factory

Please help to review the patches. Thanks. (forwarded request 132041 from michael-chang)

OBS-URL: https://build.opensuse.org/request/show/132054
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/grub2?expand=0&rev=43
This commit is contained in:
Stephan Kulow 2012-08-31 07:28:14 +00:00 committed by Git OBS Bridge
parent 0edc850993
commit e89fa67c56
7 changed files with 321 additions and 1 deletions

6
PATCH_POLICY Normal file
View File

@ -0,0 +1,6 @@
Make sure the patches you add contain tags similar to patches in the kernel
RPM. This means, it should contain From, Subject, Patch-mainline tags and also
a description of the problem, i.e. what the patch is for.
Also, if it is not a SUSE/openSUSE-specific patch (unlikely is), post the patch to
upstream too.

View File

@ -0,0 +1,46 @@
From 86fdefd6b0d447cd7d3d80f794fcd4df2aa96792 Mon Sep 17 00:00:00 2001
From: Michael Chang <mchang@suse.com>
Date: Thu, 30 Aug 2012 15:27:50 +0800
Subject: [PATCH] fix Grub2 with SUSE Xen package install
References: bnc#774666
Patch-Mainline: no
This fixes Grub2 does not offer a Xen entry after installing hypervisor
and tools, which is caused by install sequence of xen-kernel and xen is
unpredictable.
By judging the system is dom0 with xen kernel installed, the xen_list
will be set to /boot/xen.gz if it's empty. Because the xen kernel would
trigger the config updated prior to the xen package installation.
---
util/grub.d/20_linux_xen.in | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
index fd103f1..6a7c1e6 100644
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -171,6 +171,19 @@ file_is_not_sym () {
xen_list=`for i in /boot/xen*.gz; do
if grub_file_is_not_garbage "$i" && test ! -L "$i" ; then echo -n "$i " ; fi
done`
+
+# bnc#774666 - Grub2 does not offer a Xen entry after installing hypervisor and tools
+# This is a workaround to the install sequence of xen-kernel and xen is unpredictable
+if [ "x${xen_list}" = "x" ] &&
+# If the code reaches here, it means that xen-kernel has been installed, but xen hypervisor
+# is missing. This is not likely a sane condition for dom0. We assume this is xen-kernel
+# triggers config update prior to the xen package.
+# Test the system is dom0, if it is, we set the xen_list to /boot/xen.gz which should become
+# available after xen package installed.
+ [ -e /proc/xen/xsd_port -o ! -e /proc/xen ]; then
+ xen_list="/boot/xen.gz"
+fi
+
prepare_boot_cache=
boot_device_id=
--
1.7.3.4

112
grub2-once Normal file
View File

@ -0,0 +1,112 @@
#!/usr/bin/perl
use strict;
my $grub2_dir;
my $grub2_reboot;
my $show_mapped;
my $id_name;
my @menuentry;
sub parse_menuentry {
my ($parent, $menu) = @_;
my @m = $menu =~ /(submenu|menuentry) \s+ '([^']*)' .*? ( \{ (?: [^{}]* | (?3))* \} )/sxg;
for (my $i = 0; $i <= $#m; $i += 3) {
my $type = $m[$i];
my $title = $m[$i+1];
my $data = $m[$i+2];
my $name = ($parent) ? "$parent>$title" : "$title";
if ($type eq "menuentry") {
push @menuentry, $name;
} elsif ($type eq "submenu") {
&parse_menuentry ($name, $data);
}
}
}
$id_name = "";
if (@ARGV == 2 && ($ARGV[0] eq "--show-mapped")) {
$show_mapped = 1;
$id_name = $ARGV[1];
} elsif (@ARGV == 1) {
$show_mapped = 0;
$id_name = $ARGV[0];
}
die "wrong command line options" if ($id_name eq "");
open(SYSCONF, "</etc/sysconfig/bootloader") || die "no bootloader sysconfig";
$grub2_dir = "";
while (<SYSCONF>) {
if (/LOADER_TYPE="(.*)"/) {
my $bl = $1;
if ($bl eq "grub2") {
$grub2_dir = "/boot/grub2";
$grub2_reboot = "/usr/sbin/grub2-reboot";
} elsif ($bl eq "grub2-efi") {
$grub2_dir = "/boot/grub2-efi";
$grub2_reboot = "/usr/sbin/grub2-efi-reboot";
}
last;
}
}
close (SYSCONF);
die "no grub2_dir" if ($grub2_dir eq "");
open(MENU, "<$grub2_dir/grub.cfg") || die "no grub.cfg in $grub2_dir";
undef $/;
while (<MENU>) {
&parse_menuentry ("", $_);
}
close (MENU);
my $ret = "";
my $name = "";
my $id = -1;
if ($id_name =~ m!^[0-9]+$!) {
if ($id_name < @menuentry) {
$id = $id_name;
$name = $menuentry[$id];
$ret = $name;
}
} else {
my $i = -1;
my $c = 0;
$name = $id_name;
foreach my $e (@menuentry) {
if ($e =~ qr!\Q$name\E!) {
$i = $c;
last;
}
} continue {
++$c;
}
if ($i >= 0) {
$id = $i;
$name = $menuentry[$id];
$ret = "$id";
}
}
if ($show_mapped > 0) {
print $ret;
} else {
system "$grub2_reboot \"$name\"";
}

View File

@ -0,0 +1,73 @@
From 340fd0c8717c2bf33163a18bfec72243b0e51862 Mon Sep 17 00:00:00 2001
From: Michael Chang <mchang@suse.com>
Date: Thu, 30 Aug 2012 15:43:17 +0800
Subject: [PATCH] Pass corret root= for nfsroot
References: bnc#774548
Patch-Mainline: no
Fix / is mounted on nfs. The fix is to pass kernel parameters
with correct root= for nfs. However since grub2 doesn't support
nfs file system module, the /boot on nfs is not possible and
grub2-probe not work in probing nfs mounted path. The fix is merely
on the script level and not use grub2-probe for above reasons.
---
util/grub-mkconfig.in | 37 ++++++++++++++++++++++++++++++-------
1 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
index ca62e9f..d789fcc 100644
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -128,18 +128,41 @@ else
exit 1
fi
-# Device containing our userland. Typically used for root= parameter.
-GRUB_DEVICE="`${grub_probe} --target=device /`"
-GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true
+probe_nfsroot_device () {
+ while read line ; do
+ set -- $line
+ path=$5
+ fstype=$8
+ device=$9
+
+ if [ "x${path}" = "x/" ] &&
+ [ "x${fstype}" = "xnfs" -o "x${fstype}" = "xnfs4" ] ; then
+ echo "$device"
+ return
+ fi
+ done
+} </proc/self/mountinfo
+
+NFSROOT_DEVICE="`probe_nfsroot_device`"
+
+if [ "x${NFSROOT_DEVICE}" != "x" ]; then
+ GRUB_DEVICE="$NFSROOT_DEVICE"
+ GRUB_DEVICE_UUID=""
+ GRUB_FS="unknown"
+else
+ # Device containing our userland. Typically used for root= parameter.
+ GRUB_DEVICE="`${grub_probe} --target=device /`"
+ GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true
+
+ # Filesystem for the device containing our userland. Used for stuff like
+ # choosing Hurd filesystem module.
+ GRUB_FS="`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2> /dev/null || echo unknown`"
+fi
# Device containing our /boot partition. Usually the same as GRUB_DEVICE.
GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`"
GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true
-# Filesystem for the device containing our userland. Used for stuff like
-# choosing Hurd filesystem module.
-GRUB_FS="`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2> /dev/null || echo unknown`"
-
if test -f ${sysconfdir}/default/grub ; then
. ${sysconfdir}/default/grub
fi
--
1.7.3.4

View File

@ -1,3 +1,27 @@
-------------------------------------------------------------------
Thu Aug 30 08:00:54 UTC 2012 - mchang@suse.com
- add grub2-fix-Grub2-with-SUSE-Xen-package-install.patch (bnc#774666)
- add grub2-pass-corret-root-for-nfsroot.patch (bnc#774548)
-------------------------------------------------------------------
Mon Aug 20 06:27:23 UTC 2012 - mchang@suse.com
- disable grub2-enable-theme-for-terminal-window.patch to use
default black background due to current background has poor
contrast to the font color (bnc#776244).
-------------------------------------------------------------------
Fri Aug 10 19:31:40 UTC 2012 - jslaby@suse.de
- rename grub2once to grub2-once
-------------------------------------------------------------------
Wed Aug 1 08:01:41 UTC 2012 - mchang@suse.com
- add grub2once (bnc#771587)
- add not-display-menu-when-boot-once.patch
-------------------------------------------------------------------
Sat Jul 28 14:17:56 UTC 2012 - aj@suse.de

View File

@ -77,6 +77,8 @@ Source3: README.openSUSE
Source4: grub2.rpmlintrc
# rsync -Lrtvz translationproject.org::tp/latest/grub/ po
Source5: translations-20120622.tar.xz
Source6: grub2-once
Source1000: PATCH_POLICY
Patch0: grub2-correct-font-path.patch
Patch1: rename-grub-info-file-to-grub2.patch
Patch2: grub2-linux.patch
@ -90,6 +92,9 @@ Patch11: grub2-fix-mo-not-copied-to-grubdir-locale.patch
Patch12: grub2-fix-menu-in-xen-host-server.patch
Patch13: grub2-enable-theme-for-terminal-window.patch
Patch14: grub2-stdio.in.patch
Patch15: not-display-menu-when-boot-once.patch
Patch16: grub2-fix-Grub2-with-SUSE-Xen-package-install.patch
Patch17: grub2-pass-corret-root-for-nfsroot.patch
Patch99: use-grub2-efi-as-a-package-name.patch
PreReq: perl-Bootloader
Requires: gettext-runtime
@ -149,8 +154,15 @@ cd grub-%{version}
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
# disable and back to use black colored terminal window (bnc#776244)
# we could enable it when
# 1 we have background with better contrast to the font's color
# 2 we confirm it's eligible to set the terminal background this way
#%patch13 -p1
%patch14 -p2
%patch15 -p1
%patch16 -p1
%patch17 -p1
cd ..
# README.openSUSE
@ -252,6 +264,7 @@ rm $RPM_BUILD_ROOT%{_datadir}/%{name}/*.h
# Defaults
install -m 644 -D %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/default/grub
install -m 755 -D %{SOURCE6} $RPM_BUILD_ROOT%{_sbindir}/grub2-once
%find_lang %{name}
%fdupes %buildroot%{_bindir}
@ -319,6 +332,7 @@ fi
%{_sbindir}/%{name}-install
%{_sbindir}/%{name}-mkconfig
%{_sbindir}/%{name}-mknetdir
%{_sbindir}/%{name}-once
%{_sbindir}/%{name}-ofpathname
%{_sbindir}/%{name}-probe
%{_sbindir}/%{name}-reboot

View File

@ -0,0 +1,45 @@
From 78270522e8b8c0674941e0752c245dd8468e5bf8 Mon Sep 17 00:00:00 2001
From: Michael Chang <mchang@suse.com>
Date: Wed, 1 Aug 2012 15:46:34 +0800
Subject: [PATCH] not display menu when boot once
References: bnc#771587
Patch-Mainline: no
We should prevent the menu from being displayed if boot once is
specified. This is in order to compliant with Grub1's behavior
and is better than current as it's not make any sense to bother
user to make decision when decision has been made.
---
util/grub.d/00_header.in | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in
index f495f85..d1c7916 100644
--- a/util/grub.d/00_header.in
+++ b/util/grub.d/00_header.in
@@ -280,13 +280,19 @@ make_timeout ()
verbose=" --verbose"
fi
cat << EOF
-if sleep$verbose --interruptible ${1} ; then
+if [ x\${boot_once} = xtrue ]; then
+ set timeout=0
+elif sleep$verbose --interruptible ${1} ; then
set timeout=${2}
fi
EOF
else
cat << EOF
-set timeout=${2}
+if [ x\${boot_once} = xtrue ]; then
+ set timeout=0
+else
+ set timeout=${2}
+fi
EOF
fi
}
--
1.7.10.4