[elbe-devel] [PATCH 7/9] finetuning: implement <set_partition_type>
Torben Hohn
torben.hohn at linutronix.de
Mon Dec 14 17:41:11 CET 2020
gparted does not support many partition types.
Add an ImageFinetuning rule that uses fdisk to set the partition type.
Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
elbepack/finetuning.py | 19 +++++++++++++++++++
schema/dbsfed.xsd | 19 +++++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/elbepack/finetuning.py b/elbepack/finetuning.py
index ea76dd549..972ff6229 100644
--- a/elbepack/finetuning.py
+++ b/elbepack/finetuning.py
@@ -698,6 +698,25 @@ class CopyToPartition(ImageFinetuningAction):
cmd = 'cp "%s" "%s"' % (os.path.join(builddir, aname), fname)
do(cmd)
+ at FinetuningAction.register('set_partition_type')
+class SetPartitionTypeAction(ImageFinetuningAction):
+
+ def __init__(self, node):
+ ImageFinetuningAction.__init__(self, node)
+
+ def execute(self, _buildenv, _target):
+ raise NotImplementedError("<set_partition_type> may only be "
+ "used in <mount_drive>")
+
+ def execute_img(self, _buildenv, target, builddir, loop_dev):
+ part_nr = self.node.et.attrib['part']
+ part_type = self.node.et.attrib['type']
+
+ cmd = f'fdisk {loop_dev}'
+ inp = f't\n{part_nr}\n{part_type}\nw\n'
+
+ do(cmd, stdin=inp)
+
@FinetuningAction.register("unit-tests")
class TestSuites(FinetuningAction):
diff --git a/schema/dbsfed.xsd b/schema/dbsfed.xsd
index d6ca98bb4..95385dc90 100644
--- a/schema/dbsfed.xsd
+++ b/schema/dbsfed.xsd
@@ -2263,6 +2263,14 @@
</documentation>
</annotation>
</element>
+ <element name="set_partition_type" type="rfs:set_partition_type" minOccurs="0">
+ <annotation>
+ <documentation>
+ Set the type of a partition via fdisk. (to support esoteric partition types,
+ that parted does not support.)
+ </documentation>
+ </annotation>
+ </element>
<element name="command" type="rfs:partition-command" minOccurs="0" maxOccurs="unbounded">
<annotation>
<documentation>
@@ -2335,6 +2343,17 @@
</extension>
</simpleContent>
</complexType>
+ <complexType name="set_partition_type">
+ <annotation>
+ <documentation>
+ Attribute 'part' describes the partition to be modified (nr).
+ Attribute 'type' is the numerical partition id, as understood by
+ fdisk.
+ </documentation>
+ </annotation>
+ <attribute name="part" type="integer" use="required" />
+ <attribute name="type" type="string" use="required" />
+ </complexType>
<complexType name="addgroup">
<annotation>
<documentation>
--
2.20.1
More information about the elbe-devel
mailing list