wic: use part_name when defined
PATCH 1/3 wic: use part_name when defined
From: Dit Kozmaj <[email protected]>
So far part.label has been used to define GPT partition label even if part.part_name was defined.
Fix the code to use part.part_name whenever available, as it makes sense to have a GPT partition label which is different from the contained filesystem label.
--- scripts/lib/wic/plugins/imager/direct.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
scripts/lib/wic/plugins/imager/direct.py +4 -10
@@ -571,11 +571,12 @@ class PartitionedImage(): self._create_partition(self.path, part.type, parted_fs_type, part.start, part.size_sec) - if part.part_name: + if self.ptable_format == "gpt" and (part.part_name or part.label): + partition_label = part.part_name if part.part_name else part.label logger.debug("partition %d: set name to %s", - part.num, part.part_name) + part.num, partition_label) exec_native_cmd("sgdisk --change-name=%d:%s %s" % \ - (part.num, part.part_name, + (part.num, partition_label, self.path), self.native_sysroot) if part.part_type:
@@ -592,13 +593,6 @@ class PartitionedImage(): (part.num, part.uuid, self.path), self.native_sysroot) - if part.label and self.ptable_format == "gpt": - logger.debug("partition %d: set name to %s", - part.num, part.label) - exec_native_cmd("parted -s %s name %d %s" % \ - (self.path, part.num, part.label), - self.native_sysroot) - if part.active: flag_name = "legacy_boot" if self.ptable_format == 'gpt' else "boot" logger.debug("Set '%s' flag for partition '%s' on disk '%s'",
Signature · 1 line
2.34.1
PATCH 2/3 selftest: wic: Add test for --part-name argument
From: Dit Kozmaj <[email protected]>
Add test for wic --part-name argument in .wks file.
Test three different cases:
- Set only the --part-name argument.
- Set only the --label argument. In this case the GPT partition label is set to the value of --label for compatibility reasons.
- Set both. In this case the code has been changed to set the GPT partition label to the --part-name value.
The test uses a test_gpt_partition_name.wks file created for this purpose.
--- meta-selftest/wic/test_gpt_partition_name.wks | 7 ++++++ meta/lib/oeqa/selftest/cases/wic.py | 23 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 meta-selftest/wic/test_gpt_partition_name.wks
meta-selftest/wic/test_gpt_partition_name.wks new file +7 -0
@@ -0,0 +1,7 @@ +# short-description: image to test part-name in GPT partitions + +part --fstype=ext4 --part-name boot-A --label boot --size 1M --align 1024 +part / --source rootfs --fstype=ext4 --part-name root-A --align 1024 +part --fstype=ext4 --label ext-space --size 1M --align 1024 + +bootloader --ptable gpt
meta/lib/oeqa/selftest/cases/wic.py +23 -0
@@ -1348,6 +1348,29 @@ class Wic2(WicTestCase): if os.path.exists(image_path + '.bak'): os.rename(image_path + '.bak', image_path) + def test_gpt_partition_name(self): + """Test --part-name argument to set partition name in GPT table""" + config = 'IMAGE_FSTYPES += "wic"\nWKS_FILE = "test_gpt_partition_name.wks"\n' + self.append_config(config) + bitbake('core-image-minimal') + self.remove_config(config) + deploy_dir = get_bb_var('DEPLOY_DIR_IMAGE') + machine = self.td['MACHINE'] + + image_path = os.path.join(deploy_dir, 'core-image-minimal-%s.wic' % machine) + # Image is created + self.assertTrue(os.path.exists(image_path)) + + # Check the names of the three partitions + # as listed in test_gpt_partition_name.wks + result = runCmd("sfdisk --part-label %s 1" % image_path) + self.assertEqual('boot-A', result.output) + result = runCmd("sfdisk --part-label %s 2" % image_path) + self.assertEqual('root-A', result.output) + # When the --part-name is not defined, the partition name is equal to the --label + result = runCmd("sfdisk --part-label %s 3" % image_path) + self.assertEqual('ext-space', result.output) + class ModifyTests(WicTestCase): def test_wic_ls(self): """Test listing image content using 'wic ls'"""
Signature · 1 line
2.34.1
PATCH 3/3 kickstart: Expand label and part-name doc
In reply to [email protected]From: Dit Kozmaj <[email protected]>
Update --label and --part-name documentation to reflect the behaviour with GPT partition format.
--- documentation/ref-manual/kickstart.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
documentation/ref-manual/kickstart.rst +5 -1
@@ -135,6 +135,8 @@ the ``part`` and ``partition`` commands: - ``--label label``: Specifies the label to give to the filesystem to be made on the partition. If the given label is already in use by another filesystem, a new label is created for the partition. + If the partition table format is GPT and the ``--part-name`` is not + defined the partition name is set as the value of ``--label``. - ``--active``: Marks the partition as active.
@@ -172,7 +174,9 @@ the ``part`` and ``partition`` commands: "1.3". - ``--part-name``: This option is a Wic-specific option that - specifies a name for GPT partitions. + specifies a name for GPT partitions. If both ``--part-name`` and + ``--label`` are defined, the partition name is set to the value of + ``--part-name``. - ``--part-type``: This option is a Wic-specific option that specifies the partition type globally unique identifier (GUID) for
Signature · 1 line
2.34.1