[elbe-devel] [PATCH v2] hdimg: Allow additional arguments for grub-install

viraj viraj.shah at linutronix.de
Fri Sep 23 16:05:13 CEST 2022



On 9/22/22 21:01, Bastian Germann wrote:
> There might be use cases where grub-install needs additional arguments to
> the ones that are currently used. Replace the erroneous schema documentation
> to reflect this possibility and implement it in the actual grub-install calls.
> The additional arguments are prepended to Elbe's so that they are overridden
> by Elbe if duplicate arguments are supplied.
>
> Extend one example to make use of the new feature.
> While at it, fix too deep indentation.
>
> Signed-off-by: Bastian Germann <bage at linutronix.de>

Reviewed-by: Viraj Shah <viraj.shah at linutronix.de>

> ---
>  elbepack/hdimg.py                             | 20 +++++++++----------
>  .../x86_32-pc-hdimg-minimal-grub-buster.xml   |  6 +++---
>  schema/dbsfed.xsd                             |  8 ++++----
>  3 files changed, 17 insertions(+), 17 deletions(-)
>
> diff --git a/elbepack/hdimg.py b/elbepack/hdimg.py
> index ebc4931d5c..ab2c9c324c 100644
> --- a/elbepack/hdimg.py
> +++ b/elbepack/hdimg.py
> @@ -151,7 +151,7 @@ class grubinstaller_base:
>      def add_fs_entry(self, entry):
>          self.fs[entry.mountpoint] = entry
>  
> -    def install(self, target):
> +    def install(self, target, user_args):
>          pass
>  
>      @staticmethod
> @@ -162,7 +162,7 @@ class grubinstaller_base:
>  
>  class grubinstaller202(grubinstaller_base):
>  
> -    def install(self, target):
> +    def install(self, target, user_args):
>          if '/' not in self.fs:
>              return
>  
> @@ -194,9 +194,9 @@ class grubinstaller202(grubinstaller_base):
>  
>              if "efi" in self.fw_type:
>                  grub_tgt = next(t for t in self.fw_type if t.endswith("-efi"))
> -                do("chroot %s grub-install --target=%s --removable "
> +                do("chroot %s grub-install %s --target=%s --removable "
>                     "--no-floppy %s" %
> -                   (imagemnt, grub_tgt, poopdev))
> +                   (imagemnt, user_args, grub_tgt, poopdev))
>              if "shimfix" in self.fw_type:
>                  # grub-install is heavily dependent on the running system having
>                  # a BIOS or EFI.  The initvm is BIOS-based, so fix the resulting
> @@ -207,8 +207,8 @@ class grubinstaller202(grubinstaller_base):
>                     "${f[0]} /boot/efi/EFI/debian/${f[0]%%.signed}'"  %
>                     imagemnt)
>              if not self.fw_type or "bios" in self.fw_type:
> -                do("chroot %s grub-install --target=i386-pc --no-floppy %s" %
> -                   (imagemnt, poopdev))
> +                do("chroot %s grub-install %s --target=i386-pc --no-floppy %s" %
> +                   (imagemnt, user_args, poopdev))
>  
>          except CommandError as E:
>              logging.error("Fail installing grub device: %s", E)
> @@ -229,7 +229,7 @@ class grubinstaller202(grubinstaller_base):
>  
>  class grubinstaller97(grubinstaller_base):
>  
> -    def install(self, target):
> +    def install(self, target, user_args):
>          if '/' not in self.fs:
>              return
>  
> @@ -279,8 +279,8 @@ class grubinstaller97(grubinstaller_base):
>  
>              chroot(imagemnt, "update-grub")
>  
> -            do("chroot %s grub-install --no-floppy %s" %
> -               (imagemnt, poopdev))
> +            do("chroot %s grub-install %s --no-floppy %s" %
> +               (imagemnt, user_args, poopdev))
>  
>          except CommandError as E:
>              logging.error("Fail installing grub device: %s", E)
> @@ -497,7 +497,7 @@ def do_image_hd(hd, fslabel, target, grub_version, grub_fw_type=None):
>      disk.commit()
>  
>      if hd.has("grub-install") and grub_version:
> -        grub.install(target)
> +        grub.install(target, hd.text("grub-install"))
>  
>      return hd.text("name")
>  
> diff --git a/examples/x86_32-pc-hdimg-minimal-grub-buster.xml b/examples/x86_32-pc-hdimg-minimal-grub-buster.xml
> index 38c3635de4..2ff012ab13 100644
> --- a/examples/x86_32-pc-hdimg-minimal-grub-buster.xml
> +++ b/examples/x86_32-pc-hdimg-minimal-grub-buster.xml
> @@ -24,10 +24,10 @@ SPDX-FileCopyrightText: Linutronix GmbH
>  			<msdoshd>
>  				<name>sda.img</name>
>  				<size>1900MiB</size>
> -				<grub-install/>
> +				<grub-install>--no-rs-codes</grub-install>
>  				<partition>
> -								<size>remain</size>
> -								<label>rfs</label>
> +					<size>remain</size>
> +					<label>rfs</label>
>  				</partition>
>  			</msdoshd>
>  		</images>
> diff --git a/schema/dbsfed.xsd b/schema/dbsfed.xsd
> index 83f20cda4d..dec99f440c 100644
> --- a/schema/dbsfed.xsd
> +++ b/schema/dbsfed.xsd
> @@ -1408,8 +1408,8 @@ SPDX-FileCopyrightText: Linutronix GmbH
>        <element name="grub-install" type="rfs:string" minOccurs="0" maxOccurs="1">
>          <annotation>
>            <documentation>
> -            human readable name of the harddisk, this will be used as name for
> -            the image file
> +            Installs grub on this harddisk. The text content will be used as
> +            additional command line arguments to Elbe's grub-install call.
>            </documentation>
>          </annotation>
>        </element>
> @@ -1489,8 +1489,8 @@ SPDX-FileCopyrightText: Linutronix GmbH
>        <element name="grub-install" type="rfs:string" minOccurs="0" maxOccurs="1">
>          <annotation>
>            <documentation>
> -            human readable name of the harddisk, this will be used as name for
> -            the image file
> +            Installs grub on this harddisk. The text content will be used as
> +            additional command line arguments to Elbe's grub-install call.
>            </documentation>
>          </annotation>
>        </element>

-- 
Viraj Shah
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 16; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br. HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner



More information about the elbe-devel mailing list