Accepting request 246612 from Base:System
1 OBS-URL: https://build.opensuse.org/request/show/246612 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/grub2?expand=0&rev=99
This commit is contained in:
commit
047fa6f4e7
@ -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
|
@ -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
|
||||
+
|
@ -1,66 +0,0 @@
|
||||
From: Michael Chang <mchang@suse.com>
|
||||
Subject: add loader_cmdline_append environment variable
|
||||
|
||||
Add loader_cmdline_append environment variable that appends it's
|
||||
value to the loader's command line. We can use this variable to
|
||||
assign values determined at run time. It will take effect on any
|
||||
subsidiary configs loaded using configfile as well.
|
||||
|
||||
By means of this variable, we can, for example, set rootflags=
|
||||
according to the selected btrfs snapshots and tell linux kernel's
|
||||
btrfs module to mount the snapshot by the subvolume name or id.
|
||||
|
||||
Signed-off-by: Michael Chang <mchang@suse.com>
|
||||
---
|
||||
grub-core/lib/cmdline.c | 21 +++++++++++++++++++++
|
||||
1 file changed, 21 insertions(+)
|
||||
|
||||
diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c
|
||||
index a702e64..c5be945 100644
|
||||
--- a/grub-core/lib/cmdline.c
|
||||
+++ b/grub-core/lib/cmdline.c
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include <grub/lib/cmdline.h>
|
||||
#include <grub/misc.h>
|
||||
+#include <grub/mm.h>
|
||||
+#include <grub/env.h>
|
||||
|
||||
static unsigned int check_arg (char *c, int *has_space)
|
||||
{
|
||||
@@ -65,6 +67,8 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf,
|
||||
int i, space;
|
||||
unsigned int arg_size;
|
||||
char *c;
|
||||
+ const char *append = NULL;
|
||||
+ grub_size_t append_size = 0;
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
@@ -95,6 +99,23 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf,
|
||||
*buf++ = ' ';
|
||||
}
|
||||
|
||||
+ append = grub_env_get ("loader_cmdline_append");
|
||||
+
|
||||
+ if (append)
|
||||
+ append_size = grub_strlen (append);
|
||||
+
|
||||
+ if (append_size)
|
||||
+ {
|
||||
+ append_size++;
|
||||
+ if (size >= append_size)
|
||||
+ {
|
||||
+ grub_strcpy (buf, append);
|
||||
+ buf += append_size;
|
||||
+ size -= append_size;
|
||||
+ i++;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
/* Replace last space with null. */
|
||||
if (i)
|
||||
buf--;
|
||||
--
|
||||
1.8.1.4
|
||||
|
@ -1,56 +1,27 @@
|
||||
From f472bc5ac54e72eb09b0606f588085af504d754b Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Schwab <schwab@suse.de>
|
||||
Date: Tue, 12 Aug 2014 10:42:43 +0200
|
||||
Subject: [PATCH] Support R_AARCH64_PREL32 relocation
|
||||
From 668add258ff7ffcfdc2c501fe5eb32e53c69b6f4 Mon Sep 17 00:00:00 2001
|
||||
From: Andrey Borzenkov <arvidjaar@gmail.com>
|
||||
Date: Mon, 30 Dec 2013 12:56:19 +0000
|
||||
Subject: [PATCH] strip .eh_frame section from arm64-efi kernel
|
||||
|
||||
* include/grub/elf.h (R_AARCH64_PREL32): Define.
|
||||
* util/grub-mkimagexx.c (make_reloc_section): Handle it.
|
||||
(relocate_addresses): Likewise.
|
||||
Fixes grub-mkimage error "relocation 0x105 is not implemented yet."
|
||||
---
|
||||
include/grub/elf.h | 1 +
|
||||
util/grub-mkimagexx.c | 10 ++++++++++
|
||||
2 files changed, 11 insertions(+)
|
||||
ChangeLog | 4 ++++
|
||||
grub-core/Makefile.core.def | 2 +-
|
||||
2 files changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/include/grub/elf.h b/include/grub/elf.h
|
||||
index caa7963..836b304 100644
|
||||
--- a/include/grub/elf.h
|
||||
+++ b/include/grub/elf.h
|
||||
@@ -2070,6 +2070,7 @@ typedef Elf32_Addr Elf32_Conflict;
|
||||
#define R_AARCH64_ABS32 258 /* Direct 32 bit. */
|
||||
#define R_AARCH64_JUMP26 282 /* 26-bit relative. */
|
||||
#define R_AARCH64_CALL26 283 /* 26-bit relative. */
|
||||
+#define R_AARCH64_PREL32 261 /* 32-bit pc-relative. */
|
||||
#define R_AARCH64_COPY 1024 /* Copy symbol at runtime. */
|
||||
#define R_AARCH64_GLOB_DAT 1025 /* Create GOT entry. */
|
||||
#define R_AARCH64_JUMP_SLOT 1026 /* Create PLT entry. */
|
||||
diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c
|
||||
index 0a1ac9e..376dc2d 100644
|
||||
--- a/util/grub-mkimagexx.c
|
||||
+++ b/util/grub-mkimagexx.c
|
||||
@@ -836,6 +836,15 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
|
||||
*target = grub_host_to_target64 (grub_target_to_host64 (*target) + sym_addr);
|
||||
}
|
||||
break;
|
||||
+ case R_AARCH64_PREL32:
|
||||
+ {
|
||||
+ grub_uint32_t *t32 = (grub_uint32_t *) target;
|
||||
+ *t32 = grub_host_to_target64 (grub_target_to_host32 (*t32)
|
||||
+ + sym_addr
|
||||
+ - target_section_addr - offset
|
||||
+ - image_target->vaddr_offset);
|
||||
+ break;
|
||||
+ }
|
||||
case R_AARCH64_JUMP26:
|
||||
case R_AARCH64_CALL26:
|
||||
{
|
||||
@@ -1197,6 +1206,7 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out,
|
||||
}
|
||||
break;
|
||||
/* Relative relocations do not require fixup entries. */
|
||||
+ case R_AARCH64_PREL32:
|
||||
case R_AARCH64_CALL26:
|
||||
case R_AARCH64_JUMP26:
|
||||
break;
|
||||
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
|
||||
index c916246..42443bc 100644
|
||||
--- a/grub-core/Makefile.core.def
|
||||
+++ b/grub-core/Makefile.core.def
|
||||
@@ -66,7 +66,7 @@ kernel = {
|
||||
arm_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
|
||||
|
||||
arm64_efi_ldflags = '-Wl,-r,-d';
|
||||
- arm64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
|
||||
+ arm64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame';
|
||||
|
||||
i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
|
||||
i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000';
|
||||
--
|
||||
2.0.4
|
||||
2.1.0
|
||||
|
||||
|
187
grub2-btrfs-03-follow_default.patch
Normal file
187
grub2-btrfs-03-follow_default.patch
Normal file
@ -0,0 +1,187 @@
|
||||
Index: grub-2.02~beta2/grub-core/fs/btrfs.c
|
||||
===================================================================
|
||||
--- grub-2.02~beta2.orig/grub-core/fs/btrfs.c
|
||||
+++ grub-2.02~beta2/grub-core/fs/btrfs.c
|
||||
@@ -913,6 +913,7 @@ grub_btrfs_mount (grub_device_t dev)
|
||||
{
|
||||
struct grub_btrfs_data *data;
|
||||
grub_err_t err;
|
||||
+ const char *relpath = grub_env_get ("btrfs_relative_path");
|
||||
|
||||
if (!dev->disk)
|
||||
{
|
||||
@@ -943,11 +944,14 @@ grub_btrfs_mount (grub_device_t dev)
|
||||
data->devices_attached[0].dev = dev;
|
||||
data->devices_attached[0].id = data->sblock.this_device.device_id;
|
||||
|
||||
- err = btrfs_handle_subvol (data);
|
||||
- if (err)
|
||||
+ if (relpath && (relpath[0] == '1' || relpath[0] == 'y'))
|
||||
{
|
||||
- grub_free (data);
|
||||
- return NULL;
|
||||
+ err = btrfs_handle_subvol (data);
|
||||
+ if (err)
|
||||
+ {
|
||||
+ grub_free (data);
|
||||
+ return NULL;
|
||||
+ }
|
||||
}
|
||||
|
||||
return data;
|
||||
@@ -1407,24 +1411,39 @@ find_path (struct grub_btrfs_data *data,
|
||||
grub_size_t allocated = 0;
|
||||
struct grub_btrfs_dir_item *direl = NULL;
|
||||
struct grub_btrfs_key key_out;
|
||||
+ int follow_default;
|
||||
const char *ctoken;
|
||||
grub_size_t ctokenlen;
|
||||
char *path_alloc = NULL;
|
||||
char *origpath = NULL;
|
||||
unsigned symlinks_max = 32;
|
||||
+ const char *relpath = grub_env_get ("btrfs_relative_path");
|
||||
|
||||
+ follow_default = 0;
|
||||
origpath = grub_strdup (path);
|
||||
if (!origpath)
|
||||
return grub_errno;
|
||||
|
||||
- if (data->fs_tree)
|
||||
+ if (relpath && (relpath[0] == '1' || relpath[0] == 'y'))
|
||||
{
|
||||
- *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY;
|
||||
- *tree = data->fs_tree;
|
||||
- /* This is a tree root, so everything starts at objectid 256 */
|
||||
- key->object_id = grub_cpu_to_le64_compile_time (GRUB_BTRFS_OBJECT_ID_CHUNK);
|
||||
- key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM;
|
||||
- key->offset = 0;
|
||||
+ if (data->fs_tree)
|
||||
+ {
|
||||
+ *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY;
|
||||
+ *tree = data->fs_tree;
|
||||
+ /* This is a tree root, so everything starts at objectid 256 */
|
||||
+ key->object_id = grub_cpu_to_le64_compile_time (GRUB_BTRFS_OBJECT_ID_CHUNK);
|
||||
+ key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM;
|
||||
+ key->offset = 0;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY;
|
||||
+ *tree = data->sblock.root_tree;
|
||||
+ key->object_id = data->sblock.root_dir_objectid;
|
||||
+ key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM;
|
||||
+ key->offset = 0;
|
||||
+ follow_default = 1;
|
||||
+ }
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1435,15 +1454,23 @@ find_path (struct grub_btrfs_data *data,
|
||||
|
||||
while (1)
|
||||
{
|
||||
- while (path[0] == '/')
|
||||
- path++;
|
||||
- if (!path[0])
|
||||
- break;
|
||||
- slash = grub_strchr (path, '/');
|
||||
- if (!slash)
|
||||
- slash = path + grub_strlen (path);
|
||||
- ctoken = path;
|
||||
- ctokenlen = slash - path;
|
||||
+ if (!follow_default)
|
||||
+ {
|
||||
+ while (path[0] == '/')
|
||||
+ path++;
|
||||
+ if (!path[0])
|
||||
+ break;
|
||||
+ slash = grub_strchr (path, '/');
|
||||
+ if (!slash)
|
||||
+ slash = path + grub_strlen (path);
|
||||
+ ctoken = path;
|
||||
+ ctokenlen = slash - path;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ ctoken = "default";
|
||||
+ ctokenlen = sizeof ("default") - 1;
|
||||
+ }
|
||||
|
||||
if (*type != GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY)
|
||||
{
|
||||
@@ -1454,7 +1481,9 @@ find_path (struct grub_btrfs_data *data,
|
||||
|
||||
if (ctokenlen == 1 && ctoken[0] == '.')
|
||||
{
|
||||
- path = slash;
|
||||
+ if (!follow_default)
|
||||
+ path = slash;
|
||||
+ follow_default = 0;
|
||||
continue;
|
||||
}
|
||||
if (ctokenlen == 2 && ctoken[0] == '.' && ctoken[1] == '.')
|
||||
@@ -1485,8 +1514,9 @@ find_path (struct grub_btrfs_data *data,
|
||||
*type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY;
|
||||
key->object_id = key_out.offset;
|
||||
|
||||
- path = slash;
|
||||
-
|
||||
+ if (!follow_default)
|
||||
+ path = slash;
|
||||
+ follow_default = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1555,7 +1585,9 @@ find_path (struct grub_btrfs_data *data,
|
||||
return err;
|
||||
}
|
||||
|
||||
- path = slash;
|
||||
+ if (!follow_default)
|
||||
+ path = slash;
|
||||
+ follow_default = 0;
|
||||
if (cdirel->type == GRUB_BTRFS_DIR_ITEM_TYPE_SYMLINK)
|
||||
{
|
||||
struct grub_btrfs_inode inode;
|
||||
@@ -1605,14 +1637,26 @@ find_path (struct grub_btrfs_data *data,
|
||||
path = path_alloc = tmp;
|
||||
if (path[0] == '/')
|
||||
{
|
||||
- if (data->fs_tree)
|
||||
+ if (relpath && (relpath[0] == '1' || relpath[0] == 'y'))
|
||||
{
|
||||
- *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY;
|
||||
- *tree = data->fs_tree;
|
||||
- /* This is a tree root, so everything starts at objectid 256 */
|
||||
- key->object_id = grub_cpu_to_le64_compile_time (GRUB_BTRFS_OBJECT_ID_CHUNK);
|
||||
- key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM;
|
||||
- key->offset = 0;
|
||||
+ if (data->fs_tree)
|
||||
+ {
|
||||
+ *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY;
|
||||
+ *tree = data->fs_tree;
|
||||
+ /* This is a tree root, so everything starts at objectid 256 */
|
||||
+ key->object_id = grub_cpu_to_le64_compile_time (GRUB_BTRFS_OBJECT_ID_CHUNK);
|
||||
+ key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM;
|
||||
+ key->offset = 0;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY;
|
||||
+ *tree = data->sblock.root_tree;
|
||||
+ key->object_id = data->sblock.root_dir_objectid;
|
||||
+ key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM;
|
||||
+ key->offset = 0;
|
||||
+ follow_default = 1;
|
||||
+ }
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2268,6 +2312,7 @@ GRUB_MOD_INIT (btrfs)
|
||||
subvolid_set_env);
|
||||
grub_env_export ("btrfs_subvol");
|
||||
grub_env_export ("btrfs_subvolid");
|
||||
+ grub_env_export ("btrfs_relative_path");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI (btrfs)
|
160
grub2-btrfs-04-grub2-install.patch
Normal file
160
grub2-btrfs-04-grub2-install.patch
Normal file
@ -0,0 +1,160 @@
|
||||
Index: grub-2.02~beta2/grub-core/osdep/unix/config.c
|
||||
===================================================================
|
||||
--- grub-2.02~beta2.orig/grub-core/osdep/unix/config.c
|
||||
+++ grub-2.02~beta2/grub-core/osdep/unix/config.c
|
||||
@@ -82,6 +82,19 @@ grub_util_load_config (struct grub_util_
|
||||
if (v)
|
||||
cfg->grub_distributor = xstrdup (v);
|
||||
|
||||
+ v = getenv ("SUSE_BTRFS_SNAPSHOT_BOOTING");
|
||||
+ if (v)
|
||||
+ {
|
||||
+ if (grub_strncmp(v, "true", sizeof ("true") - 1) == 0)
|
||||
+ {
|
||||
+ cfg->is_suse_btrfs_snapshot_enabled = 1;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ cfg->is_suse_btrfs_snapshot_enabled = 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
cfgfile = grub_util_get_config_filename ();
|
||||
if (!grub_util_is_regular (cfgfile))
|
||||
return;
|
||||
@@ -105,8 +118,8 @@ grub_util_load_config (struct grub_util_
|
||||
*ptr++ = *iptr;
|
||||
}
|
||||
|
||||
- strcpy (ptr, "'; printf \"GRUB_ENABLE_CRYPTODISK=%s\\nGRUB_DISTRIBUTOR=%s\\n\", "
|
||||
- "\"$GRUB_ENABLE_CRYPTODISK\", \"$GRUB_DISTRIBUTOR\"");
|
||||
+ strcpy (ptr, "'; printf \"GRUB_ENABLE_CRYPTODISK=%s\\nGRUB_DISTRIBUTOR=%s\\nSUSE_BTRFS_SNAPSHOT_BOOTING=%s\\n\", "
|
||||
+ "\"$GRUB_ENABLE_CRYPTODISK\", \"$GRUB_DISTRIBUTOR\", \"$SUSE_BTRFS_SNAPSHOT_BOOTING\"");
|
||||
|
||||
argv[2] = script;
|
||||
argv[3] = '\0';
|
||||
Index: grub-2.02~beta2/include/grub/emu/config.h
|
||||
===================================================================
|
||||
--- grub-2.02~beta2.orig/include/grub/emu/config.h
|
||||
+++ grub-2.02~beta2/include/grub/emu/config.h
|
||||
@@ -37,6 +37,7 @@ struct grub_util_config
|
||||
{
|
||||
int is_cryptodisk_enabled;
|
||||
char *grub_distributor;
|
||||
+ int is_suse_btrfs_snapshot_enabled;
|
||||
};
|
||||
|
||||
void
|
||||
Index: grub-2.02~beta2/util/config.c
|
||||
===================================================================
|
||||
--- grub-2.02~beta2.orig/util/config.c
|
||||
+++ grub-2.02~beta2/util/config.c
|
||||
@@ -42,6 +42,16 @@ grub_util_parse_config (FILE *f, struct
|
||||
cfg->is_cryptodisk_enabled = 1;
|
||||
continue;
|
||||
}
|
||||
+ if (grub_strncmp (ptr, "SUSE_BTRFS_SNAPSHOT_BOOTING=",
|
||||
+ sizeof ("SUSE_BTRFS_SNAPSHOT_BOOTING=") - 1) == 0)
|
||||
+ {
|
||||
+ ptr += sizeof ("SUSE_BTRFS_SNAPSHOT_BOOTING=") - 1;
|
||||
+ if (*ptr == '"' || *ptr == '\'')
|
||||
+ ptr++;
|
||||
+ if (grub_strncmp(ptr, "true", sizeof ("true") - 1) == 0)
|
||||
+ cfg->is_suse_btrfs_snapshot_enabled = 1;
|
||||
+ continue;
|
||||
+ }
|
||||
if (grub_strncmp (ptr, "GRUB_DISTRIBUTOR=",
|
||||
sizeof ("GRUB_DISTRIBUTOR=") - 1) == 0)
|
||||
{
|
||||
Index: grub-2.02~beta2/util/grub-install.c
|
||||
===================================================================
|
||||
--- grub-2.02~beta2.orig/util/grub-install.c
|
||||
+++ grub-2.02~beta2/util/grub-install.c
|
||||
@@ -816,6 +816,8 @@ fill_core_services (const char *core_ser
|
||||
free (sysv_plist);
|
||||
}
|
||||
|
||||
+extern int use_relative_path_on_btrfs;
|
||||
+
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@@ -849,6 +851,9 @@ main (int argc, char *argv[])
|
||||
|
||||
grub_util_load_config (&config);
|
||||
|
||||
+ if (config.is_suse_btrfs_snapshot_enabled)
|
||||
+ use_relative_path_on_btrfs = 1;
|
||||
+
|
||||
if (!bootloader_id && config.grub_distributor)
|
||||
{
|
||||
char *ptr;
|
||||
@@ -1334,6 +1339,16 @@ main (int argc, char *argv[])
|
||||
fprintf (load_cfg_f, "set debug='%s'\n",
|
||||
debug_image);
|
||||
}
|
||||
+
|
||||
+ if (config.is_suse_btrfs_snapshot_enabled
|
||||
+ && grub_strncmp(grub_fs->name, "btrfs", sizeof ("btrfs") - 1) == 0)
|
||||
+ {
|
||||
+ if (!load_cfg_f)
|
||||
+ load_cfg_f = grub_util_fopen (load_cfg, "wb");
|
||||
+ have_load_cfg = 1;
|
||||
+ fprintf (load_cfg_f, "set btrfs_relative_path='y'\n");
|
||||
+ }
|
||||
+
|
||||
char *prefix_drive = NULL;
|
||||
char *install_drive = NULL;
|
||||
|
||||
Index: grub-2.02~beta2/grub-core/osdep/linux/getroot.c
|
||||
===================================================================
|
||||
--- grub-2.02~beta2.orig/grub-core/osdep/linux/getroot.c
|
||||
+++ grub-2.02~beta2/grub-core/osdep/linux/getroot.c
|
||||
@@ -364,6 +364,7 @@ get_btrfs_fs_prefix (const char *mount_p
|
||||
return ret;
|
||||
}
|
||||
|
||||
+int use_relative_path_on_btrfs = 0;
|
||||
|
||||
char **
|
||||
grub_find_root_devices_from_mountinfo (const char *dir, char **relroot)
|
||||
@@ -502,6 +503,12 @@ grub_find_root_devices_from_mountinfo (c
|
||||
{
|
||||
ret = grub_find_root_devices_from_btrfs (dir);
|
||||
fs_prefix = get_btrfs_fs_prefix (entries[i].enc_path);
|
||||
+ if (use_relative_path_on_btrfs)
|
||||
+ {
|
||||
+ if (fs_prefix)
|
||||
+ free (fs_prefix);
|
||||
+ fs_prefix = xstrdup ("/");
|
||||
+ }
|
||||
}
|
||||
if (!ret)
|
||||
{
|
||||
Index: grub-2.02~beta2/util/grub-mkrelpath.c
|
||||
===================================================================
|
||||
--- grub-2.02~beta2.orig/util/grub-mkrelpath.c
|
||||
+++ grub-2.02~beta2/util/grub-mkrelpath.c
|
||||
@@ -40,9 +40,12 @@ struct arguments
|
||||
};
|
||||
|
||||
static struct argp_option options[] = {
|
||||
+ {"relative", 'r', 0, 0, "use relative path on btrfs", 0},
|
||||
{ 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
+extern int use_relative_path_on_btrfs;
|
||||
+
|
||||
static error_t
|
||||
argp_parser (int key, char *arg, struct argp_state *state)
|
||||
{
|
||||
@@ -52,6 +55,9 @@ argp_parser (int key, char *arg, struct
|
||||
|
||||
switch (key)
|
||||
{
|
||||
+ case 'r':
|
||||
+ use_relative_path_on_btrfs = 1;
|
||||
+ break;
|
||||
case ARGP_KEY_ARG:
|
||||
if (state->arg_num == 0)
|
||||
arguments->pathname = xstrdup (arg);
|
121
grub2-btrfs-05-grub2-mkconfig.patch
Normal file
121
grub2-btrfs-05-grub2-mkconfig.patch
Normal file
@ -0,0 +1,121 @@
|
||||
---
|
||||
util/grub-mkconfig.in | 3 ++-
|
||||
util/grub-mkconfig_lib.in | 4 ++++
|
||||
util/grub.d/00_header.in | 23 ++++++++++++++++++++++-
|
||||
util/grub.d/10_linux.in | 11 ++++++++++-
|
||||
util/grub.d/20_linux_xen.in | 4 ++++
|
||||
5 files changed, 42 insertions(+), 3 deletions(-)
|
||||
|
||||
Index: grub-2.02~beta2/util/grub-mkconfig_lib.in
|
||||
===================================================================
|
||||
--- grub-2.02~beta2.orig/util/grub-mkconfig_lib.in
|
||||
+++ grub-2.02~beta2/util/grub-mkconfig_lib.in
|
||||
@@ -49,7 +49,11 @@ grub_warn ()
|
||||
|
||||
make_system_path_relative_to_its_root ()
|
||||
{
|
||||
+ if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] ; then
|
||||
+ "${grub_mkrelpath}" -r "$1"
|
||||
+ else
|
||||
"${grub_mkrelpath}" "$1"
|
||||
+ fi
|
||||
}
|
||||
|
||||
is_path_readable_by_grub ()
|
||||
Index: grub-2.02~beta2/util/grub.d/00_header.in
|
||||
===================================================================
|
||||
--- grub-2.02~beta2.orig/util/grub.d/00_header.in
|
||||
+++ grub-2.02~beta2/util/grub.d/00_header.in
|
||||
@@ -27,6 +27,14 @@ export TEXTDOMAINDIR="@localedir@"
|
||||
|
||||
. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
|
||||
|
||||
+if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] &&
|
||||
+ [ "x${GRUB_FS}" = "xbtrfs" ] ; then
|
||||
+ cat <<EOF
|
||||
+set btrfs_relative_path="y"
|
||||
+export btrfs_relative_path
|
||||
+EOF
|
||||
+fi
|
||||
+
|
||||
# Do this as early as possible, since other commands might depend on it.
|
||||
# (e.g. the `loadfont' command might need lvm or raid modules)
|
||||
for i in ${GRUB_PRELOAD_MODULES} ; do
|
||||
@@ -43,7 +51,9 @@ if [ "x${GRUB_DEFAULT_BUTTON}" = "xsaved
|
||||
if [ "x${GRUB_TIMEOUT_BUTTON}" = "x" ] ; then GRUB_TIMEOUT_BUTTON="$GRUB_TIMEOUT" ; fi
|
||||
|
||||
cat << EOF
|
||||
-if [ -s \$prefix/grubenv ]; then
|
||||
+if [ -f \${config_directory}/grubenv ]; then
|
||||
+ load_env -f \${config_directory}/grubenv
|
||||
+elif [ -s \$prefix/grubenv ]; then
|
||||
load_env
|
||||
fi
|
||||
EOF
|
||||
@@ -356,3 +366,14 @@ fi
|
||||
if [ "x${GRUB_BADRAM}" != "x" ] ; then
|
||||
echo "badram ${GRUB_BADRAM}"
|
||||
fi
|
||||
+
|
||||
+if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] &&
|
||||
+ [ "x${GRUB_FS}" = "xbtrfs" ] ; then
|
||||
+ cat <<EOF
|
||||
+if [ -n "\$extra_cmdline" ]; then
|
||||
+ submenu "Bootable snapshot #\$snapshot_num" {
|
||||
+ menuentry "If OK, run 'snapper rollback \$snapshot_num' and reboot." { true; }
|
||||
+ }
|
||||
+fi
|
||||
+EOF
|
||||
+fi
|
||||
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,8 @@ export GRUB_DEFAULT \
|
||||
GRUB_OS_PROBER_SKIP_LIST \
|
||||
GRUB_DISABLE_SUBMENU \
|
||||
GRUB_CMDLINE_LINUX_RECOVERY \
|
||||
- GRUB_USE_LINUXEFI
|
||||
+ GRUB_USE_LINUXEFI \
|
||||
+ SUSE_BTRFS_SNAPSHOT_BOOTING
|
||||
|
||||
if test "x${grub_cfg}" != "x"; then
|
||||
rm -f "${grub_cfg}.new"
|
||||
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
|
||||
@@ -53,10 +53,14 @@ fi
|
||||
|
||||
case x"$GRUB_FS" in
|
||||
xbtrfs)
|
||||
+ if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ]; then
|
||||
+ GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} \${extra_cmdline}"
|
||||
+ else
|
||||
rootsubvol="`make_system_path_relative_to_its_root /`"
|
||||
rootsubvol="${rootsubvol#/}"
|
||||
if [ "x${rootsubvol}" != x ]; then
|
||||
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
|
||||
+ fi
|
||||
fi;;
|
||||
xzfs)
|
||||
rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
|
||||
Index: grub-2.02~beta2/util/grub.d/20_linux_xen.in
|
||||
===================================================================
|
||||
--- grub-2.02~beta2.orig/util/grub.d/20_linux_xen.in
|
||||
+++ grub-2.02~beta2/util/grub.d/20_linux_xen.in
|
||||
@@ -67,10 +67,14 @@ fi
|
||||
|
||||
case x"$GRUB_FS" in
|
||||
xbtrfs)
|
||||
+ if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ]; then
|
||||
+ GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} \${extra_cmdline}"
|
||||
+ else
|
||||
rootsubvol="`make_system_path_relative_to_its_root /`"
|
||||
rootsubvol="${rootsubvol#/}"
|
||||
if [ "x${rootsubvol}" != x ]; then
|
||||
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
|
||||
+ fi
|
||||
fi;;
|
||||
xzfs)
|
||||
rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
|
@ -18,117 +18,148 @@ set -e
|
||||
|
||||
grub_mkconfig="/usr/sbin/grub2-mkconfig"
|
||||
grub_mkrelpath="/usr/bin/grub2-mkrelpath"
|
||||
grub_script_check="/usr/bin/grub2-script-check"
|
||||
grub_setting="/etc/default/grub"
|
||||
grub_cfg="/boot/grub2/grub.cfg"
|
||||
grub_snapshot_cfg="/boot/grub2/snapshot_submenu.cfg"
|
||||
|
||||
snapshot_submenu_name="snapshot_submenu.cfg"
|
||||
snapshot_menuentry_name="snapshot_menuentry.cfg"
|
||||
snapshot_menuentry_cfg="boot/grub2/${snapshot_menuentry_name}"
|
||||
snapper_snapshot_path="/.snapshots"
|
||||
snapshot_submenu_name="grub-snapshot.cfg"
|
||||
snapper_snapshots_cfg="${snapper_snapshot_path}/${snapshot_submenu_name}"
|
||||
|
||||
rel_root=`"$grub_mkrelpath" /`
|
||||
# add hotkeys for s390. (bnc#885668)
|
||||
hotkey=
|
||||
incr_hotkey()
|
||||
{
|
||||
[ -n "$hotkey" ] || return
|
||||
expr $hotkey + 1
|
||||
}
|
||||
print_hotkey()
|
||||
{
|
||||
keys="123456789abdfgijklmnoprstuvwyz"
|
||||
if [ -z "$hotkey" ]||[ $hotkey -eq 0 ]||[ $hotkey -gt 30 ]; then
|
||||
return
|
||||
fi
|
||||
echo "--hotkey=$(expr substr $keys $hotkey 1)"
|
||||
}
|
||||
|
||||
snapshot_submenu_refresh () {
|
||||
|
||||
for s_dir in /.snapshots/*; do
|
||||
snapshot_submenu () {
|
||||
|
||||
s_dir="$1"
|
||||
|
||||
snapshot="${s_dir}/snapshot"
|
||||
snapper_cfg="${s_dir}/${snapshot_submenu_name}"
|
||||
|
||||
if [ ! -d "$snapshot" ]; then
|
||||
rm -f "${snapper_cfg}"
|
||||
rm -f "${s_dir}/${snapshot_menuentry_name}"
|
||||
continue
|
||||
fi
|
||||
num="`basename $s_dir`"
|
||||
|
||||
# bnc#864842 Important snapshots are not marked as such in grub2 menu
|
||||
# the format is "important distribution version (kernel_version, timestamp, pre/post)"
|
||||
cfgs="${s_dir}/${snapshot_menuentry_name} ${snapshot}/${snapshot_menuentry_cfg}"
|
||||
date=`xmllint --xpath '/snapshot/date/text()' "${s_dir}/info.xml" || echo ""`
|
||||
date=`echo $date | sed 's/\(.*\) \(.*\):.*/\1,\2/'`
|
||||
important=`xmllint --xpath "/snapshot/userdata[key='important']/value/text()" "${s_dir}/info.xml" || echo ""`
|
||||
date=`echo $date | sed 's/\(.*\) \(.*\):.*/\1T\2/'`
|
||||
important=`xmllint --xpath "/snapshot/userdata[key='important']/value/text()" "${s_dir}/info.xml" 2>/dev/null || echo ""`
|
||||
stype=`xmllint --xpath '/snapshot/type/text()' "${s_dir}/info.xml" || echo ""`
|
||||
kernel_ver=`readlink /boot/vmlinuz | sed 's/vmlinuz-\([^-]*\).*/\1/'`
|
||||
kernel_ver=`readlink ${snapshot}/boot/vmlinuz | sed -e 's/^vmlinuz-//' -e 's/-default$//'`
|
||||
if [ -z "$kernel_ver" -a -L ${snapshot}/boot/image ]; then
|
||||
kernel_ver=`readlink ${snapshot}/boot/image | sed -e 's/^image-//' -e 's/-default$//'`
|
||||
fi
|
||||
eval `cat ${snapshot}/etc/os-release`
|
||||
test "$important" = "yes" && important="*" || important=""
|
||||
test "$important" = "yes" && important="*" || important=" "
|
||||
test "$stype" = "single" && stype=""
|
||||
|
||||
if test -n "$stype"; then
|
||||
title="${important}${NAME} $VERSION ($kernel_ver,$date,$stype)"
|
||||
else
|
||||
title="${important}${NAME} $VERSION ($kernel_ver,$date)"
|
||||
test -z "$stype" || stype=",$stype"
|
||||
desc=`xmllint --xpath '/snapshot/description/text()' "${s_dir}/info.xml" 2>/dev/null || echo ""`
|
||||
#test "$desc" = "timeline" && return 1
|
||||
test -z "$desc" || desc=",$desc"
|
||||
title="${important}${NAME} $VERSION ($kernel_ver,$date$stype$desc)"
|
||||
|
||||
cat <<EOF
|
||||
|
||||
if [ -f "${snapper_snapshot_path}/$num/snapshot/boot/grub2/grub.cfg" ]; then
|
||||
snapshot_found=true
|
||||
saved_subvol=\$btrfs_subvol
|
||||
menuentry `print_hotkey` "$title" "${snapper_snapshot_path}/$num/snapshot" "`$grub_mkrelpath ${snapper_snapshot_path}/${num}/snapshot`" {
|
||||
btrfs_subvol="\$2"
|
||||
extra_cmdline="rootflags=subvol=\$3"
|
||||
export extra_cmdline
|
||||
snapshot_num=$num
|
||||
export snapshot_num
|
||||
configfile "\$btrfs_subvol/boot/grub2/grub.cfg"
|
||||
btrfs_subvol=\$saved_subvol
|
||||
}
|
||||
fi
|
||||
|
||||
cat <<EOF > "${snapper_cfg}.new"
|
||||
EOF
|
||||
hotkey=`incr_hotkey`
|
||||
return 0
|
||||
}
|
||||
|
||||
for x in $cfgs; do
|
||||
snap="${rel_root}${snapshot}"
|
||||
snap_cfg="${rel_root}\$x"
|
||||
snapper_snapshots_cfg_refresh () {
|
||||
|
||||
if [ -f "\$snap_cfg" ]; then
|
||||
snapshot_found=true
|
||||
submenu "$title" "\$snap" "\$snap_cfg" {
|
||||
set subvol="\$2"
|
||||
export subvol
|
||||
source "\$3"
|
||||
}
|
||||
break
|
||||
if [ ! -d "$snapper_snapshot_path" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
for s_dir in ${snapper_snapshot_path}/*; do
|
||||
|
||||
snapshot="${s_dir}/snapshot"
|
||||
|
||||
# list only read-only snapshot (bnc#878528)
|
||||
if [ -w "$snapshot" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ -r "${s_dir}/info.xml" -a -r "${s_dir}/snapshot/boot/grub2/grub.cfg" ]; then
|
||||
cs="${s_dir}\n${cs}"
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
EOF
|
||||
hk=""
|
||||
[ -z "$hotkey" ] || hk="--hotkey=s"
|
||||
|
||||
if grub2-script-check "${snapper_cfg}.new"; then
|
||||
mv -f "${snapper_cfg}.new" "${snapper_cfg}"
|
||||
fi
|
||||
for c in `echo -e "${cs}" | sort -Vr`; do
|
||||
if ! snapshot_submenu "$c" > "${c}/${snapshot_submenu_name}"; then
|
||||
rm -f "${c}/${snapshot_submenu_name}"
|
||||
continue
|
||||
fi
|
||||
snapshot_cfg="${snapshot_cfg}
|
||||
if [ -f "$c/${snapshot_submenu_name}"; then
|
||||
source "$c/${snapshot_submenu_name}"
|
||||
fi"
|
||||
done
|
||||
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
grub_snapshot_cfg_refresh () {
|
||||
|
||||
: > "${grub_snapshot_cfg}.tmp"
|
||||
for s_dir in /.snapshots/*; do
|
||||
|
||||
snapshot="${s_dir}/snapshot"
|
||||
snapper_cfg="${s_dir}/${snapshot_submenu_name}"
|
||||
|
||||
if [ -f "${snapper_cfg}" ]; then
|
||||
echo "source ${rel_root}${snapper_cfg}" >>"${grub_snapshot_cfg}.tmp"
|
||||
continue
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
cat <<EOF >"${grub_snapshot_cfg}.new"
|
||||
submenu "Bootable snapshots" {
|
||||
`sort -V "${grub_snapshot_cfg}.tmp"`
|
||||
if [ x\$snapshot_found != xtrue ]; then
|
||||
submenu "Not Found" {true}
|
||||
fi
|
||||
}
|
||||
EOF
|
||||
|
||||
if grub2-script-check "${grub_snapshot_cfg}.new"; then
|
||||
mv -f "${grub_snapshot_cfg}.new" "${grub_snapshot_cfg}"
|
||||
cat <<EOF >"${snapper_snapshots_cfg}.new"
|
||||
if [ -z "\$extra_cmdline" ]; then
|
||||
submenu $hk "Start bootloader from a read-only snapshot" {${snapshot_cfg}
|
||||
if [ x\$snapshot_found != xtrue ]; then
|
||||
submenu "Not Found" { true; }
|
||||
fi
|
||||
}
|
||||
fi
|
||||
EOF
|
||||
|
||||
if ${grub_script_check} "${snapper_snapshots_cfg}.new"; then
|
||||
mv -f "${snapper_snapshots_cfg}.new" "${snapper_snapshots_cfg}"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
snapshot_submenu_clean () {
|
||||
|
||||
for s_dir in /.snapshots/*; do
|
||||
for s_dir in ${snapper_snapshot_path}/*; do
|
||||
|
||||
snapshot="${s_dir}/snapshot"
|
||||
snapper_cfg="${s_dir}/${snapshot_submenu_name}"
|
||||
|
||||
if [ -f "$snapper_cfg" ]; then
|
||||
rm -f "$snapper_cfg"
|
||||
rmdir "$s_dir" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
if [ -f "${snapper_snapshot_path}/${snapshot_submenu_name}" ]; then
|
||||
rm -f "${snapper_snapshot_path}/${snapshot_submenu_name}"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
set_grub_setting () {
|
||||
@ -137,17 +168,32 @@ set_grub_setting () {
|
||||
val=$2
|
||||
|
||||
if grep -q "$name" "$grub_setting"; then
|
||||
sed -i -e "s/.*\($name\)=.*/\1=$val/" "$grub_setting"
|
||||
sed -i -e "s!.*\($name\)=.*!\1=\"$val\"!" "$grub_setting"
|
||||
else
|
||||
echo "$name=$val" >> "$grub_setting"
|
||||
echo "$name=\"$val\"" >> "$grub_setting"
|
||||
fi
|
||||
}
|
||||
|
||||
update_grub_cfg () {
|
||||
|
||||
"$grub_mkconfig" -o "$grub_cfg"
|
||||
enable_grub_settings () {
|
||||
set_grub_setting SUSE_BTRFS_SNAPSHOT_BOOTING "true"
|
||||
}
|
||||
|
||||
disable_grub_settings () {
|
||||
set_grub_setting SUSE_BTRFS_SNAPSHOT_BOOTING "false"
|
||||
}
|
||||
|
||||
update_grub () {
|
||||
"${grub_mkconfig}" -o "${grub_cfg}"
|
||||
}
|
||||
|
||||
machine=`uname -m`
|
||||
case "$machine" in
|
||||
(s390|s390x)
|
||||
hotkey=1
|
||||
;;
|
||||
esac
|
||||
cmdline="$0 $* hotkey='$hotkey'"
|
||||
|
||||
# Check the arguments.
|
||||
while test $# -gt 0
|
||||
do
|
||||
@ -173,32 +219,20 @@ do
|
||||
done
|
||||
|
||||
if [ "x${opt_enable}" = "xtrue" ]; then
|
||||
|
||||
set_grub_setting SUSE_DISABLE_BOOTING_SNAPSHOT false
|
||||
set_grub_setting SUSE_ENABLE_CUSTOM_SNAPSHOT_SUBMENU true
|
||||
update_grub_cfg
|
||||
snapshot_submenu_refresh
|
||||
grub_snapshot_cfg_refresh
|
||||
|
||||
#enable_grub_settings
|
||||
#update_grub
|
||||
snapper_snapshots_cfg_refresh
|
||||
elif [ "x${opt_enable}" = "xfalse" ]; then
|
||||
|
||||
#disable_grub_settings
|
||||
update_grub
|
||||
snapshot_submenu_clean
|
||||
set_grub_setting SUSE_DISABLE_BOOTING_SNAPSHOT true
|
||||
set_grub_setting SUSE_ENABLE_CUSTOM_SNAPSHOT_SUBMENU false
|
||||
update_grub_cfg
|
||||
|
||||
fi
|
||||
|
||||
if [ x${opt_refresh} = "xtrue" ]; then
|
||||
|
||||
snapshot_submenu_refresh
|
||||
grub_snapshot_cfg_refresh
|
||||
|
||||
snapper_snapshots_cfg_refresh
|
||||
fi
|
||||
|
||||
if [ x${opt_clean} = "xtrue" ]; then
|
||||
|
||||
snapshot_submenu_clean
|
||||
grub_snapshot_cfg_refresh
|
||||
|
||||
fi
|
||||
|
||||
|
@ -1,3 +1,44 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Aug 27 07:53:35 UTC 2014 - schwab@suse.de
|
||||
|
||||
- aarch64-reloc.patch: replace with upstream solution
|
||||
|
||||
-------------------------------------------------------------------
|
||||
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
|
||||
|
||||
- fix openqa boot error on separate boot partition
|
||||
* refresh grub2-btrfs-05-grub2-mkconfig.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Aug 21 06:10:07 UTC 2014 - mchang@suse.com
|
||||
|
||||
- update snapper plugin for rollback support
|
||||
* refresh grub2-snapper-plugin.sh
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Aug 15 07:55:54 UTC 2014 - mchang@suse.com
|
||||
|
||||
- snapper rollback support patches.
|
||||
- rename patch
|
||||
* 0002-btrfs-add-ability-to-boot-from-subvolumes.patch to
|
||||
grub2-btrfs-01-add-ability-to-boot-from-subvolumes.patch
|
||||
* 0004-btrfs-export-subvolume-envvars.patch to
|
||||
grub2-btrfs-02-export-subvolume-envvars.patch
|
||||
- added patches
|
||||
* grub2-btrfs-03-follow_default.patch
|
||||
* grub2-btrfs-04-grub2-install.patch
|
||||
* grub2-btrfs-05-grub2-mkconfig.patch
|
||||
- remove patch
|
||||
* 0003-cmdline-add-envvar-loader_cmdline_append.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Aug 14 06:35:58 UTC 2014 - mchang@suse.com
|
||||
|
||||
|
14
grub2.spec
14
grub2.spec
@ -151,11 +151,11 @@ Patch40: aarch64-reloc.patch
|
||||
Patch41: grub2-vbe-blacklist-preferred-1440x900x32.patch
|
||||
Patch42: grub2-btrfs-fix-incorrect-address-reference.patch
|
||||
# Btrfs snapshot booting related patches
|
||||
Patch101: 0002-btrfs-add-ability-to-boot-from-subvolumes.patch
|
||||
Patch102: 0003-cmdline-add-envvar-loader_cmdline_append.patch
|
||||
Patch103: 0004-btrfs-export-subvolume-envvars.patch
|
||||
Patch110: 0001-script-provide-overridable-root-by-subvol.patch
|
||||
Patch111: 0002-script-create-menus-for-btrfs-snapshot.patch
|
||||
Patch101: grub2-btrfs-01-add-ability-to-boot-from-subvolumes.patch
|
||||
Patch102: grub2-btrfs-02-export-subvolume-envvars.patch
|
||||
Patch103: grub2-btrfs-03-follow_default.patch
|
||||
Patch104: grub2-btrfs-04-grub2-install.patch
|
||||
Patch105: grub2-btrfs-05-grub2-mkconfig.patch
|
||||
# PowerPC LE support
|
||||
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
|
||||
@ -354,8 +354,8 @@ mv po/grub.pot po/%{name}.pot
|
||||
%patch101 -p1
|
||||
%patch102 -p1
|
||||
%patch103 -p1
|
||||
%patch110 -p1
|
||||
%patch111 -p1
|
||||
%patch104 -p1
|
||||
%patch105 -p1
|
||||
%patch201 -p1
|
||||
%patch202 -p1
|
||||
%patch203 -p1
|
||||
|
Loading…
Reference in New Issue
Block a user