[elbe-devel] [PATCH v3] finetuning: Add command action in image context

Torben Hohn torben.hohn at linutronix.de
Wed Jul 15 17:58:54 CEST 2020


On Wed, Jul 15, 2020 at 10:42:24AM -0400, Olivier Dion wrote:
> The command is executed with ELBE_MNT set to the mount point of the
> target partition.
> 
> Since CmdAction implements the execute_img() method, it should now be
> of type ImageFinetuningAction.
> 
> Signed-off-by: Olivier Dion <dion at linutronix.de>

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

> ---
>  elbepack/finetuning.py | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/elbepack/finetuning.py b/elbepack/finetuning.py
> index cfcb5af1..00bb5c15 100644
> --- a/elbepack/finetuning.py
> +++ b/elbepack/finetuning.py
> @@ -378,10 +378,23 @@ class RawCmdAction(FinetuningAction):
>  
>  
>  @FinetuningAction.register('command')
> -class CmdAction(FinetuningAction):
> +class CmdAction(ImageFinetuningAction):
>  
>      def __init__(self, node):
> -        FinetuningAction.__init__(self, node)
> +        ImageFinetuningAction.__init__(self, node)
> +
> +    def execute_img(self, _buildenv, _target, builddir, loop_dev):
> +
> +        script = '\n'.join(line.lstrip(" \t")
> +                           for line
> +                           in self.node.et.text.strip("\n").splitlines())
> +
> +        mnt   = os.path.join(builddir, 'imagemnt')
> +        dev   = "%sp%s" % (loop_dev, self.node.et.attrib["part"])
> +
> +        with ImgMountFilesystem(mnt, dev) as fs:
> +            do("/bin/sh", stdin=script,
> +               env_add={"ELBE_MNT": fs.path})
>  
>      def execute(self, _buildenv, target):
>          with target:
> -- 
> 2.27.0
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; 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