Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package grub2 for openSUSE:Factory checked 
in at 2021-09-08 21:36:34
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/grub2 (Old)
 and      /work/SRC/openSUSE:Factory/.grub2.new.1899 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "grub2"

Wed Sep  8 21:36:34 2021 rev:249 rq:917187 version:2.06

Changes:
--------
--- /work/SRC/openSUSE:Factory/grub2/grub2.changes      2021-08-24 
10:54:55.844316347 +0200
+++ /work/SRC/openSUSE:Factory/.grub2.new.1899/grub2.changes    2021-09-08 
21:36:50.429904188 +0200
@@ -1,0 +2,22 @@
+Tue Sep  7 02:32:30 UTC 2021 - Michael Chang <mch...@suse.com>
+
+- Follow usr merge for looking up kernel config (bsc#1189782) (bsc#1190061)
+  * 0001-templates-Follow-the-path-of-usr-merged-kernel-confi.patch
+
+-------------------------------------------------------------------
+Wed Sep  1 05:49:47 UTC 2021 - Michael Chang <mch...@suse.com>
+
+- Add btrfs zstd compression on i386-pc and also make sure it won't break
+  existing grub installations (bsc#1161823)
+  * deleted 0001-btrfs-disable-zstd-support-for-i386-pc.patch
+  * added 0001-i386-pc-build-btrfs-zstd-support-into-separate-modul.patch
+
+-------------------------------------------------------------------
+Tue Aug 31 05:56:56 UTC 2021 - Petr Vorel <pvo...@suse.cz>
+
+- Delete the author list from %description (the %description section is
+  literally for package descriptions (only) these days, encoding was also
+  problematic).
+- Add %doc AUTHORS to get packaged that info
+
+-------------------------------------------------------------------

Old:
----
  0001-btrfs-disable-zstd-support-for-i386-pc.patch

New:
----
  0001-i386-pc-build-btrfs-zstd-support-into-separate-modul.patch
  0001-templates-Follow-the-path-of-usr-merged-kernel-confi.patch

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

Other differences:
------------------
++++++ grub2.spec ++++++
--- /var/tmp/diff_new_pack.F9CBxG/_old  2021-09-08 21:36:52.341906427 +0200
+++ /var/tmp/diff_new_pack.F9CBxG/_new  2021-09-08 21:36:52.341906427 +0200
@@ -235,7 +235,6 @@
 Patch108:       grub2-btrfs-08-workaround-snapshot-menu-default-entry.patch
 Patch109:       grub2-btrfs-09-get-default-subvolume.patch
 Patch110:       grub2-btrfs-10-config-directory.patch
-Patch111:       0001-btrfs-disable-zstd-support-for-i386-pc.patch
 # Support EFI xen loader
 Patch120:       grub2-efi-xen-chainload.patch
 Patch121:       grub2-efi-chainloader-root.patch
@@ -306,6 +305,8 @@
 Patch788:       0001-ieee1275-Avoiding-many-unecessary-open-close.patch
 Patch789:       0001-Workaround-volatile-efi-boot-variable.patch
 Patch790:       0001-30_uefi-firmware-fix-printf-format-with-null-byte.patch
+Patch791:       0001-i386-pc-build-btrfs-zstd-support-into-separate-modul.patch
+Patch792:       0001-templates-Follow-the-path-of-usr-merged-kernel-confi.patch
 
 Requires:       gettext-runtime
 %if 0%{?suse_version} >= 1140
@@ -348,17 +349,6 @@
 
 This package includes user space utlities to manage GRUB on your system.
 
-
-Authors:
---------
-    Gordon Matzigkeit
-    Yoshinori K. Okuji
-    Colin Watson
-    Colin D. Bennett
-    Vesa J????skel??inen
-    Robert Millan
-    Carles Pina
-
 %package branding-upstream
 
 Summary:        Upstream branding for GRUB2's graphical console
@@ -999,6 +989,7 @@
 %else
 %license COPYING
 %endif
+%doc AUTHORS
 %doc NEWS README
 %doc THANKS TODO ChangeLog
 %doc docs/autoiso.cfg docs/osdetect.cfg

++++++ 0001-i386-pc-build-btrfs-zstd-support-into-separate-modul.patch ++++++
>From e7fe15db1736e038a7705973424708d3151fde99 Mon Sep 17 00:00:00 2001
From: Michael Chang <mch...@suse.com>
Date: Thu, 12 Aug 2021 21:43:22 +0800
Subject: [PATCH] i386-pc: build btrfs zstd support into separate module

The zstd support in btrfs brings significant size increment to the
on-disk image that it can no longer fit into btrfs bootloader area and
short mbr gap.

In order to support grub update on outstanding i386-pc setup with these
size constraints remain in place, here we build the zstd suppprt of
btrfs into a separate module, named btrfs_zstd, to alleviate the size
change. Please note this only makes it's way to i386-pc, other
architecture is not affected.

Therefore if the system has enough space of embedding area for grub then
zstd support for btrfs will be enabled automatically in the process of
running grub-install through inserting btrfs_zstd module to the on-disk
image, otherwise a warning will be logged on screen to indicate user
that zstd support for btrfs is disabled due to the size limit.

Signed-off-by: Michael Chang <mch...@suse.com>
---
 Makefile.util.def           |   1 +
 grub-core/Makefile.core.def |  11 ++++
 grub-core/fs/btrfs.c        | 114 +++++---------------------------
 grub-core/fs/btrfs_zstd.c   |  36 +++++++++++
 grub-core/lib/zstd.c        | 126 ++++++++++++++++++++++++++++++++++++
 include/grub/btrfs.h        |   6 ++
 include/grub/lib/zstd.h     |  26 ++++++++
 include/grub/util/install.h |   2 +
 util/grub-install.c         |  20 ++++++
 util/setup.c                |  43 ++++++++++++
 10 files changed, 288 insertions(+), 97 deletions(-)
 create mode 100644 grub-core/fs/btrfs_zstd.c
 create mode 100644 grub-core/lib/zstd.c
 create mode 100644 include/grub/lib/zstd.h

diff --git a/Makefile.util.def b/Makefile.util.def
index 2f2881cb7..ac2b6aab1 100644
--- a/Makefile.util.def
+++ b/Makefile.util.def
@@ -176,6 +176,7 @@ library = {
   common = grub-core/lib/zstd/xxhash.c;
   common = grub-core/lib/zstd/zstd_common.c;
   common = grub-core/lib/zstd/zstd_decompress.c;
+  common = grub-core/lib/zstd.c;
 };
 
 program = {
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index dd1777bd3..b5328d7a0 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -1370,10 +1370,21 @@ module = {
   name = btrfs;
   common = fs/btrfs.c;
   common = lib/crc.c;
+  nopc = lib/zstd.c;
   cflags = '$(CFLAGS_POSIX) -Wno-undef';
+  i386_pc_cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/minilzo 
-DMINILZO_HAVE_CONFIG_H';
   cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/minilzo 
-I$(srcdir)/lib/zstd -DMINILZO_HAVE_CONFIG_H';
 };
 
+module = {
+  name = btrfs_zstd;
+  common = fs/btrfs_zstd.c;
+  common = lib/zstd.c;
+  cflags = '$(CFLAGS_POSIX) -Wno-undef';
+  cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/zstd';
+  enable = i386_pc;
+};
+
 module = {
   name = archelp;
   common = fs/archelp.c;
diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
index c908b460f..9625bdf16 100644
--- a/grub-core/fs/btrfs.c
+++ b/grub-core/fs/btrfs.c
@@ -17,14 +17,6 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/*
- * Tell zstd to expose functions that aren't part of the stable API, which
- * aren't safe to use when linking against a dynamic library. We vendor in a
- * specific zstd version, so we know what we're getting. We need these unstable
- * functions to provide our own allocator, which uses grub_malloc(), to zstd.
- */
-#define ZSTD_STATIC_LINKING_ONLY
-
 #include <grub/err.h>
 #include <grub/file.h>
 #include <grub/mm.h>
@@ -35,7 +27,9 @@
 #include <grub/lib/crc.h>
 #include <grub/deflate.h>
 #include <minilzo.h>
-#include <zstd.h>
+#ifndef GRUB_MACHINE_PCBIOS
+#include <grub/lib/zstd.h>
+#endif
 #include <grub/i18n.h>
 #include <grub/btrfs.h>
 #include <grub/crypto.h>
@@ -61,12 +55,15 @@ GRUB_MOD_LICENSE ("GPLv3+");
 #define GRUB_BTRFS_LZO_BLOCK_MAX_CSIZE (GRUB_BTRFS_LZO_BLOCK_SIZE + \
                                     (GRUB_BTRFS_LZO_BLOCK_SIZE / 16) + 64 + 3)
 
-#define ZSTD_BTRFS_MAX_WINDOWLOG 17
-#define ZSTD_BTRFS_MAX_INPUT     (1 << ZSTD_BTRFS_MAX_WINDOWLOG)
-
 typedef grub_uint8_t grub_btrfs_checksum_t[0x20];
 typedef grub_uint16_t grub_btrfs_uuid_t[8];
 
+#ifdef GRUB_MACHINE_PCBIOS
+grub_ssize_t (*grub_btrfs_zstd_decompress_func) (char *ibuf,
+       grub_size_t isize, grub_off_t off,
+       char *obuf, grub_size_t osize) = NULL;
+#endif
+
 struct grub_btrfs_device
 {
   grub_uint64_t device_id;
@@ -1392,94 +1389,17 @@ grub_btrfs_read_inode (struct grub_btrfs_data *data,
   return grub_btrfs_read_logical (data, elemaddr, inode, sizeof (*inode), 0);
 }
 
-static void *grub_zstd_malloc (void *state __attribute__((unused)), size_t 
size)
-{
-  return grub_malloc (size);
-}
-
-static void grub_zstd_free (void *state __attribute__((unused)), void *address)
-{
-  return grub_free (address);
-}
-
-static ZSTD_customMem grub_zstd_allocator (void)
-{
-  ZSTD_customMem allocator;
-
-  allocator.customAlloc = &grub_zstd_malloc;
-  allocator.customFree = &grub_zstd_free;
-  allocator.opaque = NULL;
-
-  return allocator;
-}
-
-static grub_ssize_t
+static inline grub_ssize_t
 grub_btrfs_zstd_decompress (char *ibuf, grub_size_t isize, grub_off_t off,
                            char *obuf, grub_size_t osize)
 {
-  void *allocated = NULL;
-  char *otmpbuf = obuf;
-  grub_size_t otmpsize = osize;
-  ZSTD_DCtx *dctx = NULL;
-  grub_size_t zstd_ret;
-  grub_ssize_t ret = -1;
-
-  /*
-   * Zstd will fail if it can't fit the entire output in the destination
-   * buffer, so if osize isn't large enough, allocate a temporary buffer.
-   */
-  if (otmpsize < ZSTD_BTRFS_MAX_INPUT)
-    {
-      allocated = grub_malloc (ZSTD_BTRFS_MAX_INPUT);
-      if (!allocated)
-       {
-         grub_error (GRUB_ERR_OUT_OF_MEMORY, "failed allocate a zstd buffer");
-         goto err;
-       }
-      otmpbuf = (char *) allocated;
-      otmpsize = ZSTD_BTRFS_MAX_INPUT;
-    }
-
-  /* Create the ZSTD_DCtx. */
-  dctx = ZSTD_createDCtx_advanced (grub_zstd_allocator ());
-  if (!dctx)
-    {
-      /* ZSTD_createDCtx_advanced() only fails if it is out of memory. */
-      grub_error (GRUB_ERR_OUT_OF_MEMORY, "failed to create a zstd context");
-      goto err;
-    }
-
-  /*
-   * Get the real input size, there may be junk at the
-   * end of the frame.
-   */
-  isize = ZSTD_findFrameCompressedSize (ibuf, isize);
-  if (ZSTD_isError (isize))
-    {
-      grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "zstd data corrupted");
-      goto err;
-    }
-
-  /* Decompress and check for errors. */
-  zstd_ret = ZSTD_decompressDCtx (dctx, otmpbuf, otmpsize, ibuf, isize);
-  if (ZSTD_isError (zstd_ret))
-    {
-      grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "zstd data corrupted");
-      goto err;
-    }
-
-  /*
-   * Move the requested data into the obuf. obuf may be equal
-   * to otmpbuf, which is why grub_memmove() is required.
-   */
-  grub_memmove (obuf, otmpbuf + off, osize);
-  ret = osize;
-
-err:
-  grub_free (allocated);
-  ZSTD_freeDCtx (dctx);
-
-  return ret;
+#ifdef GRUB_MACHINE_PCBIOS
+  if (!grub_btrfs_zstd_decompress_func)
+    return -1;
+  return grub_btrfs_zstd_decompress_func (ibuf, isize, off, obuf, osize);
+#else
+  return grub_zstd_decompress (ibuf, isize, off, obuf, osize);
+#endif
 }
 
 static grub_ssize_t
diff --git a/grub-core/fs/btrfs_zstd.c b/grub-core/fs/btrfs_zstd.c
new file mode 100644
index 000000000..d5d1e013c
--- /dev/null
+++ b/grub-core/fs/btrfs_zstd.c
@@ -0,0 +1,36 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2008  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/>.
+ */
+
+#include <grub/types.h>
+#include <grub/dl.h>
+/* For NULL.  */
+#include <grub/mm.h>
+#include <grub/btrfs.h>
+#include <grub/lib/zstd.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+GRUB_MOD_INIT (btrfs_zstd)
+{
+  grub_btrfs_zstd_decompress_func = grub_zstd_decompress;
+}
+
+GRUB_MOD_FINI (btrfs_zstd)
+{
+  grub_btrfs_zstd_decompress_func = NULL;
+}
diff --git a/grub-core/lib/zstd.c b/grub-core/lib/zstd.c
new file mode 100644
index 000000000..643e90d84
--- /dev/null
+++ b/grub-core/lib/zstd.c
@@ -0,0 +1,126 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2008  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/>.
+ */
+
+/*
+ * Tell zstd to expose functions that aren't part of the stable API, which
+ * aren't safe to use when linking against a dynamic library. We vendor in a
+ * specific zstd version, so we know what we're getting. We need these unstable
+ * functions to provide our own allocator, which uses grub_malloc(), to zstd.
+ */
+#define ZSTD_STATIC_LINKING_ONLY
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/lib/zstd.h>
+#include <zstd.h>
+
+#define ZSTD_MAX_WINDOWLOG 17
+#define ZSTD_MAX_INPUT     (1 << ZSTD_MAX_WINDOWLOG)
+
+static void *grub_zstd_malloc (void *state __attribute__((unused)), size_t 
size)
+{
+  return grub_malloc (size);
+}
+
+static void grub_zstd_free (void *state __attribute__((unused)), void *address)
+{
+  return grub_free (address);
+}
+
+static ZSTD_customMem grub_zstd_allocator (void)
+{
+  ZSTD_customMem allocator;
+
+  allocator.customAlloc = &grub_zstd_malloc;
+  allocator.customFree = &grub_zstd_free;
+  allocator.opaque = NULL;
+
+  return allocator;
+}
+
+grub_ssize_t
+grub_zstd_decompress (char *ibuf, grub_size_t isize, grub_off_t off,
+                char *obuf, grub_size_t osize)
+{
+  void *allocated = NULL;
+  char *otmpbuf = obuf;
+  grub_size_t otmpsize = osize;
+  ZSTD_DCtx *dctx = NULL;
+  grub_size_t zstd_ret;
+  grub_ssize_t ret = -1;
+
+  /*
+   * Zstd will fail if it can't fit the entire output in the destination
+   * buffer, so if osize isn't large enough, allocate a temporary buffer.
+   */
+  if (otmpsize < ZSTD_MAX_INPUT)
+    {
+      allocated = grub_malloc (ZSTD_MAX_INPUT);
+      if (!allocated)
+       {
+         grub_error (GRUB_ERR_OUT_OF_MEMORY, "failed allocate a zstd buffer");
+         goto err;
+       }
+      otmpbuf = (char *) allocated;
+      otmpsize = ZSTD_MAX_INPUT;
+    }
+
+  /* Create the ZSTD_DCtx. */
+  dctx = ZSTD_createDCtx_advanced (grub_zstd_allocator ());
+  if (!dctx)
+    {
+      /* ZSTD_createDCtx_advanced() only fails if it is out of memory. */
+      grub_error (GRUB_ERR_OUT_OF_MEMORY, "failed to create a zstd context");
+      goto err;
+    }
+
+  /*
+   * Get the real input size, there may be junk at the
+   * end of the frame.
+   */
+  isize = ZSTD_findFrameCompressedSize (ibuf, isize);
+  if (ZSTD_isError (isize))
+    {
+      grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "zstd data corrupted");
+      goto err;
+    }
+
+  /* Decompress and check for errors. */
+  zstd_ret = ZSTD_decompressDCtx (dctx, otmpbuf, otmpsize, ibuf, isize);
+  if (ZSTD_isError (zstd_ret))
+    {
+      grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "zstd data corrupted");
+      goto err;
+    }
+
+  /*
+   * Move the requested data into the obuf. obuf may be equal
+   * to otmpbuf, which is why grub_memmove() is required.
+   */
+  grub_memmove (obuf, otmpbuf + off, osize);
+  ret = osize;
+
+err:
+  grub_free (allocated);
+  ZSTD_freeDCtx (dctx);
+
+  return ret;
+}
+
diff --git a/include/grub/btrfs.h b/include/grub/btrfs.h
index 234ad9767..f8e551982 100644
--- a/include/grub/btrfs.h
+++ b/include/grub/btrfs.h
@@ -69,4 +69,10 @@ struct grub_btrfs_inode_ref
   char name[0];
 };
 
+#ifdef GRUB_MACHINE_PCBIOS
+extern grub_ssize_t (*EXPORT_VAR (grub_btrfs_zstd_decompress_func)) (char 
*ibuf,
+               grub_size_t isize, grub_off_t off,
+               char *obuf, grub_size_t osize);
+#endif
+
 #endif
diff --git a/include/grub/lib/zstd.h b/include/grub/lib/zstd.h
new file mode 100644
index 000000000..0867b0c34
--- /dev/null
+++ b/include/grub/lib/zstd.h
@@ -0,0 +1,26 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2008  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/>.
+ */
+
+#ifndef GRUB_ZSTD_HEADER
+#define GRUB_ZSTD_HEADER       1
+
+grub_ssize_t
+grub_zstd_decompress (char *ibuf, grub_size_t isize, grub_off_t off,
+                char *obuf, grub_size_t osize);
+
+#endif /* ! GRUB_ZSTD_HEADER */
diff --git a/include/grub/util/install.h b/include/grub/util/install.h
index faf9ff1ab..9e83e1339 100644
--- a/include/grub/util/install.h
+++ b/include/grub/util/install.h
@@ -208,6 +208,8 @@ grub_util_sparc_setup (const char *dir,
                       const char *dest, int force,
                       int fs_probe, int allow_floppy,
                       int add_rs_codes, int warn_short_mbr_gap);
+int
+grub_util_try_partmap_embed (const char *dest, unsigned int *nsec);
 
 char *
 grub_install_get_image_targets_string (void);
diff --git a/util/grub-install.c b/util/grub-install.c
index 891e3ced8..a2286b3dd 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -1482,6 +1482,26 @@ main (int argc, char *argv[])
        }
     }
 
+  if (install_drive
+      && platform == GRUB_INSTALL_PLATFORM_I386_PC
+      && grub_strcmp (grub_fs->name, "btrfs") == 0)
+    {
+      char *mod;
+      mod = grub_util_path_concat (2, grub_install_source_directory, 
"btrfs_zstd.mod");
+      if (grub_util_is_regular (mod))
+       {
+          unsigned int nsec = GRUB_MIN_RECOMMENDED_MBR_GAP;
+         int ret = grub_util_try_partmap_embed (install_drive, &nsec);
+         if (ret == 0)
+           grub_install_push_module ("btrfs_zstd");
+         else if (ret == 1)
+           grub_util_warn ("%s", _("btrfs zstd compression is disabled, please 
change install device to disk"));
+         else
+           grub_util_warn ("%s", _("btrfs zstd compression is disabled due to 
not enough space to embed image"));
+       }
+      grub_free (mod);
+    }
+
   if (!have_abstractions)
     {
       if ((disk_module && grub_strcmp (disk_module, "biosdisk") != 0)
diff --git a/util/setup.c b/util/setup.c
index 980e74374..6604d86bb 100644
--- a/util/setup.c
+++ b/util/setup.c
@@ -241,6 +241,49 @@ identify_partmap (grub_disk_t disk __attribute__ 
((unused)),
   return 1;
 }
 
+#ifdef GRUB_SETUP_BIOS
+int
+grub_util_try_partmap_embed (const char *dest, unsigned int *nsec)
+{
+  grub_device_t dest_dev;
+
+  dest_dev = grub_device_open (dest);
+  if (! dest_dev)
+    grub_util_error ("%s", grub_errmsg);
+
+  struct identify_partmap_ctx ctx = {
+    .dest_partmap = NULL,
+    .container = dest_dev->disk->partition,
+    .multiple_partmaps = 0
+  };
+
+  grub_partition_iterate (dest_dev->disk, identify_partmap, &ctx);
+
+  if (ctx.dest_partmap && ctx.dest_partmap->embed)
+    {
+      grub_err_t err;
+
+      grub_disk_addr_t *sectors = NULL;
+
+      err = ctx.dest_partmap->embed (dest_dev->disk, nsec, *nsec,
+                       GRUB_EMBED_PCBIOS, &sectors, 0);
+      if (err)
+       {
+         grub_errno = GRUB_ERR_NONE;
+          goto no_embed;
+       }
+      grub_free (sectors);
+      return 0;
+    }
+
+no_embed:
+  grub_device_close (dest_dev);
+  if (ctx.container)
+    return 1;
+  return 2;
+}
+#endif
+
 #ifdef GRUB_SETUP_BIOS
 #define SETUP grub_util_bios_setup
 #elif GRUB_SETUP_SPARC64
-- 
2.31.1

++++++ 0001-templates-Follow-the-path-of-usr-merged-kernel-confi.patch ++++++
>From 60d1d3b959e72c2cbd014be311c350a9b11b1289 Mon Sep 17 00:00:00 2001
From: Michael Chang <mch...@suse.com>
Date: Tue, 7 Sep 2021 10:06:50 +0800
Subject: [PATCH] templates: Follow the path of usr merged kernel config

The background for usr merge can be found at:

https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/

This patch adapts related mkconfig scripts to follow the usr merge for
looking up kernel configs.

Signed-off-by: Michael Chang <mch...@suse.com>
---
 util/grub.d/10_linux.in     | 2 +-
 util/grub.d/20_linux_xen.in | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index 7f3e79b09..00e351802 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -307,7 +307,7 @@ while [ "x$list" != "x" ] ; do
   fi
 
   config=
-  for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" 
"/etc/kernels/kernel-config-${version}" ; do
+  for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" 
"/etc/kernels/kernel-config-${version}" "/usr/lib/modules/${version}/config" ; 
do
     if test -e "${i}" ; then
       config="${i}"
       break
diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
index 8813435b7..318b6d320 100644
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -304,7 +304,7 @@ for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* /boot/kernel-*; do
        version=$(echo $basename | sed -e "s,^[^0-9]*-,,g")
        dirname=$(dirname $i)
        config=
-       for j in "${dirname}/config-${version}" 
"${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
+       for j in "${dirname}/config-${version}" 
"${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" 
"/usr/lib/modules/${version}/config" ; do
            if test -e "${j}" ; then
                config="${j}"
                break
-- 
2.33.0

Reply via email to