[elbe-devel] [PATCH v3] finetuning: Add command action in image context
Olivier Dion
dion at linutronix.de
Wed Jul 15 16:42:24 CEST 2020
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>
---
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
More information about the elbe-devel
mailing list