nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0061-grub2-btrfs-05-grub2-mkconfig.patch

8e15ce
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
8e15ce
From: Michael Chang <mchang@suse.com>
8e15ce
Date: Thu, 21 Aug 2014 03:39:11 +0000
8e15ce
Subject: [PATCH] grub2-btrfs-05-grub2-mkconfig
8e15ce
8e15ce
Signed-off-by: Michael Chang <mchang@suse.com>
8e15ce
---
8e15ce
 util/grub-mkconfig.in       |  3 ++-
8e15ce
 util/grub-mkconfig_lib.in   |  4 ++++
8e15ce
 util/grub.d/00_header.in    | 25 ++++++++++++++++++++++++-
8e15ce
 util/grub.d/10_linux.in     |  4 ++++
8e15ce
 util/grub.d/20_linux_xen.in |  4 ++++
8e15ce
 5 files changed, 38 insertions(+), 2 deletions(-)
8e15ce
8e15ce
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
8e15ce
index 005f093809b..535c0f02499 100644
8e15ce
--- a/util/grub-mkconfig.in
8e15ce
+++ b/util/grub-mkconfig.in
8e15ce
@@ -252,7 +252,8 @@ export GRUB_DEFAULT \
8e15ce
   GRUB_BADRAM \
8e15ce
   GRUB_OS_PROBER_SKIP_LIST \
8e15ce
   GRUB_DISABLE_SUBMENU \
8e15ce
-  GRUB_DEFAULT_DTB
8e15ce
+  GRUB_DEFAULT_DTB \
8e15ce
+  SUSE_BTRFS_SNAPSHOT_BOOTING
8e15ce
 
8e15ce
 if test "x${grub_cfg}" != "x"; then
8e15ce
   rm -f "${grub_cfg}.new"
8e15ce
diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in
8e15ce
index 42c2ea9ba50..fafeac95061 100644
8e15ce
--- a/util/grub-mkconfig_lib.in
8e15ce
+++ b/util/grub-mkconfig_lib.in
8e15ce
@@ -52,7 +52,11 @@ grub_warn ()
8e15ce
 
8e15ce
 make_system_path_relative_to_its_root ()
8e15ce
 {
8e15ce
+  if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] ; then
8e15ce
+  "${grub_mkrelpath}" -r "$1"
8e15ce
+  else
8e15ce
   "${grub_mkrelpath}" "$1"
8e15ce
+  fi
8e15ce
 }
8e15ce
 
8e15ce
 is_path_readable_by_grub ()
8e15ce
diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in
8e15ce
index 858b526c925..de727e6ee6b 100644
8e15ce
--- a/util/grub.d/00_header.in
8e15ce
+++ b/util/grub.d/00_header.in
8e15ce
@@ -27,6 +27,14 @@ export TEXTDOMAINDIR="@localedir@"
8e15ce
 
8e15ce
 . "$pkgdatadir/grub-mkconfig_lib"
8e15ce
 
8e15ce
+if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] &&
8e15ce
+   [ "x${GRUB_FS}" = "xbtrfs" ] ; then
8e15ce
+    cat <
8e15ce
+set btrfs_relative_path="y"
8e15ce
+export btrfs_relative_path
8e15ce
+EOF
8e15ce
+fi
8e15ce
+
8e15ce
 # Do this as early as possible, since other commands might depend on it.
8e15ce
 # (e.g. the `loadfont' command might need lvm or raid modules)
8e15ce
 for i in ${GRUB_PRELOAD_MODULES} ; do
8e15ce
@@ -45,7 +53,9 @@ if [ "x${GRUB_TIMEOUT_BUTTON}" = "x" ] ; then GRUB_TIMEOUT_BUTTON="$GRUB_TIMEOUT
8e15ce
 cat << EOF
8e15ce
 set pager=1
8e15ce
 
8e15ce
-if [ -s \$prefix/grubenv ]; then
8e15ce
+if [ -f \${config_directory}/grubenv ]; then
8e15ce
+  load_env -f \${config_directory}/grubenv
8e15ce
+elif [ -s \$prefix/grubenv ]; then
8e15ce
   load_env
8e15ce
 fi
8e15ce
 EOF
8e15ce
@@ -356,3 +366,16 @@ fi
8e15ce
 if [ "x${GRUB_BADRAM}" != "x" ] ; then
8e15ce
   echo "badram ${GRUB_BADRAM}"
8e15ce
 fi
8e15ce
+
8e15ce
+if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] &&
8e15ce
+   [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ] &&
8e15ce
+   [ "x${GRUB_FS}" = "xbtrfs" ] ; then
8e15ce
+    # Note: No $snapshot_num on *read-only* rollback!  (bsc#901487)
8e15ce
+    cat <
8e15ce
+if [ -n "\$extra_cmdline" ]; then
8e15ce
+  submenu "Bootable snapshot #\$snapshot_num" {
8e15ce
+    menuentry "If OK, run 'snapper rollback' and reboot." { true; }
8e15ce
+  }
8e15ce
+fi
8e15ce
+EOF
8e15ce
+fi
8e15ce
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
8e15ce
index 0f3c19e30cc..cbfaca34cc7 100644
8e15ce
--- a/util/grub.d/10_linux.in
8e15ce
+++ b/util/grub.d/10_linux.in
8e15ce
@@ -66,10 +66,14 @@ fi
8e15ce
 
8e15ce
 case x"$GRUB_FS" in
8e15ce
     xbtrfs)
8e15ce
+	if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ]; then
8e15ce
+	GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} \${extra_cmdline}"
8e15ce
+	else
8e15ce
 	rootsubvol="`make_system_path_relative_to_its_root /`"
8e15ce
 	rootsubvol="${rootsubvol#/}"
8e15ce
 	if [ "x${rootsubvol}" != x ]; then
8e15ce
 	    GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
8e15ce
+	fi
8e15ce
 	fi;;
8e15ce
     xzfs)
8e15ce
 	rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
8e15ce
diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
8e15ce
index ada20775a14..e9e73b815fb 100644
8e15ce
--- a/util/grub.d/20_linux_xen.in
8e15ce
+++ b/util/grub.d/20_linux_xen.in
8e15ce
@@ -73,10 +73,14 @@ fi
8e15ce
 
8e15ce
 case x"$GRUB_FS" in
8e15ce
     xbtrfs)
8e15ce
+	if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ]; then
8e15ce
+	GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} \${extra_cmdline}"
8e15ce
+	else
8e15ce
 	rootsubvol="`make_system_path_relative_to_its_root /`"
8e15ce
 	rootsubvol="${rootsubvol#/}"
8e15ce
 	if [ "x${rootsubvol}" != x ]; then
8e15ce
 	    GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
8e15ce
+	fi
8e15ce
 	fi;;
8e15ce
     xzfs)
8e15ce
 	rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`