[elbe-devel] [PATCH v2 6/8] finetuning: implement ImageFinetuningAction <extract_partition>

Torben Hohn torben.hohn at linutronix.de
Wed Dec 5 09:54:10 CET 2018


extract partition extracts a single partition image from
the "currently mounted" (using <losetup>) loop device.

The extracted partition image is marked for gzip compression.

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

diff --git a/elbepack/finetuning.py b/elbepack/finetuning.py
index a499b56e..93a531d5 100644
--- a/elbepack/finetuning.py
+++ b/elbepack/finetuning.py
@@ -569,6 +569,32 @@ class LosetupAction(FinetuningAction):
 FinetuningAction.register(LosetupAction)
 
 
+class ExtractPartitionAction(ImageFinetuningAction):
+
+    tag = 'extract_partition'
+
+    def __init__(self, node):
+        ImageFinetuningAction.__init__(self, node)
+
+    def execute(self, _log, _buildenv, _target):
+        raise NotImplementedError("<extract_partition> may only be "
+                                  "used in <mount_drive>")
+
+    def execute_img(self, log, _buildenv, target, builddir, loop_dev):
+        part_nr = self.node.et.attrib['part']
+        imgname = os.path.join(builddir, self.node.et.text)
+
+        cmd = 'dd if=%sp%s of="%s"' % (loop_dev, part_nr, imgname)
+
+        log.do(cmd)
+
+        target.images.append(self.node.et.text)
+        target.image_packers[self.node.et.text] = ('gzip -f', '.gz')
+
+
+FinetuningAction.register(ExtractPartitionAction)
+
+
 def do_finetuning(xml, log, buildenv, target):
 
     if not xml.has('target/finetuning'):
diff --git a/schema/dbsfed.xsd b/schema/dbsfed.xsd
index 88f4d9cf..887a8bfc 100644
--- a/schema/dbsfed.xsd
+++ b/schema/dbsfed.xsd
@@ -1940,9 +1940,31 @@
       </documentation>
     </annotation>
     <choice>
+      <element name="extract_partition" type="rfs:extract_partition" minOccurs="0">
+        <annotation>
+          <documentation>
+            Extract a Partition from the currently mounted loop device.
+          </documentation>
+        </annotation>
+      </element>
     </choice>
   </group>
 
+  <complexType name="extract_partition">
+    <annotation>
+      <documentation>
+        Describe the partition to be extracted (nr) and the destination filename.
+	The value of the tag describes the filename of the generated Imagefile.
+	The Image is per default compressed with gzip afterwards.
+      </documentation>
+    </annotation>
+    <simpleContent>
+      <extension base="rfs:string">
+        <attribute name="part" type="integer" use="required" />
+      </extension>
+    </simpleContent>
+  </complexType>
+
   <complexType name="addgroup">
     <annotation>
       <documentation>
-- 
2.11.0




More information about the elbe-devel mailing list