diff --git a/PATCH_POLICY b/PATCH_POLICY new file mode 100644 index 0000000..ae2f30b --- /dev/null +++ b/PATCH_POLICY @@ -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. diff --git a/grub2-fix-Grub2-with-SUSE-Xen-package-install.patch b/grub2-fix-Grub2-with-SUSE-Xen-package-install.patch new file mode 100644 index 0000000..0517302 --- /dev/null +++ b/grub2-fix-Grub2-with-SUSE-Xen-package-install.patch @@ -0,0 +1,46 @@ +From 86fdefd6b0d447cd7d3d80f794fcd4df2aa96792 Mon Sep 17 00:00:00 2001 +From: Michael Chang +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 + diff --git a/grub2-once b/grub2-once new file mode 100644 index 0000000..f9fcf3a --- /dev/null +++ b/grub2-once @@ -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, ") { + 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 () { + &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\""; +} + diff --git a/grub2-pass-corret-root-for-nfsroot.patch b/grub2-pass-corret-root-for-nfsroot.patch new file mode 100644 index 0000000..1f1304a --- /dev/null +++ b/grub2-pass-corret-root-for-nfsroot.patch @@ -0,0 +1,73 @@ +From 340fd0c8717c2bf33163a18bfec72243b0e51862 Mon Sep 17 00:00:00 2001 +From: Michael Chang +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 ++} +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 +