[rocko] wic: add 'part-name' argument for naming GPT partitions

Message ID 20171108110409.19900-1-nicolas.dechesne@linaro.org
State New
Headers show
Series
  • [rocko] wic: add 'part-name' argument for naming GPT partitions
Related show

Commit Message

Nicolas Dechesne Nov. 8, 2017, 11:04 a.m.
From: Artur Mądrzak <artur@madrzak.eu>

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, without it WIC cannot be used on Qualcomm based machines.

Signed-off-by: Artur Mądrzak <artur@madrzak.eu>
Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 9b60e3466ed7cff0cea10815851eb1304002eb52)
---
 scripts/lib/wic/help.py                  |  2 ++
 scripts/lib/wic/ksparser.py              |  1 +
 scripts/lib/wic/partition.py             |  1 +
 scripts/lib/wic/plugins/imager/direct.py | 11 +++++++++++
 4 files changed, 15 insertions(+)

Comments

Ed Bartosh Nov. 8, 2017, 11:22 a.m. | #1
On Wed, Nov 08, 2017 at 12:04:09PM +0100, Nicolas Dechesne wrote:
> From: Artur Mądrzak <artur@madrzak.eu>
> 
> 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, without it WIC cannot be used on Qualcomm based machines.
> 

+1

Thanks for the patch!

> Signed-off-by: Artur Mądrzak <artur@madrzak.eu>
> Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> (cherry picked from commit 9b60e3466ed7cff0cea10815851eb1304002eb52)
> ---
>  scripts/lib/wic/help.py                  |  2 ++
>  scripts/lib/wic/ksparser.py              |  1 +
>  scripts/lib/wic/partition.py             |  1 +
>  scripts/lib/wic/plugins/imager/direct.py | 11 +++++++++++
>  4 files changed, 15 insertions(+)
> 
> diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
> index bd9c62e2e8..2ac45e052e 100644
> --- a/scripts/lib/wic/help.py
> +++ b/scripts/lib/wic/help.py
> @@ -970,6 +970,8 @@ DESCRIPTION
>                              This option cannot be used with --fixed-size
>                              option.
>  
> +         --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/ksparser.py b/scripts/lib/wic/ksparser.py
> index 99b66eebc5..7850e81d2f 100644
> --- a/scripts/lib/wic/ksparser.py
> +++ b/scripts/lib/wic/ksparser.py
> @@ -144,6 +144,7 @@ class KickStart():
>          part.add_argument('--no-table', action='store_true')
>          part.add_argument('--ondisk', '--ondrive', dest='disk', default='sda')
>          part.add_argument("--overhead-factor", type=overheadtype)
> +        part.add_argument('--part-name')
>          part.add_argument('--part-type')
>          part.add_argument('--rootfs-dir')
>  
> diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
> index b623bb9e6d..66e61ba70c 100644
> --- a/scripts/lib/wic/partition.py
> +++ b/scripts/lib/wic/partition.py
> @@ -51,6 +51,7 @@ class Partition():
>          self.no_table = args.no_table
>          self.num = None
>          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/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
> index 60317eed22..bdb8385620 100644
> --- a/scripts/lib/wic/plugins/imager/direct.py
> +++ b/scripts/lib/wic/plugins/imager/direct.py
> @@ -366,6 +366,10 @@ class PartitionedImage():
>          for num in range(len(self.partitions)):
>              part = self.partitions[num]
>  
> +            if self.ptable_format == 'msdos' and part.part_name:
> +                raise WicError("setting custom partition name is not " \
> +                               "implemented for msdos partitions")
> +
>              if self.ptable_format == 'msdos' and part.part_type:
>                  # The --part-type can also be implemented for MBR partitions,
>                  # in which case it would map to the 1-byte "partition type"
> @@ -519,6 +523,13 @@ class PartitionedImage():
>              self._create_partition(self.path, part.type,
>                                     parted_fs_type, part.start, part.size_sec)
>  
> +            if part.part_name:
> +                logger.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,
> +                                          self.path), self.native_sysroot)
> +
>              if part.part_type:
>                  logger.debug("partition %d: set type UID to %s",
>                               part.num, part.part_type)
> -- 
> 2.15.0
> 
> -- 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
Armin Kuster Nov. 8, 2017, 3:46 p.m. | #2
On 11/08/2017 03:04 AM, Nicolas Dechesne wrote:
> From: Artur Mądrzak <artur@madrzak.eu>
>
> 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, without it WIC cannot be used on Qualcomm based machines.
This is adding new functionality to a stable release.  What other
machines need this to work?

- armin
>
> Signed-off-by: Artur Mądrzak <artur@madrzak.eu>
> Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> (cherry picked from commit 9b60e3466ed7cff0cea10815851eb1304002eb52)
> ---
>  scripts/lib/wic/help.py                  |  2 ++
>  scripts/lib/wic/ksparser.py              |  1 +
>  scripts/lib/wic/partition.py             |  1 +
>  scripts/lib/wic/plugins/imager/direct.py | 11 +++++++++++
>  4 files changed, 15 insertions(+)
>
> diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
> index bd9c62e2e8..2ac45e052e 100644
> --- a/scripts/lib/wic/help.py
> +++ b/scripts/lib/wic/help.py
> @@ -970,6 +970,8 @@ DESCRIPTION
>                              This option cannot be used with --fixed-size
>                              option.
>  
> +         --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/ksparser.py b/scripts/lib/wic/ksparser.py
> index 99b66eebc5..7850e81d2f 100644
> --- a/scripts/lib/wic/ksparser.py
> +++ b/scripts/lib/wic/ksparser.py
> @@ -144,6 +144,7 @@ class KickStart():
>          part.add_argument('--no-table', action='store_true')
>          part.add_argument('--ondisk', '--ondrive', dest='disk', default='sda')
>          part.add_argument("--overhead-factor", type=overheadtype)
> +        part.add_argument('--part-name')
>          part.add_argument('--part-type')
>          part.add_argument('--rootfs-dir')
>  
> diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
> index b623bb9e6d..66e61ba70c 100644
> --- a/scripts/lib/wic/partition.py
> +++ b/scripts/lib/wic/partition.py
> @@ -51,6 +51,7 @@ class Partition():
>          self.no_table = args.no_table
>          self.num = None
>          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/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
> index 60317eed22..bdb8385620 100644
> --- a/scripts/lib/wic/plugins/imager/direct.py
> +++ b/scripts/lib/wic/plugins/imager/direct.py
> @@ -366,6 +366,10 @@ class PartitionedImage():
>          for num in range(len(self.partitions)):
>              part = self.partitions[num]
>  
> +            if self.ptable_format == 'msdos' and part.part_name:
> +                raise WicError("setting custom partition name is not " \
> +                               "implemented for msdos partitions")
> +
>              if self.ptable_format == 'msdos' and part.part_type:
>                  # The --part-type can also be implemented for MBR partitions,
>                  # in which case it would map to the 1-byte "partition type"
> @@ -519,6 +523,13 @@ class PartitionedImage():
>              self._create_partition(self.path, part.type,
>                                     parted_fs_type, part.start, part.size_sec)
>  
> +            if part.part_name:
> +                logger.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,
> +                                          self.path), self.native_sysroot)
> +
>              if part.part_type:
>                  logger.debug("partition %d: set type UID to %s",
>                               part.num, part.part_type)
Nicolas Dechesne Nov. 8, 2017, 3:48 p.m. | #3
On Wed, Nov 8, 2017 at 4:46 PM, akuster808 <akuster808@gmail.com> wrote:
>
>
> On 11/08/2017 03:04 AM, Nicolas Dechesne wrote:
>> From: Artur Mądrzak <artur@madrzak.eu>
>>
>> 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, without it WIC cannot be used on Qualcomm based machines.
> This is adding new functionality to a stable release.  What other
> machines need this to work?

that's one way to look at it. I am looking at it as "this patch fixes
WIC for my board" ;)

More seriously.. +Ed , who indicated the patch was a good target for
backport on the list already.

>
> - armin
>>
>> Signed-off-by: Artur Mądrzak <artur@madrzak.eu>
>> Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
>> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
>> (cherry picked from commit 9b60e3466ed7cff0cea10815851eb1304002eb52)
>> ---
>>  scripts/lib/wic/help.py                  |  2 ++
>>  scripts/lib/wic/ksparser.py              |  1 +
>>  scripts/lib/wic/partition.py             |  1 +
>>  scripts/lib/wic/plugins/imager/direct.py | 11 +++++++++++
>>  4 files changed, 15 insertions(+)
>>
>> diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
>> index bd9c62e2e8..2ac45e052e 100644
>> --- a/scripts/lib/wic/help.py
>> +++ b/scripts/lib/wic/help.py
>> @@ -970,6 +970,8 @@ DESCRIPTION
>>                              This option cannot be used with --fixed-size
>>                              option.
>>
>> +         --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/ksparser.py b/scripts/lib/wic/ksparser.py
>> index 99b66eebc5..7850e81d2f 100644
>> --- a/scripts/lib/wic/ksparser.py
>> +++ b/scripts/lib/wic/ksparser.py
>> @@ -144,6 +144,7 @@ class KickStart():
>>          part.add_argument('--no-table', action='store_true')
>>          part.add_argument('--ondisk', '--ondrive', dest='disk', default='sda')
>>          part.add_argument("--overhead-factor", type=overheadtype)
>> +        part.add_argument('--part-name')
>>          part.add_argument('--part-type')
>>          part.add_argument('--rootfs-dir')
>>
>> diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
>> index b623bb9e6d..66e61ba70c 100644
>> --- a/scripts/lib/wic/partition.py
>> +++ b/scripts/lib/wic/partition.py
>> @@ -51,6 +51,7 @@ class Partition():
>>          self.no_table = args.no_table
>>          self.num = None
>>          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/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
>> index 60317eed22..bdb8385620 100644
>> --- a/scripts/lib/wic/plugins/imager/direct.py
>> +++ b/scripts/lib/wic/plugins/imager/direct.py
>> @@ -366,6 +366,10 @@ class PartitionedImage():
>>          for num in range(len(self.partitions)):
>>              part = self.partitions[num]
>>
>> +            if self.ptable_format == 'msdos' and part.part_name:
>> +                raise WicError("setting custom partition name is not " \
>> +                               "implemented for msdos partitions")
>> +
>>              if self.ptable_format == 'msdos' and part.part_type:
>>                  # The --part-type can also be implemented for MBR partitions,
>>                  # in which case it would map to the 1-byte "partition type"
>> @@ -519,6 +523,13 @@ class PartitionedImage():
>>              self._create_partition(self.path, part.type,
>>                                     parted_fs_type, part.start, part.size_sec)
>>
>> +            if part.part_name:
>> +                logger.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,
>> +                                          self.path), self.native_sysroot)
>> +
>>              if part.part_type:
>>                  logger.debug("partition %d: set type UID to %s",
>>                               part.num, part.part_type)
>
Nicolas Dechesne Nov. 30, 2017, 4:20 p.m. | #4
On Wed, Nov 8, 2017 at 4:48 PM, Nicolas Dechesne
<nicolas.dechesne@linaro.org> wrote:
> On Wed, Nov 8, 2017 at 4:46 PM, akuster808 <akuster808@gmail.com> wrote:
>>
>>
>> On 11/08/2017 03:04 AM, Nicolas Dechesne wrote:
>>> From: Artur Mądrzak <artur@madrzak.eu>
>>>
>>> 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, without it WIC cannot be used on Qualcomm based machines.
>> This is adding new functionality to a stable release.  What other
>> machines need this to work?
>
> that's one way to look at it. I am looking at it as "this patch fixes
> WIC for my board" ;)
>
> More seriously.. +Ed , who indicated the patch was a good target for
> backport on the list already.

back on this topic. Any chance to get this WIC patch into rocko?

>
>>
>> - armin
>>>
>>> Signed-off-by: Artur Mądrzak <artur@madrzak.eu>
>>> Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
>>> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
>>> (cherry picked from commit 9b60e3466ed7cff0cea10815851eb1304002eb52)
>>> ---
>>>  scripts/lib/wic/help.py                  |  2 ++
>>>  scripts/lib/wic/ksparser.py              |  1 +
>>>  scripts/lib/wic/partition.py             |  1 +
>>>  scripts/lib/wic/plugins/imager/direct.py | 11 +++++++++++
>>>  4 files changed, 15 insertions(+)
>>>
>>> diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
>>> index bd9c62e2e8..2ac45e052e 100644
>>> --- a/scripts/lib/wic/help.py
>>> +++ b/scripts/lib/wic/help.py
>>> @@ -970,6 +970,8 @@ DESCRIPTION
>>>                              This option cannot be used with --fixed-size
>>>                              option.
>>>
>>> +         --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/ksparser.py b/scripts/lib/wic/ksparser.py
>>> index 99b66eebc5..7850e81d2f 100644
>>> --- a/scripts/lib/wic/ksparser.py
>>> +++ b/scripts/lib/wic/ksparser.py
>>> @@ -144,6 +144,7 @@ class KickStart():
>>>          part.add_argument('--no-table', action='store_true')
>>>          part.add_argument('--ondisk', '--ondrive', dest='disk', default='sda')
>>>          part.add_argument("--overhead-factor", type=overheadtype)
>>> +        part.add_argument('--part-name')
>>>          part.add_argument('--part-type')
>>>          part.add_argument('--rootfs-dir')
>>>
>>> diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
>>> index b623bb9e6d..66e61ba70c 100644
>>> --- a/scripts/lib/wic/partition.py
>>> +++ b/scripts/lib/wic/partition.py
>>> @@ -51,6 +51,7 @@ class Partition():
>>>          self.no_table = args.no_table
>>>          self.num = None
>>>          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/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
>>> index 60317eed22..bdb8385620 100644
>>> --- a/scripts/lib/wic/plugins/imager/direct.py
>>> +++ b/scripts/lib/wic/plugins/imager/direct.py
>>> @@ -366,6 +366,10 @@ class PartitionedImage():
>>>          for num in range(len(self.partitions)):
>>>              part = self.partitions[num]
>>>
>>> +            if self.ptable_format == 'msdos' and part.part_name:
>>> +                raise WicError("setting custom partition name is not " \
>>> +                               "implemented for msdos partitions")
>>> +
>>>              if self.ptable_format == 'msdos' and part.part_type:
>>>                  # The --part-type can also be implemented for MBR partitions,
>>>                  # in which case it would map to the 1-byte "partition type"
>>> @@ -519,6 +523,13 @@ class PartitionedImage():
>>>              self._create_partition(self.path, part.type,
>>>                                     parted_fs_type, part.start, part.size_sec)
>>>
>>> +            if part.part_name:
>>> +                logger.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,
>>> +                                          self.path), self.native_sysroot)
>>> +
>>>              if part.part_type:
>>>                  logger.debug("partition %d: set type UID to %s",
>>>                               part.num, part.part_type)
>>

Patch

diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
index bd9c62e2e8..2ac45e052e 100644
--- a/scripts/lib/wic/help.py
+++ b/scripts/lib/wic/help.py
@@ -970,6 +970,8 @@  DESCRIPTION
                             This option cannot be used with --fixed-size
                             option.
 
+         --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/ksparser.py b/scripts/lib/wic/ksparser.py
index 99b66eebc5..7850e81d2f 100644
--- a/scripts/lib/wic/ksparser.py
+++ b/scripts/lib/wic/ksparser.py
@@ -144,6 +144,7 @@  class KickStart():
         part.add_argument('--no-table', action='store_true')
         part.add_argument('--ondisk', '--ondrive', dest='disk', default='sda')
         part.add_argument("--overhead-factor", type=overheadtype)
+        part.add_argument('--part-name')
         part.add_argument('--part-type')
         part.add_argument('--rootfs-dir')
 
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index b623bb9e6d..66e61ba70c 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -51,6 +51,7 @@  class Partition():
         self.no_table = args.no_table
         self.num = None
         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/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index 60317eed22..bdb8385620 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -366,6 +366,10 @@  class PartitionedImage():
         for num in range(len(self.partitions)):
             part = self.partitions[num]
 
+            if self.ptable_format == 'msdos' and part.part_name:
+                raise WicError("setting custom partition name is not " \
+                               "implemented for msdos partitions")
+
             if self.ptable_format == 'msdos' and part.part_type:
                 # The --part-type can also be implemented for MBR partitions,
                 # in which case it would map to the 1-byte "partition type"
@@ -519,6 +523,13 @@  class PartitionedImage():
             self._create_partition(self.path, part.type,
                                    parted_fs_type, part.start, part.size_sec)
 
+            if part.part_name:
+                logger.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,
+                                          self.path), self.native_sysroot)
+
             if part.part_type:
                 logger.debug("partition %d: set type UID to %s",
                              part.num, part.part_type)