All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Artur Mądrzak" <artur@madrzak.eu>
To: openembedded-core@lists.openembedded.org
Subject: [morty][PATCH] wic: add 'part-name' argument for naming GPT partitions
Date: Tue, 7 Nov 2017 21:07:08 +0100	[thread overview]
Message-ID: <20171107200707.GA9864@mobilek> (raw)

The WIC's 'part' can now give a name for GPT partition in WKS file.
It's similar to '--label', but is naming partintions instead file systems.
It's required by some bootloaders to partitions have specified names.

Backport from master to be able generate SD card image for Dragonboard410c.

Signed-off-by: Artur Mądrzak <artur@madrzak.eu>
---
 scripts/lib/wic/help.py                |  2 ++
 scripts/lib/wic/imager/direct.py       |  1 +
 scripts/lib/wic/ksparser.py            |  1 +
 scripts/lib/wic/partition.py           |  1 +
 scripts/lib/wic/utils/partitionedfs.py | 15 ++++++++++++++-
 5 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
index e5347ec4b7..324499e438 100644
--- a/scripts/lib/wic/help.py
+++ b/scripts/lib/wic/help.py
@@ -727,6 +727,8 @@ DESCRIPTION
                             equal to 1.
                             The default value is 1.3.
 
+         --part-name: This option is specific to wic. It specifies name for GPT partitions.
+
          --part-type: This option is specific to wic. It specifies partition
                       type GUID for GPT partitions.
                       List of partition type GUIDS can be found here:
diff --git a/scripts/lib/wic/imager/direct.py b/scripts/lib/wic/imager/direct.py
index 4c547e04a6..6cb209aa88 100644
--- a/scripts/lib/wic/imager/direct.py
+++ b/scripts/lib/wic/imager/direct.py
@@ -299,6 +299,7 @@ class DirectImageCreator(BaseImageCreator):
                                        boot=part.active,
                                        align=part.align,
                                        no_table=part.no_table,
+                                       part_name=part.part_name,
                                        part_type=part.part_type,
                                        uuid=part.uuid,
                                        system_id=part.system_id)
diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py
index 0894e2b199..3c99136144 100644
--- a/scripts/lib/wic/ksparser.py
+++ b/scripts/lib/wic/ksparser.py
@@ -134,6 +134,7 @@ class KickStart():
         part.add_argument('--no-table', action='store_true')
         part.add_argument('--ondisk', '--ondrive', dest='disk')
         part.add_argument("--overhead-factor", type=overheadtype, default=1.3)
+        part.add_argument('--part-name')
         part.add_argument('--part-type')
         part.add_argument('--rootfs-dir')
         part.add_argument('--size', type=sizetype, default=0)
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index ec3aa6622c..2ffe7e3350 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -51,6 +51,7 @@ class Partition():
         self.mountpoint = args.mountpoint
         self.no_table = args.no_table
         self.overhead_factor = args.overhead_factor
+        self.part_name = args.part_name
         self.part_type = args.part_type
         self.rootfs_dir = args.rootfs_dir
         self.size = args.size
diff --git a/scripts/lib/wic/utils/partitionedfs.py b/scripts/lib/wic/utils/partitionedfs.py
index 9ea4a30cbb..d18fa1d489 100644
--- a/scripts/lib/wic/utils/partitionedfs.py
+++ b/scripts/lib/wic/utils/partitionedfs.py
@@ -91,7 +91,7 @@ class Image():
 
     def add_partition(self, size, disk_name, mountpoint, source_file=None, fstype=None,
                       label=None, fsopts=None, boot=False, align=None, no_table=False,
-                      part_type=None, uuid=None, system_id=None):
+                      part_name=None, part_type=None, uuid=None, system_id=None):
         """ Add the next partition. Partitions have to be added in the
         first-to-last order. """
 
@@ -113,6 +113,7 @@ class Image():
                 'boot': boot, # Bootable flag
                 'align': align, # Partition alignment
                 'no_table' : no_table, # Partition does not appear in partition table
+                'part_name' : part_name, # Partition name
                 'part_type' : part_type, # Partition type
                 'uuid': uuid, # Partition UUID
                 'system_id': system_id} # Partition system id
@@ -146,6 +147,11 @@ class Image():
                 raise ImageError("setting custom partition type is not " \
                                  "implemented for msdos partitions")
 
+            if ptable_format == 'msdos' and part['part_name']:
+                raise ImageError("setting custom partition name is not " \
+                                 "implemented for msdos partitions")
+
+
             # Get the disk where the partition is located
             disk = self.disks[part['disk_name']]
             disk['numpart'] += 1
@@ -301,6 +307,13 @@ class Image():
             self.__create_partition(disk['disk'].device, part['type'],
                                     parted_fs_type, part['start'], part['size'])
 
+            if part['part_name']:
+                msger.debug("partition %d: set  name to %s" % \
+                            (part['num'], part['part_name']))
+                exec_native_cmd("sgdisk --change-name=%d:%s %s" % \
+                                         (part['num'], part['part_name'],
+                                          disk['disk'].device), self.native_sysroot)
+
             if part['part_type']:
                 msger.debug("partition %d: set type UID to %s" % \
                             (part['num'], part['part_type']))
-- 
2.13.6



             reply	other threads:[~2017-11-07 20:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-07 20:07 Artur Mądrzak [this message]
2017-11-08 11:02 ` [morty][PATCH] wic: add 'part-name' argument for naming GPT partitions Nicolas Dechesne

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171107200707.GA9864@mobilek \
    --to=artur@madrzak.eu \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.