Package: release.debian.org
Severity: normal
User: release.debian....@packages.debian.org
Usertags: unblock

Please unblock package grub2

Version -16 was unblocked in #770039 however a piuparts failure (#770412)
introduced in that version prevented it from propagating to testing.

In the -16 unblock Colin said:

> grub2 2.02~beta2-16 finishes off Xen host/guest integration.  GRUB has
> had most of this for a while, but the packaging work to make it possible
> to install grub-xen-host in the host, grub-xen in the guest, and then
> automatically boot GRUB in the guest wasn't present.
>
> I know this is a bit more than your standard unblock request, and indeed
> we're still waiting for this to pass through NEW.  But we're
> anticipating this being *really* useful for administrators of Xen
> hosting setups - it beats the messes that were PV-GRUB Legacy and
> PyGrub, or even keeping track of kernel versions by hand - and it would
> be fantastic to have this in jessie.

In addition -17 adds:

Related to the -16 changes:
- A fix for the piuparts failure (#770412)
- A typo fix (mismatched quotes) for the functionality introduced in -16
- A fix to update-grub which ensures that grub can actually load the Debian
  kernel under Xen (#755256). This is necessary because the Debian kernels are
  now xz compressed, which native kernels deal with internally but which the
  bootloader is required to deal with for Xen. Without this the functionality
  introduced here wouldn't actually be capable of booting Jessie without
  modifications, which would be unfortunate.

Unrelated to -16:
- A trivial typo fix (LP: #1390766) which fixes an error path in grub-mkconfig.
- Enables the "linuxefi" command for i386. This enables the potential for
  secure boot on x86 platforms with a 32-bit UEFI implementation (this
  functionality is already present for 64-bit grub.efi).

This last one is perhaps a bit controversial for an unblock request. The actual
change amounts to adding/correcting some casts to grub_addr_t in the existing
linuxefi code and enabling that module for the i386-efi build target. The
changes are all within the linuxefi code and AIUI can only have any impact if
the linuxefi command is explicitly used in the grub.cfg (which it is not by
default), so the risk of regressions to existing usecases is IMO low.

The incremental diff from -16 to -17 is below and the full -15 to -17 is
attached. These have been filtered to remove noise which git-dpm update-patches
introduces, essentiually changing the hashes in the From and index lines of any
patch which follows one which has changed. I couldn't figure out how to get
filterdiff to do anything sensible without listing each patch explicitly, so
I'm afraid I did this by hand.

I've also attached the patches-applied difference from -15 to -17 without the
debian dir since it is easier to read than the diff-of-a-diff.

Since the last version required a d-i ack I've CC-d Kibi preemptively.

diff -Nru grub2-2.02~beta2/debian/changelog grub2-2.02~beta2/debian/changelog
--- grub2-2.02~beta2/debian/changelog   2014-11-06 13:32:03.000000000 +0000
+++ grub2-2.02~beta2/debian/changelog   2014-11-30 17:15:23.000000000 +0000
@@ -1,3 +1,20 @@
+grub2 (2.02~beta2-17) unstable; urgency=medium
+
+  [ Colin Watson ]
+  * Fix up some pointer-to-integer casts in linuxefi so that it can build on
+    i386-efi.
+  * Backport from upstream:
+    - Fix typo (gettext_print instead of gettext_printf) (LP: #1390766).
+
+  [ Ian Campbell ]
+  * Correct syntax error in grub-xen-host bootstrap configuration file.
+  * Log failure when grub-install fails in postinst, rather than failing the
+    entire postinst. (Closes: #770412)
+  * Arrange to insmod xzio and lzopio when booting a kernel as a Xen guest.
+    (Closes: #755256)
+
+ -- Ian Campbell <i...@debian.org>  Sun, 30 Nov 2014 17:15:21 +0000
+
 grub2 (2.02~beta2-16) unstable; urgency=medium
 
   [ Ian Campbell ]
diff -Nru grub2-2.02~beta2/debian/.git-dpm grub2-2.02~beta2/debian/.git-dpm
--- grub2-2.02~beta2/debian/.git-dpm    2014-11-06 10:57:25.000000000 +0000
+++ grub2-2.02~beta2/debian/.git-dpm    2014-11-30 14:20:36.000000000 +0000
@@ -1,6 +1,6 @@
 # see git-dpm(1) from git-dpm package
-c211ee1c228bc978ffc4b399155ebfeb7524d2e0
-c211ee1c228bc978ffc4b399155ebfeb7524d2e0
+b837a9997cb306dc9aaeb3308f05d08cef402456
+b837a9997cb306dc9aaeb3308f05d08cef402456
 e8f07821cce1bd0ab6d5622c2a42440f15f4fd71
 e8f07821cce1bd0ab6d5622c2a42440f15f4fd71
 grub2_2.02~beta2.orig.tar.xz
diff -Nru grub2-2.02~beta2/debian/grub-xen-host_grub.cfg 
grub2-2.02~beta2/debian/grub-xen-host_grub.cfg
--- grub2-2.02~beta2/debian/grub-xen-host_grub.cfg      2014-11-06 
10:57:25.000000000 +0000
+++ grub2-2.02~beta2/debian/grub-xen-host_grub.cfg      2014-11-30 
14:20:34.000000000 +0000
@@ -1,13 +1,13 @@
 # First search for a suitable grub to chainload
 if search -s -f /boot/xen/pvboot-@@PVBOOT_ARCH@@.elf ; then
        echo "Chainloading (${root})/boot/xen/pvboot-@@PVBOOT_ARCH@@.elf"
-       multiboot /boot/xen/pvboot-@@PVBOOT_ARCH@@.elf"
+       multiboot "/boot/xen/pvboot-@@PVBOOT_ARCH@@.elf"
        boot
 fi
 
 if search -s -f /xen/pvboot-@@PVBOOT_ARCH@@.elf ; then
        echo "Chainloading (${root})/xen/pvboot-@@PVBOOT_ARCH@@.elf"
-       multiboot /xen/pvboot-@@PVBOOT_ARCH@@.elf"
+       multiboot "/xen/pvboot-@@PVBOOT_ARCH@@.elf"
        boot
 fi
 
diff -Nru grub2-2.02~beta2/debian/patches/gettext-print-typo.patch 
grub2-2.02~beta2/debian/patches/gettext-print-typo.patch
--- grub2-2.02~beta2/debian/patches/gettext-print-typo.patch    1970-01-01 
01:00:00.000000000 +0100
+++ grub2-2.02~beta2/debian/patches/gettext-print-typo.patch    2014-11-30 
14:20:34.000000000 +0000
@@ -0,0 +1,27 @@
+From 20886bef9351d5c20a9de1fb3339fe40114f01d1 Mon Sep 17 00:00:00 2001
+From: Andrey Borzenkov <arvidj...@gmail.com>
+Date: Thu, 14 Aug 2014 21:02:31 +0400
+Subject: Fix typo (gettext_print instead of gettext_printf)
+
+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1390766
+Origin: upstream, 
http://git.savannah.gnu.org/gitweb/?p=grub.git;a=commitdiff;h=c291f47b2c003ef6daeafaedd458db838bad6fb8
+Last-Update: 2014-11-18
+
+Patch-Name: gettext-print-typo.patch
+---
+ util/grub-mkconfig.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
+index ccce9e5..4641563 100644
+--- a/util/grub-mkconfig.in
++++ b/util/grub-mkconfig.in
+@@ -131,7 +131,7 @@ set $grub_probe dummy
+ if test -f "$1"; then
+     :
+ else
+-    gettext_print "%s: Not found.\n" "$1" 1>&2
++    gettext_printf "%s: Not found.\n" "$1" 1>&2
+     exit 1
+ fi
+ 
diff -Nru grub2-2.02~beta2/debian/patches/insmod-xzio-and-lzopio-on-xen.patch 
grub2-2.02~beta2/debian/patches/insmod-xzio-and-lzopio-on-xen.patch
--- grub2-2.02~beta2/debian/patches/insmod-xzio-and-lzopio-on-xen.patch 
1970-01-01 01:00:00.000000000 +0100
+++ grub2-2.02~beta2/debian/patches/insmod-xzio-and-lzopio-on-xen.patch 
2014-11-30 14:20:36.000000000 +0000
@@ -0,0 +1,33 @@
+From b837a9997cb306dc9aaeb3308f05d08cef402456 Mon Sep 17 00:00:00 2001
+From: Ian Campbell <i...@debian.org>
+Date: Sun, 30 Nov 2014 12:12:52 +0000
+Subject: Arrange to insmod xzio and lzopio when booting a kernel as a Xen
+ guest
+
+This is needed in case the Linux kernel is compiled with CONFIG_KERNEL_XZ or
+CONFIG_KERNEL_LZO rather than CONFIG_KERNEL_GZ (gzio is already loaded by
+grub.cfg today).
+
+Signed-off-by: Ian Campbell <i...@debian.org>
+
+Bug-Debian: https://bugs.debian.org/755256
+Forwarded: http://lists.gnu.org/archive/html/grub-devel/2014-11/msg00091.html
+Last-Update: 2014-11-30
+
+Patch-Name: insmod-xzio-and-lzopio-on-xen.patch
+---
+ util/grub.d/10_linux.in | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
+index 79fa03a..86e35f2 100644
+--- a/util/grub.d/10_linux.in
++++ b/util/grub.d/10_linux.in
+@@ -150,6 +150,7 @@ linux_entry ()
+   fi
+ 
+   echo "      insmod gzio" | sed "s/^/$submenu_indentation/"
++  echo "      if [ x\$grub_platform = xxen ]; then insmod xzio; insmod 
lzopio; fi" | sed "s/^/$submenu_indentation/"
+ 
+   if [ x$dirname = x/ ]; then
+     if [ -z "${prepare_root_cache}" ]; then
diff -Nru grub2-2.02~beta2/debian/patches/linuxefi_amd64_only.patch 
grub2-2.02~beta2/debian/patches/linuxefi_amd64_only.patch
--- grub2-2.02~beta2/debian/patches/linuxefi_amd64_only.patch   2014-10-24 
08:43:11.000000000 +0100
+++ grub2-2.02~beta2/debian/patches/linuxefi_amd64_only.patch   1970-01-01 
01:00:00.000000000 +0100
@@ -1,25 +0,0 @@
-From d17d82d5217170e5f3124ed1c5aa77a7b8f253d7 Mon Sep 17 00:00:00 2001
-From: Colin Watson <cjwat...@ubuntu.com>
-Date: Mon, 13 Jan 2014 12:13:16 +0000
-Subject: Only build linuxefi on amd64
-
-Forwarded: no
-Last-Update: 2013-12-25
-
-Patch-Name: linuxefi_amd64_only.patch
----
- grub-core/Makefile.core.def | 1 -
- 1 file changed, 1 deletion(-)
-
-diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
-index 8c246c6..8fed2fb 100644
---- a/grub-core/Makefile.core.def
-+++ b/grub-core/Makefile.core.def
-@@ -1709,7 +1709,6 @@ module = {
-   name = linuxefi;
-   efi = loader/i386/efi/linux.c;
-   efi = lib/cmdline.c;
--  enable = i386_efi;
-   enable = x86_64_efi;
- };
- 
diff -Nru grub2-2.02~beta2/debian/patches/linuxefi_debug.patch 
grub2-2.02~beta2/debian/patches/linuxefi_debug.patch
--- grub2-2.02~beta2/debian/patches/linuxefi_debug.patch        2014-10-24 
08:43:11.000000000 +0100
+++ grub2-2.02~beta2/debian/patches/linuxefi_debug.patch        2014-11-30 
14:20:34.000000000 +0000
@@ -1,4 +1,4 @@
-From 935cb0d861b3e0a0ab9340f7f1527fa1d0d388af Mon Sep 17 00:00:00 2001
+From 755d4a32dc78349fb80a966e9fb150bc8cfd6426 Mon Sep 17 00:00:00 2001
 From: Colin Watson <cjwat...@ubuntu.com>
 Date: Mon, 13 Jan 2014 12:13:18 +0000
 Subject: Add more debugging to linuxefi
@@ -12,7 +12,7 @@
  1 file changed, 25 insertions(+), 3 deletions(-)
 
 diff --git a/grub-core/loader/i386/efi/linux.c 
b/grub-core/loader/i386/efi/linux.c
-index b79e632..a124c5e 100644
+index ebaf1db..2bf38fa 100644
 --- a/grub-core/loader/i386/efi/linux.c
 +++ b/grub-core/loader/i386/efi/linux.c
 @@ -19,6 +19,7 @@
@@ -61,7 +61,7 @@
 +  grub_dprintf ("linuxefi", "initrd_mem = %lx\n", (unsigned long) initrd_mem);
 +
    params->ramdisk_size = size;
-   params->ramdisk_image = (grub_uint32_t)(grub_uint64_t) initrd_mem;
+   params->ramdisk_image = (grub_uint32_t)(grub_addr_t) initrd_mem;
  
 @@ -236,6 +251,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ 
((unused)),
        goto fail;
diff -Nru grub2-2.02~beta2/debian/patches/linuxefi.patch 
grub2-2.02~beta2/debian/patches/linuxefi.patch
--- grub2-2.02~beta2/debian/patches/linuxefi.patch      2014-10-24 
08:43:11.000000000 +0100
+++ grub2-2.02~beta2/debian/patches/linuxefi.patch      2014-11-30 
14:20:34.000000000 +0000
@@ -1,11 +1,11 @@
-From 2359f527c5091fb6633eec1b165db05c07eb83cf Mon Sep 17 00:00:00 2001
+From e4951626e0ab33c446cfd7e9a22044f602ca0106 Mon Sep 17 00:00:00 2001
 From: Matthew Garrett <m...@redhat.com>
 Date: Mon, 13 Jan 2014 12:13:15 +0000
 Subject: Add "linuxefi" loader which avoids ExitBootServices
 
 Origin: vendor, 
http://pkgs.fedoraproject.org/cgit/grub2.git/tree/grub2-linuxefi.patch
 Forwarded: no
-Last-Update: 2013-12-25
+Last-Update: 2014-11-18
 
 Patch-Name: linuxefi.patch
 ---
@@ -81,7 +81,7 @@
  grub_efi_allocate_pages (grub_efi_physical_address_t address,
 diff --git a/grub-core/loader/i386/efi/linux.c 
b/grub-core/loader/i386/efi/linux.c
 new file mode 100644
-index 0000000..b79e632
+index 0000000..ebaf1db
 --- /dev/null
 +++ b/grub-core/loader/i386/efi/linux.c
 @@ -0,0 +1,371 @@
@@ -181,13 +181,13 @@
 +  grub_dl_unref (my_mod);
 +  loaded = 0;
 +  if (initrd_mem)
-+    grub_efi_free_pages((grub_efi_physical_address_t)initrd_mem, 
BYTES_TO_PAGES(params->ramdisk_size));
++    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)initrd_mem, 
BYTES_TO_PAGES(params->ramdisk_size));
 +  if (linux_cmdline)
-+    grub_efi_free_pages((grub_efi_physical_address_t)linux_cmdline, 
BYTES_TO_PAGES(params->cmdline_size + 1));
++    
grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)linux_cmdline, 
BYTES_TO_PAGES(params->cmdline_size + 1));
 +  if (kernel_mem)
-+    grub_efi_free_pages((grub_efi_physical_address_t)kernel_mem, 
BYTES_TO_PAGES(kernel_size));
++    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)kernel_mem, 
BYTES_TO_PAGES(kernel_size));
 +  if (params)
-+    grub_efi_free_pages((grub_efi_physical_address_t)params, 
BYTES_TO_PAGES(16384));
++    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)params, 
BYTES_TO_PAGES(16384));
 +  return GRUB_ERR_NONE;
 +}
 +
@@ -235,7 +235,7 @@
 +    }
 +
 +  params->ramdisk_size = size;
-+  params->ramdisk_image = (grub_uint32_t)(grub_uint64_t) initrd_mem;
++  params->ramdisk_image = (grub_uint32_t)(grub_addr_t) initrd_mem;
 +
 +  ptr = initrd_mem;
 +
@@ -262,7 +262,7 @@
 +  grub_free (files);
 +
 +  if (initrd_mem && grub_errno)
-+    grub_efi_free_pages((grub_efi_physical_address_t)initrd_mem, 
BYTES_TO_PAGES(size));
++    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)initrd_mem, 
BYTES_TO_PAGES(size));
 +
 +  return grub_errno;
 +}
@@ -371,7 +371,7 @@
 +                              linux_cmdline + sizeof (LINUX_IMAGE) - 1,
 +                            lh.cmdline_size - (sizeof (LINUX_IMAGE) - 1));
 +
-+  lh.cmd_line_ptr = (grub_uint32_t)(grub_uint64_t)linux_cmdline;
++  lh.cmd_line_ptr = (grub_uint32_t)(grub_addr_t)linux_cmdline;
 +
 +  handover_offset = lh.handover_offset;
 +
@@ -408,7 +408,7 @@
 +    {
 +      grub_loader_set (grub_linuxefi_boot, grub_linuxefi_unload, 0);
 +      loaded = 1;
-+      lh.code32_start = (grub_uint32_t)(grub_uint64_t) kernel_mem;
++      lh.code32_start = (grub_uint32_t)(grub_addr_t) kernel_mem;
 +    }
 +
 +  memcpy(params, &lh, 2 * 512);
@@ -427,13 +427,13 @@
 +    }
 +
 +  if (linux_cmdline && !loaded)
-+    grub_efi_free_pages((grub_efi_physical_address_t)linux_cmdline, 
BYTES_TO_PAGES(lh.cmdline_size + 1));
++    
grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)linux_cmdline, 
BYTES_TO_PAGES(lh.cmdline_size + 1));
 +
 +  if (kernel_mem && !loaded)
-+    grub_efi_free_pages((grub_efi_physical_address_t)kernel_mem, 
BYTES_TO_PAGES(kernel_size));
++    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)kernel_mem, 
BYTES_TO_PAGES(kernel_size));
 +
 +  if (params && !loaded)
-+    grub_efi_free_pages((grub_efi_physical_address_t)params, 
BYTES_TO_PAGES(16384));
++    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)params, 
BYTES_TO_PAGES(16384));
 +
 +  return grub_errno;
 +}
diff -Nru grub2-2.02~beta2/debian/patches/series 
grub2-2.02~beta2/debian/patches/series
--- grub2-2.02~beta2/debian/patches/series      2014-11-06 10:57:25.000000000 
+0000
+++ grub2-2.02~beta2/debian/patches/series      2014-11-30 14:20:36.000000000 
+0000
@@ -21,7 +21,6 @@
 uefi_firmware_setup.patch
 mkconfig_ubuntu_distributor.patch
 linuxefi.patch
-linuxefi_amd64_only.patch
 linuxefi_debug.patch
 linuxefi_require_shim.patch
 linuxefi_non_sb_fallback.patch
@@ -61,3 +60,5 @@
 ieee1275-clear-reset.patch
 ppc64el-disable-vsx.patch
 grub-install-pvxen-paths.patch
+gettext-print-typo.patch
+insmod-xzio-and-lzopio-on-xen.patch
diff -Nru grub2-2.02~beta2/debian/postinst.in 
grub2-2.02~beta2/debian/postinst.in
--- grub2-2.02~beta2/debian/postinst.in 2014-11-06 10:57:25.000000000 +0000
+++ grub2-2.02~beta2/debian/postinst.in 2014-11-30 14:20:34.000000000 +0000
@@ -299,6 +299,14 @@
   type running-in-container >/dev/null 2>&1 && running-in-container >/dev/null
 }
 
+run_grub_install()
+{
+    if ! grub-install $@ ; then
+        echo "Failed: grub-install $@" >&2
+        echo "WARNING: Bootloader is not properly installed, system may not be 
bootable" >&2
+    fi
+}
+
 case "$1" in
   configure)
     . /usr/share/debconf/confmodule
@@ -696,7 +704,7 @@
             grub-efi-arm)   target=arm-efi ;;
             grub-efi-arm64) target=arm64-efi ;;
           esac
-          grub-install --target="$target"
+          run_grub_install --target="$target"
         fi
 
         # /boot/grub/ has more chances of being accessible by GRUB
@@ -714,22 +722,22 @@
             # Output may be empty; if so, just update the core image but
             # don't install it to any PReP partition.
             prep_bootdev="$(/usr/lib/grub/powerpc-ieee1275/prep-bootdev)"
-            grub-install --target=powerpc-ieee1275 $prep_bootdev
+            run_grub_install --target=powerpc-ieee1275 $prep_bootdev
           ;;
         esac
       ;;
 
       grub-yeeloong)
-        grub-install --target=mipsel-loongson
+        run_grub_install --target=mipsel-loongson
       ;;
 
       grub-xen)
         # Install for x86_64 regardless of arch, since a 32-bit userspace can 
still boot with a 64-bit kernel.
-       mkdir -p /boot/xen
-        grub-install --target=x86_64-xen
+        mkdir -p /boot/xen
+        run_grub_install --target=x86_64-xen
         case $(dpkg --print-architecture) in
           i386)
-            grub-install --target=i386-xen
+            run_grub_install --target=i386-xen
           ;;
         esac
       ;;

unblock grub2/2.02~beta2-17

Thanks,
Ian.

-- System Information:
Debian Release: jessie/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
armhf
armel

Kernel: Linux 3.16.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
--- grub2-2.02~beta2-15/grub-core/loader/i386/efi/linux.c	2014-12-03 11:36:23.000000000 +0000
+++ grub2-2.02~beta2-17/grub-core/loader/i386/efi/linux.c	2014-12-03 11:24:52.000000000 +0000
@@ -107,13 +107,13 @@ grub_linuxefi_unload (void)
   grub_dl_unref (my_mod);
   loaded = 0;
   if (initrd_mem)
-    grub_efi_free_pages((grub_efi_physical_address_t)initrd_mem, BYTES_TO_PAGES(params->ramdisk_size));
+    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)initrd_mem, BYTES_TO_PAGES(params->ramdisk_size));
   if (linux_cmdline)
-    grub_efi_free_pages((grub_efi_physical_address_t)linux_cmdline, BYTES_TO_PAGES(params->cmdline_size + 1));
+    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)linux_cmdline, BYTES_TO_PAGES(params->cmdline_size + 1));
   if (kernel_mem)
-    grub_efi_free_pages((grub_efi_physical_address_t)kernel_mem, BYTES_TO_PAGES(kernel_size));
+    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)kernel_mem, BYTES_TO_PAGES(kernel_size));
   if (params)
-    grub_efi_free_pages((grub_efi_physical_address_t)params, BYTES_TO_PAGES(16384));
+    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)params, BYTES_TO_PAGES(16384));
   return GRUB_ERR_NONE;
 }
 
@@ -163,7 +163,7 @@ grub_cmd_initrd (grub_command_t cmd __at
   grub_dprintf ("linuxefi", "initrd_mem = %lx\n", (unsigned long) initrd_mem);
 
   params->ramdisk_size = size;
-  params->ramdisk_image = (grub_uint32_t)(grub_uint64_t) initrd_mem;
+  params->ramdisk_image = (grub_uint32_t)(grub_addr_t) initrd_mem;
 
   ptr = initrd_mem;
 
@@ -190,7 +190,7 @@ grub_cmd_initrd (grub_command_t cmd __at
   grub_free (files);
 
   if (initrd_mem && grub_errno)
-    grub_efi_free_pages((grub_efi_physical_address_t)initrd_mem, BYTES_TO_PAGES(size));
+    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)initrd_mem, BYTES_TO_PAGES(size));
 
   return grub_errno;
 }
@@ -304,7 +304,7 @@ grub_cmd_linux (grub_command_t cmd __att
                               linux_cmdline + sizeof (LINUX_IMAGE) - 1,
 			      lh.cmdline_size - (sizeof (LINUX_IMAGE) - 1));
 
-  lh.cmd_line_ptr = (grub_uint32_t)(grub_uint64_t)linux_cmdline;
+  lh.cmd_line_ptr = (grub_uint32_t)(grub_addr_t)linux_cmdline;
 
   handover_offset = lh.handover_offset;
 
@@ -343,7 +343,7 @@ grub_cmd_linux (grub_command_t cmd __att
     {
       grub_loader_set (grub_linuxefi_boot, grub_linuxefi_unload, 0);
       loaded = 1;
-      lh.code32_start = (grub_uint32_t)(grub_uint64_t) kernel_mem;
+      lh.code32_start = (grub_uint32_t)(grub_addr_t) kernel_mem;
     }
 
   memcpy(params, &lh, 2 * 512);
@@ -362,13 +362,13 @@ grub_cmd_linux (grub_command_t cmd __att
     }
 
   if (linux_cmdline && !loaded)
-    grub_efi_free_pages((grub_efi_physical_address_t)linux_cmdline, BYTES_TO_PAGES(lh.cmdline_size + 1));
+    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)linux_cmdline, BYTES_TO_PAGES(lh.cmdline_size + 1));
 
   if (kernel_mem && !loaded)
-    grub_efi_free_pages((grub_efi_physical_address_t)kernel_mem, BYTES_TO_PAGES(kernel_size));
+    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)kernel_mem, BYTES_TO_PAGES(kernel_size));
 
   if (params && !loaded)
-    grub_efi_free_pages((grub_efi_physical_address_t)params, BYTES_TO_PAGES(16384));
+    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)params, BYTES_TO_PAGES(16384));
 
   return grub_errno;
 }
--- grub2-2.02~beta2-15/grub-core/Makefile.core.def	2014-12-03 11:36:23.000000000 +0000
+++ grub2-2.02~beta2-17/grub-core/Makefile.core.def	2014-12-03 11:24:52.000000000 +0000
@@ -1720,6 +1720,7 @@ module = {
   name = linuxefi;
   efi = loader/i386/efi/linux.c;
   efi = lib/cmdline.c;
+  enable = i386_efi;
   enable = x86_64_efi;
 };
 
--- grub2-2.02~beta2-15/util/grub.d/10_linux.in	2014-12-03 11:36:23.000000000 +0000
+++ grub2-2.02~beta2-17/util/grub.d/10_linux.in	2014-12-03 11:24:52.000000000 +0000
@@ -150,6 +150,7 @@ linux_entry ()
   fi
 
   echo "	insmod gzio" | sed "s/^/$submenu_indentation/"
+  echo "	if [ x\$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi" | sed "s/^/$submenu_indentation/"
 
   if [ x$dirname = x/ ]; then
     if [ -z "${prepare_root_cache}" ]; then
--- grub2-2.02~beta2-15/util/grub-install.c	2014-12-03 11:36:23.000000000 +0000
+++ grub2-2.02~beta2-17/util/grub-install.c	2014-12-03 11:24:52.000000000 +0000
@@ -1979,6 +1979,28 @@ main (int argc, char *argv[])
 	}
       break;
 
+    case GRUB_INSTALL_PLATFORM_I386_XEN:
+      {
+	char *path = grub_util_path_concat (2, bootdir, "xen");
+	char *dst = grub_util_path_concat (2, path, "pvboot-i386.elf");
+	grub_install_mkdir_p (path);
+	grub_install_copy_file (imgfile, dst, 1);
+	free (dst);
+	free (path);
+      }
+      break;
+
+    case GRUB_INSTALL_PLATFORM_X86_64_XEN:
+      {
+	char *path = grub_util_path_concat (2, bootdir, "xen");
+	char *dst = grub_util_path_concat (2, path, "pvboot-x86_64.elf");
+	grub_install_mkdir_p (path);
+	grub_install_copy_file (imgfile, dst, 1);
+	free (dst);
+	free (path);
+      }
+      break;
+
     case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON:
     case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS:
     case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS:
@@ -1987,8 +2009,6 @@ main (int argc, char *argv[])
     case GRUB_INSTALL_PLATFORM_MIPSEL_ARC:
     case GRUB_INSTALL_PLATFORM_ARM_UBOOT:
     case GRUB_INSTALL_PLATFORM_I386_QEMU:
-    case GRUB_INSTALL_PLATFORM_I386_XEN:
-    case GRUB_INSTALL_PLATFORM_X86_64_XEN:
       grub_util_warn ("%s",
 		      _("WARNING: no platform-specific install was performed"));
       break;
--- grub2-2.02~beta2-15/util/grub-mkconfig.in	2014-12-03 11:36:23.000000000 +0000
+++ grub2-2.02~beta2-17/util/grub-mkconfig.in	2014-12-03 11:24:52.000000000 +0000
@@ -131,7 +131,7 @@ set $grub_probe dummy
 if test -f "$1"; then
     :
 else
-    gettext_print "%s: Not found.\n" "$1" 1>&2
+    gettext_printf "%s: Not found.\n" "$1" 1>&2
     exit 1
 fi
 
diff -Nru grub2-2.02~beta2/debian/changelog grub2-2.02~beta2/debian/changelog
--- grub2-2.02~beta2/debian/changelog	2014-10-15 21:34:05.000000000 +0100
+++ grub2-2.02~beta2/debian/changelog	2014-11-30 17:15:23.000000000 +0000
@@ -1,3 +1,29 @@
+grub2 (2.02~beta2-17) unstable; urgency=medium
+
+  [ Colin Watson ]
+  * Fix up some pointer-to-integer casts in linuxefi so that it can build on
+    i386-efi.
+  * Backport from upstream:
+    - Fix typo (gettext_print instead of gettext_printf) (LP: #1390766).
+
+  [ Ian Campbell ]
+  * Correct syntax error in grub-xen-host bootstrap configuration file.
+  * Log failure when grub-install fails in postinst, rather than failing the
+    entire postinst. (Closes: #770412)
+  * Arrange to insmod xzio and lzopio when booting a kernel as a Xen guest.
+    (Closes: #755256)
+
+ -- Ian Campbell <i...@debian.org>  Sun, 30 Nov 2014 17:15:21 +0000
+
+grub2 (2.02~beta2-16) unstable; urgency=medium
+
+  [ Ian Campbell ]
+  * Provide prebuilt grub-xen binaries for host use in a new grub-xen-host
+    package.
+  * Build/Install binaries into /boot/xen when installing grub-xen.
+
+ -- Ian Campbell <i...@debian.org>  Thu, 06 Nov 2014 13:32:01 +0000
+
 grub2 (2.02~beta2-15) unstable; urgency=medium
 
   * Disable nvram installation again on chrp_ibm machines that are emulated
diff -Nru grub2-2.02~beta2/debian/control grub2-2.02~beta2/debian/control
--- grub2-2.02~beta2/debian/control	2014-10-15 13:28:03.000000000 +0100
+++ grub2-2.02~beta2/debian/control	2014-11-30 17:15:15.000000000 +0000
@@ -634,6 +634,23 @@
  This package contains a version of GRUB that has been built for use with
  the Xen hypervisor (i.e. PV-GRUB).
 
+Package: grub-xen-host
+Architecture: i386 amd64
+Depends: ${shlibs:Depends}, ${misc:Depends}, grub-xen-bin (= ${binary:Version})
+Multi-Arch: foreign
+Description: GRand Unified Bootloader, version 2 (Xen host version)
+ GRUB is a portable, powerful bootloader.  This version of GRUB is based on a
+ cleaner design than its predecessors, and provides the following new features:
+ .
+  - Scripting in grub.cfg using BASH-like syntax.
+  - Support for modern partition maps such as GPT.
+  - Modular generation of grub.cfg via update-grub.  Packages providing GRUB
+    add-ons can plug in their own script rules and trigger updates by invoking
+    update-grub.
+ .
+ This package arranges for GRUB binary images which can be used to boot a Xen
+ guest (i.e. PV-GRUB) to be present in the control domain filesystem.
+
 Package: grub-yeeloong-bin
 Architecture: any-mipsel
 Depends: ${shlibs:Depends}, ${misc:Depends}, grub-common (= ${binary:Version})
diff -Nru grub2-2.02~beta2/debian/.git-dpm grub2-2.02~beta2/debian/.git-dpm
--- grub2-2.02~beta2/debian/.git-dpm	2014-10-15 13:28:12.000000000 +0100
+++ grub2-2.02~beta2/debian/.git-dpm	2014-11-30 14:20:36.000000000 +0000
@@ -1,6 +1,6 @@
 # see git-dpm(1) from git-dpm package
-603e3eaf4807b988cb87e3dd8a00a0518dc237aa
-603e3eaf4807b988cb87e3dd8a00a0518dc237aa
+b837a9997cb306dc9aaeb3308f05d08cef402456
+b837a9997cb306dc9aaeb3308f05d08cef402456
 e8f07821cce1bd0ab6d5622c2a42440f15f4fd71
 e8f07821cce1bd0ab6d5622c2a42440f15f4fd71
 grub2_2.02~beta2.orig.tar.xz
diff -Nru grub2-2.02~beta2/debian/grub-xen-host_grub-bootstrap.cfg grub2-2.02~beta2/debian/grub-xen-host_grub-bootstrap.cfg
--- grub2-2.02~beta2/debian/grub-xen-host_grub-bootstrap.cfg	1970-01-01 01:00:00.000000000 +0100
+++ grub2-2.02~beta2/debian/grub-xen-host_grub-bootstrap.cfg	2014-11-30 14:20:34.000000000 +0000
@@ -0,0 +1 @@
+normal (memdisk)/grub.cfg
diff -Nru grub2-2.02~beta2/debian/grub-xen-host_grub.cfg grub2-2.02~beta2/debian/grub-xen-host_grub.cfg
--- grub2-2.02~beta2/debian/grub-xen-host_grub.cfg	1970-01-01 01:00:00.000000000 +0100
+++ grub2-2.02~beta2/debian/grub-xen-host_grub.cfg	2014-11-30 14:20:34.000000000 +0000
@@ -0,0 +1,24 @@
+# First search for a suitable grub to chainload
+if search -s -f /boot/xen/pvboot-@@PVBOOT_ARCH@@.elf ; then
+	echo "Chainloading (${root})/boot/xen/pvboot-@@PVBOOT_ARCH@@.elf"
+	multiboot "/boot/xen/pvboot-@@PVBOOT_ARCH@@.elf"
+	boot
+fi
+
+if search -s -f /xen/pvboot-@@PVBOOT_ARCH@@.elf ; then
+	echo "Chainloading (${root})/xen/pvboot-@@PVBOOT_ARCH@@.elf"
+	multiboot "/xen/pvboot-@@PVBOOT_ARCH@@.elf"
+	boot
+fi
+
+# Second try looking for grub.cfg
+
+if search -s -f /boot/grub/grub.cfg ; then
+	echo "Reading (${root})/boot/grub/grub.cfg"
+	configfile /boot/grub/grub.cfg
+fi
+
+if search -s -f /grub/grub.cfg ; then
+	echo "Reading (${root})/grub/grub.cfg"
+	configfile /grub/grub.cfg
+fi
diff -Nru grub2-2.02~beta2/debian/grub-xen-host.install grub2-2.02~beta2/debian/grub-xen-host.install
--- grub2-2.02~beta2/debian/grub-xen-host.install	1970-01-01 01:00:00.000000000 +0100
+++ grub2-2.02~beta2/debian/grub-xen-host.install	2014-11-30 14:20:34.000000000 +0000
@@ -0,0 +1,2 @@
+obj/grub-xen-host-i386/grub-i386-xen.bin usr/lib/grub-xen
+obj/grub-xen-host-amd64/grub-x86_64-xen.bin usr/lib/grub-xen
diff -Nru grub2-2.02~beta2/debian/grub-xen-host.lintian-overrides grub2-2.02~beta2/debian/grub-xen-host.lintian-overrides
--- grub2-2.02~beta2/debian/grub-xen-host.lintian-overrides	1970-01-01 01:00:00.000000000 +0100
+++ grub2-2.02~beta2/debian/grub-xen-host.lintian-overrides	2014-11-30 14:20:34.000000000 +0000
@@ -0,0 +1,2 @@
+grub-xen-host: statically-linked-binary usr/lib/grub-xen/grub-i386-xen.bin
+grub-xen-host: statically-linked-binary usr/lib/grub-xen/grub-x86_64-xen.bin
diff -Nru grub2-2.02~beta2/debian/patches/gettext-print-typo.patch grub2-2.02~beta2/debian/patches/gettext-print-typo.patch
--- grub2-2.02~beta2/debian/patches/gettext-print-typo.patch	1970-01-01 01:00:00.000000000 +0100
+++ grub2-2.02~beta2/debian/patches/gettext-print-typo.patch	2014-11-30 14:20:34.000000000 +0000
@@ -0,0 +1,27 @@
+From 20886bef9351d5c20a9de1fb3339fe40114f01d1 Mon Sep 17 00:00:00 2001
+From: Andrey Borzenkov <arvidj...@gmail.com>
+Date: Thu, 14 Aug 2014 21:02:31 +0400
+Subject: Fix typo (gettext_print instead of gettext_printf)
+
+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1390766
+Origin: upstream, http://git.savannah.gnu.org/gitweb/?p=grub.git;a=commitdiff;h=c291f47b2c003ef6daeafaedd458db838bad6fb8
+Last-Update: 2014-11-18
+
+Patch-Name: gettext-print-typo.patch
+---
+ util/grub-mkconfig.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
+index ccce9e5..4641563 100644
+--- a/util/grub-mkconfig.in
++++ b/util/grub-mkconfig.in
+@@ -131,7 +131,7 @@ set $grub_probe dummy
+ if test -f "$1"; then
+     :
+ else
+-    gettext_print "%s: Not found.\n" "$1" 1>&2
++    gettext_printf "%s: Not found.\n" "$1" 1>&2
+     exit 1
+ fi
+ 
diff -Nru grub2-2.02~beta2/debian/patches/grub-install-pvxen-paths.patch grub2-2.02~beta2/debian/patches/grub-install-pvxen-paths.patch
--- grub2-2.02~beta2/debian/patches/grub-install-pvxen-paths.patch	1970-01-01 01:00:00.000000000 +0100
+++ grub2-2.02~beta2/debian/patches/grub-install-pvxen-paths.patch	2014-11-30 14:20:34.000000000 +0000
@@ -0,0 +1,71 @@
+From 313d9a785287753409051363335a26e75855cbd6 Mon Sep 17 00:00:00 2001
+From: Ian Campbell <i...@hellion.org.uk>
+Date: Sat, 6 Sep 2014 12:20:12 +0100
+Subject: grub-install: Install PV Xen binaries into the upstream specified
+ path
+
+Upstream have defined a specification for where guests ought to place their
+xenpv grub binaries in order to facilitate chainloading from a stage 1 grub
+loaded from dom0.
+
+http://xenbits.xen.org/docs/unstable-staging/misc/x86-xenpv-bootloader.html
+
+The spec calls for installation into /boot/xen/pvboot-i386.elf or
+/boot/xen/pvboot-x86_64.elf.
+
+Signed-off-by: Ian Campbell <i...@hellion.org.uk>
+
+Bug-Debian: https://bugs.debian.org/762307
+Forwarded: http://lists.gnu.org/archive/html/grub-devel/2014-10/msg00041.html
+Last-Update: 2014-10-24
+
+Patch-Name: grub-install-pvxen-paths.patch
+
+---
+v2: Respect bootdir, create /boot/xen as needed.
+---
+ util/grub-install.c | 24 ++++++++++++++++++++++--
+ 1 file changed, 22 insertions(+), 2 deletions(-)
+
+diff --git a/util/grub-install.c b/util/grub-install.c
+index 70f514c..7a7734e 100644
+--- a/util/grub-install.c
++++ b/util/grub-install.c
+@@ -1979,6 +1979,28 @@ main (int argc, char *argv[])
+ 	}
+       break;
+ 
++    case GRUB_INSTALL_PLATFORM_I386_XEN:
++      {
++	char *path = grub_util_path_concat (2, bootdir, "xen");
++	char *dst = grub_util_path_concat (2, path, "pvboot-i386.elf");
++	grub_install_mkdir_p (path);
++	grub_install_copy_file (imgfile, dst, 1);
++	free (dst);
++	free (path);
++      }
++      break;
++
++    case GRUB_INSTALL_PLATFORM_X86_64_XEN:
++      {
++	char *path = grub_util_path_concat (2, bootdir, "xen");
++	char *dst = grub_util_path_concat (2, path, "pvboot-x86_64.elf");
++	grub_install_mkdir_p (path);
++	grub_install_copy_file (imgfile, dst, 1);
++	free (dst);
++	free (path);
++      }
++      break;
++
+     case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON:
+     case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS:
+     case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS:
+@@ -1987,8 +2009,6 @@ main (int argc, char *argv[])
+     case GRUB_INSTALL_PLATFORM_MIPSEL_ARC:
+     case GRUB_INSTALL_PLATFORM_ARM_UBOOT:
+     case GRUB_INSTALL_PLATFORM_I386_QEMU:
+-    case GRUB_INSTALL_PLATFORM_I386_XEN:
+-    case GRUB_INSTALL_PLATFORM_X86_64_XEN:
+       grub_util_warn ("%s",
+ 		      _("WARNING: no platform-specific install was performed"));
+       break;
diff -Nru grub2-2.02~beta2/debian/patches/insmod-xzio-and-lzopio-on-xen.patch grub2-2.02~beta2/debian/patches/insmod-xzio-and-lzopio-on-xen.patch
--- grub2-2.02~beta2/debian/patches/insmod-xzio-and-lzopio-on-xen.patch	1970-01-01 01:00:00.000000000 +0100
+++ grub2-2.02~beta2/debian/patches/insmod-xzio-and-lzopio-on-xen.patch	2014-11-30 14:20:36.000000000 +0000
@@ -0,0 +1,33 @@
+From b837a9997cb306dc9aaeb3308f05d08cef402456 Mon Sep 17 00:00:00 2001
+From: Ian Campbell <i...@debian.org>
+Date: Sun, 30 Nov 2014 12:12:52 +0000
+Subject: Arrange to insmod xzio and lzopio when booting a kernel as a Xen
+ guest
+
+This is needed in case the Linux kernel is compiled with CONFIG_KERNEL_XZ or
+CONFIG_KERNEL_LZO rather than CONFIG_KERNEL_GZ (gzio is already loaded by
+grub.cfg today).
+
+Signed-off-by: Ian Campbell <i...@debian.org>
+
+Bug-Debian: https://bugs.debian.org/755256
+Forwarded: http://lists.gnu.org/archive/html/grub-devel/2014-11/msg00091.html
+Last-Update: 2014-11-30
+
+Patch-Name: insmod-xzio-and-lzopio-on-xen.patch
+---
+ util/grub.d/10_linux.in | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
+index 79fa03a..86e35f2 100644
+--- a/util/grub.d/10_linux.in
++++ b/util/grub.d/10_linux.in
+@@ -150,6 +150,7 @@ linux_entry ()
+   fi
+ 
+   echo "	insmod gzio" | sed "s/^/$submenu_indentation/"
++  echo "	if [ x\$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi" | sed "s/^/$submenu_indentation/"
+ 
+   if [ x$dirname = x/ ]; then
+     if [ -z "${prepare_root_cache}" ]; then
diff -Nru grub2-2.02~beta2/debian/patches/linuxefi_amd64_only.patch grub2-2.02~beta2/debian/patches/linuxefi_amd64_only.patch
--- grub2-2.02~beta2/debian/patches/linuxefi_amd64_only.patch	2014-10-15 13:28:03.000000000 +0100
+++ grub2-2.02~beta2/debian/patches/linuxefi_amd64_only.patch	1970-01-01 01:00:00.000000000 +0100
@@ -1,25 +0,0 @@
-From d17d82d5217170e5f3124ed1c5aa77a7b8f253d7 Mon Sep 17 00:00:00 2001
-From: Colin Watson <cjwat...@ubuntu.com>
-Date: Mon, 13 Jan 2014 12:13:16 +0000
-Subject: Only build linuxefi on amd64
-
-Forwarded: no
-Last-Update: 2013-12-25
-
-Patch-Name: linuxefi_amd64_only.patch
----
- grub-core/Makefile.core.def | 1 -
- 1 file changed, 1 deletion(-)
-
-diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
-index 8c246c6..8fed2fb 100644
---- a/grub-core/Makefile.core.def
-+++ b/grub-core/Makefile.core.def
-@@ -1709,7 +1709,6 @@ module = {
-   name = linuxefi;
-   efi = loader/i386/efi/linux.c;
-   efi = lib/cmdline.c;
--  enable = i386_efi;
-   enable = x86_64_efi;
- };
- 
diff -Nru grub2-2.02~beta2/debian/patches/linuxefi_debug.patch grub2-2.02~beta2/debian/patches/linuxefi_debug.patch
--- grub2-2.02~beta2/debian/patches/linuxefi_debug.patch	2014-10-15 13:28:03.000000000 +0100
+++ grub2-2.02~beta2/debian/patches/linuxefi_debug.patch	2014-11-30 14:20:34.000000000 +0000
@@ -1,4 +1,4 @@
-From 935cb0d861b3e0a0ab9340f7f1527fa1d0d388af Mon Sep 17 00:00:00 2001
+From 755d4a32dc78349fb80a966e9fb150bc8cfd6426 Mon Sep 17 00:00:00 2001
 From: Colin Watson <cjwat...@ubuntu.com>
 Date: Mon, 13 Jan 2014 12:13:18 +0000
 Subject: Add more debugging to linuxefi
@@ -12,7 +12,7 @@
  1 file changed, 25 insertions(+), 3 deletions(-)
 
 diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c
-index b79e632..a124c5e 100644
+index ebaf1db..2bf38fa 100644
 --- a/grub-core/loader/i386/efi/linux.c
 +++ b/grub-core/loader/i386/efi/linux.c
 @@ -19,6 +19,7 @@
@@ -61,7 +61,7 @@
 +  grub_dprintf ("linuxefi", "initrd_mem = %lx\n", (unsigned long) initrd_mem);
 +
    params->ramdisk_size = size;
-   params->ramdisk_image = (grub_uint32_t)(grub_uint64_t) initrd_mem;
+   params->ramdisk_image = (grub_uint32_t)(grub_addr_t) initrd_mem;
  
 @@ -236,6 +251,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
        goto fail;
diff -Nru grub2-2.02~beta2/debian/patches/linuxefi.patch grub2-2.02~beta2/debian/patches/linuxefi.patch
--- grub2-2.02~beta2/debian/patches/linuxefi.patch	2014-10-15 13:28:03.000000000 +0100
+++ grub2-2.02~beta2/debian/patches/linuxefi.patch	2014-11-30 14:20:34.000000000 +0000
@@ -1,11 +1,11 @@
-From 2359f527c5091fb6633eec1b165db05c07eb83cf Mon Sep 17 00:00:00 2001
+From e4951626e0ab33c446cfd7e9a22044f602ca0106 Mon Sep 17 00:00:00 2001
 From: Matthew Garrett <m...@redhat.com>
 Date: Mon, 13 Jan 2014 12:13:15 +0000
 Subject: Add "linuxefi" loader which avoids ExitBootServices
 
 Origin: vendor, http://pkgs.fedoraproject.org/cgit/grub2.git/tree/grub2-linuxefi.patch
 Forwarded: no
-Last-Update: 2013-12-25
+Last-Update: 2014-11-18
 
 Patch-Name: linuxefi.patch
 ---
@@ -81,7 +81,7 @@
  grub_efi_allocate_pages (grub_efi_physical_address_t address,
 diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c
 new file mode 100644
-index 0000000..b79e632
+index 0000000..ebaf1db
 --- /dev/null
 +++ b/grub-core/loader/i386/efi/linux.c
 @@ -0,0 +1,371 @@
@@ -181,13 +181,13 @@
 +  grub_dl_unref (my_mod);
 +  loaded = 0;
 +  if (initrd_mem)
-+    grub_efi_free_pages((grub_efi_physical_address_t)initrd_mem, BYTES_TO_PAGES(params->ramdisk_size));
++    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)initrd_mem, BYTES_TO_PAGES(params->ramdisk_size));
 +  if (linux_cmdline)
-+    grub_efi_free_pages((grub_efi_physical_address_t)linux_cmdline, BYTES_TO_PAGES(params->cmdline_size + 1));
++    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)linux_cmdline, BYTES_TO_PAGES(params->cmdline_size + 1));
 +  if (kernel_mem)
-+    grub_efi_free_pages((grub_efi_physical_address_t)kernel_mem, BYTES_TO_PAGES(kernel_size));
++    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)kernel_mem, BYTES_TO_PAGES(kernel_size));
 +  if (params)
-+    grub_efi_free_pages((grub_efi_physical_address_t)params, BYTES_TO_PAGES(16384));
++    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)params, BYTES_TO_PAGES(16384));
 +  return GRUB_ERR_NONE;
 +}
 +
@@ -235,7 +235,7 @@
 +    }
 +
 +  params->ramdisk_size = size;
-+  params->ramdisk_image = (grub_uint32_t)(grub_uint64_t) initrd_mem;
++  params->ramdisk_image = (grub_uint32_t)(grub_addr_t) initrd_mem;
 +
 +  ptr = initrd_mem;
 +
@@ -262,7 +262,7 @@
 +  grub_free (files);
 +
 +  if (initrd_mem && grub_errno)
-+    grub_efi_free_pages((grub_efi_physical_address_t)initrd_mem, BYTES_TO_PAGES(size));
++    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)initrd_mem, BYTES_TO_PAGES(size));
 +
 +  return grub_errno;
 +}
@@ -371,7 +371,7 @@
 +                              linux_cmdline + sizeof (LINUX_IMAGE) - 1,
 +			      lh.cmdline_size - (sizeof (LINUX_IMAGE) - 1));
 +
-+  lh.cmd_line_ptr = (grub_uint32_t)(grub_uint64_t)linux_cmdline;
++  lh.cmd_line_ptr = (grub_uint32_t)(grub_addr_t)linux_cmdline;
 +
 +  handover_offset = lh.handover_offset;
 +
@@ -408,7 +408,7 @@
 +    {
 +      grub_loader_set (grub_linuxefi_boot, grub_linuxefi_unload, 0);
 +      loaded = 1;
-+      lh.code32_start = (grub_uint32_t)(grub_uint64_t) kernel_mem;
++      lh.code32_start = (grub_uint32_t)(grub_addr_t) kernel_mem;
 +    }
 +
 +  memcpy(params, &lh, 2 * 512);
@@ -427,13 +427,13 @@
 +    }
 +
 +  if (linux_cmdline && !loaded)
-+    grub_efi_free_pages((grub_efi_physical_address_t)linux_cmdline, BYTES_TO_PAGES(lh.cmdline_size + 1));
++    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)linux_cmdline, BYTES_TO_PAGES(lh.cmdline_size + 1));
 +
 +  if (kernel_mem && !loaded)
-+    grub_efi_free_pages((grub_efi_physical_address_t)kernel_mem, BYTES_TO_PAGES(kernel_size));
++    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)kernel_mem, BYTES_TO_PAGES(kernel_size));
 +
 +  if (params && !loaded)
-+    grub_efi_free_pages((grub_efi_physical_address_t)params, BYTES_TO_PAGES(16384));
++    grub_efi_free_pages((grub_efi_physical_address_t)(grub_addr_t)params, BYTES_TO_PAGES(16384));
 +
 +  return grub_errno;
 +}
diff -Nru grub2-2.02~beta2/debian/patches/series grub2-2.02~beta2/debian/patches/series
--- grub2-2.02~beta2/debian/patches/series	2014-10-15 13:28:04.000000000 +0100
+++ grub2-2.02~beta2/debian/patches/series	2014-11-30 14:20:36.000000000 +0000
@@ -21,7 +21,6 @@
 uefi_firmware_setup.patch
 mkconfig_ubuntu_distributor.patch
 linuxefi.patch
-linuxefi_amd64_only.patch
 linuxefi_debug.patch
 linuxefi_require_shim.patch
 linuxefi_non_sb_fallback.patch
@@ -60,3 +59,6 @@
 mips-abiflags.patch
 ieee1275-clear-reset.patch
 ppc64el-disable-vsx.patch
+grub-install-pvxen-paths.patch
+gettext-print-typo.patch
+insmod-xzio-and-lzopio-on-xen.patch
diff -Nru grub2-2.02~beta2/debian/postinst.in grub2-2.02~beta2/debian/postinst.in
--- grub2-2.02~beta2/debian/postinst.in	2014-10-15 13:28:04.000000000 +0100
+++ grub2-2.02~beta2/debian/postinst.in	2014-11-30 14:20:34.000000000 +0000
@@ -299,6 +299,14 @@
   type running-in-container >/dev/null 2>&1 && running-in-container >/dev/null
 }
 
+run_grub_install()
+{
+    if ! grub-install $@ ; then
+        echo "Failed: grub-install $@" >&2
+        echo "WARNING: Bootloader is not properly installed, system may not be bootable" >&2
+    fi
+}
+
 case "$1" in
   configure)
     . /usr/share/debconf/confmodule
@@ -696,7 +704,7 @@
             grub-efi-arm)   target=arm-efi ;;
             grub-efi-arm64) target=arm64-efi ;;
           esac
-          grub-install --target="$target"
+          run_grub_install --target="$target"
         fi
 
         # /boot/grub/ has more chances of being accessible by GRUB
@@ -714,13 +722,24 @@
             # Output may be empty; if so, just update the core image but
             # don't install it to any PReP partition.
             prep_bootdev="$(/usr/lib/grub/powerpc-ieee1275/prep-bootdev)"
-            grub-install --target=powerpc-ieee1275 $prep_bootdev
+            run_grub_install --target=powerpc-ieee1275 $prep_bootdev
           ;;
         esac
       ;;
 
       grub-yeeloong)
-        grub-install --target=mipsel-loongson
+        run_grub_install --target=mipsel-loongson
+      ;;
+
+      grub-xen)
+        # Install for x86_64 regardless of arch, since a 32-bit userspace can still boot with a 64-bit kernel.
+        mkdir -p /boot/xen
+        run_grub_install --target=x86_64-xen
+        case $(dpkg --print-architecture) in
+          i386)
+            run_grub_install --target=i386-xen
+          ;;
+        esac
       ;;
     esac
 
diff -Nru grub2-2.02~beta2/debian/rules grub2-2.02~beta2/debian/rules
--- grub2-2.02~beta2/debian/rules	2014-10-15 13:28:04.000000000 +0100
+++ grub2-2.02~beta2/debian/rules	2014-11-30 14:20:34.000000000 +0000
@@ -36,7 +36,11 @@
 AUTOGEN_DEB_FILES = config templates preinst postinst postrm dirs install links maintscript
 
 BUILD_PACKAGES := $(strip $(shell dh_listpackages))
+# REAL_PACKAGES build an actual grub variant (and therefore have both configure
+# and build stages). EXTRA_PACKAGES do not build grub but may depend on a
+# REAL_PACKAGE (and therefore only have a build stage)
 REAL_PACKAGES = grub-common grub-emu grub-pc grub-coreboot grub-efi-ia32 grub-efi-amd64 grub-efi-ia64 grub-efi-arm grub-efi-arm64 grub-ieee1275 grub-firmware-qemu grub-uboot grub-xen grub-yeeloong
+EXTRA_PACKAGES = grub-rescue-pc grub-xen-host
 
 ifneq (,$(filter i386 amd64,$(DEB_HOST_ARCH_CPU)))
 COMMON_PLATFORM := pc
@@ -109,7 +113,7 @@
 override_dh_auto_install: $(patsubst %,install/%,$(BUILD_PACKAGES))
 
 $(patsubst %,configure/%,$(REAL_PACKAGES)) :: configure/% : debian/stamps/configure-%
-$(patsubst %,build/%,$(REAL_PACKAGES) grub-rescue-pc) :: build/% : debian/stamps/build-%
+$(patsubst %,build/%,$(REAL_PACKAGES) $(EXTRA_PACKAGES)) :: build/% : debian/stamps/build-%
 
 debian/stamps/configure-%: package = $(subst debian/stamps/configure-,,$@)
 debian/stamps/configure-%: export DH_OPTIONS = -p$(package) -Bobj/$(package)
@@ -176,6 +180,32 @@
 	dh_auto_build
 	touch $@
 
+debian/stamps/build-grub-xen-host-i386: PVBOOT_ARCH := i386
+debian/stamps/build-grub-xen-host-amd64: PVBOOT_ARCH := x86_64
+debian/stamps/build-grub-xen-host-%: debian/stamps/build-grub-xen-%
+	target=$(subst debian/stamps/build-grub-xen-host-,,$@) ; \
+	obj_dir=$(CURDIR)/obj/grub-xen-$${target} ; \
+	grub_dir=`mktemp -d` ; \
+	grub_memdisk=`mktemp` ; \
+	trap "rm -rf $${grub_dir} $${grub_memdisk}" EXIT HUP INT QUIT TERM ; \
+	mkdir -p $${grub_dir}/boot/grub ; \
+	mkdir -p $(CURDIR)/obj/$(package) ; \
+	sed -e "s/@@PVBOOT_ARCH@@/$(PVBOOT_ARCH)/g" \
+	    <debian/grub-xen-host_grub.cfg \
+	    >$${grub_dir}/grub.cfg ; \
+	tar -cf - -C $${grub_dir} grub.cfg > $${grub_memdisk} ; \
+	$${obj_dir}/grub-mkimage \
+		-O $(PVBOOT_ARCH)-xen \
+		-c $(CURDIR)/debian/grub-xen-host_grub-bootstrap.cfg \
+		-d $${obj_dir}/grub-core \
+		$${obj_dir}/grub-core/*.mod \
+		-m $${grub_memdisk} \
+		-o $(CURDIR)/obj/$(package)/grub-$(PVBOOT_ARCH)-xen.bin
+	touch $@
+
+debian/stamps/build-grub-xen-host: debian/stamps/build-grub-xen-host-i386 debian/stamps/build-grub-xen-host-amd64
+	touch $@
+
 debian/stamps/build-grub-pc: debian/stamps/configure-grub-pc
 	dh_auto_build
 ifeq ($(with_check), yes)
@@ -371,7 +401,7 @@
 endif
 
 override_dh_install:
-	dh_install -pgrub2 -pgrub-linuxbios -pgrub-efi -pgrub-rescue-pc -pgrub-firmware-qemu
+	dh_install -pgrub2 -pgrub-linuxbios -pgrub-efi -pgrub-rescue-pc -pgrub-firmware-qemu -pgrub-xen-host
 	dh_install -pgrub-common -pgrub2-common -pgrub-theme-starfield -pgrub-mount-udeb --sourcedir=debian/tmp-grub-$(COMMON_PLATFORM)
 	rm -f debian/grub2-common/usr/share/info/dir*
 	rm -f debian/grub-theme-starfield/usr/share/grub/themes/starfield/COPYING.CC-BY-SA-3.0
@@ -400,8 +430,8 @@
 endif
 
 override_dh_installdocs:
-	dh_installdocs -pgrub-common -pgrub-rescue-pc -pgrub-firmware-qemu -A AUTHORS NEWS README THANKS TODO
-	dh_installdocs -Ngrub-common -Ngrub-rescue-pc -Ngrub-firmware-qemu --link-doc=grub-common
+	dh_installdocs -pgrub-common -pgrub-rescue-pc -pgrub-firmware-qemu -pgrub-xen-host -A AUTHORS NEWS README THANKS TODO
+	dh_installdocs -Ngrub-common -Ngrub-rescue-pc -Ngrub-firmware-qemu -Ngrub-xen-host --link-doc=grub-common
 
 ifeq ($(FLICKER_FREE_BOOT),yes)
 override_dh_installinit:

Reply via email to