[elbe-devel] [PATCH 3/6] finetuning: implement <img_convert /> for <project-finetuning>
Torben Hohn
torben.hohn at linutronix.de
Wed Dec 19 17:02:01 CET 2018
Vmware is not able to handle raw images. However, development VMs are
generally supposed to be run using vmware.
Implement <img_convert /> for <project-finetuning> which allows
to use qemu-img to convert image to a different format in
<project-finetuning>.
qemu-utils is added to the runtime dependencies, to obtain
the qemu-img command.
Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
debian/control | 2 ++
elbepack/finetuning.py | 42 ++++++++++++++++++++++++++++++++++++++++++
schema/dbsfed.xsd | 27 +++++++++++++++++++++++++++
3 files changed, 71 insertions(+)
diff --git a/debian/control b/debian/control
index 158df1ba..a52a1305 100644
--- a/debian/control
+++ b/debian/control
@@ -141,6 +141,7 @@ Depends: ${misc:Depends},
python3-sqlalchemy,
python3-debian,
qemu-user-static,
+ qemu-utils,
reprepro,
rsync,
kpartx,
@@ -178,6 +179,7 @@ Depends: ${misc:Depends},
python-sqlalchemy,
python-debian,
qemu-user-static,
+ qemu-utils,
reprepro,
rsync,
kpartx,
diff --git a/elbepack/finetuning.py b/elbepack/finetuning.py
index 57778463..324aebef 100644
--- a/elbepack/finetuning.py
+++ b/elbepack/finetuning.py
@@ -555,6 +555,48 @@ class LosetupAction(FinetuningAction):
FinetuningAction.register(LosetupAction)
+class ImgConvertAction(FinetuningAction):
+
+ tag = 'img_convert'
+
+ def __init__(self, node):
+ FinetuningAction.__init__(self, node)
+
+ def execute(self, _log, _buildenv, _target):
+ raise NotImplementedError("<img_convert> may only be "
+ "used in <project-finetuning>")
+
+ def execute_prj(self, log, _buildenv, target, builddir):
+ src = self.node.et.text
+ dst = self.node.et.attrib['dst']
+ fmt = self.node.et.attrib['fmt']
+
+ if src not in target.images:
+ log.printo("Error: Artifact '%s' does not exist." % src)
+ log.printo("Valid Artifacts are:")
+ for i in target.images:
+ log.printo(i)
+ raise FinetuningException("Artifact '%s' does not exist" % src)
+
+ src_fname = os.path.join(builddir, src)
+ dst_fname = os.path.join(builddir, dst)
+
+ cmd = 'qemu-img convert -O "%s" "%s" "%s"' % (fmt,
+ src_fname,
+ dst_fname)
+ log.do(cmd)
+
+ target.images.append(dst)
+ target.image_packers[dst] = ('gzip -f', '.gz')
+
+ if not self.node.bool_attr('keep_src'):
+ target.images.remove(src)
+ del target.image_packers[src]
+
+
+FinetuningAction.register(ImgConvertAction)
+
+
class ExtractPartitionAction(ImageFinetuningAction):
tag = 'extract_partition'
diff --git a/schema/dbsfed.xsd b/schema/dbsfed.xsd
index 45c96b1d..b1fb0f45 100644
--- a/schema/dbsfed.xsd
+++ b/schema/dbsfed.xsd
@@ -1904,6 +1904,14 @@
</documentation>
</annotation>
</element>
+ <element name="img_convert" type="rfs:img_convert" minOccurs="0">
+ <annotation>
+ <documentation>
+ Convert a Partitionimage to another format. The new Image is added to
+ the list of artifacts.
+ </documentation>
+ </annotation>
+ </element>
</choice>
</group>
@@ -1973,6 +1981,25 @@
</simpleContent>
</complexType>
+ <complexType name="img_convert">
+ <annotation>
+ <documentation>
+ Describe the Image to be converted.
+ The value of the tag describes the filename of the source Imagefile.
+ The dst attribute the destination filename, and the fmt attribute is
+ the format. (See 'qemu-img --help' for a list of possible formats)
+ The Image is per default compressed with gzip afterwards.
+ </documentation>
+ </annotation>
+ <simpleContent>
+ <extension base="rfs:string">
+ <attribute name="dst" type="string" use="required" />
+ <attribute name="fmt" type="string" use="required" />
+ <attribute name="keep_src" type="boolean" use="optional" />
+ </extension>
+ </simpleContent>
+ </complexType>
+
<complexType name="adduser">
<annotation>
<documentation>
--
2.11.0
More information about the elbe-devel
mailing list