Hello community,

here is the log from the commit of package grub2 for openSUSE:Factory checked 
in at 2014-08-30 16:03:50
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/grub2 (Old)
 and      /work/SRC/openSUSE:Factory/.grub2.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "grub2"

Changes:
--------
--- /work/SRC/openSUSE:Factory/grub2/grub2.changes      2014-08-15 
09:55:43.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.grub2.new/grub2.changes 2014-08-30 
16:04:12.000000000 +0200
@@ -1,0 +2,41 @@
+Wed Aug 27 07:53:35 UTC 2014 - sch...@suse.de
+
+- aarch64-reloc.patch: replace with upstream solution
+
+-------------------------------------------------------------------
+Mon Aug 25 03:10:18 UTC 2014 - mch...@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 - mch...@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 - mch...@suse.com
+
+- update snapper plugin for rollback support
+  * refresh grub2-snapper-plugin.sh 
+
+-------------------------------------------------------------------
+Fri Aug 15 07:55:54 UTC 2014 - mch...@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
+  
+-------------------------------------------------------------------

Old:
----
  0001-script-provide-overridable-root-by-subvol.patch
  0002-btrfs-add-ability-to-boot-from-subvolumes.patch
  0002-script-create-menus-for-btrfs-snapshot.patch
  0003-cmdline-add-envvar-loader_cmdline_append.patch
  0004-btrfs-export-subvolume-envvars.patch

New:
----
  grub2-btrfs-01-add-ability-to-boot-from-subvolumes.patch
  grub2-btrfs-02-export-subvolume-envvars.patch
  grub2-btrfs-03-follow_default.patch
  grub2-btrfs-04-grub2-install.patch
  grub2-btrfs-05-grub2-mkconfig.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ grub2.spec ++++++
--- /var/tmp/diff_new_pack.jibj9k/_old  2014-08-30 16:04:14.000000000 +0200
+++ /var/tmp/diff_new_pack.jibj9k/_new  2014-08-30 16:04:14.000000000 +0200
@@ -151,11 +151,11 @@
 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 @@
 %patch101 -p1
 %patch102 -p1
 %patch103 -p1
-%patch110 -p1
-%patch111 -p1
+%patch104 -p1
+%patch105 -p1
 %patch201 -p1
 %patch202 -p1
 %patch203 -p1

++++++ aarch64-reloc.patch ++++++
--- /var/tmp/diff_new_pack.jibj9k/_old  2014-08-30 16:04:14.000000000 +0200
+++ /var/tmp/diff_new_pack.jibj9k/_new  2014-08-30 16:04:14.000000000 +0200
@@ -1,56 +1,27 @@
-From f472bc5ac54e72eb09b0606f588085af504d754b Mon Sep 17 00:00:00 2001
-From: Andreas Schwab <sch...@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 <arvidj...@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
 

++++++ grub2-btrfs-01-add-ability-to-boot-from-subvolumes.patch ++++++
++++ 696 lines (skipped)

++++++ grub2-btrfs-02-export-subvolume-envvars.patch ++++++
From: Michael Chang <mch...@suse.com>
Subject: export btrfs_subvol and btrfs_subvolid

We should export btrfs_subvol and btrfs_subvolid to have both visible 
to subsidiary configuration files loaded using configfile. 

Signed-off-by: Michael Chang <mch...@suse.com>

Index: grub-2.00/grub-core/fs/btrfs.c
===================================================================
--- grub-2.00.orig/grub-core/fs/btrfs.c
+++ grub-2.00/grub-core/fs/btrfs.c
@@ -2252,6 +2252,8 @@ GRUB_MOD_INIT (btrfs)
                                subvol_set_env);
   grub_register_variable_hook ("btrfs_subvolid", subvolid_get_env,
                                subvolid_set_env);
+  grub_env_export ("btrfs_subvol");
+  grub_env_export ("btrfs_subvolid");
 }
 
 GRUB_MOD_FINI (btrfs)
++++++ grub2-btrfs-03-follow_default.patch ++++++
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)
++++++ grub2-btrfs-04-grub2-install.patch ++++++
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);
++++++ grub2-btrfs-05-grub2-mkconfig.patch ++++++
---
 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`
++++++ grub2-snapper-plugin.sh ++++++
--- /var/tmp/diff_new_pack.jibj9k/_old  2014-08-30 16:04:15.000000000 +0200
+++ /var/tmp/diff_new_pack.jibj9k/_new  2014-08-30 16:04:15.000000000 +0200
@@ -18,117 +18,148 @@
 
 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}"
+
+# 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)"
+}
 
-rel_root=`"$grub_mkrelpath" /`
 
-snapshot_submenu_refresh () {
+snapshot_submenu () {
 
-for s_dir in /.snapshots/*; do
+  s_dir="$1"
 
   snapshot="${s_dir}/snapshot"
-  snapper_cfg="${s_dir}/${snapshot_submenu_name}"
+  num="`basename $s_dir`"
   
-  if [ ! -d "$snapshot" ]; then
-    rm -f "${snapper_cfg}"
-    rm -f "${s_dir}/${snapshot_menuentry_name}"
-    continue
-  fi
-
   # 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"
-  
-  for x in $cfgs; do
-    snap="${rel_root}${snapshot}"
-    snap_cfg="${rel_root}\$x"
-
-    if [ -f "\$snap_cfg" ]; then
-      snapshot_found=true
-       submenu "$title" "\$snap" "\$snap_cfg" {
-               set subvol="\$2"
-               export subvol
-               source "\$3"
-       }
-      break
-    fi
-  done
-
 EOF
- 
-  if grub2-script-check "${snapper_cfg}.new"; then
-    mv -f "${snapper_cfg}.new" "${snapper_cfg}"
-  fi
+  hotkey=`incr_hotkey`
+  return 0
+}
 
-done
+snapper_snapshots_cfg_refresh () {
 
-}
+  if [ ! -d "$snapper_snapshot_path" ]; then
+    return
+  fi
 
-grub_snapshot_cfg_refresh () {
+  for s_dir in ${snapper_snapshot_path}/*; do
 
-: > "${grub_snapshot_cfg}.tmp"
-for s_dir in /.snapshots/*; do
+    snapshot="${s_dir}/snapshot"
 
-  snapshot="${s_dir}/snapshot"
-  snapper_cfg="${s_dir}/${snapshot_submenu_name}"
+    # 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
 
-  if [ -f "${snapper_cfg}" ]; then
-    echo "source ${rel_root}${snapper_cfg}" >>"${grub_snapshot_cfg}.tmp"
-    continue
-  fi
+  done
 
-done
+  hk=""
+  [ -z "$hotkey" ] || hk="--hotkey=s"
 
-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
+  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
 
-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 @@
   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 () {
+enable_grub_settings () {
+  set_grub_setting SUSE_BTRFS_SNAPSHOT_BOOTING "true"
+}
 
-  "$grub_mkconfig" -o "$grub_cfg"
+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 @@
 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
+

-- 
To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org
For additional commands, e-mail: opensuse-commit+h...@opensuse.org

Reply via email to