[elbe-devel] [PATCH 3/4] finetuning: Add nomount attribute to <command> in <losetup>

Torben Hohn torben.hohn at linutronix.de
Thu Jan 20 16:56:13 CET 2022


Allow running commands in project finetuning even when the device
can not be mounted.

This allows to run mkswap for example. Later on this might also
allow to encrypt a device, etc.

Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
 elbepack/finetuning.py | 8 ++++++--
 schema/dbsfed.xsd      | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/elbepack/finetuning.py b/elbepack/finetuning.py
index 3f15a1d20..52051223b 100644
--- a/elbepack/finetuning.py
+++ b/elbepack/finetuning.py
@@ -388,9 +388,13 @@ class CmdAction(ImageFinetuningAction):
         mnt   = os.path.join(builddir, 'imagemnt')
         dev   = "%sp%s" % (loop_dev, self.node.et.attrib["part"])
 
-        with ImgMountFilesystem(mnt, dev) as fs:
+        if self.node.bool_attr('nomount'):
             do("/bin/sh", stdin=script,
-               env_add={"ELBE_MNT": fs.path})
+               env_add={"ELBE_DEV": dev})
+        else:
+            with ImgMountFilesystem(mnt, dev) as fs:
+                do("/bin/sh", stdin=script,
+                   env_add={"ELBE_MNT": fs.path})
 
     def execute(self, _buildenv, target):
         with target:
diff --git a/schema/dbsfed.xsd b/schema/dbsfed.xsd
index 34f4562c0..d288f97d0 100644
--- a/schema/dbsfed.xsd
+++ b/schema/dbsfed.xsd
@@ -2344,6 +2344,7 @@
     <simpleContent>
       <extension base="rfs:string">
         <attribute name="part" type="integer" use="required" />
+        <attribute name="nomount" type="boolean" use="optional" />
       </extension>
     </simpleContent>
   </complexType>
-- 
2.20.1



More information about the elbe-devel mailing list