[elbe-devel] [PATCH 7/9] finetuning: implement ImageFinetuningAction <extract_partition>
Torben Hohn
torben.hohn at linutronix.de
Wed Nov 28 17:29:02 CET 2018
extract partition extracts a single partition image from
the "currently mounted" (using <mount_drive>) loop device.
The extracted partition image is marked for gzip compression.
---
elbepack/finetuning.py | 26 ++++++++++++++++++++++++++
schema/dbsfed.xsd | 22 ++++++++++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/elbepack/finetuning.py b/elbepack/finetuning.py
index c53b13c6..3e395722 100644
--- a/elbepack/finetuning.py
+++ b/elbepack/finetuning.py
@@ -569,6 +569,32 @@ class MountDriveImageAction(FinetuningAction):
FinetuningAction.register(MountDriveImageAction)
+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 d9317c72..bb3a7cdf 100644
--- a/schema/dbsfed.xsd
+++ b/schema/dbsfed.xsd
@@ -1923,9 +1923,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