[elbe-devel] [PATCH 1/3] finetuning: Add image partition shell action
Olivier Dion
dion at linutronix.de
Mon Jun 22 19:14:46 CEST 2020
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.
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
More information about the elbe-devel
mailing list