SHA256
1
0
forked from pool/grub2

Accepting request 246173 from home:michael-chang:branches:Base:System

- remove unused patch, which's supersceded by new snapper rollback
  support patches
  * 0001-script-provide-overridable-root-by-subvol.patch
  * 0002-script-create-menus-for-btrfs-snapshot.patch

OBS-URL: https://build.opensuse.org/request/show/246173
OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=109
This commit is contained in:
Michael Chang 2014-08-25 04:35:41 +00:00 committed by Git OBS Bridge
parent a3e47f6d4e
commit a15924f2d5
4 changed files with 8 additions and 359 deletions

View File

@ -1,114 +0,0 @@
From: Michael Chang <mchang@suse.com>
Subject: provide overridable root by subvol
References: fate#316522, fate#316232
Patch-Mainline: no
This patch provides a environment variable $subvol that can be used
to override path relative to absolute root by specific $subvol.
v1:
Introduce $boot_prefix for setting prefix on seeking other /boot
directory.
Signed-off-by: Michael Chang <mchang@suse.com>
Index: grub-2.02~beta2/util/grub.d/10_linux.in
===================================================================
--- grub-2.02~beta2.orig/util/grub.d/10_linux.in
+++ grub-2.02~beta2/util/grub.d/10_linux.in
@@ -55,7 +55,9 @@ case x"$GRUB_FS" in
xbtrfs)
rootsubvol="`make_system_path_relative_to_its_root /`"
rootsubvol="${rootsubvol#/}"
- if [ "x${rootsubvol}" != x ]; then
+ if [ "x$overridable_root_by_subvol" = "xtrue" ]; then
+ GRUB_CMDLINE_LINUX="\${rootflags} ${GRUB_CMDLINE_LINUX}"
+ elif [ "x${rootsubvol}" != x ]; then
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
fi;;
xzfs)
@@ -126,17 +128,43 @@ linux_entry ()
fi
printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
fi
+
+ if [ "x$overridable_root_by_subvol" = "xtrue" -a "x$GRUB_FS" = "xbtrfs" ]; then
+ sed "s/^/$submenu_indentation/" << EOF
+ if [ "x\$subvol" = "x" ]; then
+ bootdir="${rel_dirname}"
+ rootdir="${rootsubvol}"
+ else
+ bootdir="\${subvol}${dirname}"
+ rootdir="\${subvol}"
+ fi
+ if [ "x\${rootdir}" != "x" ]; then
+ rootflags="rootflags=subvol=\${rootdir}"
+ else
+ rootflags=""
+ fi
+EOF
+ fi
+
message="$(gettext_printf "Loading Linux %s ..." ${version})"
if [ -d /sys/firmware/efi ] && [ "x${GRUB_USE_LINUXEFI}" = "xtrue" ]; then
sed "s/^/$submenu_indentation/" << EOF
echo '$message'
- linuxefi ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
EOF
+ if [ "x$overridable_root_by_subvol" = "xtrue" -a "x$GRUB_FS" = "xbtrfs" ]; then
+ echo " linuxefi \${bootdir}/${basename} root=${linux_root_device_thisversion} ro ${args}" | sed "s/^/$submenu_indentation/"
+ else
+ echo " linuxefi ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}" | sed "s/^/$submenu_indentation/"
+ fi
else
sed "s/^/$submenu_indentation/" << EOF
echo '$(echo "$message" | grub_quote)'
- linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ${args}
EOF
+ if [ "x$overridable_root_by_subvol" = "xtrue" -a "x$GRUB_FS" = "xbtrfs" ]; then
+ echo " linux \${bootdir}/${basename} root=${linux_root_device_thisversion} ${args}" | sed "s/^/$submenu_indentation/"
+ else
+ echo " linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ${args}" | sed "s/^/$submenu_indentation/"
+ fi
fi
if test -n "${initrd}" ; then
# TRANSLATORS: ramdisk isn't identifier. Should be translated.
@@ -144,13 +172,21 @@ EOF
if [ -d /sys/firmware/efi ] && [ "x${GRUB_USE_LINUXEFI}" = "xtrue" ]; then
sed "s/^/$submenu_indentation/" << EOF
echo '$message'
- initrdefi ${rel_dirname}/${initrd}
EOF
+ if [ "x$overridable_root_by_subvol" = "xtrue" -a "x$GRUB_FS" = "xbtrfs" ]; then
+ echo " initrdefi \${bootdir}/${initrd}" | sed "s/^/$submenu_indentation/"
+ else
+ echo " initrdefi ${rel_dirname}/${initrd}" | sed "s/^/$submenu_indentation/"
+ fi
else
sed "s/^/$submenu_indentation/" << EOF
echo '$(echo "$message" | grub_quote)'
- initrd ${rel_dirname}/${initrd}
EOF
+ if [ "x$overridable_root_by_subvol" = "xtrue" -a "x$GRUB_FS" = "xbtrfs" ]; then
+ echo " initrd \${bootdir}/${initrd}" | sed "s/^/$submenu_indentation/"
+ else
+ echo " initrd ${rel_dirname}/${initrd}" | sed "s/^/$submenu_indentation/"
+ fi
fi
fi
sed "s/^/$submenu_indentation/" << EOF
@@ -161,11 +197,11 @@ EOF
machine=`uname -m`
case "x$machine" in
xi?86 | xx86_64)
- list=`for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do
+ list=`for i in ${boot_prefix}/boot/vmlinuz-* ${boot_prefix}/vmlinuz-* ${boot_prefix}/boot/kernel-* ; do
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
done` ;;
*)
- list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do
+ list=`for i in ${boot_prefix}/boot/vmlinuz-* ${boot_prefix}/boot/vmlinux-* ${boot_prefix}/vmlinuz-* ${boot_prefix}/vmlinux-* ${boot_prefix}/boot/kernel-* ; do
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
done` ;;
esac

View File

@ -1,241 +0,0 @@
From: Michael Chang <mchang@suse.com>
Subject: create menus for btrfs snapshot
References: fate#316522, fate#316232
Patch-Mainline: no
This patch adds a new script that will create the menus used for
booting btrfs snapshots.
v1:
* Support existing snapshots by creating their missing slave configs.
* Temporarily default to disable this feature until receiving more
tests from QA.
* Introduce GRUB_ENABLE_CUSTOM_SNAPSHOT_SUBMENU to allow custom
submenu for listing snapshots rather than the default one.
v2:
* Fix bootable snapshots not found while root is on Btrfs subvolume
(bnc#859587)
* Create missing slave config in /.snapshots/<num>/
* Prefix with SUSE_ for related options
v3:
* When booting btrfs snapshots disabled, deleting snapshot master config
if it's not customized
Signed-off-by: Michael Chang <mchang@suse.com>
Index: grub-2.02~beta2/Makefile.util.def
===================================================================
--- grub-2.02~beta2.orig/Makefile.util.def
+++ grub-2.02~beta2/Makefile.util.def
@@ -509,6 +509,13 @@ script = {
installdir = grubconf;
};
+script = {
+ name = '80_btrfs_snapshot';
+ common = util/grub.d/80_btrfs_snapshot.in;
+ installdir = grubconf;
+ condition = COND_HOST_LINUX;
+};
+
program = {
mansection = 1;
name = grub-mkrescue;
Index: grub-2.02~beta2/util/grub-mkconfig.in
===================================================================
--- grub-2.02~beta2.orig/util/grub-mkconfig.in
+++ grub-2.02~beta2/util/grub-mkconfig.in
@@ -250,7 +250,10 @@ export GRUB_DEFAULT \
GRUB_OS_PROBER_SKIP_LIST \
GRUB_DISABLE_SUBMENU \
GRUB_CMDLINE_LINUX_RECOVERY \
- GRUB_USE_LINUXEFI
+ GRUB_USE_LINUXEFI \
+ SUSE_DISABLE_BOOTING_SNAPSHOT \
+ SUSE_DISABLE_BOOTING_SNAPSHOT_SUBMENU \
+ SUSE_ENABLE_CUSTOM_SNAPSHOT_SUBMENU
if test "x${grub_cfg}" != "x"; then
rm -f "${grub_cfg}.new"
Index: grub-2.02~beta2/util/grub.d/80_btrfs_snapshot.in
===================================================================
--- /dev/null
+++ grub-2.02~beta2/util/grub.d/80_btrfs_snapshot.in
@@ -0,0 +1,174 @@
+#! /bin/sh
+set -e
+
+# grub-mkconfig helper script.
+# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+#
+# GRUB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# GRUB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+
+prefix="@prefix@"
+exec_prefix="@exec_prefix@"
+datarootdir="@datarootdir@"
+
+. "${datarootdir}/grub2/grub-mkconfig_lib"
+
+# It's pointless to proceed if not using Btrfs
+if [ "x${GRUB_FS}" != "xbtrfs" ]; then
+ exit 0
+fi
+
+# The default master/main config path looked up by core.img
+master_cfg="/boot/grub2/grub.cfg"
+
+# The config with submenu of bootable btrfs snapshots
+master_snapshot_cfg="/boot/grub2/snapshot_submenu.cfg"
+
+# The slave config path in btrfs snapshot that will be sourced by master config
+# The menu entries in slave config will have it's root overridable by specified
+# subvolume name
+slave_cfg_name="snapshot_menuentry.cfg"
+slave_cfg="boot/grub2/${slave_cfg_name}"
+
+# The current config which is being outputted by grub-mkconfig
+output_cfg=`readlink /proc/$PPID/fd/1 | sed s/.new$//`
+
+grub_mkconfig_dir=`dirname $0`
+grub_script_check="${bindir}/grub2-script-check"
+
+
+# The real root (subvolume) where system installed to
+rel_root=`make_system_path_relative_to_its_root /`
+
+# Remove any slave config if booting snapshot gets disabled, in case it will become
+# inconsistent on further updates, note this also removes master_snapshot_cfg
+
+# Temporarily we disable this as it is quite new and still in developing
+# It's subjected to be enabled by default in future as the option name
+# SUSE_DISABLE_BOOTING_SNAPSHOT suggests. So for new you'll need to explicit
+# specify SUSE_DISABLE_BOOTING_SNAPSHOT=false the update the config
+if [ "x${SUSE_DISABLE_BOOTING_SNAPSHOT}" != "xfalse" ]; then
+ rm -f "/${slave_cfg}"
+# Delete snapshot master config if not customized
+ if [ "x${SUSE_ENABLE_CUSTOM_SNAPSHOT_SUBMENU}" != "xtrue" ]; then
+ rm -f "${master_snapshot_cfg}"
+ fi
+ exit 0
+fi
+
+# Only attempt to update slave config with master
+if [ "x$output_cfg" = "x$master_cfg" ]; then
+ # Create the slave config by redirecting the standard output to it
+ # Output menu entries with overridable root
+ overridable_root_by_subvol=true ${grub_mkconfig_dir}/10_linux >"/${slave_cfg}.new"
+
+ # Check if the config is sane to use
+ if ${grub_script_check} "/${slave_cfg}.new"; then
+ mv -f "/${slave_cfg}.new" "/${slave_cfg}"
+ fi
+
+ # Scan existing snapshots to create their missing slave configs
+ # This should only be done once
+
+ for s_dir in /.snapshots/*; do
+
+ snapshot="${s_dir}/snapshot"
+ config="${snapshot}/etc/default/grub"
+ bootdir="${snapshot}/boot"
+
+ if [ ! -d "$snapshot" ]; then
+ continue
+ elif [ -f "${snapshot}/${slave_cfg}" ]; then
+ continue
+ elif [ -f "${s_dir}/${slave_cfg_name}" ]; then
+ continue
+ fi
+
+ (
+ # source config for kernel command lines .. etc
+ if [ -f "$config" ]; then
+ . "$config"
+ else
+ # skip when no config
+ continue
+ fi
+
+ overridable_root_by_subvol=true boot_prefix="$bootdir" ${grub_mkconfig_dir}/10_linux > "/${slave_cfg}.new"
+ )
+
+ # Check if the config is sane to use
+ if ${grub_script_check} "/${slave_cfg}.new"; then
+ mv -f "/${slave_cfg}.new" "${s_dir}/${slave_cfg_name}"
+ fi
+ done
+
+fi
+
+# Create the bootable snapshots submenus in master config, use the ${OS} to indicate
+# distribution that owns these snapshots.
+if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
+ OS=GNU/Linux
+else
+ OS="${GRUB_DISTRIBUTOR}"
+fi
+
+# Offer an option to allow disabling (built-in) snapshot submenu. It's possible to use
+# any other submenu with more integrated information retrieved from certain snapshot
+# utility's metadata and this option would help to get their boot menu tidy without
+# submenu with duplicated purpose.
+if [ "x${SUSE_DISABLE_BOOTING_SNAPSHOT_SUBMENU}" != "xtrue" ]; then
+ cat <<EOF
+if [ -f \${config_directory}/`basename ${master_snapshot_cfg}` ]; then
+ source \${config_directory}/`basename ${master_snapshot_cfg}`
+elif [ -z "\${config_directory}" -a -f \$prefix/`basename ${master_snapshot_cfg}` ]; then
+ source \$prefix/`basename ${master_snapshot_cfg}`;
+fi
+EOF
+fi
+
+# Still we create the file regardless SUSE_DISABLE_BOOTING_SNAPSHOT_SUBMENU, as it
+# could be source to run as a backup
+# Here we search and list snapshots created by snapper by using it's convention on
+# naming snapshots
+
+if [ "x${SUSE_ENABLE_CUSTOM_SNAPSHOT_SUBMENU}" != "xtrue" ]; then
+
+# Write default config if custom one not in use
+ cat <<EOF >"${master_snapshot_cfg}"
+insmod regexp
+submenu "Bootable snapshots for ${OS}" {
+ for x in ${rel_root}/.snapshots/*; do
+ if [ -f "\$x/${slave_cfg_name}" ]; then
+ snapshot_found=true
+ submenu "\$x" "\$x/snapshot" "\$x/${slave_cfg_name}" {
+ set subvol="\$2"
+ export subvol
+ source "\$3"
+ }
+ elif [ -f "\$x/snapshot/${slave_cfg}" ]; then
+ snapshot_found=true
+ submenu "\$x" "\$x/snapshot" "\$x/snapshot/${slave_cfg}" {
+ set subvol="\$2"
+ export subvol
+ source "\$3"
+ }
+ fi
+ done
+ if [ x\$snapshot_found != xtrue ]; then
+ submenu "Not Found" {true}
+ fi
+}
+EOF
+
+fi
+

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Mon Aug 25 03:10:18 UTC 2014 - mchang@suse.com
- remove unused patch, which's supersceded by new snapper rollback
support patches
* 0001-script-provide-overridable-root-by-subvol.patch
* 0002-script-create-menus-for-btrfs-snapshot.patch
------------------------------------------------------------------- -------------------------------------------------------------------
Fri Aug 22 10:05:13 UTC 2014 - mchang@suse.com Fri Aug 22 10:05:13 UTC 2014 - mchang@suse.com

View File

@ -156,8 +156,6 @@ Patch102: grub2-btrfs-02-export-subvolume-envvars.patch
Patch103: grub2-btrfs-03-follow_default.patch Patch103: grub2-btrfs-03-follow_default.patch
Patch104: grub2-btrfs-04-grub2-install.patch Patch104: grub2-btrfs-04-grub2-install.patch
Patch105: grub2-btrfs-05-grub2-mkconfig.patch Patch105: grub2-btrfs-05-grub2-mkconfig.patch
Patch110: 0001-script-provide-overridable-root-by-subvol.patch
Patch111: 0002-script-create-menus-for-btrfs-snapshot.patch
# PowerPC LE support # PowerPC LE support
Patch201: grub2-ppc64le-01-Add-Little-Endian-support-for-Power64-to-the-build.patch Patch201: grub2-ppc64le-01-Add-Little-Endian-support-for-Power64-to-the-build.patch
Patch202: grub2-ppc64le-02-Build-grub-as-O1-until-we-add-savegpr-and-restgpr-ro.patch Patch202: grub2-ppc64le-02-Build-grub-as-O1-until-we-add-savegpr-and-restgpr-ro.patch
@ -358,8 +356,6 @@ mv po/grub.pot po/%{name}.pot
%patch103 -p1 %patch103 -p1
%patch104 -p1 %patch104 -p1
%patch105 -p1 %patch105 -p1
#%patch110 -p1
#%patch111 -p1
%patch201 -p1 %patch201 -p1
%patch202 -p1 %patch202 -p1
%patch203 -p1 %patch203 -p1