diff mbox series

[isar-cip-core,v3] wic/plugins/efibootguard*: Take --size and --fixed-size into account

Message ID 20240508135539.2780114-1-Quirin.Gylstorff@siemens.com (mailing list archive)
State Superseded
Headers show
Series [isar-cip-core,v3] wic/plugins/efibootguard*: Take --size and --fixed-size into account | expand

Commit Message

Quirin Gylstorff May 8, 2024, 1:55 p.m. UTC
From: Quirin Gylstorff <quirin.gylstorff@siemens.com>

This fixes the issue that wic arguments --size and --fixed-size
are not correctly interpreted.

This fixes issue #104.

Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---
Changes v3:
 - remove unnecesary setting of FAT-Size(-F) and sector size(-S 512)
   the sector size default is 512 and as FAT size should be caluclate
   according to the partition size.
Changes v2:
 - replace size calculation with part.prepare_rootfs_msdos

 .../wic/plugins/source/efibootguard-boot.py   | 34 ++++---------------
 .../wic/plugins/source/efibootguard-efi.py    | 30 ++--------------
 2 files changed, 9 insertions(+), 55 deletions(-)

Comments

Jan Kiszka May 8, 2024, 5:31 p.m. UTC | #1
On 08.05.24 15:55, Quirin Gylstorff wrote:
> From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
> 
> This fixes the issue that wic arguments --size and --fixed-size
> are not correctly interpreted.
> 
> This fixes issue #104.
> 
> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
> ---
> Changes v3:
>  - remove unnecesary setting of FAT-Size(-F) and sector size(-S 512)
>    the sector size default is 512 and as FAT size should be caluclate
>    according to the partition size.
> Changes v2:
>  - replace size calculation with part.prepare_rootfs_msdos
> 
>  .../wic/plugins/source/efibootguard-boot.py   | 34 ++++---------------
>  .../wic/plugins/source/efibootguard-efi.py    | 30 ++--------------
>  2 files changed, 9 insertions(+), 55 deletions(-)
> 
> diff --git a/scripts/lib/wic/plugins/source/efibootguard-boot.py b/scripts/lib/wic/plugins/source/efibootguard-boot.py
> index 4e3aefb..2b06fd1 100644
> --- a/scripts/lib/wic/plugins/source/efibootguard-boot.py
> +++ b/scripts/lib/wic/plugins/source/efibootguard-boot.py
> @@ -136,40 +136,20 @@ class EfibootguardBootPlugin(SourcePlugin):
>                  msger.error("file %s not found in directory %s",
>                              boot_file, kernel_dir)
>                  exit(1)
> -        cls._create_img(part_rootfs_dir, part, cr_workdir)
> +        cls._create_img(part_rootfs_dir, part, cr_workdir,
> +                        native_sysroot, oe_builddir)
>  
>      @classmethod
> -    def _create_img(cls, part_rootfs_dir, part, cr_workdir):
> -            # Write label as utf-16le to EFILABEL file
> +    def _create_img(cls, part_rootfs_dir, part, cr_workdir,
> +                    native_sysroot, oe_builddir):
> +        # Write label as utf-16le to EFILABEL file
>          with open("%s/EFILABEL" % part_rootfs_dir, 'wb') as filedescriptor:
>              filedescriptor.write(part.label.upper().encode("utf-16le"))
>  
> -        du_cmd = "du --apparent-size -ks %s" % part_rootfs_dir
> -        blocks = int(exec_cmd(du_cmd).split()[0])
> -
> -        extra_blocks = part.get_extra_block_count(blocks)
> -        if extra_blocks < BOOTDD_EXTRA_SPACE:
> -            extra_blocks = BOOTDD_EXTRA_SPACE
> -
> -        blocks += extra_blocks
> -        blocks = blocks + (16 - (blocks % 16))
> -
> -        msger.debug("Added %d extra blocks to %s to get to %d total blocks",
> -                    extra_blocks, part.mountpoint, blocks)
> -
> -        # dosfs image, created by mkdosfs
>          bootimg = "%s/%s.%s.img" % (cr_workdir, part.label, part.lineno)
>  
> -        dosfs_cmd = "mkdosfs -F 16 -S 512 -n %s -C %s %d -i %s" % \
> -            (part.label.upper(), bootimg, blocks, part.fsuuid)
> -        exec_cmd(dosfs_cmd)
> -
> -        mcopy_cmd = "mcopy -v -i %s -s %s/* ::/" % (bootimg, part_rootfs_dir)
> -        exec_cmd(mcopy_cmd, True)
> -
> -        chmod_cmd = "chmod 644 %s" % bootimg
> -        exec_cmd(chmod_cmd)
> -
> +        part.prepare_rootfs_msdos(bootimg, cr_workdir, oe_builddir,
> +                                  part_rootfs_dir, native_sysroot, None)
>          du_cmd = "du -Lbks %s" % bootimg
>          bootimg_size = int(exec_cmd(du_cmd).split()[0])
>  
> diff --git a/scripts/lib/wic/plugins/source/efibootguard-efi.py b/scripts/lib/wic/plugins/source/efibootguard-efi.py
> index e82e990..48f7523 100644
> --- a/scripts/lib/wic/plugins/source/efibootguard-efi.py
> +++ b/scripts/lib/wic/plugins/source/efibootguard-efi.py
> @@ -100,35 +100,9 @@ class EfibootguardEFIPlugin(SourcePlugin):
>                                                 name)
>          exec_cmd(cp_to_deploy_cmd, True)
>  
> -        du_cmd = "du --apparent-size -ks %s" % part_rootfs_dir
> -        blocks = int(exec_cmd(du_cmd).split()[0])
> -
> -        extra_blocks = part.get_extra_block_count(blocks)
> -        if extra_blocks < BOOTDD_EXTRA_SPACE:
> -            extra_blocks = BOOTDD_EXTRA_SPACE
> -        blocks += extra_blocks
> -        blocks = blocks + (16 - (blocks % 16))
> -
> -        msger.debug("Added %d extra blocks to %s to get to %d total blocks",
> -                    extra_blocks, part.mountpoint, blocks)
> -
> -        # dosfs image, created by mkdosfs
>          efi_part_image = "%s/%s.%s.img" % (cr_workdir, part.label, part.lineno)
> -
> -        dosfs_cmd = "mkdosfs -S 512 -n %s -C %s %d -i %s" % \
> -            (part.label.upper(), efi_part_image, blocks, part.fsuuid)
> -        exec_cmd(dosfs_cmd)
> -
> -        # mtools for buster have problems with resursive mcopy.
> -        # Therefore, create the target dir via mmd first.
> -        mmd_cmd = "mmd -i %s ::/EFI ::/EFI/BOOT" % (efi_part_image)
> -        exec_cmd(mmd_cmd, True)
> -        mcopy_cmd = "mcopy -v -i %s -s %s/EFI/BOOT/* ::/EFI/BOOT" % \
> -            (efi_part_image, part_rootfs_dir)
> -        exec_cmd(mcopy_cmd, True)
> -
> -        chmod_cmd = "chmod 644 %s" % efi_part_image
> -        exec_cmd(chmod_cmd)
> +        part.prepare_rootfs_msdos(efi_part_image, cr_workdir, oe_builddir,
> +                                  part_rootfs_dir, native_sysroot, None)
>  
>          du_cmd = "du -Lbks %s" % efi_part_image
>          efi_part_image_size = int(exec_cmd(du_cmd).split()[0])

Thanks, applied.

Jan
Jan Kiszka May 8, 2024, 7:56 p.m. UTC | #2
On 08.05.24 19:31, Jan Kiszka wrote:
> On 08.05.24 15:55, Quirin Gylstorff wrote:
>> From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
>>
>> This fixes the issue that wic arguments --size and --fixed-size
>> are not correctly interpreted.
>>
>> This fixes issue #104.
>>
>> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
>> ---
>> Changes v3:
>>  - remove unnecesary setting of FAT-Size(-F) and sector size(-S 512)
>>    the sector size default is 512 and as FAT size should be caluclate
>>    according to the partition size.
>> Changes v2:
>>  - replace size calculation with part.prepare_rootfs_msdos
>>
>>  .../wic/plugins/source/efibootguard-boot.py   | 34 ++++---------------
>>  .../wic/plugins/source/efibootguard-efi.py    | 30 ++--------------
>>  2 files changed, 9 insertions(+), 55 deletions(-)
>>
>> diff --git a/scripts/lib/wic/plugins/source/efibootguard-boot.py b/scripts/lib/wic/plugins/source/efibootguard-boot.py
>> index 4e3aefb..2b06fd1 100644
>> --- a/scripts/lib/wic/plugins/source/efibootguard-boot.py
>> +++ b/scripts/lib/wic/plugins/source/efibootguard-boot.py
>> @@ -136,40 +136,20 @@ class EfibootguardBootPlugin(SourcePlugin):
>>                  msger.error("file %s not found in directory %s",
>>                              boot_file, kernel_dir)
>>                  exit(1)
>> -        cls._create_img(part_rootfs_dir, part, cr_workdir)
>> +        cls._create_img(part_rootfs_dir, part, cr_workdir,
>> +                        native_sysroot, oe_builddir)
>>  
>>      @classmethod
>> -    def _create_img(cls, part_rootfs_dir, part, cr_workdir):
>> -            # Write label as utf-16le to EFILABEL file
>> +    def _create_img(cls, part_rootfs_dir, part, cr_workdir,
>> +                    native_sysroot, oe_builddir):
>> +        # Write label as utf-16le to EFILABEL file
>>          with open("%s/EFILABEL" % part_rootfs_dir, 'wb') as filedescriptor:
>>              filedescriptor.write(part.label.upper().encode("utf-16le"))
>>  
>> -        du_cmd = "du --apparent-size -ks %s" % part_rootfs_dir
>> -        blocks = int(exec_cmd(du_cmd).split()[0])
>> -
>> -        extra_blocks = part.get_extra_block_count(blocks)
>> -        if extra_blocks < BOOTDD_EXTRA_SPACE:
>> -            extra_blocks = BOOTDD_EXTRA_SPACE
>> -
>> -        blocks += extra_blocks
>> -        blocks = blocks + (16 - (blocks % 16))
>> -
>> -        msger.debug("Added %d extra blocks to %s to get to %d total blocks",
>> -                    extra_blocks, part.mountpoint, blocks)
>> -
>> -        # dosfs image, created by mkdosfs
>>          bootimg = "%s/%s.%s.img" % (cr_workdir, part.label, part.lineno)
>>  
>> -        dosfs_cmd = "mkdosfs -F 16 -S 512 -n %s -C %s %d -i %s" % \
>> -            (part.label.upper(), bootimg, blocks, part.fsuuid)
>> -        exec_cmd(dosfs_cmd)
>> -
>> -        mcopy_cmd = "mcopy -v -i %s -s %s/* ::/" % (bootimg, part_rootfs_dir)
>> -        exec_cmd(mcopy_cmd, True)
>> -
>> -        chmod_cmd = "chmod 644 %s" % bootimg
>> -        exec_cmd(chmod_cmd)
>> -
>> +        part.prepare_rootfs_msdos(bootimg, cr_workdir, oe_builddir,
>> +                                  part_rootfs_dir, native_sysroot, None)
>>          du_cmd = "du -Lbks %s" % bootimg
>>          bootimg_size = int(exec_cmd(du_cmd).split()[0])
>>  
>> diff --git a/scripts/lib/wic/plugins/source/efibootguard-efi.py b/scripts/lib/wic/plugins/source/efibootguard-efi.py
>> index e82e990..48f7523 100644
>> --- a/scripts/lib/wic/plugins/source/efibootguard-efi.py
>> +++ b/scripts/lib/wic/plugins/source/efibootguard-efi.py
>> @@ -100,35 +100,9 @@ class EfibootguardEFIPlugin(SourcePlugin):
>>                                                 name)
>>          exec_cmd(cp_to_deploy_cmd, True)
>>  
>> -        du_cmd = "du --apparent-size -ks %s" % part_rootfs_dir
>> -        blocks = int(exec_cmd(du_cmd).split()[0])
>> -
>> -        extra_blocks = part.get_extra_block_count(blocks)
>> -        if extra_blocks < BOOTDD_EXTRA_SPACE:
>> -            extra_blocks = BOOTDD_EXTRA_SPACE
>> -        blocks += extra_blocks
>> -        blocks = blocks + (16 - (blocks % 16))
>> -
>> -        msger.debug("Added %d extra blocks to %s to get to %d total blocks",
>> -                    extra_blocks, part.mountpoint, blocks)
>> -
>> -        # dosfs image, created by mkdosfs
>>          efi_part_image = "%s/%s.%s.img" % (cr_workdir, part.label, part.lineno)
>> -
>> -        dosfs_cmd = "mkdosfs -S 512 -n %s -C %s %d -i %s" % \
>> -            (part.label.upper(), efi_part_image, blocks, part.fsuuid)
>> -        exec_cmd(dosfs_cmd)
>> -
>> -        # mtools for buster have problems with resursive mcopy.
>> -        # Therefore, create the target dir via mmd first.
>> -        mmd_cmd = "mmd -i %s ::/EFI ::/EFI/BOOT" % (efi_part_image)
>> -        exec_cmd(mmd_cmd, True)
>> -        mcopy_cmd = "mcopy -v -i %s -s %s/EFI/BOOT/* ::/EFI/BOOT" % \
>> -            (efi_part_image, part_rootfs_dir)
>> -        exec_cmd(mcopy_cmd, True)
>> -
>> -        chmod_cmd = "chmod 644 %s" % efi_part_image
>> -        exec_cmd(chmod_cmd)
>> +        part.prepare_rootfs_msdos(efi_part_image, cr_workdir, oe_builddir,
>> +                                  part_rootfs_dir, native_sysroot, None)
>>  
>>          du_cmd = "du -Lbks %s" % efi_part_image
>>          efi_part_image_size = int(exec_cmd(du_cmd).split()[0])
> 
> Thanks, applied.
> 

...and taken out again - there seems to be some regression with the
security image:

https://gitlab.com/cip-project/cip-core/isar-cip-core/-/jobs/6810329484

Jan
Jan Kiszka June 11, 2024, 11:56 a.m. UTC | #3
On 08.05.24 21:56, Jan Kiszka wrote:
> On 08.05.24 19:31, Jan Kiszka wrote:
>> On 08.05.24 15:55, Quirin Gylstorff wrote:
>>> From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
>>>
>>> This fixes the issue that wic arguments --size and --fixed-size
>>> are not correctly interpreted.
>>>
>>> This fixes issue #104.
>>>
>>> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
>>> ---
>>> Changes v3:
>>>  - remove unnecesary setting of FAT-Size(-F) and sector size(-S 512)
>>>    the sector size default is 512 and as FAT size should be caluclate
>>>    according to the partition size.
>>> Changes v2:
>>>  - replace size calculation with part.prepare_rootfs_msdos
>>>
>>>  .../wic/plugins/source/efibootguard-boot.py   | 34 ++++---------------
>>>  .../wic/plugins/source/efibootguard-efi.py    | 30 ++--------------
>>>  2 files changed, 9 insertions(+), 55 deletions(-)
>>>
>>> diff --git a/scripts/lib/wic/plugins/source/efibootguard-boot.py b/scripts/lib/wic/plugins/source/efibootguard-boot.py
>>> index 4e3aefb..2b06fd1 100644
>>> --- a/scripts/lib/wic/plugins/source/efibootguard-boot.py
>>> +++ b/scripts/lib/wic/plugins/source/efibootguard-boot.py
>>> @@ -136,40 +136,20 @@ class EfibootguardBootPlugin(SourcePlugin):
>>>                  msger.error("file %s not found in directory %s",
>>>                              boot_file, kernel_dir)
>>>                  exit(1)
>>> -        cls._create_img(part_rootfs_dir, part, cr_workdir)
>>> +        cls._create_img(part_rootfs_dir, part, cr_workdir,
>>> +                        native_sysroot, oe_builddir)
>>>  
>>>      @classmethod
>>> -    def _create_img(cls, part_rootfs_dir, part, cr_workdir):
>>> -            # Write label as utf-16le to EFILABEL file
>>> +    def _create_img(cls, part_rootfs_dir, part, cr_workdir,
>>> +                    native_sysroot, oe_builddir):
>>> +        # Write label as utf-16le to EFILABEL file
>>>          with open("%s/EFILABEL" % part_rootfs_dir, 'wb') as filedescriptor:
>>>              filedescriptor.write(part.label.upper().encode("utf-16le"))
>>>  
>>> -        du_cmd = "du --apparent-size -ks %s" % part_rootfs_dir
>>> -        blocks = int(exec_cmd(du_cmd).split()[0])
>>> -
>>> -        extra_blocks = part.get_extra_block_count(blocks)
>>> -        if extra_blocks < BOOTDD_EXTRA_SPACE:
>>> -            extra_blocks = BOOTDD_EXTRA_SPACE
>>> -
>>> -        blocks += extra_blocks
>>> -        blocks = blocks + (16 - (blocks % 16))
>>> -
>>> -        msger.debug("Added %d extra blocks to %s to get to %d total blocks",
>>> -                    extra_blocks, part.mountpoint, blocks)
>>> -
>>> -        # dosfs image, created by mkdosfs
>>>          bootimg = "%s/%s.%s.img" % (cr_workdir, part.label, part.lineno)
>>>  
>>> -        dosfs_cmd = "mkdosfs -F 16 -S 512 -n %s -C %s %d -i %s" % \
>>> -            (part.label.upper(), bootimg, blocks, part.fsuuid)
>>> -        exec_cmd(dosfs_cmd)
>>> -
>>> -        mcopy_cmd = "mcopy -v -i %s -s %s/* ::/" % (bootimg, part_rootfs_dir)
>>> -        exec_cmd(mcopy_cmd, True)
>>> -
>>> -        chmod_cmd = "chmod 644 %s" % bootimg
>>> -        exec_cmd(chmod_cmd)
>>> -
>>> +        part.prepare_rootfs_msdos(bootimg, cr_workdir, oe_builddir,
>>> +                                  part_rootfs_dir, native_sysroot, None)
>>>          du_cmd = "du -Lbks %s" % bootimg
>>>          bootimg_size = int(exec_cmd(du_cmd).split()[0])
>>>  
>>> diff --git a/scripts/lib/wic/plugins/source/efibootguard-efi.py b/scripts/lib/wic/plugins/source/efibootguard-efi.py
>>> index e82e990..48f7523 100644
>>> --- a/scripts/lib/wic/plugins/source/efibootguard-efi.py
>>> +++ b/scripts/lib/wic/plugins/source/efibootguard-efi.py
>>> @@ -100,35 +100,9 @@ class EfibootguardEFIPlugin(SourcePlugin):
>>>                                                 name)
>>>          exec_cmd(cp_to_deploy_cmd, True)
>>>  
>>> -        du_cmd = "du --apparent-size -ks %s" % part_rootfs_dir
>>> -        blocks = int(exec_cmd(du_cmd).split()[0])
>>> -
>>> -        extra_blocks = part.get_extra_block_count(blocks)
>>> -        if extra_blocks < BOOTDD_EXTRA_SPACE:
>>> -            extra_blocks = BOOTDD_EXTRA_SPACE
>>> -        blocks += extra_blocks
>>> -        blocks = blocks + (16 - (blocks % 16))
>>> -
>>> -        msger.debug("Added %d extra blocks to %s to get to %d total blocks",
>>> -                    extra_blocks, part.mountpoint, blocks)
>>> -
>>> -        # dosfs image, created by mkdosfs
>>>          efi_part_image = "%s/%s.%s.img" % (cr_workdir, part.label, part.lineno)
>>> -
>>> -        dosfs_cmd = "mkdosfs -S 512 -n %s -C %s %d -i %s" % \
>>> -            (part.label.upper(), efi_part_image, blocks, part.fsuuid)
>>> -        exec_cmd(dosfs_cmd)
>>> -
>>> -        # mtools for buster have problems with resursive mcopy.
>>> -        # Therefore, create the target dir via mmd first.
>>> -        mmd_cmd = "mmd -i %s ::/EFI ::/EFI/BOOT" % (efi_part_image)
>>> -        exec_cmd(mmd_cmd, True)
>>> -        mcopy_cmd = "mcopy -v -i %s -s %s/EFI/BOOT/* ::/EFI/BOOT" % \
>>> -            (efi_part_image, part_rootfs_dir)
>>> -        exec_cmd(mcopy_cmd, True)
>>> -
>>> -        chmod_cmd = "chmod 644 %s" % efi_part_image
>>> -        exec_cmd(chmod_cmd)
>>> +        part.prepare_rootfs_msdos(efi_part_image, cr_workdir, oe_builddir,
>>> +                                  part_rootfs_dir, native_sysroot, None)
>>>  
>>>          du_cmd = "du -Lbks %s" % efi_part_image
>>>          efi_part_image_size = int(exec_cmd(du_cmd).split()[0])
>>
>> Thanks, applied.
>>
> 
> ...and taken out again - there seems to be some regression with the
> security image:
> 
> https://gitlab.com/cip-project/cip-core/isar-cip-core/-/jobs/6810329484
> 

Did I miss some follow-up for this patch? Or did this rather fall
through the cracks?

Jan
diff mbox series

Patch

diff --git a/scripts/lib/wic/plugins/source/efibootguard-boot.py b/scripts/lib/wic/plugins/source/efibootguard-boot.py
index 4e3aefb..2b06fd1 100644
--- a/scripts/lib/wic/plugins/source/efibootguard-boot.py
+++ b/scripts/lib/wic/plugins/source/efibootguard-boot.py
@@ -136,40 +136,20 @@  class EfibootguardBootPlugin(SourcePlugin):
                 msger.error("file %s not found in directory %s",
                             boot_file, kernel_dir)
                 exit(1)
-        cls._create_img(part_rootfs_dir, part, cr_workdir)
+        cls._create_img(part_rootfs_dir, part, cr_workdir,
+                        native_sysroot, oe_builddir)
 
     @classmethod
-    def _create_img(cls, part_rootfs_dir, part, cr_workdir):
-            # Write label as utf-16le to EFILABEL file
+    def _create_img(cls, part_rootfs_dir, part, cr_workdir,
+                    native_sysroot, oe_builddir):
+        # Write label as utf-16le to EFILABEL file
         with open("%s/EFILABEL" % part_rootfs_dir, 'wb') as filedescriptor:
             filedescriptor.write(part.label.upper().encode("utf-16le"))
 
-        du_cmd = "du --apparent-size -ks %s" % part_rootfs_dir
-        blocks = int(exec_cmd(du_cmd).split()[0])
-
-        extra_blocks = part.get_extra_block_count(blocks)
-        if extra_blocks < BOOTDD_EXTRA_SPACE:
-            extra_blocks = BOOTDD_EXTRA_SPACE
-
-        blocks += extra_blocks
-        blocks = blocks + (16 - (blocks % 16))
-
-        msger.debug("Added %d extra blocks to %s to get to %d total blocks",
-                    extra_blocks, part.mountpoint, blocks)
-
-        # dosfs image, created by mkdosfs
         bootimg = "%s/%s.%s.img" % (cr_workdir, part.label, part.lineno)
 
-        dosfs_cmd = "mkdosfs -F 16 -S 512 -n %s -C %s %d -i %s" % \
-            (part.label.upper(), bootimg, blocks, part.fsuuid)
-        exec_cmd(dosfs_cmd)
-
-        mcopy_cmd = "mcopy -v -i %s -s %s/* ::/" % (bootimg, part_rootfs_dir)
-        exec_cmd(mcopy_cmd, True)
-
-        chmod_cmd = "chmod 644 %s" % bootimg
-        exec_cmd(chmod_cmd)
-
+        part.prepare_rootfs_msdos(bootimg, cr_workdir, oe_builddir,
+                                  part_rootfs_dir, native_sysroot, None)
         du_cmd = "du -Lbks %s" % bootimg
         bootimg_size = int(exec_cmd(du_cmd).split()[0])
 
diff --git a/scripts/lib/wic/plugins/source/efibootguard-efi.py b/scripts/lib/wic/plugins/source/efibootguard-efi.py
index e82e990..48f7523 100644
--- a/scripts/lib/wic/plugins/source/efibootguard-efi.py
+++ b/scripts/lib/wic/plugins/source/efibootguard-efi.py
@@ -100,35 +100,9 @@  class EfibootguardEFIPlugin(SourcePlugin):
                                                name)
         exec_cmd(cp_to_deploy_cmd, True)
 
-        du_cmd = "du --apparent-size -ks %s" % part_rootfs_dir
-        blocks = int(exec_cmd(du_cmd).split()[0])
-
-        extra_blocks = part.get_extra_block_count(blocks)
-        if extra_blocks < BOOTDD_EXTRA_SPACE:
-            extra_blocks = BOOTDD_EXTRA_SPACE
-        blocks += extra_blocks
-        blocks = blocks + (16 - (blocks % 16))
-
-        msger.debug("Added %d extra blocks to %s to get to %d total blocks",
-                    extra_blocks, part.mountpoint, blocks)
-
-        # dosfs image, created by mkdosfs
         efi_part_image = "%s/%s.%s.img" % (cr_workdir, part.label, part.lineno)
-
-        dosfs_cmd = "mkdosfs -S 512 -n %s -C %s %d -i %s" % \
-            (part.label.upper(), efi_part_image, blocks, part.fsuuid)
-        exec_cmd(dosfs_cmd)
-
-        # mtools for buster have problems with resursive mcopy.
-        # Therefore, create the target dir via mmd first.
-        mmd_cmd = "mmd -i %s ::/EFI ::/EFI/BOOT" % (efi_part_image)
-        exec_cmd(mmd_cmd, True)
-        mcopy_cmd = "mcopy -v -i %s -s %s/EFI/BOOT/* ::/EFI/BOOT" % \
-            (efi_part_image, part_rootfs_dir)
-        exec_cmd(mcopy_cmd, True)
-
-        chmod_cmd = "chmod 644 %s" % efi_part_image
-        exec_cmd(chmod_cmd)
+        part.prepare_rootfs_msdos(efi_part_image, cr_workdir, oe_builddir,
+                                  part_rootfs_dir, native_sysroot, None)
 
         du_cmd = "du -Lbks %s" % efi_part_image
         efi_part_image_size = int(exec_cmd(du_cmd).split()[0])