[elbe-devel] [PATCH 1/3] finetuning: Add image partition shell action
Torben Hohn
torben.hohn at linutronix.de
Wed Jun 24 11:28:38 CEST 2020
On Mon, Jun 22, 2020 at 01:14:46PM -0400, Olivier Dion wrote:
> Scripts defined under nodes losetup/sh are written to
> builddir/finetuning-lostup-sh-%d, where %d is the partition number of
> the image. They are then executed with ELBE_MNT set to the mount
> point of the target partition.
i dont see the point in writing the script to a file, before executing
it.
why dont you just do(script) ?
also sh is little bit short.
in the normal finetuning we already have <command>
https://github.com/Linutronix/elbe/blob/master/elbepack/finetuning.py#L380
you could just implement execute_prj() and execute_img()
on class CmdAction
>
> Signed-off-by: Olivier Dion <dion at linutronix.de>
> ---
> elbepack/finetuning.py | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
> diff --git a/elbepack/finetuning.py b/elbepack/finetuning.py
> index cfcb5af1..082dd158 100644
> --- a/elbepack/finetuning.py
> +++ b/elbepack/finetuning.py
> @@ -679,6 +679,29 @@ class CopyToPartition(ImageFinetuningAction):
> cmd = 'cp "%s" "%s"' % (os.path.join(builddir, aname), fname)
> do(cmd)
>
> + at FinetuningAction.register("sh")
> +class ShellPartition(ImageFinetuningAction):
> +
> + 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"])
> + spath = os.path.join(builddir, "finetuning-losetup-sh-%s" %
> + self.node.et.attrib["part"])
> +
> + with open(spath, "w") as f:
> + f.write(script)
> +
> + os.chmod(spath, 0o755)
> +
> + with ImgMountFilesystem(mnt, dev) as fs:
> + do(spath,
> + env_add={"ELBE_MNT": fs.path})
> +
>
> @FinetuningAction.register("unit-tests")
> class TestSuites(FinetuningAction):
> --
> 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