Bug#759018: [PATCH RFC] Provide prebuilt grub-xen binaries for host (dom0) use

Ian Campbell ijc at hellion.org.uk
Sat Aug 23 20:38:07 UTC 2014


Source: grub2
Severity: wishlist
Version: 2.02~beta2-11
Control: retitle -1 please provide prebuilt grub-xen binaries for host (dom0) use

I'm attaching a new version with a grub.cfg which is tested and seems to
work. I've also taken the liberty of filing this into a wishlist bug
(keeping entire quoted text below for the bug).

I needed to do a little hack which is to rmmod memdisk before searching
for /boot/grub/grub.cfg or else it just loops infinitely finding the
grub.cfg in the memdisk. I have a feeling that the same thing might
apply to debian/grub-firmware-qemu_grub.cfg.

Ian.

On Mon, 2014-07-28 at 18:50 +0100, Ian Campbell wrote:
> Any thoughts on providing something like this, something like the patch
> below? My hope is that the xen-utils package can eventually Recommend:
> it.
> 
> I wasn't sure whether to go for a static binary built at build time or a
> grub-mkimage invocation in a postinst. I went for the former in the end
> since I couldn't really think of a good reason to do the more dynamic
> thing.
> 
> One thing I'm not sure about is the proper content for
> debian/grub-xen-host_grub.cfg. I copied the qemu one but it has a few
> issues, namely that the "Search & source /boot/grub/grub.cfg" just ends
> up finding the builtin grub.cfg in the memdisk over again. I suspect the
> same would happen with the qemu version (although I've not tried it).
> Adding "rmmod memdisk" solves that issue, at which point selecting the
> search menu item appends the standard debian stuff to the list where I
> would expect it to replace the menu.
> 
> Perhaps a better option would be a script which first searches
> for /boot/..../core.img (produced by the grub-xen package) and if found
> chainloads it otherwise searches for /boot/grub/grub.cfg and loads it.
> Thoughts?
> 
> Ian.
> 
> --------------------------
> 
> From ffec013d9a220844811a705f6af4441347ddbef5 Mon Sep 17 00:00:00 2001
> From: Ian Campbell <ijc at hellion.org.uk>
> Date: Sun, 27 Jul 2014 18:48:01 +0100
> Subject: [PATCH] Provide prebuilt grub-xen binaries for host use in a new
>  grub-xen-host package.
> 
> These can be referenced via kernel= in guest cfg to boot a guest using grub2.
> 
> debian/grub-xen-host_grub.cfg is the same as the qemu-firmware variant,
> although I'm not sure what the best content is so it's more of a placeholder
> for now.
> ---
>  debian/changelog              |  8 ++++++++
>  debian/control                | 17 +++++++++++++++++
>  debian/grub-xen-host.dirs     |  1 +
>  debian/grub-xen-host.install  |  2 ++
>  debian/grub-xen-host_grub.cfg | 37 +++++++++++++++++++++++++++++++++++++
>  debian/rules                  | 37 +++++++++++++++++++++++++++++++++----
>  6 files changed, 98 insertions(+), 4 deletions(-)
>  create mode 100644 debian/grub-xen-host.dirs
>  create mode 100644 debian/grub-xen-host.install
>  create mode 100644 debian/grub-xen-host_grub.cfg
> 
> diff --git a/debian/changelog b/debian/changelog
> index 5e45a82..80e8022 100644
> --- a/debian/changelog
> +++ b/debian/changelog
> @@ -1,3 +1,11 @@
> +grub2 (2.02~beta2-12) UNRELEASED; urgency=medium
> +
> +  [ Ian Campbell ]
> +  * Provide prebuilt grub-xen binaries for host use in a new grub-xen-host
> +    package.
> +
> + -- Colin Watson <cjwatson at debian.org>  Sun, 27 Jul 2014 18:43:57 +0100
> +
>  grub2 (2.02~beta2-11) unstable; urgency=medium
>  
>    * Force grub-pc/mixed_legacy_and_grub2 to be reshown, rather than failing
> diff --git a/debian/control b/debian/control
> index 22c7fc2..1578702 100644
> --- a/debian/control
> +++ b/debian/control
> @@ -632,6 +632,23 @@ Description: GRand Unified Bootloader, version 2 (Xen version)
>   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 --git a/debian/grub-xen-host.dirs b/debian/grub-xen-host.dirs
> new file mode 100644
> index 0000000..a8dc877
> --- /dev/null
> +++ b/debian/grub-xen-host.dirs
> @@ -0,0 +1 @@
> +usr/lib/grub-xen
> diff --git a/debian/grub-xen-host.install b/debian/grub-xen-host.install
> new file mode 100644
> index 0000000..43c7506
> --- /dev/null
> +++ b/debian/grub-xen-host.install
> @@ -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 --git a/debian/grub-xen-host_grub.cfg b/debian/grub-xen-host_grub.cfg
> new file mode 100644
> index 0000000..d23f22a
> --- /dev/null
> +++ b/debian/grub-xen-host_grub.cfg
> @@ -0,0 +1,37 @@
> +set default=0
> +set fallback=1
> +set timeout=10
> +
> +menuentry "Search & load /boot/multiboot.img" {
> +	search -s -f /boot/multiboot.img
> +	if multiboot /boot/multiboot.img ; then
> +		boot
> +	fi
> +	unset timeout
> +}
> +
> +# For separate /boot partition.
> +menuentry "Search & load /multiboot.img" {
> +	search -s -f /multiboot.img
> +	if multiboot /multiboot.img ; then
> +		boot
> +	fi
> +	unset timeout
> +}
> +
> +menuentry "Search & source /boot/grub/grub.cfg" {
> +	search -s -f /boot/grub/grub.cfg
> +	source /boot/grub/grub.cfg
> +	unset timeout
> +}
> +
> +# For separate /boot partition.
> +menuentry "Search & source /grub/grub.cfg" {
> +	search -s -f /grub/grub.cfg
> +	source /grub/grub.cfg
> +	unset timeout
> +}
> +
> +menuentry "Reboot" {
> +	reboot
> +}
> diff --git a/debian/rules b/debian/rules
> index f478e94..b5d3d68 100755
> --- a/debian/rules
> +++ b/debian/rules
> @@ -35,7 +35,7 @@ confflags = PACKAGE_VERSION="$(deb_version)" PACKAGE_STRING="GRUB $(deb_version)
>  AUTOGEN_DEB_FILES = config templates preinst postinst postrm dirs install links maintscript
>  
>  BUILD_PACKAGES := $(strip $(shell dh_listpackages))
> -REAL_PACKAGES = 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
> +REAL_PACKAGES = 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-xen-host grub-yeeloong
>  
>  ifneq (,$(filter i386 amd64,$(DEB_HOST_ARCH_CPU)))
>  COMMON_PLATFORM := pc
> @@ -177,6 +177,35 @@ debian/stamps/build-grub-efi-ia32 debian/stamps/build-grub-efi-amd64 debian/stam
>  	dh_auto_build
>  	touch $@
>  
> +debian/stamps/configure-grub-xen-host:
> +	touch $@
> +
> +debian/stamps/configure-grub-xen-host-%:
> +	touch $@
> +
> +debian/stamps/build-grub-xen-host-i386: GRUB_TARGET := i386-xen
> +debian/stamps/build-grub-xen-host-amd64: GRUB_TARGET := x86_64-xen
> +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) ; \
> +	cp debian/grub-xen-host_grub.cfg $${grub_dir}/boot/grub/grub.cfg ; \
> +	tar -cf - -C $${grub_dir} boot > $${grub_memdisk} ; \
> +	$${obj_dir}/grub-mkimage \
> +		-O $(GRUB_TARGET) \
> +		-d $${obj_dir}/grub-core \
> +		$${obj_dir}/grub-core/*.mod \
> +		-m $${grub_memdisk} \
> +		-o $(CURDIR)/obj/$(package)/grub-$(GRUB_TARGET).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)
> @@ -356,7 +385,7 @@ ifeq (yes,$(shell dpkg-vendor --derives-from Ubuntu && echo yes))
>  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
> @@ -383,8 +412,8 @@ endif
>  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 -pgrub-xen-host --link-doc=grub-common
>  
>  ifeq (yes,$(shell dpkg-vendor --derives-from Ubuntu && echo yes))
>  override_dh_installinit:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Provide-prebuilt-grub-xen-binaries-for-host-use-in-a.patch
Type: text/x-patch
Size: 7514 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-grub-devel/attachments/20140823/f822bd9b/attachment-0003.bin>


More information about the Pkg-grub-devel mailing list