[OE-core] [morty][PATCH] wic: add 'part-name' argument for naming GPT partitions

Nicolas Dechesne nicolas.dechesne at linaro.org
Wed Nov 8 11:02:43 UTC 2017


+Armin.

On Tue, Nov 7, 2017 at 9:07 PM, Artur Mądrzak <artur at madrzak.eu> wrote:
> 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 at madrzak.eu>

Reviewed-by: Nicolas Dechesne <nicolas.dechesne at linaro.org>

> ---
>  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
>



More information about the Openembedded-core mailing list