Message ID | 20240503085950.667611-1-Quirin.Gylstorff@siemens.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [isar-cip-core] wic/plugins/efibootguard*: Take --size and --fixed-size into account | expand |
On 03.05.24 10:59, 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. > > part.get_extra_block_count is removed as it is already take into > account by part.get_rootfs_size[1]. > > This fixes issue #104. > > [1]: https://github.com/ilbers/isar/blob/26e9653eb5e096e8b367ebd73054b2fd2310e9bc/scripts/lib/wic/partition.py#L104 > > Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com> > --- > .../wic/plugins/source/efibootguard-boot.py | 20 ++++++------------- > .../wic/plugins/source/efibootguard-efi.py | 20 ++++++++----------- > 2 files changed, 14 insertions(+), 26 deletions(-) > > diff --git a/scripts/lib/wic/plugins/source/efibootguard-boot.py b/scripts/lib/wic/plugins/source/efibootguard-boot.py > index 4e3aefb..c8d6a19 100644 > --- a/scripts/lib/wic/plugins/source/efibootguard-boot.py > +++ b/scripts/lib/wic/plugins/source/efibootguard-boot.py > @@ -143,25 +143,17 @@ class EfibootguardBootPlugin(SourcePlugin): > # 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 --block-size=1K --summarize %s" % part_rootfs_dir > + rootfs_size_kb = int(exec_cmd(du_cmd).split()[0]) Naming: it's not a rootfs that we are building here. Logic: What makes this different from prepare_rootfs_msdos? Why are there blocks passed around, and we are using bytes? > > - 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) > - > + adjusted_rootfs_size = part.get_rootfs_size(rootfs_size_kb) > # dosfs image, created by mkdosfs > bootimg = "%s/%s.%s.img" % (cr_workdir, part.label, part.lineno) > > + # create a fat16 partition with a sector size of 512 > + # block size is always 1k > dosfs_cmd = "mkdosfs -F 16 -S 512 -n %s -C %s %d -i %s" % \ > - (part.label.upper(), bootimg, blocks, part.fsuuid) > + (part.label.upper(), bootimg, adjusted_rootfs_size, part.fsuuid) > exec_cmd(dosfs_cmd) > > mcopy_cmd = "mcopy -v -i %s -s %s/* ::/" % (bootimg, part_rootfs_dir) > diff --git a/scripts/lib/wic/plugins/source/efibootguard-efi.py b/scripts/lib/wic/plugins/source/efibootguard-efi.py > index e82e990..1796eb1 100644 > --- a/scripts/lib/wic/plugins/source/efibootguard-efi.py > +++ b/scripts/lib/wic/plugins/source/efibootguard-efi.py > @@ -100,23 +100,19 @@ 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) > + du_cmd = "du --apparent-size --block-size=1k --summarize %s" % part_rootfs_dir > + rootfs_size_kb = int(exec_cmd(du_cmd).split()[0]) > > + # get_rootfs_size use kb as input > + adjusted_rootfs_size = part.get_rootfs_size(rootfs_size_kb) > # dosfs image, created by mkdosfs > efi_part_image = "%s/%s.%s.img" % (cr_workdir, part.label, part.lineno) > > + # create a fat partition with a sector size of 512 > + # mkdosfs selects automatically the allocation type table > + # block size is always 1k > dosfs_cmd = "mkdosfs -S 512 -n %s -C %s %d -i %s" % \ > - (part.label.upper(), efi_part_image, blocks, part.fsuuid) > + (part.label.upper(), efi_part_image, adjusted_rootfs_size, part.fsuuid) > exec_cmd(dosfs_cmd) > > # mtools for buster have problems with resursive mcopy. Would it be possible to reuse prepare_rootfs_msdos somehow? If not, could we at least avoid some code duplications? Thanks, Jan
diff --git a/scripts/lib/wic/plugins/source/efibootguard-boot.py b/scripts/lib/wic/plugins/source/efibootguard-boot.py index 4e3aefb..c8d6a19 100644 --- a/scripts/lib/wic/plugins/source/efibootguard-boot.py +++ b/scripts/lib/wic/plugins/source/efibootguard-boot.py @@ -143,25 +143,17 @@ class EfibootguardBootPlugin(SourcePlugin): # 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 --block-size=1K --summarize %s" % part_rootfs_dir + rootfs_size_kb = int(exec_cmd(du_cmd).split()[0]) - 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) - + adjusted_rootfs_size = part.get_rootfs_size(rootfs_size_kb) # dosfs image, created by mkdosfs bootimg = "%s/%s.%s.img" % (cr_workdir, part.label, part.lineno) + # create a fat16 partition with a sector size of 512 + # block size is always 1k dosfs_cmd = "mkdosfs -F 16 -S 512 -n %s -C %s %d -i %s" % \ - (part.label.upper(), bootimg, blocks, part.fsuuid) + (part.label.upper(), bootimg, adjusted_rootfs_size, part.fsuuid) exec_cmd(dosfs_cmd) mcopy_cmd = "mcopy -v -i %s -s %s/* ::/" % (bootimg, part_rootfs_dir) diff --git a/scripts/lib/wic/plugins/source/efibootguard-efi.py b/scripts/lib/wic/plugins/source/efibootguard-efi.py index e82e990..1796eb1 100644 --- a/scripts/lib/wic/plugins/source/efibootguard-efi.py +++ b/scripts/lib/wic/plugins/source/efibootguard-efi.py @@ -100,23 +100,19 @@ 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) + du_cmd = "du --apparent-size --block-size=1k --summarize %s" % part_rootfs_dir + rootfs_size_kb = int(exec_cmd(du_cmd).split()[0]) + # get_rootfs_size use kb as input + adjusted_rootfs_size = part.get_rootfs_size(rootfs_size_kb) # dosfs image, created by mkdosfs efi_part_image = "%s/%s.%s.img" % (cr_workdir, part.label, part.lineno) + # create a fat partition with a sector size of 512 + # mkdosfs selects automatically the allocation type table + # block size is always 1k dosfs_cmd = "mkdosfs -S 512 -n %s -C %s %d -i %s" % \ - (part.label.upper(), efi_part_image, blocks, part.fsuuid) + (part.label.upper(), efi_part_image, adjusted_rootfs_size, part.fsuuid) exec_cmd(dosfs_cmd) # mtools for buster have problems with resursive mcopy.