[elbe-devel] [PATCH v2 4/4] Add support for hybrid images (UEFI+Bios)

Torben Hohn torben.hohn at linutronix.de
Thu Mar 29 10:12:18 CEST 2018


On Wed, Mar 28, 2018 at 02:16:56PM +0200, Martin Kaistra wrote:
> This patch adds the possibility to create images which
> can boot from UEFI as well as Bios.
> 
> How to use:
> You need to add the packages grub-efi-amd64-bin and grub-pc
> and a small (1MiB should be enough) partition with <biosgrub> in
> addition to a standard UEFI image.
> 
> Signed-off-by: Martin Kaistra <martin.kaistra at linutronix.de>

Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>

> ---
>  elbepack/elbeproject.py | 6 +++++-
>  elbepack/hdimg.py       | 9 ++++++---
>  2 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
> index 047020bc..1cb22ef5 100644
> --- a/elbepack/elbeproject.py
> +++ b/elbepack/elbeproject.py
> @@ -466,7 +466,11 @@ class ElbeProject (object):
>          # jessie and wheezy grubs are 2.0 but differ in behaviour
>          #
>          # We might also want support for legacy grub
> -        if self.get_rpcaptcache().is_installed('grub-pc'):
> +        if (self.get_rpcaptcache().is_installed('grub-pc') and
> +                self.get_rpcaptcache().is_installed('grub-efi-amd64-bin')):
> +            grub_version = 202
> +            grub_fw_type = "hybrid"
> +        elif self.get_rpcaptcache().is_installed('grub-pc'):
>              if self.codename == "wheezy":
>                  grub_version = 199
>              else:
> diff --git a/elbepack/hdimg.py b/elbepack/hdimg.py
> index 2fc042d9..e0aab938 100644
> --- a/elbepack/hdimg.py
> +++ b/elbepack/hdimg.py
> @@ -186,7 +186,7 @@ def size_to_int(size):
>  
>  
>  class grubinstaller_base(object):
> -    def __init__(self, outf, fw_type="bios"):
> +    def __init__(self, outf, fw_type=None):
>          self.outf = outf
>          self.root = None
>          self.boot = None
> @@ -260,12 +260,13 @@ class grubinstaller202(grubinstaller_base):
>              self.outf.do("chroot %s  update-initramfs -u -k all" % imagemnt)
>              self.outf.do("chroot %s  update-grub2" % imagemnt)
>  
> -            if self.fw_type == "efi":
> +            if self.fw_type == "efi" or self.fw_type == "hybrid":
>                  self.outf.do(
>                      "chroot %s grub-install --target=x86_64-efi --removable "
>                      "--no-floppy /dev/poop0" %
>                      (imagemnt))
> -            else:
> +            if self.fw_type == "hybrid" or self.fw_type is None:
> +                # when we are in hybrid mode, install grub also into MBR
>                  self.outf.do(
>                      "chroot %s grub-install --no-floppy /dev/poop0" %
>                      (imagemnt))
> @@ -526,6 +527,8 @@ def do_image_hd(outf, hd, fslabel, target, grub_version, grub_fw_type):
>          grub = grubinstaller199(outf)
>      elif grub_version == 202 and grub_fw_type == "efi":
>          grub = grubinstaller202(outf, "efi")
> +    elif grub_version == 202 and grub_fw_type == "hybrid":
> +        grub = grubinstaller202(outf, "hybrid")
>      elif grub_version == 202:
>          grub = grubinstaller202(outf)
>      else:
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Mit freundlichen Grüßen
Torben Hohn

Linutronix GmbH

Standort: Bremen

Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Firmensitz / Registered Office: D-88690 Uhldingen, Bahnhofstr. 3
Registergericht / Local District Court: Amtsgericht Freiburg i. Br.; HRB
Nr. / Trade register no.: 700 806

Geschäftsführer / Managing Directors: Heinz Egger, Thomas Gleixner

Eine Bitte von uns: Sollten Sie diese E-Mail irrtümlich erhalten haben,
benachrichtigen Sie uns in diesem Falle bitte sobald wie es Ihnen
möglich ist, durch Antwort-Mail. Vielen Dank!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.linutronix.de/pipermail/elbe-devel/attachments/20180329/2a4ebd6c/attachment.sig>


More information about the elbe-devel mailing list