Skip to contentSkip to conversation

wic: add attribute parameter to parted

PATCH In review Mohammed 2 participants 2 messages Aug 19, 2025

lore
Share & tools
lore

Mohammed

author
#0 lore raw

PATCH 1/1 wic: add attribute parameter to parted

Add argument parameter which will use sgdisk to set argument
Certain bootloaders use attribute to recognize correct boot partitions and having the option via wic tool would remove the need to do via external scripts

---
 scripts/lib/wic/help.py                  | 3 +++
 scripts/lib/wic/ksparser.py              | 1 +
 scripts/lib/wic/partition.py             | 1 +
 scripts/lib/wic/plugins/imager/direct.py | 5 +++++
 4 files changed, 10 insertions(+)
scripts/lib/wic/help.py +3 -0
index 2e3061f343..fef856dbbb 100644
@@ -1070,6 +1070,9 @@ DESCRIPTION
                 an MBR header. Partitions with this flag will be included in
                 this MBR header.
 
+        --attribute: This option is specific to wic. This option is used to set
+                      the partition attribute.
+
     * bootloader
 
       This command allows the user to specify various bootloader
scripts/lib/wic/ksparser.py +1 -0
index 7ef3dc83dd..af4fb91d58 100644
@@ -189,6 +189,7 @@ class KickStart():
         part.add_argument('--fsuuid')
         part.add_argument('--no-fstab-update', action='store_true')
         part.add_argument('--mbr', action='store_true')
+        part.add_argument('--attribute')
 
         bootloader = subparsers.add_parser('bootloader')
         bootloader.add_argument('--append')
scripts/lib/wic/partition.py +1 -0
index b34691d313..cf5c51f105 100644
@@ -61,6 +61,7 @@ class Partition():
         self.update_fstab_in_rootfs = False
         self.hidden = args.hidden
         self.mbr = args.mbr
+        self.attribute = args.attribute
 
         self.lineno = lineno
         self.source_file = ""
scripts/lib/wic/plugins/imager/direct.py +5 -0
index 6e1f1c8cba..877a5d2a97 100644
@@ -664,6 +664,11 @@ class PartitionedImage():
                 exec_native_cmd("sfdisk --sector-size %s --part-attrs %s %s RequiredPartition" % \
                                 (self.sector_size, self.path, part.num),
                                 self.native_sysroot)
+            
+            if part.attribute:
+                logger.debug("Set attribute:'%s' for partition '%s' on disk '%s'", part.attribute ,part.num, self.path)
+                exec_native_cmd("sgdisk -A %s:=:%s %s" % (part.num, part.attribute, self.path), \
+                self.native_sysroot)
 
         if self.ptable_format == "gpt-hybrid":
             # Write a protective GPT partition
#1 lore raw
Quoted 18 lines · Mohammed via lists.openembedded.org

Add argument parameter which will use sgdisk to set argument
Certain bootloaders use attribute to recognize correct boot partitions and having the option via wic tool would remove the need to do via external scripts

---
 scripts/lib/wic/help.py                  | 3 +++
 scripts/lib/wic/ksparser.py              | 1 +
 scripts/lib/wic/partition.py             | 1 +
 scripts/lib/wic/plugins/imager/direct.py | 5 +++++
 4 files changed, 10 insertions(+)
scripts/lib/wic/help.py +0 -0
index 2e3061f343..fef856dbbb 100644

scripts/lib/wic/help.py DESCRIPTION · line 1073

Quoted 4 lines
scripts/lib/wic/help.py +1 -0
@@ -1070,6 +1070,9 @@ DESCRIPTION
                 an MBR header. Partitions with this flag will be included in
                 this MBR header.
 
+        --attribute: This option is specific to wic. This option is used to set

Drop the line "This option is specific to wic."
secondly as mentioned to prior version please add a selftest for this option

Quoted 54 lines
scripts/lib/wic/help.py +2 -0
+                      the partition attribute.
+
     * bootloader
 
       This command allows the user to specify various bootloader
scripts/lib/wic/ksparser.py +1 -0
index 7ef3dc83dd..af4fb91d58 100644
@@ -189,6 +189,7 @@ class KickStart():
         part.add_argument('--fsuuid')
         part.add_argument('--no-fstab-update', action='store_true')
         part.add_argument('--mbr', action='store_true')
+        part.add_argument('--attribute')
 
         bootloader = subparsers.add_parser('bootloader')
         bootloader.add_argument('--append')
scripts/lib/wic/partition.py +1 -0
index b34691d313..cf5c51f105 100644
@@ -61,6 +61,7 @@ class Partition():
         self.update_fstab_in_rootfs = False
         self.hidden = args.hidden
         self.mbr = args.mbr
+        self.attribute = args.attribute
 
         self.lineno = lineno
         self.source_file = ""
scripts/lib/wic/plugins/imager/direct.py +5 -1
index 6e1f1c8cba..877a5d2a97 100644
@@ -664,6 +664,11 @@ class PartitionedImage():
                 exec_native_cmd("sfdisk --sector-size %s --part-attrs %s %s RequiredPartition" % \
                                 (self.sector_size, self.path, part.num),
                                 self.native_sysroot)
+
+            if part.attribute:
+                logger.debug("Set attribute:'%s' for partition '%s' on disk '%s'", part.attribute ,part.num, self.path)
+                exec_native_cmd("sgdisk -A %s:=:%s %s" % (part.num, part.attribute, self.path), \
+                self.native_sysroot)
 
         if self.ptable_format == "gpt-hybrid":
             # Write a protective GPT partition
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#222110): https://lists.openembedded.org/g/openembedded-core/message/222110
Mute This Topic: https://lists.openembedded.org/mt/114750349/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-