wic: re-implement sector-size support
PATCH v3 1/2 wic: re-implement sector-size support
The previous implementation to add variable sector-size support:
- required the variable WIC_SECTOR_SIZE either be defined in a configuration file or be defined in a --vars file
- this means that every invocation of "wic ls", "wic cp", or "wic rm" needed this variable defined (config or --vars)
- required the user to create separate *wks files for every sector size they wanted to use
- required the user to specify the mkfs-extraopts by hand to specify the correct sector size: e.g.
bootloader --ptable gpt part --fstype ext4 --source rootfs --label rofs-a --mkfs-extraopts "-b 4096" part --fstype ext4 --source rootfs --use-uuid --mkfs-extraopts "-b 4096"
- specifying --mkfs-extraopts replaces the defaults with the user-supplied values
- only provided details to support using variable sector-sizes with ext[234] filesystems
- it would not be possible to generate images with different sector sizes in the same build since the configuration and *wks files would need to change and the build re-run for each size
Update the sector-size handling so that:
- the sector-size will now be provided on the cmdline to the "wic ls", "wic cp", "wic rm", and "wic create" commands: default = 512
- this means the configuration and/or --vars file does not need to be changed in order to perform those operations on images with different sector sizes
- support is provided implicitly for mkdosfs and ext[234] partitions
- the user no longer needs to know and supply the sector-size magic in --mkfs-extraopts (thereby clobbering the other defaults)
AI-Generated: codex/gpt-5.1-codex-max
---
changes since v2:
- none
changes since v1:
- none
--- meta/lib/oeqa/selftest/cases/wic.py | 39 ++++--------- scripts/lib/wic/engine.py | 45 +++++++-------- scripts/lib/wic/help.py | 23 +++++--- scripts/lib/wic/partition.py | 55 +++++++++++++++++-- scripts/lib/wic/plugins/imager/direct.py | 18 ++---- scripts/lib/wic/plugins/source/bootimg_efi.py | 5 +- .../lib/wic/plugins/source/bootimg_pcbios.py | 11 ++-- .../wic/plugins/source/isoimage_isohybrid.py | 5 +- scripts/wic | 8 +++ 9 files changed, 125 insertions(+), 84 deletions(-)
meta/lib/oeqa/selftest/cases/wic.py +11 -28
@@ -935,33 +935,22 @@ bootloader --ptable gpt""") finally: os.remove(wks_file) - def test_wic_sector_size(self): - """Test generation image sector size""" - + def test_wic_sector_size_cli(self): + """Test sector size handling via CLI option.""" + oldpath = os.environ['PATH'] os.environ['PATH'] = get_bb_var("PATH", "wic-tools") try: - # Add WIC_SECTOR_SIZE into config - config = 'WIC_SECTOR_SIZE = "4096"\n'\ - 'WICVARS:append = " WIC_SECTOR_SIZE"\n' - self.append_config(config) bitbake('core-image-minimal') - # Check WIC_SECTOR_SIZE apply to bitbake variable - wic_sector_size_str = get_bb_var('WIC_SECTOR_SIZE', 'core-image-minimal') - wic_sector_size = int(wic_sector_size_str) - self.assertEqual(4096, wic_sector_size) - - self.logger.info("Test wic_sector_size: %d \n" % wic_sector_size) - with NamedTemporaryFile("w", suffix=".wks") as wks: wks.writelines( ['bootloader --ptable gpt\n', - 'part --fstype ext4 --source rootfs --label rofs-a --mkfs-extraopts "-b 4096"\n', - 'part --fstype ext4 --source rootfs --use-uuid --mkfs-extraopts "-b 4096"\n']) + 'part --fstype ext4 --source rootfs --label rofs-a\n', + 'part --fstype ext4 --source rootfs --use-uuid\n']) wks.flush() - cmd = "wic create %s -e core-image-minimal -o %s" % (wks.name, self.resultdir) + cmd = "wic create %s -e core-image-minimal -o %s --sector-size 4096" % (wks.name, self.resultdir) runCmd(cmd) wksname = os.path.splitext(os.path.basename(wks.name))[0] images = glob(os.path.join(self.resultdir, "%s-*direct" % wksname))
@@ -969,24 +958,18 @@ bootloader --ptable gpt""") sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') # list partitions - result = runCmd("wic ls %s -n %s" % (images[0], sysroot)) + result = runCmd("wic ls %s -n %s --sector-size 4096" % (images[0], sysroot)) self.assertEqual(3, len(result.output.split('\n'))) - # verify partition size with wic - res = runCmd("export PARTED_SECTOR_SIZE=%d; parted -m %s unit b p" % (wic_sector_size, images[0]), + # verify partition size with parted output + res = runCmd("export PARTED_SECTOR_SIZE=%d; parted -m %s unit b p" % (4096, images[0]), stderr=subprocess.PIPE) - # parse parted output which looks like this: - # BYT;\n - # /var/tmp/wic/build/tmpgjzzefdd-202410281021-sda.direct:78569472B:file:4096:4096:gpt::;\n - # 1:139264B:39284735B:39145472B:ext4:rofs-a:;\n - # 2:39284736B:78430207B:39145472B:ext4:primary:;\n disk_info = res.output.splitlines()[1] - # Check sector sizes sector_size_logical = int(disk_info.split(":")[3]) sector_size_physical = int(disk_info.split(":")[4]) - self.assertEqual(wic_sector_size, sector_size_logical, "Logical sector size is not %d." % wic_sector_size) - self.assertEqual(wic_sector_size, sector_size_physical, "Physical sector size is not %d." % wic_sector_size) + self.assertEqual(4096, sector_size_logical, "Logical sector size is not 4096.") + self.assertEqual(4096, sector_size_physical, "Physical sector size is not 4096.") finally: os.environ['PATH'] = oldpath
scripts/lib/wic/engine.py +23 -22
102 lines not on this page · raw message
scripts/lib/wic/help.py +16 -7
@@ -118,7 +118,7 @@ wic_create_usage = """ usage: wic create <wks file or image name> [-o <DIRNAME> | --outdir <DIRNAME>] [-e | --image-name] [-s, --skip-build-check] [-D, --debug] [-r, --rootfs-dir] [-b, --bootimg-dir] - [-k, --kernel-dir] [-n, --native-sysroot] [-f, --build-rootfs] + [-k, --kernel-dir] [-n, --native-sysroot] [--sector-size <bytes>] [-f, --build-rootfs] [-c, --compress-with] [-m, --bmap] This command creates an OpenEmbedded image based on the 'OE kickstart
@@ -139,13 +139,16 @@ SYNOPSIS wic create <wks file or image name> [-o <DIRNAME> | --outdir <DIRNAME>] [-e | --image-name] [-s, --skip-build-check] [-D, --debug] [-r, --rootfs-dir] [-b, --bootimg-dir] - [-k, --kernel-dir] [-n, --native-sysroot] [-f, --build-rootfs] + [-k, --kernel-dir] [-n, --native-sysroot] [--sector-size <bytes>] [-f, --build-rootfs] [-c, --compress-with] [-m, --bmap] [--no-fstab-update] DESCRIPTION This command creates an OpenEmbedded image based on the 'OE kickstart commands' found in the <wks file>. + Use the --sector-size option to select the sector size (in bytes) + used for partition layout calculations (default is 512). + In order to do this, wic needs to know the locations of the various build artifacts required to build the image.
@@ -278,7 +281,7 @@ wic_ls_usage = """ List content of a partitioned image - usage: wic ls <image>[:<partition>[<path>]] [--native-sysroot <path>] + usage: wic ls <image>[:<partition>[<path>]] [--native-sysroot <path>] [--sector-size <bytes>] This command outputs either list of image partitions or directory contents of vfat and ext* partitions.
@@ -296,7 +299,7 @@ SYNOPSIS wic ls <image> wic ls <image>:<vfat or ext* partition> wic ls <image>:<vfat or ext* partition><path> - wic ls <image>:<vfat or ext* partition><path> --native-sysroot <path> + wic ls <image>:<vfat or ext* partition><path> --native-sysroot <path> [--sector-size <bytes>] DESCRIPTION This command lists either partitions of the image or directory contents
@@ -336,6 +339,8 @@ DESCRIPTION The -n option is used to specify the path to the native sysroot containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used for partition math + (default is 512 bytes). """
@@ -343,7 +348,7 @@ wic_cp_usage = """ Copy files and directories to/from the vfat or ext* partition - usage: wic cp <src> <dest> [--native-sysroot <path>] + usage: wic cp <src> <dest> [--native-sysroot <path>] [--sector-size <bytes>] source/destination image in format <image>:<partition>[<path>]
@@ -364,7 +369,7 @@ SYNOPSIS wic cp <src> <dest>:<partition> wic cp <src>:<partition> <dest> wic cp <src> <dest-image>:<partition><path> - wic cp <src> <dest-image>:<partition><path> --native-sysroot <path> + wic cp <src> <dest-image>:<partition><path> --native-sysroot <path> [--sector-size <bytes>] DESCRIPTION This command copies files or directories either
@@ -408,13 +413,15 @@ DESCRIPTION The -n option is used to specify the path to the native sysroot containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used for partition math + (default is 512 bytes). """ wic_rm_usage = """ Remove files or directories from the vfat or ext* partitions - usage: wic rm <image>:<partition><path> [--native-sysroot <path>] + usage: wic rm <image>:<partition><path> [--native-sysroot <path>] [--sector-size <bytes>] This command removes files or directories from the vfat or ext* partitions of the partitioned image.
@@ -466,6 +473,8 @@ DESCRIPTION The -n option is used to specify the path to the native sysroot containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used for partition math + (default is 512 bytes). The -r option is used to remove directories and their contents recursively,this only applies to ext* partition.
scripts/lib/wic/partition.py +50 -5
94 lines not on this page · raw message
scripts/lib/wic/plugins/imager/direct.py +5 -13
@@ -67,6 +67,7 @@ class DirectPlugin(ImagerPlugin): self._image = None self.ptable_format = self.ks.bootloader.ptable self.parts = self.ks.partitions + self.sector_size = options.sector_size or 512 # as a convenience, set source to the boot partition source # instead of forcing it to be set via bootloader --source
@@ -78,7 +79,7 @@ class DirectPlugin(ImagerPlugin): image_path = self._full_path(self.workdir, self.parts[0].disk, "direct") self._image = PartitionedImage(image_path, self.ptable_format, self.ks.bootloader.diskid, self.parts, self.native_sysroot, - options.extra_space) + options.extra_space, self.sector_size) def setup_workdir(self, workdir): if workdir:
@@ -294,15 +295,13 @@ MBR_OVERHEAD = 1 # Overhead of the GPT partitioning scheme GPT_OVERHEAD = 34 -# Size of a sector in bytes -SECTOR_SIZE = 512 - class PartitionedImage(): """ Partitioned image in a file. """ - def __init__(self, path, ptable_format, disk_id, partitions, native_sysroot=None, extra_space=0): + def __init__(self, path, ptable_format, disk_id, partitions, native_sysroot=None, extra_space=0, + sector_size=512): self.path = path # Path to the image file self.numpart = 0 # Number of allocated partitions self.realpart = 0 # Number of partitions in the partition table
@@ -332,14 +331,7 @@ class PartitionedImage(): self.partitions = partitions self.partimages = [] # Size of a sector used in calculations - sector_size_str = get_bitbake_var('WIC_SECTOR_SIZE') - if sector_size_str is not None: - try: - self.sector_size = int(sector_size_str) - except ValueError: - self.sector_size = SECTOR_SIZE - else: - self.sector_size = SECTOR_SIZE + self.sector_size = sector_size or 512 self.native_sysroot = native_sysroot num_real_partitions = len([p for p in self.partitions if not p.no_table])
scripts/lib/wic/plugins/source/bootimg_efi.py +3 -2
@@ -415,8 +415,9 @@ class BootimgEFIPlugin(SourcePlugin): label = part.label if part.label else "ESP" - dosfs_cmd = "mkdosfs -v -n %s -i %s -C %s %d" % \ - (label, part.fsuuid, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or 512 + dosfs_cmd = "mkdosfs -v -n %s -i %s -S %d -C %s %d" % \ + (label, part.fsuuid, sector_size, bootimg, blocks) exec_native_cmd(dosfs_cmd, native_sysroot) logger.debug("mkdosfs:\n%s" % (str(out)))
scripts/lib/wic/plugins/source/bootimg_pcbios.py +6 -5
@@ -132,7 +132,7 @@ class BootimgPcbiosPlugin(SourcePlugin): cls._do_prepare_grub(part, cr_workdir, oe_builddir, kernel_dir, rootfs_dir, native_sysroot) elif source_params['loader-bios'] == 'syslinux': - cls._do_prepare_syslinux(part, cr_workdir, bootimg_dir, + cls._do_prepare_syslinux(part, creator, cr_workdir, bootimg_dir, kernel_dir, native_sysroot) else: raise WicError("unrecognized bootimg_pcbios loader: %s" % source_params['loader-bios'])
@@ -142,7 +142,7 @@ class BootimgPcbiosPlugin(SourcePlugin): except KeyError: # Required by do_install_disk cls.loader = 'syslinux' - cls._do_prepare_syslinux(part, cr_workdir, bootimg_dir, + cls._do_prepare_syslinux(part, creator, cr_workdir, bootimg_dir, kernel_dir, native_sysroot) @classmethod
@@ -240,7 +240,7 @@ class BootimgPcbiosPlugin(SourcePlugin): cfg.close() @classmethod - def _do_prepare_syslinux(cls, part, cr_workdir, bootimg_dir, + def _do_prepare_syslinux(cls, part, creator, cr_workdir, bootimg_dir, kernel_dir, native_sysroot): """ Called to do the actual content population for a partition i.e. it
@@ -292,8 +292,9 @@ class BootimgPcbiosPlugin(SourcePlugin): label = part.label if part.label else "boot" - dosfs_cmd = "mkdosfs -n %s -i %s -S 512 -C %s %d" % \ - (label, part.fsuuid, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or 512 + dosfs_cmd = "mkdosfs -n %s -i %s -S %d -C %s %d" % \ + (label, part.fsuuid, sector_size, bootimg, blocks) exec_native_cmd(dosfs_cmd, native_sysroot) mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir)
scripts/lib/wic/plugins/source/isoimage_isohybrid.py +3 -2
@@ -367,8 +367,9 @@ class IsoImagePlugin(SourcePlugin): esp_label = source_params.get('esp_label', 'EFIimg') - dosfs_cmd = 'mkfs.vfat -n \'%s\' -S 512 -C %s %d' \ - % (esp_label, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or 512 + dosfs_cmd = "mkfs.vfat -n '%s' -S %d -C %s %d" % \ + (esp_label, sector_size, bootimg, blocks) exec_native_cmd(dosfs_cmd, native_sysroot) mmd_cmd = "mmd -i %s ::/EFI" % bootimg
scripts/wic +8 -0
@@ -376,6 +376,8 @@ def wic_init_parser_create(subparser): default="direct", help="the wic imager plugin") subparser.add_argument("--extra-space", type=int, dest="extra_space", default=0, help="additional free disk space to add to the image") + subparser.add_argument("--sector-size", dest="sector_size", type=int, default=512, + help="sector size in bytes (default: 512)") return
@@ -413,6 +415,8 @@ def imgtype(arg): def wic_init_parser_ls(subparser): subparser.add_argument("path", type=imgtype, help="image spec: <image>[:<vfat partition>[<path>]]") + subparser.add_argument("--sector-size", dest="sector_size", type=int, default=512, + help="sector size in bytes (default: 512)") subparser.add_argument("-n", "--native-sysroot", help="path to the native sysroot containing the tools") subparser.add_argument("-e", "--image-name", dest="image_name",
@@ -433,6 +437,8 @@ def wic_init_parser_cp(subparser): help="image spec: <image>:<vfat partition>[<path>] or <file>") subparser.add_argument("dest", help="image spec: <image>:<vfat partition>[<path>] or <file>") + subparser.add_argument("--sector-size", dest="sector_size", type=int, default=512, + help="sector size in bytes (default: 512)") subparser.add_argument("-n", "--native-sysroot", help="path to the native sysroot containing the tools") subparser.add_argument("-e", "--image-name", dest="image_name",
@@ -445,6 +451,8 @@ def wic_init_parser_cp(subparser): def wic_init_parser_rm(subparser): subparser.add_argument("path", type=imgpathtype, help="path: <image>:<vfat partition><path>") + subparser.add_argument("--sector-size", dest="sector_size", type=int, default=512, + help="sector size in bytes (default: 512)") subparser.add_argument("-n", "--native-sysroot", help="path to the native sysroot containing the tools") subparser.add_argument("-r", dest="recursive_delete", action="store_true", default=False,
Signature · 1 line
2.51.0
PATCH v3 2/2 ufs image class: add
Add an image class and wks file that demonstrates generating a wic image with a 4096-byte sector size.
---
changes since v2:
- tested more scenarios and made sure to fix the warning in every case
changes since v1:
- add Mark as a co-creator (sorry for missing this the first time!)
- provide a fix for the following warning:
WARNING: core-image-minimal-1.0-r0 do_image_wic_ufs: Function do_image_wic_ufs doesn't exist
--- meta/classes-recipe/image.bbclass | 2 +- meta/classes-recipe/image_types_ufs.bbclass | 221 ++++++++++++++++++++ scripts/lib/wic/canned-wks/mkdisk-ufs.wks | 5 + 3 files changed, 227 insertions(+), 1 deletion(-) create mode 100644 meta/classes-recipe/image_types_ufs.bbclass create mode 100644 scripts/lib/wic/canned-wks/mkdisk-ufs.wks
meta/classes-recipe/image.bbclass +1 -1
@@ -18,7 +18,7 @@ inherit populate_sdk_base IMGCLASSES += "${@['', 'populate_sdk_ext']['linux' in d.getVar("SDK_OS")]}" IMGCLASSES += "${@bb.utils.contains_any('IMAGE_FSTYPES', 'live iso hddimg', 'image-live', '', d)}" IMGCLASSES += "${@bb.utils.contains('IMAGE_FSTYPES', 'container', 'image-container', '', d)}" -IMGCLASSES += "image_types_wic" +IMGCLASSES += "image_types_wic image_types_ufs" IMGCLASSES += "rootfs-postcommands" IMGCLASSES += "image-postinst-intercepts" IMGCLASSES += "overlayfs-etc"
meta/classes-recipe/image_types_ufs.bbclass new file +221 -0
221 lines not on this page · raw message
scripts/lib/wic/canned-wks/mkdisk-ufs.wks new file +5 -0
@@ -0,0 +1,5 @@ +bootloader --ptable msdos + +part /boot --source rootfs --fstype=vfat --label boot --change-directory boot/ +part / --source rootfs --fstype=ext4 --label root --exclude-path boot/ +part swap --fstype=swap --label swap --size 1M
Signature · 1 line
2.51.0
Quoted 22 lines · Trevor Woerner via lists.openembedded.org
The previous implementation to add variable sector-size support:
- required the variableWIC_SECTOR_SIZEeither be defined in a configuration file or be defined in a --vars file
- this means that every invocation of "wic ls", "wic cp", or "wic rm" needed this variable defined (config or --vars)
- required the user to create separate *wks files for every sector size they wanted to use
- required the user to specify the mkfs-extraopts by hand to specify the correct sector size: e.g.bootloader --ptable gpt part --fstype ext4 --source rootfs --label rofs-a --mkfs-extraopts "-b 4096" part --fstype ext4 --source rootfs --use-uuid --mkfs-extraopts "-b4096"
- specifying --mkfs-extraopts replaces the defaults with the user-supplied values
- only provided details to support using variable sector-sizes with ext[234] filesystems
- it would not be possible to generate images with different sector sizes in the same build since the configuration and *wks files would need to change and the build re-run for each size
Quoted 10 lines
Update the sector-size handling so that:
- the sector-size will now be provided on the cmdline to the "wic ls", "wic cp", "wic rm", and "wic create" commands: default = 512
- this means the configuration and/or --vars file does not need to be changed in order to perform those operations on images with different sector sizes
- support is provided implicitly for mkdosfs and ext[234] partitions
- the user no longer needs to know and supply the sector-size magic in --mkfs-extraopts (thereby clobbering the other defaults)
It wasn't clear to me when scanning the patch. For configuration files with a sector size, is it now completely ignored ?
Apologies if I missed where existing configs were used to prime the parameters to the functions.
Bruce
Quoted 678 lines
AI-Generated: codex/gpt-5.1-codex-max
Signed-off-by Trevor Woerner <[email protected]>---
changes since v2:
- nonechanges since v1:
- none--- meta/lib/oeqa/selftest/cases/wic.py | 39 ++++--------- scripts/lib/wic/engine.py | 45 +++++++-------- scripts/lib/wic/help.py | 23 +++++--- scripts/lib/wic/partition.py | 55 +++++++++++++++++-- scripts/lib/wic/plugins/imager/direct.py | 18 ++---- scripts/lib/wic/plugins/source/bootimg_efi.py | 5 +- .../lib/wic/plugins/source/bootimg_pcbios.py | 11 ++-- .../wic/plugins/source/isoimage_isohybrid.py | 5 +- scripts/wic | 8 +++ 9 files changed, 125 insertions(+), 84 deletions(-)meta/lib/oeqa/selftest/cases/wic.py +5
-19@@ -935,33 +935,22 @@ bootloader --ptable gpt""") finally: os.remove(wks_file) - def test_wic_sector_size(self): - """Test generation image sector size""" - + def test_wic_sector_size_cli(self): + """Test sector size handling via CLI option.""" + oldpath = os.environ['PATH'] os.environ['PATH'] = get_bb_var("PATH", "wic-tools") try: - # Add WIC_SECTOR_SIZE into config - config = 'WIC_SECTOR_SIZE = "4096"\n'\ - 'WICVARS:append = " WIC_SECTOR_SIZE"\n' - self.append_config(config) bitbake('core-image-minimal') - # Check WIC_SECTOR_SIZE apply to bitbake variable - wic_sector_size_str = get_bb_var('WIC_SECTOR_SIZE', 'core-image-minimal') - wic_sector_size = int(wic_sector_size_str) - self.assertEqual(4096, wic_sector_size) - - self.logger.info("Test wic_sector_size: %d \n" % wic_sector_size) - with NamedTemporaryFile("w", suffix=".wks") as wks: wks.writelines( ['bootloader --ptable gpt\n', - 'part --fstype ext4 --source rootfs --label rofs-a --mkfs-extraopts "-b 4096"\n', - 'part --fstype ext4 --source rootfs --use-uuid --mkfs-extraopts "-b 4096"\n']) + 'part --fstype ext4 --source rootfs --label rofs-a\n', + 'part --fstype ext4 --source rootfs --use-uuid\n']) wks.flush() - cmd = "wic create %s -e core-image-minimal -o %s" % (wks.name, self.resultdir)
+ cmd = "wic create %s -e core-image-minimal -o %s
--sector-size 4096" % (wks.name, self.resultdir)
runCmd(cmd)
wksname = os.path.splitext(os.path.basename(wks.name))[0] images = glob(os.path.join(self.resultdir, "%s-*direct" %
wksname))meta/lib/oeqa/selftest/cases/wic.py +3
-6@@ -969,24 +958,18 @@ bootloader --ptable gpt""") sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') # list partitions - result = runCmd("wic ls %s -n %s" % (images[0], sysroot)) + result = runCmd("wic ls %s -n %s --sector-size 4096" % (images[0], sysroot)) self.assertEqual(3, len(result.output.split('\n'))) - # verify partition size with wic - res = runCmd("export PARTED_SECTOR_SIZE=%d; parted -m %s unit b p" % (wic_sector_size, images[0]), + # verify partition size with parted output + res = runCmd("export PARTED_SECTOR_SIZE=%d; parted -m %s unit b p" % (4096, images[0]), stderr=subprocess.PIPE) - # parse parted output which looks like this: - # BYT;\n - #/var/tmp/wic/build/tmpgjzzefdd-202410281021-sda.direct:78569472B:file:4096:4096:gpt::;\n
meta/lib/oeqa/selftest/cases/wic.py +0
-4- # 1:139264B:39284735B:39145472B:ext4:rofs-a:;\n - # 2:39284736B:78430207B:39145472B:ext4:primary:;\n disk_info = res.output.splitlines()[1] - # Check sector sizes sector_size_logical = int(disk_info.split(":")[3]) sector_size_physical = int(disk_info.split(":")[4]) - self.assertEqual(wic_sector_size, sector_size_logical,"Logical sector size is not %d." %
wic_sector_size)
- self.assertEqual(wic_sector_size,sector_size_physical,
"Physical sector size is not %d." %wic_sector_size)
+ self.assertEqual(4096,sector_size_logical, "Logical sector
size is not 4096.")
+ self.assertEqual(4096,sector_size_physical, "Physical sector
size is not 4096.")finally:
os.environ['PATH'] = oldpathscripts/lib/wic/engine.py +1
-1@@ -224,7 +224,7 @@ def wic_list(args, scripts_path): class Disk: - def __init__(self, imagepath, native_sysroot, fstypes=('fat', 'ext')): + def __init__(self, imagepath, native_sysroot, fstypes=('fat', 'ext'),sector_size=512):
self.imagepath = imagepath
self.native_sysroot =native_sysroot
self.fstypes = fstypesscripts/lib/wic/engine.py +2
-11@@ -233,16 +233,7 @@ class Disk: self._lsector_size = None self._psector_size = None self._ptable_format = None - - # define sector size - sector_size_str = get_bitbake_var('WIC_SECTOR_SIZE') - if sector_size_str is not None: - try: - self.sector_size = int(sector_size_str) - except ValueError: - self.sector_size = None - else: - self.sector_size = None + self.sector_size = sector_size # find parted # read paths from $PATH environment variable@@ -271,7 +262,7 @@ class Disk: if self._partitions is None: self._partitions = OrderedDict() - if self.sector_size is not None: + if self.sector_size: out = exec_cmd("export PARTED_SECTOR_SIZE=%d; %s -sm %s unit B print" % \ (self.sector_size, self.parted,self.imagepath), True)
else:scripts/lib/wic/engine.py +1
-0@@ -312,11 +303,15 @@ class Disk: raise WicError("Partition %s is not in the image" % pnum) part = self.partitions[pnum] # check if fstype is supported + # NOTE: parted is unable to identify dos-type partitions with a4k sector-size
+ # if the type is empty and a non-default sector size is
used, assume 'fat'scripts/lib/wic/engine.py +2
-0+ # fdisk identifies them without issue + part_fstype = part.fstype if part.fstype or self.sector_size ==512 else 'fat'
for fstype in self.fstypes:scripts/lib/wic/engine.py +2
-2- if part.fstype.startswith(fstype): + if part_fstype.startswith(fstype): break else: - raise WicError("Not supported fstype: {}".format(part.fstype)) + raise WicError("Not supported fstype: {}".format(part_fstype)) if pnum not in self._partimages: tmpf = tempfile.NamedTemporaryFile(prefix="wic-part") dst_fname = tmpf.name@@ -586,8 +581,9 @@ class Disk: label = part.get("name") label_str = "-n {}".format(label) if labelelse ''
- cmd = "{} {} -C {} {}".format(self.mkdosfs,
label_str, partfname,scripts/lib/wic/engine.py +1
-1- part['size']) + sector_str = "-S {}".format(self.sector_size)if self.sector_size else ''
+ cmd = "{} {} {} -C {}
{}".format(self.mkdosfs,label_str,sector_str, partfname,
+ part['size'])
exec_cmd(cmd)
# copy content from the temporary directory
to the new partitioncmd = "{} -snompi {} {}/*::".format(self.mcopy, partfname, tmpdir)
scripts/lib/wic/engine.py +2
-1@@ -609,14 +605,19 @@ class Disk: def wic_ls(args, native_sysroot): """List contents of partitioned image or vfat partition.""" - disk = Disk(args.path.image, native_sysroot) + disk = Disk(args.path.image, native_sysroot, sector_size=args.sector_size) if not args.path.part: if disk.partitions: print('Num Start End Size Fstype') for part in disk.partitions.values(): + # size values are in bytes from parted; convert tosectors if a custom sector size was requested
scripts/lib/wic/engine.py +2
-0+ display_size = part.size + if args.sector_size and args.sector_size !=disk._lsector_size:
scripts/lib/wic/engine.py +7
-5+ display_size = part.size // args.sector_size print("{:2d} {:12d} {:12d} {:12d} {}".format(\ - part.pnum, part.start, part.end, - part.size, part.fstype)) + part.pnum, part.start // args.sector_size, + part.end // args.sector_size, + display_size, part.fstype)) else: path = args.path.path or '/' print(disk.dir(args.path.part, path))@@ -627,9 +628,9 @@ def wic_cp(args, native_sysroot): partitioned image. """ if isinstance(args.dest, str): - disk = Disk(args.src.image, native_sysroot) + disk = Disk(args.src.image, native_sysroot, sector_size=args.sector_size) else: - disk = Disk(args.dest.image, native_sysroot) + disk = Disk(args.dest.image, native_sysroot, sector_size=args.sector_size) disk.copy(args.src, args.dest)@@ -638,7 +639,7 @@ def wic_rm(args, native_sysroot): Remove files or directories from the vfat partition of partitioned image. """ - disk = Disk(args.path.image, native_sysroot) + disk = Disk(args.path.image, native_sysroot, sector_size=args.sector_size) disk.remove(args.path.part, args.path.path, args.recursive_delete)def
wic_write(args, native_sysroot):scripts/lib/wic/help.py +0
-0@@ -118,7 +118,7 @@ wic_create_usage = """ usage: wic create <wks file or image name> [-o <DIRNAME> | --outdir<DIRNAME>]
[-e | --image-name] [-s, --skip-build-check] [-D, --debug] [-r, --rootfs-dir] [-b, --bootimg-dir]scripts/lib/wic/help.py +1
-1- [-k, --kernel-dir] [-n, --native-sysroot] [-f, --build-rootfs] + [-k, --kernel-dir] [-n, --native-sysroot] [--sector-size<bytes>] [-f, --build-rootfs]
[-c, --compress-with] [-m, --bmap]This command creates an OpenEmbedded image based on the 'OE kickstart
scripts/lib/wic/help.py +0
-0@@ -139,13 +139,16 @@ SYNOPSIS wic create <wks file or image name> [-o <DIRNAME> | --outdir<DIRNAME>]
[-e | --image-name] [-s, --skip-build-check] [-D, --debug] [-r, --rootfs-dir] [-b, --bootimg-dir]scripts/lib/wic/help.py +1
-1- [-k, --kernel-dir] [-n, --native-sysroot] [-f, --build-rootfs] + [-k, --kernel-dir] [-n, --native-sysroot] [--sector-size <bytes>][-f, --build-rootfs]
[-c, --compress-with] [-m, --bmap] [--no-fstab-update]DESCRIPTION
This command creates an OpenEmbedded image based on the 'OE kickstart commands' found in the <wks file>.scripts/lib/wic/help.py +4
-1+ Use the --sector-size option to select the sector size (in bytes) + used for partition layout calculations (default is 512). + In order to do this, wic needs to know the locations of the various build artifacts required to build the image.@@ -278,7 +281,7 @@ wic_ls_usage = """ List content of a partitioned image - usage: wic ls <image>[:<partition>[<path>]] [--native-sysroot <path>] + usage: wic ls <image>[:<partition>[<path>]] [--native-sysroot <path>][--sector-size <bytes>]
This command outputs either list of image partitions or directory
contents
of vfat and ext* partitions.scripts/lib/wic/help.py +1
-1@@ -296,7 +299,7 @@ SYNOPSIS wic ls <image> wic ls <image>:<vfat or ext* partition> wic ls <image>:<vfat or ext* partition><path> - wic ls <image>:<vfat or ext* partition><path> --native-sysroot <path> + wic ls <image>:<vfat or ext* partition><path> --native-sysroot <path>[--sector-size <bytes>]
DESCRIPTION
This command lists either partitions of the image or directory
contentsscripts/lib/wic/help.py +3
-1@@ -336,6 +339,8 @@ DESCRIPTION The -n option is used to specify the path to the native sysroot containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used for partition math + (default is 512 bytes). """@@ -343,7 +348,7 @@ wic_cp_usage = """ Copy files and directories to/from the vfat or ext* partition - usage: wic cp <src> <dest> [--native-sysroot <path>] + usage: wic cp <src> <dest> [--native-sysroot <path>] [--sector-size<bytes>]
source/destination image in format <image>:<partition>[<path>]
scripts/lib/wic/help.py +1
-1@@ -364,7 +369,7 @@ SYNOPSIS wic cp <src> <dest>:<partition> wic cp <src>:<partition> <dest> wic cp <src> <dest-image>:<partition><path> - wic cp <src> <dest-image>:<partition><path> --native-sysroot <path> + wic cp <src> <dest-image>:<partition><path> --native-sysroot <path>[--sector-size <bytes>]
DESCRIPTION
This command copies files or directories eitherscripts/lib/wic/help.py +3
-1@@ -408,13 +413,15 @@ DESCRIPTION The -n option is used to specify the path to the native sysroot containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used for partition math + (default is 512 bytes). """ wic_rm_usage = """ Remove files or directories from the vfat or ext* partitions - usage: wic rm <image>:<partition><path> [--native-sysroot <path>] + usage: wic rm <image>:<partition><path> [--native-sysroot <path>][--sector-size <bytes>]
This command removes files or directories from the vfat or ext*
partitions of
the partitioned image.scripts/lib/wic/help.py +2
-0@@ -466,6 +473,8 @@ DESCRIPTION The -n option is used to specify the path to the native sysroot containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used for partition math + (default is 512 bytes). The -r option is used to remove directories and their contents recursively,this only applies to ext* partition.scripts/lib/wic/partition.py +5
-0@@ -65,6 +65,50 @@ class Partition(): self.lineno = lineno self.source_file = "" + self.sector_size = 512 + + def _mkdosfs_extraopts(self): + """ + Build mkdosfs extra options ensuring the CLI sector size isapplied.
scripts/lib/wic/partition.py +20
-0+ """ + extraopts = self.mkfs_extraopts or '' + tokens = [] + skip_next = False + for tok in extraopts.split(): + if skip_next: + skip_next = False + continue + if tok == '-S': + skip_next = True + continue + if tok.startswith('-S'): + continue + tokens.append(tok) + tokens.extend(['-S', str(self.sector_size)]) + return ' '.join(tokens).strip() + + def _mkfs_ext_extraopts(self, base_opts): + """ + Build mkfs.ext* extra options ensuring the CLI sector size isapplied.
scripts/lib/wic/partition.py +3
-0+ """ + extraopts = self.mkfs_extraopts or base_opts + # Only add an explicit block size when a non-default sector sizeis requested.
scripts/lib/wic/partition.py +17
-0+ if self.sector_size and self.sector_size != 512: + tokens = [] + skip_next = False + for tok in extraopts.split(): + if skip_next: + skip_next = False + continue + if tok == '-b': + skip_next = True + continue + if tok.startswith('-b'): + continue + tokens.append(tok) + tokens.extend(['-b', str(self.sector_size)]) + return ' '.join(tokens).strip() + return extraopts def get_extra_block_count(self, current_blocks): """@@ -138,6 +182,8 @@ class Partition(): Prepare content for individual partitions, depending on partition command parameters. """ + # capture the sector size requested on the CLI for mkdosfsinvocations
+ self.sector_size =getattr(creator, 'sector_size', 512)or 512
self.updated_fstab_path =updated_fstab_path
if self.updated_fstab_path and not (self.fstype.startswith("ext")
or self.fstype == "msdos"):
self.update_fstab_in_rootfs = Truescripts/lib/wic/partition.py +4
-5@@ -293,7 +339,7 @@ class Partition(): with open(rootfs, 'w') as sparse: os.ftruncate(sparse.fileno(), rootfs_size * 1024) - extraopts = self.mkfs_extraopts or "-F -i 8192" + extraopts = self._mkfs_ext_extraopts("-F -i 8192") # use hash_seed to generate reproducible ext4 images (extraopts, pseudo) = self.get_hash_seed_ext4(extraopts, pseudo)@@ -401,7 +447,7 @@ class Partition(): size_str = "" - extraopts = self.mkfs_extraopts or '-S 512' + extraopts = self._mkdosfs_extraopts() dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \ (label_str, self.fsuuid, size_str, extraopts, rootfs,@@ -452,7 +498,7 @@ class Partition(): with open(rootfs, 'w') as sparse: os.ftruncate(sparse.fileno(), size * 1024) - extraopts = self.mkfs_extraopts or "-i 8192" + extraopts = self._mkfs_ext_extraopts("-i 8192") # use hash_seed to generate reproducible ext4 images (extraopts, pseudo) = self.get_hash_seed_ext4(extraopts, None)@@ -498,7 +544,7 @@ class Partition(): size_str = "" - extraopts = self.mkfs_extraopts or '-S 512' + extraopts = self._mkdosfs_extraopts() dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \ (label_str, self.fsuuid, extraopts, size_str, rootfs,@@ -559,4 +605,3 @@ class Partition(): logger.warn("%s Inodes (of size %d) are too small." % (get_err_str(self), size)) break -scripts/lib/wic/plugins/imager/direct.py +2
-1@@ -67,6 +67,7 @@ class DirectPlugin(ImagerPlugin): self._image = None self.ptable_format = self.ks.bootloader.ptable self.parts = self.ks.partitions + self.sector_size = options.sector_size or 512 # as a convenience, set source to the boot partition source # instead of forcing it to be set via bootloader --source@@ -78,7 +79,7 @@ class DirectPlugin(ImagerPlugin): image_path = self._full_path(self.workdir, self.parts[0].disk, "direct") self._image = PartitionedImage(image_path, self.ptable_format, self.ks.bootloader.diskid, self.parts, self.native_sysroot, - options.extra_space) + options.extra_space, self.sector_size)def
setup_workdir(self, workdir):
if workdir:scripts/lib/wic/plugins/imager/direct.py +0
-4@@ -294,15 +295,13 @@ MBR_OVERHEAD = 1 # Overhead of the GPT partitioning scheme GPT_OVERHEAD = 34 -# Size of a sector in bytes -SECTOR_SIZE = 512 - class PartitionedImage(): """ Partitioned image in a file. """ - def __init__(self, path, ptable_format, disk_id, partitions,native_sysroot=None, extra_space=0):
+ def __init__(self, path,ptable_format,disk_id, partitions,
native_sysroot=None, extra_space=0,scripts/lib/wic/plugins/imager/direct.py +2
-8+ sector_size=512): self.path = path # Path to the image file self.numpart = 0 # Number of allocated partitions self.realpart = 0 # Number of partitions in the partition table@@ -332,14 +331,7 @@ class PartitionedImage(): self.partitions = partitions self.partimages = [] # Size of a sector used in calculations - sector_size_str = get_bitbake_var('WIC_SECTOR_SIZE') - if sector_size_str is not None: - try: - self.sector_size = int(sector_size_str) - except ValueError: - self.sector_size = SECTOR_SIZE - else: - self.sector_size = SECTOR_SIZE + self.sector_size = sector_size or 512 self.native_sysroot = native_sysroot num_real_partitions = len([p for p in self.partitions if notp.no_table])
scripts/lib/wic/plugins/source/bootimg_efi.py +3
-2@@ -415,8 +415,9 @@ class BootimgEFIPlugin(SourcePlugin): label = part.label if part.label else "ESP" - dosfs_cmd = "mkdosfs -v -n %s -i %s -C %s %d" % \ - (label, part.fsuuid, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or 512 + dosfs_cmd = "mkdosfs -v -n %s -i %s -S %d -C %s %d" % \ + (label, part.fsuuid, sector_size, bootimg, blocks) exec_native_cmd(dosfs_cmd, native_sysroot) logger.debug("mkdosfs:\n%s" % (str(out)))scripts/lib/wic/plugins/source/bootimg_pcbios.py +1
-1@@ -132,7 +132,7 @@ class BootimgPcbiosPlugin(SourcePlugin): cls._do_prepare_grub(part, cr_workdir, oe_builddir, kernel_dir, rootfs_dir, native_sysroot) elif source_params['loader-bios'] == 'syslinux': - cls._do_prepare_syslinux(part, cr_workdir, bootimg_dir, + cls._do_prepare_syslinux(part, creator, cr_workdir, bootimg_dir, kernel_dir, native_sysroot) else:raise WicError("unrecognized
bootimg_pcbiosloader: %s" %
source_params['loader-bios'])scripts/lib/wic/plugins/source/bootimg_pcbios.py +1
-1@@ -142,7 +142,7 @@ class BootimgPcbiosPlugin(SourcePlugin): except KeyError: # Required by do_install_disk cls.loader = 'syslinux' - cls._do_prepare_syslinux(part, cr_workdir, bootimg_dir, + cls._do_prepare_syslinux(part, creator, cr_workdir, bootimg_dir, kernel_dir, native_sysroot)@classmethod
scripts/lib/wic/plugins/source/bootimg_pcbios.py +4
-3@@ -240,7 +240,7 @@ class BootimgPcbiosPlugin(SourcePlugin): cfg.close() @classmethod - def _do_prepare_syslinux(cls, part, cr_workdir, bootimg_dir, + def _do_prepare_syslinux(cls, part, creator, cr_workdir, bootimg_dir, kernel_dir, native_sysroot): """ Called to do the actual content population for a partition i.e. it@@ -292,8 +292,9 @@ class BootimgPcbiosPlugin(SourcePlugin): label = part.label if part.label else "boot" - dosfs_cmd = "mkdosfs -n %s -i %s -S 512 -C %s %d" % \ - (label, part.fsuuid, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or 512 + dosfs_cmd = "mkdosfs -n %s -i %s -S %d -C %s %d" % \ + (label, part.fsuuid, sector_size, bootimg, blocks) exec_native_cmd(dosfs_cmd, native_sysroot) mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir)scripts/lib/wic/plugins/source/isoimage_isohybrid.py +3
-2@@ -367,8 +367,9 @@ class IsoImagePlugin(SourcePlugin): esp_label = source_params.get('esp_label', 'EFIimg') - dosfs_cmd = 'mkfs.vfat -n \'%s\' -S 512 -C %s %d' \ - % (esp_label, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or 512 + dosfs_cmd = "mkfs.vfat -n '%s' -S %d -C %s %d" % \ + (esp_label, sector_size, bootimg, blocks) exec_native_cmd(dosfs_cmd, native_sysroot) mmd_cmd = "mmd -i %s ::/EFI" % bootimgscripts/wic +4
-0@@ -376,6 +376,8 @@ def wic_init_parser_create(subparser): default="direct", help="the wic imager plugin") subparser.add_argument("--extra-space", type=int, dest="extra_space", default=0, help="additional free disk space to add to the image") + subparser.add_argument("--sector-size", dest="sector_size", type=int, default=512, + help="sector size in bytes (default: 512)") return@@ -413,6 +415,8 @@ def imgtype(arg): def wic_init_parser_ls(subparser): subparser.add_argument("path", type=imgtype, help="image spec: <image>[:<vfat partition>[<path>]]") + subparser.add_argument("--sector-size", dest="sector_size", type=int, default=512, + help="sector size in bytes (default: 512)") subparser.add_argument("-n", "--native-sysroot",help="path to the native sysroot containing the
tools")subparser.add_argument("-e", "--image-name", dest="image_name",scripts/wic +2
-0@@ -433,6 +437,8 @@ def wic_init_parser_cp(subparser): help="image spec: <image>:<vfat partition>[<path>] or <file>") subparser.add_argument("dest", help="image spec: <image>:<vfat partition>[<path>] or <file>") + subparser.add_argument("--sector-size", dest="sector_size", type=int, default=512, + help="sector size in bytes (default: 512)")subparser.add_argument("-n", "--native-sysroot",
help="path to the native sysroot containing the
tools")subparser.add_argument("-e", "--image-name", dest="image_name",scripts/wic +2
-0@@ -445,6 +451,8 @@ def wic_init_parser_cp(subparser): def wic_init_parser_rm(subparser): subparser.add_argument("path", type=imgpathtype, help="path: <image>:<vfat partition><path>") + subparser.add_argument("--sector-size", dest="sector_size", type=int, default=512, + help="sector size in bytes (default: 512)") subparser.add_argument("-n", "--native-sysroot", help="path to the native sysroot containing thetools")
subparser.add_argument("-r", dest="recursive_delete",
action="store_true", default=False,
--
2.51.0-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#231176):
https://lists.openembedded.org/g/openembedded-core/message/231176
Mute This Topic: https://lists.openembedded.org/mt/117833550/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end - "Use the force Harry" - Gandalf, Star Trek II
Quoted 36 lines · Bruce Ashfield
Quoted 22 lines · Trevor Woerner via lists.openembedded.org
The previous implementation to add variable sector-size support:
- required the variableWIC_SECTOR_SIZEeither be defined in a configuration file or be defined in a --vars file
- this means that every invocation of "wic ls", "wic cp", or "wic rm" needed this variable defined (config or --vars)
- required the user to create separate *wks files for every sector size they wanted to use
- required the user to specify the mkfs-extraopts by hand to specify the correct sector size: e.g.bootloader --ptable gpt part --fstype ext4 --source rootfs --label rofs-a --mkfs-extraopts "-b 4096" part --fstype ext4 --source rootfs --use-uuid --mkfs-extraopts "-b4096"
- specifying --mkfs-extraopts replaces the defaults with the user-supplied values
- only provided details to support using variable sector-sizes with ext[234] filesystems
- it would not be possible to generate images with different sector sizes in the same build since the configuration and *wks files would need to change and the build re-run for each sizeQuoted 10 lines
Update the sector-size handling so that:
- the sector-size will now be provided on the cmdline to the "wic ls", "wic cp", "wic rm", and "wic create" commands: default = 512
- this means the configuration and/or --vars file does not need to be changed in order to perform those operations on images with different sector sizes
- support is provided implicitly for mkdosfs and ext[234] partitions
- the user no longer needs to know and supply the sector-size magic in --mkfs-extraopts (thereby clobbering the other defaults)
Quoted 2 lines
It wasn't clear to me when scanning the patch. For configuration files with a sector size, is it now completely ignored ?
Yes.
While trying to use the existing implementation in actual production workflows we found a number of shortcomings that are addressed with this update. Additionally, the ultimate goal is to make wic an independent utility from oe-core so it can be easily used by external tools post-build.
If sector-size is not available on the cmdline, then a --vars file would be needed for every simple wic invocation such as "wic cp", "wic ls", and "wic rm"... which would be silly. Take a look at the patch I submitted a week or so ago to see how the oe-selftests would have to be updated to support this.
If sector-size is available both on the cmdline and in a --vars file then which one wins? Ultimately having it specified in both places is only going to lead to confusion as people will be changing it in one place and not realizing it's also defined (and taking precedence) from somewhere else. I believe this is currently the case with --native-sysroot, which probably needs fixing as well since several oe-selftests are trying to use it, but I doubt it is working the way the test writers expect.
One parameter specified in one place so a user would not need multiple sets of configuration files to perform a simple "wic ls" of images with different sector sizes; simply specify it on the cmdline if you want something other than 512.
Quoted 690 lines
Apologies if I missed where existing configs were used to prime the parameters to the functions.
Bruce
Quoted 678 lines
AI-Generated: codex/gpt-5.1-codex-max
Signed-off-by Trevor Woerner <[email protected]>---
changes since v2:
- nonechanges since v1:
- none--- meta/lib/oeqa/selftest/cases/wic.py | 39 ++++--------- scripts/lib/wic/engine.py | 45 +++++++-------- scripts/lib/wic/help.py | 23 +++++--- scripts/lib/wic/partition.py | 55 +++++++++++++++++-- scripts/lib/wic/plugins/imager/direct.py | 18 ++---- scripts/lib/wic/plugins/source/bootimg_efi.py | 5 +- .../lib/wic/plugins/source/bootimg_pcbios.py | 11 ++-- .../wic/plugins/source/isoimage_isohybrid.py | 5 +- scripts/wic | 8 +++ 9 files changed, 125 insertions(+), 84 deletions(-)meta/lib/oeqa/selftest/cases/wic.py +5
-19@@ -935,33 +935,22 @@ bootloader --ptable gpt""") finally: os.remove(wks_file) - def test_wic_sector_size(self): - """Test generation image sector size""" - + def test_wic_sector_size_cli(self): + """Test sector size handling via CLI option.""" + oldpath = os.environ['PATH'] os.environ['PATH'] = get_bb_var("PATH", "wic-tools") try: - # Add WIC_SECTOR_SIZE into config - config = 'WIC_SECTOR_SIZE = "4096"\n'\ - 'WICVARS:append = " WIC_SECTOR_SIZE"\n' - self.append_config(config) bitbake('core-image-minimal') - # Check WIC_SECTOR_SIZE apply to bitbake variable - wic_sector_size_str = get_bb_var('WIC_SECTOR_SIZE', 'core-image-minimal') - wic_sector_size = int(wic_sector_size_str) - self.assertEqual(4096, wic_sector_size) - - self.logger.info("Test wic_sector_size: %d \n" % wic_sector_size) - with NamedTemporaryFile("w", suffix=".wks") as wks: wks.writelines( ['bootloader --ptable gpt\n', - 'part --fstype ext4 --source rootfs --label rofs-a --mkfs-extraopts "-b 4096"\n', - 'part --fstype ext4 --source rootfs --use-uuid --mkfs-extraopts "-b 4096"\n']) + 'part --fstype ext4 --source rootfs --label rofs-a\n', + 'part --fstype ext4 --source rootfs --use-uuid\n']) wks.flush() - cmd = "wic create %s -e core-image-minimal -o %s" % (wks.name, self.resultdir)
+ cmd = "wic create %s -e core-image-minimal -o %s
--sector-size 4096" % (wks.name, self.resultdir)
runCmd(cmd)
wksname = os.path.splitext(os.path.basename(wks.name))[0] images = glob(os.path.join(self.resultdir, "%s-*direct" %
wksname))meta/lib/oeqa/selftest/cases/wic.py +3
-6@@ -969,24 +958,18 @@ bootloader --ptable gpt""") sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') # list partitions - result = runCmd("wic ls %s -n %s" % (images[0], sysroot)) + result = runCmd("wic ls %s -n %s --sector-size 4096" % (images[0], sysroot)) self.assertEqual(3, len(result.output.split('\n'))) - # verify partition size with wic - res = runCmd("export PARTED_SECTOR_SIZE=%d; parted -m %s unit b p" % (wic_sector_size, images[0]), + # verify partition size with parted output + res = runCmd("export PARTED_SECTOR_SIZE=%d; parted -m %s unit b p" % (4096, images[0]), stderr=subprocess.PIPE) - # parse parted output which looks like this: - # BYT;\n - #/var/tmp/wic/build/tmpgjzzefdd-202410281021-sda.direct:78569472B:file:4096:4096:gpt::;\n
meta/lib/oeqa/selftest/cases/wic.py +0
-4- # 1:139264B:39284735B:39145472B:ext4:rofs-a:;\n - # 2:39284736B:78430207B:39145472B:ext4:primary:;\n disk_info = res.output.splitlines()[1] - # Check sector sizes sector_size_logical = int(disk_info.split(":")[3]) sector_size_physical = int(disk_info.split(":")[4]) - self.assertEqual(wic_sector_size, sector_size_logical,"Logical sector size is not %d." %
wic_sector_size)
- self.assertEqual(wic_sector_size,sector_size_physical,
"Physical sector size is not %d." %wic_sector_size)
+ self.assertEqual(4096,sector_size_logical, "Logical sector
size is not 4096.")
+ self.assertEqual(4096,sector_size_physical, "Physical sector
size is not 4096.")finally:
os.environ['PATH'] = oldpathscripts/lib/wic/engine.py +1
-1@@ -224,7 +224,7 @@ def wic_list(args, scripts_path): class Disk: - def __init__(self, imagepath, native_sysroot, fstypes=('fat', 'ext')): + def __init__(self, imagepath, native_sysroot, fstypes=('fat', 'ext'),sector_size=512):
self.imagepath = imagepath
self.native_sysroot =native_sysroot
self.fstypes = fstypesscripts/lib/wic/engine.py +2
-11@@ -233,16 +233,7 @@ class Disk: self._lsector_size = None self._psector_size = None self._ptable_format = None - - # define sector size - sector_size_str = get_bitbake_var('WIC_SECTOR_SIZE') - if sector_size_str is not None: - try: - self.sector_size = int(sector_size_str) - except ValueError: - self.sector_size = None - else: - self.sector_size = None + self.sector_size = sector_size # find parted # read paths from $PATH environment variable@@ -271,7 +262,7 @@ class Disk: if self._partitions is None: self._partitions = OrderedDict() - if self.sector_size is not None: + if self.sector_size: out = exec_cmd("export PARTED_SECTOR_SIZE=%d; %s -sm %s unit B print" % \ (self.sector_size, self.parted,self.imagepath), True)
else:scripts/lib/wic/engine.py +1
-0@@ -312,11 +303,15 @@ class Disk: raise WicError("Partition %s is not in the image" % pnum) part = self.partitions[pnum] # check if fstype is supported + # NOTE: parted is unable to identify dos-type partitions with a4k sector-size
+ # if the type is empty and a non-default sector size is
used, assume 'fat'scripts/lib/wic/engine.py +2
-0+ # fdisk identifies them without issue + part_fstype = part.fstype if part.fstype or self.sector_size ==512 else 'fat'
for fstype in self.fstypes:scripts/lib/wic/engine.py +2
-2- if part.fstype.startswith(fstype): + if part_fstype.startswith(fstype): break else: - raise WicError("Not supported fstype: {}".format(part.fstype)) + raise WicError("Not supported fstype: {}".format(part_fstype)) if pnum not in self._partimages: tmpf = tempfile.NamedTemporaryFile(prefix="wic-part") dst_fname = tmpf.name@@ -586,8 +581,9 @@ class Disk: label = part.get("name") label_str = "-n {}".format(label) if labelelse ''
- cmd = "{} {} -C {} {}".format(self.mkdosfs,
label_str, partfname,scripts/lib/wic/engine.py +1
-1- part['size']) + sector_str = "-S {}".format(self.sector_size)if self.sector_size else ''
+ cmd = "{} {} {} -C {}
{}".format(self.mkdosfs,label_str,sector_str, partfname,
+ part['size'])
exec_cmd(cmd)
# copy content from the temporary directory
to the new partitioncmd = "{} -snompi {} {}/*::".format(self.mcopy, partfname, tmpdir)
scripts/lib/wic/engine.py +2
-1@@ -609,14 +605,19 @@ class Disk: def wic_ls(args, native_sysroot): """List contents of partitioned image or vfat partition.""" - disk = Disk(args.path.image, native_sysroot) + disk = Disk(args.path.image, native_sysroot, sector_size=args.sector_size) if not args.path.part: if disk.partitions: print('Num Start End Size Fstype') for part in disk.partitions.values(): + # size values are in bytes from parted; convert tosectors if a custom sector size was requested
scripts/lib/wic/engine.py +2
-0+ display_size = part.size + if args.sector_size and args.sector_size !=disk._lsector_size:
scripts/lib/wic/engine.py +7
-5+ display_size = part.size // args.sector_size print("{:2d} {:12d} {:12d} {:12d} {}".format(\ - part.pnum, part.start, part.end, - part.size, part.fstype)) + part.pnum, part.start // args.sector_size, + part.end // args.sector_size, + display_size, part.fstype)) else: path = args.path.path or '/' print(disk.dir(args.path.part, path))@@ -627,9 +628,9 @@ def wic_cp(args, native_sysroot): partitioned image. """ if isinstance(args.dest, str): - disk = Disk(args.src.image, native_sysroot) + disk = Disk(args.src.image, native_sysroot, sector_size=args.sector_size) else: - disk = Disk(args.dest.image, native_sysroot) + disk = Disk(args.dest.image, native_sysroot, sector_size=args.sector_size) disk.copy(args.src, args.dest)@@ -638,7 +639,7 @@ def wic_rm(args, native_sysroot): Remove files or directories from the vfat partition of partitioned image. """ - disk = Disk(args.path.image, native_sysroot) + disk = Disk(args.path.image, native_sysroot, sector_size=args.sector_size) disk.remove(args.path.part, args.path.path, args.recursive_delete)def
wic_write(args, native_sysroot):scripts/lib/wic/help.py +0
-0@@ -118,7 +118,7 @@ wic_create_usage = """ usage: wic create <wks file or image name> [-o <DIRNAME> | --outdir<DIRNAME>]
[-e | --image-name] [-s, --skip-build-check] [-D, --debug] [-r, --rootfs-dir] [-b, --bootimg-dir]scripts/lib/wic/help.py +1
-1- [-k, --kernel-dir] [-n, --native-sysroot] [-f, --build-rootfs] + [-k, --kernel-dir] [-n, --native-sysroot] [--sector-size<bytes>] [-f, --build-rootfs]
[-c, --compress-with] [-m, --bmap]This command creates an OpenEmbedded image based on the 'OE kickstart
scripts/lib/wic/help.py +0
-0@@ -139,13 +139,16 @@ SYNOPSIS wic create <wks file or image name> [-o <DIRNAME> | --outdir<DIRNAME>]
[-e | --image-name] [-s, --skip-build-check] [-D, --debug] [-r, --rootfs-dir] [-b, --bootimg-dir]scripts/lib/wic/help.py +1
-1- [-k, --kernel-dir] [-n, --native-sysroot] [-f, --build-rootfs] + [-k, --kernel-dir] [-n, --native-sysroot] [--sector-size <bytes>][-f, --build-rootfs]
[-c, --compress-with] [-m, --bmap] [--no-fstab-update]DESCRIPTION
This command creates an OpenEmbedded image based on the 'OE kickstart commands' found in the <wks file>.scripts/lib/wic/help.py +4
-1+ Use the --sector-size option to select the sector size (in bytes) + used for partition layout calculations (default is 512). + In order to do this, wic needs to know the locations of the various build artifacts required to build the image.@@ -278,7 +281,7 @@ wic_ls_usage = """ List content of a partitioned image - usage: wic ls <image>[:<partition>[<path>]] [--native-sysroot <path>] + usage: wic ls <image>[:<partition>[<path>]] [--native-sysroot <path>][--sector-size <bytes>]
This command outputs either list of image partitions or directory
contents
of vfat and ext* partitions.scripts/lib/wic/help.py +1
-1@@ -296,7 +299,7 @@ SYNOPSIS wic ls <image> wic ls <image>:<vfat or ext* partition> wic ls <image>:<vfat or ext* partition><path> - wic ls <image>:<vfat or ext* partition><path> --native-sysroot <path> + wic ls <image>:<vfat or ext* partition><path> --native-sysroot <path>[--sector-size <bytes>]
DESCRIPTION
This command lists either partitions of the image or directory
contentsscripts/lib/wic/help.py +3
-1@@ -336,6 +339,8 @@ DESCRIPTION The -n option is used to specify the path to the native sysroot containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used for partition math + (default is 512 bytes). """@@ -343,7 +348,7 @@ wic_cp_usage = """ Copy files and directories to/from the vfat or ext* partition - usage: wic cp <src> <dest> [--native-sysroot <path>] + usage: wic cp <src> <dest> [--native-sysroot <path>] [--sector-size<bytes>]
source/destination image in format <image>:<partition>[<path>]
scripts/lib/wic/help.py +1
-1@@ -364,7 +369,7 @@ SYNOPSIS wic cp <src> <dest>:<partition> wic cp <src>:<partition> <dest> wic cp <src> <dest-image>:<partition><path> - wic cp <src> <dest-image>:<partition><path> --native-sysroot <path> + wic cp <src> <dest-image>:<partition><path> --native-sysroot <path>[--sector-size <bytes>]
DESCRIPTION
This command copies files or directories eitherscripts/lib/wic/help.py +3
-1@@ -408,13 +413,15 @@ DESCRIPTION The -n option is used to specify the path to the native sysroot containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used for partition math + (default is 512 bytes). """ wic_rm_usage = """ Remove files or directories from the vfat or ext* partitions - usage: wic rm <image>:<partition><path> [--native-sysroot <path>] + usage: wic rm <image>:<partition><path> [--native-sysroot <path>][--sector-size <bytes>]
This command removes files or directories from the vfat or ext*
partitions of
the partitioned image.scripts/lib/wic/help.py +2
-0@@ -466,6 +473,8 @@ DESCRIPTION The -n option is used to specify the path to the native sysroot containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used for partition math + (default is 512 bytes). The -r option is used to remove directories and their contents recursively,this only applies to ext* partition.scripts/lib/wic/partition.py +5
-0@@ -65,6 +65,50 @@ class Partition(): self.lineno = lineno self.source_file = "" + self.sector_size = 512 + + def _mkdosfs_extraopts(self): + """ + Build mkdosfs extra options ensuring the CLI sector size isapplied.
scripts/lib/wic/partition.py +20
-0+ """ + extraopts = self.mkfs_extraopts or '' + tokens = [] + skip_next = False + for tok in extraopts.split(): + if skip_next: + skip_next = False + continue + if tok == '-S': + skip_next = True + continue + if tok.startswith('-S'): + continue + tokens.append(tok) + tokens.extend(['-S', str(self.sector_size)]) + return ' '.join(tokens).strip() + + def _mkfs_ext_extraopts(self, base_opts): + """ + Build mkfs.ext* extra options ensuring the CLI sector size isapplied.
scripts/lib/wic/partition.py +3
-0+ """ + extraopts = self.mkfs_extraopts or base_opts + # Only add an explicit block size when a non-default sector sizeis requested.
scripts/lib/wic/partition.py +17
-0+ if self.sector_size and self.sector_size != 512: + tokens = [] + skip_next = False + for tok in extraopts.split(): + if skip_next: + skip_next = False + continue + if tok == '-b': + skip_next = True + continue + if tok.startswith('-b'): + continue + tokens.append(tok) + tokens.extend(['-b', str(self.sector_size)]) + return ' '.join(tokens).strip() + return extraopts def get_extra_block_count(self, current_blocks): """@@ -138,6 +182,8 @@ class Partition(): Prepare content for individual partitions, depending on partition command parameters. """ + # capture the sector size requested on the CLI for mkdosfsinvocations
+ self.sector_size =getattr(creator, 'sector_size', 512)or 512
self.updated_fstab_path =updated_fstab_path
if self.updated_fstab_path and not (self.fstype.startswith("ext")
or self.fstype == "msdos"):
self.update_fstab_in_rootfs = Truescripts/lib/wic/partition.py +4
-5@@ -293,7 +339,7 @@ class Partition(): with open(rootfs, 'w') as sparse: os.ftruncate(sparse.fileno(), rootfs_size * 1024) - extraopts = self.mkfs_extraopts or "-F -i 8192" + extraopts = self._mkfs_ext_extraopts("-F -i 8192") # use hash_seed to generate reproducible ext4 images (extraopts, pseudo) = self.get_hash_seed_ext4(extraopts, pseudo)@@ -401,7 +447,7 @@ class Partition(): size_str = "" - extraopts = self.mkfs_extraopts or '-S 512' + extraopts = self._mkdosfs_extraopts() dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \ (label_str, self.fsuuid, size_str, extraopts, rootfs,@@ -452,7 +498,7 @@ class Partition(): with open(rootfs, 'w') as sparse: os.ftruncate(sparse.fileno(), size * 1024) - extraopts = self.mkfs_extraopts or "-i 8192" + extraopts = self._mkfs_ext_extraopts("-i 8192") # use hash_seed to generate reproducible ext4 images (extraopts, pseudo) = self.get_hash_seed_ext4(extraopts, None)@@ -498,7 +544,7 @@ class Partition(): size_str = "" - extraopts = self.mkfs_extraopts or '-S 512' + extraopts = self._mkdosfs_extraopts() dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \ (label_str, self.fsuuid, extraopts, size_str, rootfs,@@ -559,4 +605,3 @@ class Partition(): logger.warn("%s Inodes (of size %d) are too small." % (get_err_str(self), size)) break -scripts/lib/wic/plugins/imager/direct.py +2
-1@@ -67,6 +67,7 @@ class DirectPlugin(ImagerPlugin): self._image = None self.ptable_format = self.ks.bootloader.ptable self.parts = self.ks.partitions + self.sector_size = options.sector_size or 512 # as a convenience, set source to the boot partition source # instead of forcing it to be set via bootloader --source@@ -78,7 +79,7 @@ class DirectPlugin(ImagerPlugin): image_path = self._full_path(self.workdir, self.parts[0].disk, "direct") self._image = PartitionedImage(image_path, self.ptable_format, self.ks.bootloader.diskid, self.parts, self.native_sysroot, - options.extra_space) + options.extra_space, self.sector_size)def
setup_workdir(self, workdir):
if workdir:scripts/lib/wic/plugins/imager/direct.py +0
-4@@ -294,15 +295,13 @@ MBR_OVERHEAD = 1 # Overhead of the GPT partitioning scheme GPT_OVERHEAD = 34 -# Size of a sector in bytes -SECTOR_SIZE = 512 - class PartitionedImage(): """ Partitioned image in a file. """ - def __init__(self, path, ptable_format, disk_id, partitions,native_sysroot=None, extra_space=0):
+ def __init__(self, path,ptable_format,disk_id, partitions,
native_sysroot=None, extra_space=0,scripts/lib/wic/plugins/imager/direct.py +2
-8+ sector_size=512): self.path = path # Path to the image file self.numpart = 0 # Number of allocated partitions self.realpart = 0 # Number of partitions in the partition table@@ -332,14 +331,7 @@ class PartitionedImage(): self.partitions = partitions self.partimages = [] # Size of a sector used in calculations - sector_size_str = get_bitbake_var('WIC_SECTOR_SIZE') - if sector_size_str is not None: - try: - self.sector_size = int(sector_size_str) - except ValueError: - self.sector_size = SECTOR_SIZE - else: - self.sector_size = SECTOR_SIZE + self.sector_size = sector_size or 512 self.native_sysroot = native_sysroot num_real_partitions = len([p for p in self.partitions if notp.no_table])
scripts/lib/wic/plugins/source/bootimg_efi.py +3
-2@@ -415,8 +415,9 @@ class BootimgEFIPlugin(SourcePlugin): label = part.label if part.label else "ESP" - dosfs_cmd = "mkdosfs -v -n %s -i %s -C %s %d" % \ - (label, part.fsuuid, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or 512 + dosfs_cmd = "mkdosfs -v -n %s -i %s -S %d -C %s %d" % \ + (label, part.fsuuid, sector_size, bootimg, blocks) exec_native_cmd(dosfs_cmd, native_sysroot) logger.debug("mkdosfs:\n%s" % (str(out)))scripts/lib/wic/plugins/source/bootimg_pcbios.py +1
-1@@ -132,7 +132,7 @@ class BootimgPcbiosPlugin(SourcePlugin): cls._do_prepare_grub(part, cr_workdir, oe_builddir, kernel_dir, rootfs_dir, native_sysroot) elif source_params['loader-bios'] == 'syslinux': - cls._do_prepare_syslinux(part, cr_workdir, bootimg_dir, + cls._do_prepare_syslinux(part, creator, cr_workdir, bootimg_dir, kernel_dir, native_sysroot) else:raise WicError("unrecognized
bootimg_pcbiosloader: %s" %
source_params['loader-bios'])scripts/lib/wic/plugins/source/bootimg_pcbios.py +1
-1@@ -142,7 +142,7 @@ class BootimgPcbiosPlugin(SourcePlugin): except KeyError: # Required by do_install_disk cls.loader = 'syslinux' - cls._do_prepare_syslinux(part, cr_workdir, bootimg_dir, + cls._do_prepare_syslinux(part, creator, cr_workdir, bootimg_dir, kernel_dir, native_sysroot)@classmethod
scripts/lib/wic/plugins/source/bootimg_pcbios.py +4
-3@@ -240,7 +240,7 @@ class BootimgPcbiosPlugin(SourcePlugin): cfg.close() @classmethod - def _do_prepare_syslinux(cls, part, cr_workdir, bootimg_dir, + def _do_prepare_syslinux(cls, part, creator, cr_workdir, bootimg_dir, kernel_dir, native_sysroot): """ Called to do the actual content population for a partition i.e. it@@ -292,8 +292,9 @@ class BootimgPcbiosPlugin(SourcePlugin): label = part.label if part.label else "boot" - dosfs_cmd = "mkdosfs -n %s -i %s -S 512 -C %s %d" % \ - (label, part.fsuuid, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or 512 + dosfs_cmd = "mkdosfs -n %s -i %s -S %d -C %s %d" % \ + (label, part.fsuuid, sector_size, bootimg, blocks) exec_native_cmd(dosfs_cmd, native_sysroot) mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir)scripts/lib/wic/plugins/source/isoimage_isohybrid.py +3
-2@@ -367,8 +367,9 @@ class IsoImagePlugin(SourcePlugin): esp_label = source_params.get('esp_label', 'EFIimg') - dosfs_cmd = 'mkfs.vfat -n \'%s\' -S 512 -C %s %d' \ - % (esp_label, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or 512 + dosfs_cmd = "mkfs.vfat -n '%s' -S %d -C %s %d" % \ + (esp_label, sector_size, bootimg, blocks) exec_native_cmd(dosfs_cmd, native_sysroot) mmd_cmd = "mmd -i %s ::/EFI" % bootimgscripts/wic +4
-0@@ -376,6 +376,8 @@ def wic_init_parser_create(subparser): default="direct", help="the wic imager plugin") subparser.add_argument("--extra-space", type=int, dest="extra_space", default=0, help="additional free disk space to add to the image") + subparser.add_argument("--sector-size", dest="sector_size", type=int, default=512, + help="sector size in bytes (default: 512)") return@@ -413,6 +415,8 @@ def imgtype(arg): def wic_init_parser_ls(subparser): subparser.add_argument("path", type=imgtype, help="image spec: <image>[:<vfat partition>[<path>]]") + subparser.add_argument("--sector-size", dest="sector_size", type=int, default=512, + help="sector size in bytes (default: 512)") subparser.add_argument("-n", "--native-sysroot",help="path to the native sysroot containing the
tools")subparser.add_argument("-e", "--image-name", dest="image_name",scripts/wic +2
-0@@ -433,6 +437,8 @@ def wic_init_parser_cp(subparser): help="image spec: <image>:<vfat partition>[<path>] or <file>") subparser.add_argument("dest", help="image spec: <image>:<vfat partition>[<path>] or <file>") + subparser.add_argument("--sector-size", dest="sector_size", type=int, default=512, + help="sector size in bytes (default: 512)")subparser.add_argument("-n", "--native-sysroot",
help="path to the native sysroot containing the
tools")subparser.add_argument("-e", "--image-name", dest="image_name",scripts/wic +2
-0@@ -445,6 +451,8 @@ def wic_init_parser_cp(subparser): def wic_init_parser_rm(subparser): subparser.add_argument("path", type=imgpathtype, help="path: <image>:<vfat partition><path>") + subparser.add_argument("--sector-size", dest="sector_size", type=int, default=512, + help="sector size in bytes (default: 512)") subparser.add_argument("-n", "--native-sysroot", help="path to the native sysroot containing thetools")
subparser.add_argument("-r", dest="recursive_delete",
action="store_true", default=False,
--
2.51.0-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#231176):
https://lists.openembedded.org/g/openembedded-core/message/231176
Mute This Topic: https://lists.openembedded.org/mt/117833550/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end - "Use the force Harry" - Gandalf, Star Trek II
Quoted 68 lines · Trevor Woerner
Quoted 1 line · Bruce Ashfield
On Sun, Feb 15, 2026 at 9:32 PM Trevor Woerner via
lists.openembedded.org
Quoted 10 lines
Quoted 8 lines · <[email protected]> wrote:
The previous implementation to add variable sector-size support:
- required the variableWIC_SECTOR_SIZEeither be defined in a configuration file or be defined in a --vars file
- this means that every invocation of "wic ls", "wic cp", or "wic rm" needed this variable defined (config or --vars)
- required the user to create separate *wks files for every sector size they wanted to use
- required the user to specify the mkfs-extraopts by hand to specifythe
Quoted 3 lines
Quoted 3 lines
correct sector size: e.g. bootloader --ptable gpt part --fstype ext4 --source rootfs --label rofs-a--mkfs-extraopts
Quoted 2 lines
Quoted 2 lines
"-b 4096"
part --fstype ext4 --source rootfs --use-uuid --mkfs-extraopts"-b
Quoted 20 lines
Quoted 9 lines
4096"
- specifying --mkfs-extraopts replaces the defaults with the user-supplied values
- only provided details to support using variable sector-sizes with ext[234] filesystems
- it would not be possible to generate images with different sector sizes in the same build since the configuration and *wks files would need to change and the build re-run for each sizeQuoted 10 lines
Update the sector-size handling so that:
- the sector-size will now be provided on the cmdline to the "wic ls", "wic cp", "wic rm", and "wic create" commands: default = 512
- this means the configuration and/or --vars file does not need to be changed in order to perform those operations on images with different sector sizes
- support is provided implicitly for mkdosfs and ext[234] partitions
- the user no longer needs to know and supply the sector-size magic in --mkfs-extraopts (thereby clobbering the other defaults)Quoted 2 lines
It wasn't clear to me when scanning the patch. For configuration files with a sector size, is it now completely ignored ?
Yes.
While trying to use the existing implementation in actual production workflows we found a number of shortcomings that are addressed with this update. Additionally, the ultimate goal is to make wic an independent utility from oe-core so it can be easily used by external tools post-build.
If sector-size is not available on the cmdline, then a --vars file would be needed for every simple wic invocation such as "wic cp", "wic ls", and "wic rm"... which would be silly. Take a look at the patch I submitted a week or so ago to see how the oe-selftests would have to be updated to support this.
If sector-size is available both on the cmdline and in a --vars file then which one wins? Ultimately having it specified in both places is only going to lead to confusion as people will be changing it in one place and not realizing it's also defined (and taking precedence) from somewhere else. I believe this is currently the case with --native-sysroot, which probably needs fixing as well since several oe-selftests are trying to use it, but I doubt it is working the way the test writers expect.
Quoted 5 lines
One parameter specified in one place so a user would not need multiple sets of configuration files to perform a simple "wic ls" of images with different sector sizes; simply specify it on the cmdline if you want something other than 512.
That's not a good migration path. You can't simply throw away someone's existing configuration and ask them to update to a new one. I didn't even see an error thrown with migration instructions.
There's many different users of things like this, we can't simply change the interface without some way to migrate.
Bruce
Quoted 748 lines
Quoted 54 lines
Apologies if I missed where existing configs were used to prime the parameters to the functions.
Bruce
Quoted 46 lines
AI-Generated: codex/gpt-5.1-codex-max
Signed-off-by Trevor Woerner <[email protected]>---
changes since v2:
- nonechanges since v1:
- none--- meta/lib/oeqa/selftest/cases/wic.py | 39 ++++--------- scripts/lib/wic/engine.py | 45 +++++++-------- scripts/lib/wic/help.py | 23 +++++--- scripts/lib/wic/partition.py | 55 +++++++++++++++++-- scripts/lib/wic/plugins/imager/direct.py | 18 ++---- scripts/lib/wic/plugins/source/bootimg_efi.py | 5 +- .../lib/wic/plugins/source/bootimg_pcbios.py | 11 ++-- .../wic/plugins/source/isoimage_isohybrid.py | 5 +- scripts/wic | 8 +++ 9 files changed, 125 insertions(+), 84 deletions(-)meta/lib/oeqa/selftest/cases/wic.py +3
-7@@ -935,33 +935,22 @@ bootloader --ptable gpt""") finally: os.remove(wks_file) - def test_wic_sector_size(self): - """Test generation image sector size""" - + def test_wic_sector_size_cli(self): + """Test sector size handling via CLI option.""" + oldpath = os.environ['PATH'] os.environ['PATH'] = get_bb_var("PATH", "wic-tools") try: - # Add WIC_SECTOR_SIZE into config - config = 'WIC_SECTOR_SIZE = "4096"\n'\ - 'WICVARS:append = " WIC_SECTOR_SIZE"\n' - self.append_config(config) bitbake('core-image-minimal')Quoted 13 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""")
Quoted 13 lines
meta/lib/oeqa/selftest/cases/wic.py +0
-8- # Check WIC_SECTOR_SIZE apply to bitbake variable - wic_sector_size_str = get_bb_var('WIC_SECTOR_SIZE', 'core-image-minimal') - wic_sector_size = int(wic_sector_size_str) - self.assertEqual(4096, wic_sector_size) - - self.logger.info("Test wic_sector_size: %d \n" % wic_sector_size) - with NamedTemporaryFile("w", suffix=".wks") as wks: wks.writelines( ['bootloader --ptable gpt\n', - 'part --fstype ext4 --source rootfs --labelrofs-a
Quoted 6 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""") · line 954
Quoted 6 lines
meta/lib/oeqa/selftest/cases/wic.py +2
-3--mkfs-extraopts "-b 4096"\n', - 'part --fstype ext4 --source rootfs --use-uuid --mkfs-extraopts "-b 4096"\n']) + 'part --fstype ext4 --source rootfs --label rofs-a\n', + 'part --fstype ext4 --source rootfs--use-uuid\n'])
Quoted 7 lines
Quoted 7 lines
wks.flush()- cmd = "wic create %s -e core-image-minimal -o %s" % (
wks.name, self.resultdir)
+ cmd = "wic create %s -e core-image-minimal -o %s
--sector-size 4096" % (wks.name, self.resultdir)
runCmd(cmd)
wksname = os.path.splitext(os.path.basename(wks.name))[0]
Quoted 1 line
Quoted 1 line
images = glob(os.path.join(self.resultdir,
"%s-*direct" %
Quoted 10 lines
Quoted 10 lines
wksname))
meta/lib/oeqa/selftest/cases/wic.py +1
-1@@ -969,24 +958,18 @@ bootloader --ptable gpt""") sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') # list partitions - result = runCmd("wic ls %s -n %s" % (images[0], sysroot)) + result = runCmd("wic ls %s -n %s --sector-size 4096" % (images[0], sysroot)) self.assertEqual(3, len(result.output.split('\n')))Quoted 2 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""") · line 977
Quoted 2 lines
meta/lib/oeqa/selftest/cases/wic.py +0
-2- # verify partition size with wic - res = runCmd("export PARTED_SECTOR_SIZE=%d; parted -m %sunit
Quoted 3 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""") · line 967
Quoted 3 lines
meta/lib/oeqa/selftest/cases/wic.py +2
-0b p" % (wic_sector_size, images[0]), + # verify partition size with parted output + res = runCmd("export PARTED_SECTOR_SIZE=%d; parted -m %sunit
Quoted 7 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""") · line 973
Quoted 7 lines
meta/lib/oeqa/selftest/cases/wic.py +0
-3b p" % (4096, images[0]), stderr=subprocess.PIPE) - # parse parted output which looks like this: - # BYT;\n - #/var/tmp/wic/build/tmpgjzzefdd-202410281021-sda.direct:78569472B:file:4096:4096:gpt::;\n
Quoted 11 lines
Quoted 11 lines
meta/lib/oeqa/selftest/cases/wic.py +0
-4- # 1:139264B:39284735B:39145472B:ext4:rofs-a:;\n - # 2:39284736B:78430207B:39145472B:ext4:primary:;\n disk_info = res.output.splitlines()[1] - # Check sector sizes sector_size_logical = int(disk_info.split(":")[3]) sector_size_physical = int(disk_info.split(":")[4]) - self.assertEqual(wic_sector_size, sector_size_logical,"Logical sector size is not %d." %
wic_sector_size)
- self.assertEqual(wic_sector_size,sector_size_physical,
"Physical sector size is not %d." %wic_sector_size)
+ self.assertEqual(4096,sector_size_logical, "Logicalsector
Quoted 2 lines
Quoted 2 lines
size is not 4096.")
+ self.assertEqual(4096,sector_size_physical, "Physicalsector
Quoted 11 lines
Quoted 11 lines
size is not 4096.")
finally:
os.environ['PATH'] = oldpathscripts/lib/wic/engine.py +0
-0@@ -224,7 +224,7 @@ def wic_list(args, scripts_path):Quoted 2 lines
scripts/lib/wic/engine.py def wic_list(args, scripts_path): · line 227
Quoted 2 lines
scripts/lib/wic/engine.py +0
-1class Disk: - def __init__(self, imagepath, native_sysroot, fstypes=('fat','ext')):
Quoted 1 line
scripts/lib/wic/engine.py def wic_list(args, scripts_path): · line 227
Quoted 1 line
scripts/lib/wic/engine.py +1
-0+ def __init__(self, imagepath, native_sysroot, fstypes=('fat','ext'),
Quoted 26 lines
Quoted 26 lines
sector_size=512):
self.imagepath = imagepath
self.native_sysroot =native_sysroot
self.fstypes = fstypesscripts/lib/wic/engine.py +1
-10@@ -233,16 +233,7 @@ class Disk: self._lsector_size = None self._psector_size = None self._ptable_format = None - - # define sector size - sector_size_str = get_bitbake_var('WIC_SECTOR_SIZE') - if sector_size_str is not None: - try: - self.sector_size = int(sector_size_str) - except ValueError: - self.sector_size = None - else: - self.sector_size = None + self.sector_size = sector_size # find parted # read paths from $PATH environment variable@@ -271,7 +262,7 @@ class Disk: if self._partitions is None: self._partitions = OrderedDict()Quoted 3 lines
scripts/lib/wic/engine.py class Disk:
Quoted 3 lines
scripts/lib/wic/engine.py +1
-1- if self.sector_size is not None: + if self.sector_size: out = exec_cmd("export PARTED_SECTOR_SIZE=%d; %s -sm%s
Quoted 9 lines
scripts/lib/wic/engine.py class Disk: · line 306
Quoted 9 lines
scripts/lib/wic/engine.py +0
-0unit B print" % \ (self.sector_size, self.parted,self.imagepath), True)
else:scripts/lib/wic/engine.py +1
-0@@ -312,11 +303,15 @@ class Disk: raise WicError("Partition %s is not in the image" % pnum) part = self.partitions[pnum] # check if fstype is supported + # NOTE: parted is unable to identify dos-type partitions witha
Quoted 5 lines
scripts/lib/wic/engine.py
Quoted 5 lines
4k sector-size
+ # if the type is empty and a non-default sector size is
used, assume 'fat'scripts/lib/wic/engine.py +2
-0+ # fdisk identifies them without issue + part_fstype = part.fstype if part.fstype or self.sector_size==
Quoted 7 lines
scripts/lib/wic/engine.py class Disk:
Quoted 7 lines
512 else 'fat'
for fstype in self.fstypes:scripts/lib/wic/engine.py +1
-2- if part.fstype.startswith(fstype): + if part_fstype.startswith(fstype): break else: - raise WicError("Not supported fstype:{}".format(part.fstype))
Quoted 1 line
Quoted 1 line
+ raise WicError("Not supported fstype:
{}".format(part_fstype))
Quoted 9 lines
Quoted 9 lines
if pnum not in self._partimages:
tmpf =tempfile.NamedTemporaryFile(prefix="wic-part")dst_fname= tmpf.namescripts/lib/wic/engine.py +0
-0@@ -586,8 +581,9 @@ class Disk: label = part.get("name") label_str = "-n {}".format(label) if labelelse ''
- cmd = "{} {} -C {}
{}".format(self.mkdosfs,
Quoted 2 lines
Quoted 2 lines
label_str, partfname,
-part['size'])
Quoted 1 line
Quoted 1 line
+
sector_str= "-S{}".format(self.sector_size)
Quoted 4 lines
Quoted 4 lines
if self.sector_size else ''
+ cmd = "{} {} {} -C {}
{}".format(self.mkdosfs,label_str,sector_str, partfname, +part['size'])
Quoted 2 lines
Quoted 2 lines
exec_cmd(cmd)
# copy content from the temporarydirectory
Quoted 5 lines
Quoted 5 lines
to the new partition
cmd = "{} -snompi {} {}/*::".format(self.mcopy, partfname, tmpdir)
scripts/lib/wic/engine.py +0
-0@@ -609,14 +605,19 @@ class Disk:Quoted 8 lines
scripts/lib/wic/engine.py class Disk:
Quoted 8 lines
scripts/lib/wic/engine.py +1
-1def wic_ls(args, native_sysroot): """List contents of partitioned image or vfat partition.""" - disk = Disk(args.path.image, native_sysroot) + disk = Disk(args.path.image, native_sysroot, sector_size=args.sector_size) if not args.path.part: if disk.partitions: print('Num Start End SizeFstype')
Quoted 39 lines
Quoted 39 lines
scripts/lib/wic/engine.py +1
-0for part in disk.partitions.values(): + # size values are in bytes from parted; convert tosectors if a custom sector size was requested
scripts/lib/wic/engine.py +2
-0+ display_size = part.size + if args.sector_size and args.sector_size !=disk._lsector_size:
scripts/lib/wic/engine.py +7
-5+ display_size = part.size // args.sector_size print("{:2d} {:12d} {:12d} {:12d} {}".format(\ - part.pnum, part.start, part.end, - part.size, part.fstype)) + part.pnum, part.start // args.sector_size, + part.end // args.sector_size, + display_size, part.fstype)) else: path = args.path.path or '/' print(disk.dir(args.path.part, path))@@ -627,9 +628,9 @@ def wic_cp(args, native_sysroot): partitioned image. """ if isinstance(args.dest, str): - disk = Disk(args.src.image, native_sysroot) + disk = Disk(args.src.image, native_sysroot, sector_size=args.sector_size) else: - disk = Disk(args.dest.image, native_sysroot) + disk = Disk(args.dest.image, native_sysroot, sector_size=args.sector_size) disk.copy(args.src, args.dest)@@ -638,7 +639,7 @@ def wic_rm(args, native_sysroot): Remove files or directories from the vfat partition of partitioned image. """ - disk = Disk(args.path.image, native_sysroot) + disk = Disk(args.path.image, native_sysroot, sector_size=args.sector_size) disk.remove(args.path.part, args.path.path, args.recursive_delete)Quoted 11 lines
Quoted 11 lines
def
wic_write(args, native_sysroot):scripts/lib/wic/help.py +0
-0@@ -118,7 +118,7 @@ wic_create_usage = """ usage: wic create <wks file or image name> [-o <DIRNAME> | --outdir<DIRNAME>]
[-e | --image-name] [-s, --skip-build-check] [-D, --debug] [-r, --rootfs-dir] [-b, --bootimg-dir]- [-k, --kernel-dir] [-n, --native-sysroot] [-f,
--build-rootfs]
Quoted 4 lines
Quoted 4 lines
+ [-k, --kernel-dir] [-n, --native-sysroot] [--sector-size
<bytes>] [-f, --build-rootfs][-c, --compress-with] [-m, --bmap]Quoted 8 lines
scripts/lib/wic/help.py
Quoted 8 lines
This command creates an OpenEmbedded image based on the 'OE kickstart
scripts/lib/wic/help.py +0
-0@@ -139,13 +139,16 @@ SYNOPSIS wic create <wks file or image name> [-o <DIRNAME> | --outdir<DIRNAME>]
[-e | --image-name] [-s, --skip-build-check] [-D, --debug] [-r, --rootfs-dir] [-b, --bootimg-dir]scripts/lib/wic/help.py +1
-1- [-k, --kernel-dir] [-n, --native-sysroot] [-f, --build-rootfs] + [-k, --kernel-dir] [-n, --native-sysroot] [--sector-size<bytes>]
Quoted 21 lines
Quoted 21 lines
[-f, --build-rootfs]
[-c, --compress-with] [-m, --bmap] [--no-fstab-update]DESCRIPTION
This command creates an OpenEmbedded image based on the 'OE kickstart commands' found in the <wks file>.scripts/lib/wic/help.py +4
-1+ Use the --sector-size option to select the sector size (in bytes) + used for partition layout calculations (default is 512). + In order to do this, wic needs to know the locations of the various build artifacts required to build the image.@@ -278,7 +281,7 @@ wic_ls_usage = """ List content of a partitioned image - usage: wic ls <image>[:<partition>[<path>]] [--native-sysroot <path>] + usage: wic ls <image>[:<partition>[<path>]] [--native-sysroot <path>][--sector-size <bytes>]
Quoted 8 lines
scripts/lib/wic/help.py SYNOPSIS · line 299
Quoted 8 lines
This command outputs either list of image partitions or directory
contents
of vfat and ext* partitions.scripts/lib/wic/help.py +0
-1@@ -296,7 +299,7 @@ SYNOPSIS wic ls <image> wic ls <image>:<vfat or ext* partition> wic ls <image>:<vfat or ext* partition><path> - wic ls <image>:<vfat or ext* partition><path> --native-sysroot<path>
Quoted 1 line
scripts/lib/wic/help.py SYNOPSIS · line 302
Quoted 1 line
scripts/lib/wic/help.py +1
-0+ wic ls <image>:<vfat or ext* partition><path> --native-sysroot<path>
Quoted 10 lines
scripts/lib/wic/help.py DESCRIPTION · line 342
Quoted 10 lines
[--sector-size <bytes>]
DESCRIPTION
This command lists either partitions of the image or directory
contentsscripts/lib/wic/help.py +1
-0@@ -336,6 +339,8 @@ DESCRIPTION The -n option is used to specify the path to the native sysroot containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used for partitionmath
Quoted 12 lines
Quoted 12 lines
scripts/lib/wic/help.py +2
-1+ (default is 512 bytes). """@@ -343,7 +348,7 @@ wic_cp_usage = """ Copy files and directories to/from the vfat or ext* partition - usage: wic cp <src> <dest> [--native-sysroot <path>] + usage: wic cp <src> <dest> [--native-sysroot <path>] [--sector-size<bytes>]
Quoted 7 lines
scripts/lib/wic/help.py SYNOPSIS · line 367
Quoted 7 lines
source/destination image in format <image>:<partition>[<path>]
scripts/lib/wic/help.py +0
-1@@ -364,7 +369,7 @@ SYNOPSIS wic cp <src> <dest>:<partition> wic cp <src>:<partition> <dest> wic cp <src> <dest-image>:<partition><path> - wic cp <src> <dest-image>:<partition><path> --native-sysroot<path>
Quoted 1 line
scripts/lib/wic/help.py SYNOPSIS · line 372
Quoted 1 line
scripts/lib/wic/help.py +1
-0+ wic cp <src> <dest-image>:<partition><path> --native-sysroot<path>
Quoted 9 lines
scripts/lib/wic/help.py DESCRIPTION · line 416
Quoted 9 lines
[--sector-size <bytes>]
DESCRIPTION
This command copies files or directories eitherscripts/lib/wic/help.py +1
-0@@ -408,13 +413,15 @@ DESCRIPTION The -n option is used to specify the path to the native sysroot containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used for partitionmath
Quoted 11 lines
Quoted 11 lines
scripts/lib/wic/help.py +2
-1+ (default is 512 bytes). """ wic_rm_usage = """ Remove files or directories from the vfat or ext* partitions - usage: wic rm <image>:<partition><path> [--native-sysroot <path>] + usage: wic rm <image>:<partition><path> [--native-sysroot <path>][--sector-size <bytes>]
Quoted 8 lines
scripts/lib/wic/help.py DESCRIPTION · line 476
Quoted 8 lines
This command removes files or directories from the vfat or ext*
partitions of
the partitioned image.scripts/lib/wic/help.py +1
-0@@ -466,6 +473,8 @@ DESCRIPTION The -n option is used to specify the path to the native sysroot containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used for partitionmath
Quoted 5 lines
Review
Quoted 5 lines
scripts/lib/wic/help.py +1
-0+ (default is 512 bytes). The -r option is used to remove directories and their contents recursively,this only applies to ext* partition.(quoted diff) +0
-0
b/scripts/lib/wic/partition.pyQuoted 29 lines
Quoted 29 lines
index
8fed686e903e..df6e3271649b100644scripts/lib/wic/partition.py +5
-0@@ -65,6 +65,50 @@ class Partition(): self.lineno = lineno self.source_file = "" + self.sector_size = 512 + + def _mkdosfs_extraopts(self): + """ + Build mkdosfs extra options ensuring the CLI sector size isapplied.
scripts/lib/wic/partition.py +16
-0+ """ + extraopts = self.mkfs_extraopts or '' + tokens = [] + skip_next = False + for tok in extraopts.split(): + if skip_next: + skip_next = False + continue + if tok == '-S': + skip_next = True + continue + if tok.startswith('-S'): + continue + tokens.append(tok) + tokens.extend(['-S', str(self.sector_size)]) + return ' '.join(tokens).strip()Quoted 8 lines
scripts/lib/wic/partition.py class Partition():
Quoted 8 lines
scripts/lib/wic/partition.py +4
-0+ + def _mkfs_ext_extraopts(self, base_opts): + """ + Build mkfs.ext* extra options ensuring the CLI sector size isapplied.
scripts/lib/wic/partition.py +3
-0+ """ + extraopts = self.mkfs_extraopts or base_opts + # Only add an explicit block size when a non-default sectorsize
Quoted 18 lines
Quoted 18 lines
is requested.
scripts/lib/wic/partition.py +16
-0+ if self.sector_size and self.sector_size != 512: + tokens = [] + skip_next = False + for tok in extraopts.split(): + if skip_next: + skip_next = False + continue + if tok == '-b': + skip_next = True + continue + if tok.startswith('-b'): + continue + tokens.append(tok) + tokens.extend(['-b', str(self.sector_size)]) + return ' '.join(tokens).strip() + return extraoptsQuoted 11 lines
Quoted 11 lines
def
get_extra_block_count(self, current_blocks):
"""scripts/lib/wic/partition.py +1
-0@@ -138,6 +182,8 @@ class Partition(): Prepare content for individual partitions, depending on partition command parameters. """ + # capture the sector size requested on the CLI for mkdosfsinvocations
+ self.sector_size =getattr(creator, 'sector_size', 512)or 512
self.updated_fstab_path =updated_fstab_pathif self.updated_fstab_path and not(
self.fstype.startswith("ext")Quoted 11 lines
scripts/lib/wic/partition.py class Partition(): · line 345
Quoted 11 lines
or self.fstype == "msdos"):
self.update_fstab_in_rootfs = Truescripts/lib/wic/partition.py +1
-1@@ -293,7 +339,7 @@ class Partition(): with open(rootfs, 'w') as sparse: os.ftruncate(sparse.fileno(), rootfs_size * 1024) - extraopts = self.mkfs_extraopts or "-F -i 8192" + extraopts = self._mkfs_ext_extraopts("-F -i 8192") # use hash_seed to generate reproducible ext4 images (extraopts, pseudo) = self.get_hash_seed_ext4(extraopts,pseudo)
Quoted 9 lines
scripts/lib/wic/partition.py class Partition(): · line 453
Quoted 9 lines
scripts/lib/wic/partition.py +1
-1@@ -401,7 +447,7 @@ class Partition(): size_str = "" - extraopts = self.mkfs_extraopts or '-S 512' + extraopts = self._mkdosfs_extraopts() dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \ (label_str, self.fsuuid, size_str, extraopts,rootfs,
Quoted 11 lines
Quoted 11 lines
scripts/lib/wic/partition.py +1
-1@@ -452,7 +498,7 @@ class Partition(): with open(rootfs, 'w') as sparse: os.ftruncate(sparse.fileno(), size * 1024) - extraopts = self.mkfs_extraopts or "-i 8192" + extraopts = self._mkfs_ext_extraopts("-i 8192") # use hash_seed to generate reproducible ext4 images (extraopts, pseudo) = self.get_hash_seed_ext4(extraopts, None)@@ -498,7 +544,7 @@ class Partition():Quoted 7 lines
scripts/lib/wic/partition.py class Partition():
Quoted 7 lines
scripts/lib/wic/partition.py +1
-1size_str = "" - extraopts = self.mkfs_extraopts or '-S 512' + extraopts = self._mkdosfs_extraopts() dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \ (label_str, self.fsuuid, extraopts, size_str,rootfs,
Quoted 2 lines
scripts/lib/wic/partition.py class Partition(): · line 605
Quoted 2 lines
scripts/lib/wic/partition.py +0
-0@@ -559,4 +605,3 @@ class Partition(): logger.warn("%s Inodes (of size %d) are toosmall." %
Quoted 14 lines
Quoted 14 lines
scripts/lib/wic/partition.py +0
-1(get_err_str(self), size)) break -scripts/lib/wic/plugins/imager/direct.py +1
-0@@ -67,6 +67,7 @@ class DirectPlugin(ImagerPlugin): self._image = None self.ptable_format = self.ks.bootloader.ptable self.parts = self.ks.partitions + self.sector_size = options.sector_size or 512Quoted 8 lines
scripts/lib/wic/plugins/imager/direct.py class DirectPlugin(ImagerPlugin): · line 83
Quoted 8 lines
scripts/lib/wic/plugins/imager/direct.py +0
-0# as a convenience, set source to the boot partition source # instead of forcing it to be set via bootloader --source@@ -78,7 +79,7 @@ class DirectPlugin(ImagerPlugin): image_path = self._full_path(self.workdir, self.parts[0].disk, "direct") self._image = PartitionedImage(image_path, self.ptable_format, self.ks.bootloader.diskid, self.parts,self.native_sysroot,
Quoted 18 lines
Quoted 18 lines
scripts/lib/wic/plugins/imager/direct.py +1
-1- options.extra_space) + options.extra_space, self.sector_size)def
setup_workdir(self, workdir):
if workdir:scripts/lib/wic/plugins/imager/direct.py +0
-3@@ -294,15 +295,13 @@ MBR_OVERHEAD = 1 # Overhead of the GPT partitioning scheme GPT_OVERHEAD = 34 -# Size of a sector in bytes -SECTOR_SIZE = 512 - class PartitionedImage(): """ Partitioned image in a file. """Quoted 8 lines
Quoted 8 lines
scripts/lib/wic/plugins/imager/direct.py +0
-1- def __init__(self, path, ptable_format, disk_id, partitions,native_sysroot=None, extra_space=0):
+ def __init__(self, path,ptable_format,disk_id, partitions,
native_sysroot=None, extra_space=0,
+ sector_size=512):
self.path = path # Path to the image file self.numpart = 0 # Number of allocated partitions self.realpart = 0 # Number of partitions in the partitiontable
Quoted 34 lines
Quoted 34 lines
scripts/lib/wic/plugins/imager/direct.py +1
-8@@ -332,14 +331,7 @@ class PartitionedImage(): self.partitions = partitions self.partimages = [] # Size of a sector used in calculations - sector_size_str = get_bitbake_var('WIC_SECTOR_SIZE') - if sector_size_str is not None: - try: - self.sector_size = int(sector_size_str) - except ValueError: - self.sector_size = SECTOR_SIZE - else: - self.sector_size = SECTOR_SIZE + self.sector_size = sector_size or 512 self.native_sysroot = native_sysroot num_real_partitions = len([p for p in self.partitions if notp.no_table])
scripts/lib/wic/plugins/source/bootimg_efi.py +3
-2@@ -415,8 +415,9 @@ class BootimgEFIPlugin(SourcePlugin): label = part.label if part.label else "ESP" - dosfs_cmd = "mkdosfs -v -n %s -i %s -C %s %d" % \ - (label, part.fsuuid, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or 512 + dosfs_cmd = "mkdosfs -v -n %s -i %s -S %d -C %s %d" % \ + (label, part.fsuuid, sector_size, bootimg, blocks) exec_native_cmd(dosfs_cmd, native_sysroot) logger.debug("mkdosfs:\n%s" % (str(out)))Quoted 8 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin): · line 133
Quoted 8 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-0@@ -132,7 +132,7 @@ class BootimgPcbiosPlugin(SourcePlugin): cls._do_prepare_grub(part, cr_workdir, oe_builddir, kernel_dir, rootfs_dir,
native_sysroot)Quoted 2 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin): · line 135
Quoted 2 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-1elif source_params['loader-bios'] == 'syslinux': - cls._do_prepare_syslinux(part, cr_workdir,
bootimg_dir,Quoted 5 lines
Quoted 5 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +1
-0+ cls._do_prepare_syslinux(part, creator, cr_workdir, bootimg_dir, kernel_dir, native_sysroot) else:raise WicError("unrecognized
bootimg_pcbiosloader:%s" %
Quoted 10 lines
Quoted 10 lines
source_params['loader-bios'])
scripts/lib/wic/plugins/source/bootimg_pcbios.py +1
-1@@ -142,7 +142,7 @@ class BootimgPcbiosPlugin(SourcePlugin): except KeyError: # Required by do_install_disk cls.loader = 'syslinux' - cls._do_prepare_syslinux(part, cr_workdir, bootimg_dir, + cls._do_prepare_syslinux(part, creator, cr_workdir, bootimg_dir, kernel_dir, native_sysroot)Quoted 7 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin): · line 243
Quoted 7 lines
@classmethod
scripts/lib/wic/plugins/source/bootimg_pcbios.py +1
-1@@ -240,7 +240,7 @@ class BootimgPcbiosPlugin(SourcePlugin): cfg.close() @classmethod - def _do_prepare_syslinux(cls, part, cr_workdir, bootimg_dir, + def _do_prepare_syslinux(cls, part, creator, cr_workdir,
bootimg_dir,Quoted 3 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin):
Quoted 3 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-0kernel_dir, native_sysroot): """ Called to do the actual content population for a partitioni.e. it
Quoted 28 lines
Quoted 28 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +3
-2@@ -292,8 +292,9 @@ class BootimgPcbiosPlugin(SourcePlugin): label = part.label if part.label else "boot" - dosfs_cmd = "mkdosfs -n %s -i %s -S 512 -C %s %d" % \ - (label, part.fsuuid, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or 512 + dosfs_cmd = "mkdosfs -n %s -i %s -S %d -C %s %d" % \ + (label, part.fsuuid, sector_size, bootimg, blocks) exec_native_cmd(dosfs_cmd, native_sysroot) mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir)scripts/lib/wic/plugins/source/isoimage_isohybrid.py +3
-2@@ -367,8 +367,9 @@ class IsoImagePlugin(SourcePlugin): esp_label = source_params.get('esp_label', 'EFIimg') - dosfs_cmd = 'mkfs.vfat -n \'%s\' -S 512 -C %s %d' \ - % (esp_label, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or 512 + dosfs_cmd = "mkfs.vfat -n '%s' -S %d -C %s %d" % \ + (esp_label, sector_size, bootimg, blocks) exec_native_cmd(dosfs_cmd, native_sysroot)Quoted 8 lines
scripts/wic def wic_init_parser_create(subparser): · line 377
Quoted 8 lines
scripts/lib/wic/plugins/source/isoimage_isohybrid.py +0
-0mmd_cmd = "mmd -i %s ::/EFI" % bootimgscripts/wic +0
-0@@ -376,6 +376,8 @@ def wic_init_parser_create(subparser): default="direct", help="the wic imager plugin") subparser.add_argument("--extra-space", type=int,dest="extra_space",
Quoted 1 line
scripts/wic def wic_init_parser_create(subparser): · line 378
Quoted 1 line
scripts/wic +0
-0default=0, help="additional free disk space toadd
Quoted 2 lines
scripts/wic def wic_init_parser_create(subparser): · line 380
Quoted 2 lines
scripts/wic +1
-0to the image") + subparser.add_argument("--sector-size", dest="sector_size",type=int,
Quoted 11 lines
scripts/wic def imgtype(arg): · line 419
Quoted 11 lines
scripts/wic +2
-0default=512, + help="sector size in bytes (default: 512)") return@@ -413,6 +415,8 @@ def imgtype(arg): def wic_init_parser_ls(subparser): subparser.add_argument("path", type=imgtype, help="image spec: <image>[:<vfat partition>[<path>]]") + subparser.add_argument("--sector-size", dest="sector_size",type=int,
Quoted 4 lines
Quoted 4 lines
scripts/wic +1
-0default=512, + help="sector size in bytes (default: 512)") subparser.add_argument("-n", "--native-sysroot",help="path to the native sysroot containing
the
Quoted 9 lines
scripts/wic def wic_init_parser_cp(subparser): · line 442
Quoted 9 lines
tools")
subparser.add_argument("-e", "--image-name", dest="image_name",scripts/wic +1
-0@@ -433,6 +437,8 @@ def wic_init_parser_cp(subparser): help="image spec: <image>:<vfat partition>[<path>] or <file>") subparser.add_argument("dest", help="image spec: <image>:<vfat partition>[<path>] or <file>") + subparser.add_argument("--sector-size", dest="sector_size",type=int,
Quoted 4 lines
Quoted 4 lines
scripts/wic +1
-0default=512, + help="sector size in bytes (default: 512)")subparser.add_argument("-n", "--native-sysroot",
help="path to the native sysroot containingthe
Quoted 7 lines
scripts/wic def wic_init_parser_cp(subparser): · line 454
Quoted 7 lines
tools")
subparser.add_argument("-e", "--image-name", dest="image_name",scripts/wic +1
-0@@ -445,6 +451,8 @@ def wic_init_parser_cp(subparser): def wic_init_parser_rm(subparser): subparser.add_argument("path", type=imgpathtype, help="path: <image>:<vfat partition><path>") + subparser.add_argument("--sector-size", dest="sector_size",type=int,
Quoted 4 lines
scripts/wic def imgtype(arg):
Quoted 4 lines
scripts/wic +1
-0default=512, + help="sector size in bytes (default: 512)") subparser.add_argument("-n", "--native-sysroot", help="path to the native sysroot containingthe
Quoted 7 lines
Quoted 7 lines
tools")
subparser.add_argument("-r", dest="recursive_delete",
action="store_true", default=False,
--
2.51.0Quoted 7 lines
Quoted 7 lines
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#231176):
https://lists.openembedded.org/g/openembedded-core/message/231176
Mute This Topic: https://lists.openembedded.org/mt/117833550/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub[
Quoted 7 lines
Quoted 4 lines
[email protected]]
-=-=-=-=-=-=-=-=-=-=-=---
- Thou shalt not follow the NULL pointer, for chaos and madness awaitthee
Quoted 2 lines
at its end
- "Use the force Harry" - Gandalf, Star Trek II
Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end - "Use the force Harry" - Gandalf, Star Trek II
Quoted 76 lines · Bruce Ashfield
Quoted 68 lines · Trevor Woerner
Quoted 1 line · Bruce Ashfield
On Sun, Feb 15, 2026 at 9:32 PM Trevor Woerner via
lists.openembedded.org
Quoted 10 lines
Quoted 8 lines · <[email protected]> wrote:
The previous implementation to add variable sector-size support:
- required the variableWIC_SECTOR_SIZEeither be defined in a configuration file or be defined in a --vars file
- this means that every invocation of "wic ls", "wic cp", or "wic rm" needed this variable defined (config or --vars)
- required the user to create separate *wks files for every sector size they wanted to use
- required the user to specify the mkfs-extraopts by hand to specifythe
Quoted 3 lines
Quoted 3 lines
correct sector size: e.g. bootloader --ptable gpt part --fstype ext4 --source rootfs --label rofs-a--mkfs-extraopts
Quoted 2 lines
Quoted 2 lines
"-b 4096"
part --fstype ext4 --source rootfs --use-uuid --mkfs-extraopts"-b
Quoted 20 lines
Quoted 9 lines
4096"
- specifying --mkfs-extraopts replaces the defaults with the user-supplied values
- only provided details to support using variable sector-sizes with ext[234] filesystems
- it would not be possible to generate images with different sector sizes in the same build since the configuration and *wks files would need to change and the build re-run for each sizeQuoted 10 lines
Update the sector-size handling so that:
- the sector-size will now be provided on the cmdline to the "wic ls", "wic cp", "wic rm", and "wic create" commands: default = 512
- this means the configuration and/or --vars file does not need to be changed in order to perform those operations on images with different sector sizes
- support is provided implicitly for mkdosfs and ext[234] partitions
- the user no longer needs to know and supply the sector-size magic in --mkfs-extraopts (thereby clobbering the other defaults)Quoted 2 lines
It wasn't clear to me when scanning the patch. For configuration files with a sector size, is it now completely ignored ?
Yes.
While trying to use the existing implementation in actual production workflows we found a number of shortcomings that are addressed with this update. Additionally, the ultimate goal is to make wic an independent utility from oe-core so it can be easily used by external tools post-build.
If sector-size is not available on the cmdline, then a --vars file would be needed for every simple wic invocation such as "wic cp", "wic ls", and "wic rm"... which would be silly. Take a look at the patch I submitted a week or so ago to see how the oe-selftests would have to be updated to support this.
If sector-size is available both on the cmdline and in a --vars file then which one wins? Ultimately having it specified in both places is only going to lead to confusion as people will be changing it in one place and not realizing it's also defined (and taking precedence) from somewhere else. I believe this is currently the case with --native-sysroot, which probably needs fixing as well since several oe-selftests are trying to use it, but I doubt it is working the way the test writers expect.
Quoted 5 lines
One parameter specified in one place so a user would not need multiple sets of configuration files to perform a simple "wic ls" of images with different sector sizes; simply specify it on the cmdline if you want something other than 512.
Quoted 7 lines
That's not a good migration path. You can't simply throw away someone's existing configuration and ask them to update to a new one. I didn't even see an error thrown with migration instructions.
There's many different users of things like this, we can't simply change the interface without some way to migrate.
I don't disagree with you entirely.
But if the user specifies --sector-size <N> on the cmdline, they will expect the sector-size to be N. If they don't specify this on the cmdline, they would rightfully expect the default of 512 to be used...
...unless some configuration file anywhere in their build specifies WIC_SECTOR_SIZE, in which case wic is supposed to use that value?
I could print a warning if sector size is set via WIC_SECTOR_SIZE?
Quoted 759 lines
Bruce
Quoted 748 lines
Quoted 54 lines
Apologies if I missed where existing configs were used to prime the parameters to the functions.
Bruce
Quoted 46 lines
AI-Generated: codex/gpt-5.1-codex-max
Signed-off-by Trevor Woerner <[email protected]>---
changes since v2:
- nonechanges since v1:
- none--- meta/lib/oeqa/selftest/cases/wic.py | 39 ++++--------- scripts/lib/wic/engine.py | 45 +++++++-------- scripts/lib/wic/help.py | 23 +++++--- scripts/lib/wic/partition.py | 55 +++++++++++++++++-- scripts/lib/wic/plugins/imager/direct.py | 18 ++---- scripts/lib/wic/plugins/source/bootimg_efi.py | 5 +- .../lib/wic/plugins/source/bootimg_pcbios.py | 11 ++-- .../wic/plugins/source/isoimage_isohybrid.py | 5 +- scripts/wic | 8 +++ 9 files changed, 125 insertions(+), 84 deletions(-)meta/lib/oeqa/selftest/cases/wic.py +3
-7@@ -935,33 +935,22 @@ bootloader --ptable gpt""") finally: os.remove(wks_file) - def test_wic_sector_size(self): - """Test generation image sector size""" - + def test_wic_sector_size_cli(self): + """Test sector size handling via CLI option.""" + oldpath = os.environ['PATH'] os.environ['PATH'] = get_bb_var("PATH", "wic-tools") try: - # Add WIC_SECTOR_SIZE into config - config = 'WIC_SECTOR_SIZE = "4096"\n'\ - 'WICVARS:append = " WIC_SECTOR_SIZE"\n' - self.append_config(config) bitbake('core-image-minimal')Quoted 13 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""")
Quoted 13 lines
meta/lib/oeqa/selftest/cases/wic.py +0
-8- # Check WIC_SECTOR_SIZE apply to bitbake variable - wic_sector_size_str = get_bb_var('WIC_SECTOR_SIZE', 'core-image-minimal') - wic_sector_size = int(wic_sector_size_str) - self.assertEqual(4096, wic_sector_size) - - self.logger.info("Test wic_sector_size: %d \n" % wic_sector_size) - with NamedTemporaryFile("w", suffix=".wks") as wks: wks.writelines( ['bootloader --ptable gpt\n', - 'part --fstype ext4 --source rootfs --labelrofs-a
Quoted 6 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""") · line 954
Quoted 6 lines
meta/lib/oeqa/selftest/cases/wic.py +2
-3--mkfs-extraopts "-b 4096"\n', - 'part --fstype ext4 --source rootfs --use-uuid --mkfs-extraopts "-b 4096"\n']) + 'part --fstype ext4 --source rootfs --label rofs-a\n', + 'part --fstype ext4 --source rootfs--use-uuid\n'])
Quoted 7 lines
Quoted 7 lines
wks.flush()- cmd = "wic create %s -e core-image-minimal -o %s" % (
wks.name, self.resultdir)
+ cmd = "wic create %s -e core-image-minimal -o %s
--sector-size 4096" % (wks.name, self.resultdir)
runCmd(cmd)
wksname = os.path.splitext(os.path.basename(wks.name))[0]
Quoted 1 line
Quoted 1 line
images = glob(os.path.join(self.resultdir,
"%s-*direct" %
Quoted 10 lines
Quoted 10 lines
wksname))
meta/lib/oeqa/selftest/cases/wic.py +1
-1@@ -969,24 +958,18 @@ bootloader --ptable gpt""") sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') # list partitions - result = runCmd("wic ls %s -n %s" % (images[0], sysroot)) + result = runCmd("wic ls %s -n %s --sector-size 4096" % (images[0], sysroot)) self.assertEqual(3, len(result.output.split('\n')))Quoted 2 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""") · line 977
Quoted 2 lines
meta/lib/oeqa/selftest/cases/wic.py +0
-2- # verify partition size with wic - res = runCmd("export PARTED_SECTOR_SIZE=%d; parted -m %sunit
Quoted 3 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""") · line 967
Quoted 3 lines
meta/lib/oeqa/selftest/cases/wic.py +2
-0b p" % (wic_sector_size, images[0]), + # verify partition size with parted output + res = runCmd("export PARTED_SECTOR_SIZE=%d; parted -m %sunit
Quoted 7 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""") · line 973
Quoted 7 lines
meta/lib/oeqa/selftest/cases/wic.py +0
-3b p" % (4096, images[0]), stderr=subprocess.PIPE) - # parse parted output which looks like this: - # BYT;\n - #/var/tmp/wic/build/tmpgjzzefdd-202410281021-sda.direct:78569472B:file:4096:4096:gpt::;\n
Quoted 11 lines
Quoted 11 lines
meta/lib/oeqa/selftest/cases/wic.py +0
-4- # 1:139264B:39284735B:39145472B:ext4:rofs-a:;\n - # 2:39284736B:78430207B:39145472B:ext4:primary:;\n disk_info = res.output.splitlines()[1] - # Check sector sizes sector_size_logical = int(disk_info.split(":")[3]) sector_size_physical = int(disk_info.split(":")[4]) - self.assertEqual(wic_sector_size, sector_size_logical,"Logical sector size is not %d." %
wic_sector_size)
- self.assertEqual(wic_sector_size,sector_size_physical,
"Physical sector size is not %d." %wic_sector_size)
+ self.assertEqual(4096,sector_size_logical, "Logicalsector
Quoted 2 lines
Quoted 2 lines
size is not 4096.")
+ self.assertEqual(4096,sector_size_physical, "Physicalsector
Quoted 11 lines
Quoted 11 lines
size is not 4096.")
finally:
os.environ['PATH'] = oldpathscripts/lib/wic/engine.py +0
-0@@ -224,7 +224,7 @@ def wic_list(args, scripts_path):Quoted 2 lines
scripts/lib/wic/engine.py def wic_list(args, scripts_path): · line 227
Quoted 2 lines
scripts/lib/wic/engine.py +0
-1class Disk: - def __init__(self, imagepath, native_sysroot, fstypes=('fat','ext')):
Quoted 1 line
scripts/lib/wic/engine.py def wic_list(args, scripts_path): · line 227
Quoted 1 line
scripts/lib/wic/engine.py +1
-0+ def __init__(self, imagepath, native_sysroot, fstypes=('fat','ext'),
Quoted 26 lines
Quoted 26 lines
sector_size=512):
self.imagepath = imagepath
self.native_sysroot =native_sysroot
self.fstypes = fstypesscripts/lib/wic/engine.py +1
-10@@ -233,16 +233,7 @@ class Disk: self._lsector_size = None self._psector_size = None self._ptable_format = None - - # define sector size - sector_size_str = get_bitbake_var('WIC_SECTOR_SIZE') - if sector_size_str is not None: - try: - self.sector_size = int(sector_size_str) - except ValueError: - self.sector_size = None - else: - self.sector_size = None + self.sector_size = sector_size # find parted # read paths from $PATH environment variable@@ -271,7 +262,7 @@ class Disk: if self._partitions is None: self._partitions = OrderedDict()Quoted 3 lines
scripts/lib/wic/engine.py class Disk:
Quoted 3 lines
scripts/lib/wic/engine.py +1
-1- if self.sector_size is not None: + if self.sector_size: out = exec_cmd("export PARTED_SECTOR_SIZE=%d; %s -sm%s
Quoted 9 lines
scripts/lib/wic/engine.py class Disk: · line 306
Quoted 9 lines
scripts/lib/wic/engine.py +0
-0unit B print" % \ (self.sector_size, self.parted,self.imagepath), True)
else:scripts/lib/wic/engine.py +1
-0@@ -312,11 +303,15 @@ class Disk: raise WicError("Partition %s is not in the image" % pnum) part = self.partitions[pnum] # check if fstype is supported + # NOTE: parted is unable to identify dos-type partitions witha
Quoted 5 lines
scripts/lib/wic/engine.py
Quoted 5 lines
4k sector-size
+ # if the type is empty and a non-default sector size is
used, assume 'fat'scripts/lib/wic/engine.py +2
-0+ # fdisk identifies them without issue + part_fstype = part.fstype if part.fstype or self.sector_size==
Quoted 7 lines
scripts/lib/wic/engine.py class Disk:
Quoted 7 lines
512 else 'fat'
for fstype in self.fstypes:scripts/lib/wic/engine.py +1
-2- if part.fstype.startswith(fstype): + if part_fstype.startswith(fstype): break else: - raise WicError("Not supported fstype:{}".format(part.fstype))
Quoted 1 line
Quoted 1 line
+ raise WicError("Not supported fstype:
{}".format(part_fstype))
Quoted 9 lines
Quoted 9 lines
if pnum not in self._partimages:
tmpf =tempfile.NamedTemporaryFile(prefix="wic-part")dst_fname= tmpf.namescripts/lib/wic/engine.py +0
-0@@ -586,8 +581,9 @@ class Disk: label = part.get("name") label_str = "-n {}".format(label) if labelelse ''
- cmd = "{} {} -C {}
{}".format(self.mkdosfs,
Quoted 2 lines
Quoted 2 lines
label_str, partfname,
-part['size'])
Quoted 1 line
Quoted 1 line
+
sector_str= "-S{}".format(self.sector_size)
Quoted 4 lines
Quoted 4 lines
if self.sector_size else ''
+ cmd = "{} {} {} -C {}
{}".format(self.mkdosfs,label_str,sector_str, partfname, +part['size'])
Quoted 2 lines
Quoted 2 lines
exec_cmd(cmd)
# copy content from the temporarydirectory
Quoted 5 lines
Quoted 5 lines
to the new partition
cmd = "{} -snompi {} {}/*::".format(self.mcopy, partfname, tmpdir)
scripts/lib/wic/engine.py +0
-0@@ -609,14 +605,19 @@ class Disk:Quoted 8 lines
scripts/lib/wic/engine.py class Disk:
Quoted 8 lines
scripts/lib/wic/engine.py +1
-1def wic_ls(args, native_sysroot): """List contents of partitioned image or vfat partition.""" - disk = Disk(args.path.image, native_sysroot) + disk = Disk(args.path.image, native_sysroot, sector_size=args.sector_size) if not args.path.part: if disk.partitions: print('Num Start End SizeFstype')
Quoted 39 lines
Quoted 39 lines
scripts/lib/wic/engine.py +1
-0for part in disk.partitions.values(): + # size values are in bytes from parted; convert tosectors if a custom sector size was requested
scripts/lib/wic/engine.py +2
-0+ display_size = part.size + if args.sector_size and args.sector_size !=disk._lsector_size:
scripts/lib/wic/engine.py +7
-5+ display_size = part.size // args.sector_size print("{:2d} {:12d} {:12d} {:12d} {}".format(\ - part.pnum, part.start, part.end, - part.size, part.fstype)) + part.pnum, part.start // args.sector_size, + part.end // args.sector_size, + display_size, part.fstype)) else: path = args.path.path or '/' print(disk.dir(args.path.part, path))@@ -627,9 +628,9 @@ def wic_cp(args, native_sysroot): partitioned image. """ if isinstance(args.dest, str): - disk = Disk(args.src.image, native_sysroot) + disk = Disk(args.src.image, native_sysroot, sector_size=args.sector_size) else: - disk = Disk(args.dest.image, native_sysroot) + disk = Disk(args.dest.image, native_sysroot, sector_size=args.sector_size) disk.copy(args.src, args.dest)@@ -638,7 +639,7 @@ def wic_rm(args, native_sysroot): Remove files or directories from the vfat partition of partitioned image. """ - disk = Disk(args.path.image, native_sysroot) + disk = Disk(args.path.image, native_sysroot, sector_size=args.sector_size) disk.remove(args.path.part, args.path.path, args.recursive_delete)Quoted 11 lines
Quoted 11 lines
def
wic_write(args, native_sysroot):scripts/lib/wic/help.py +0
-0@@ -118,7 +118,7 @@ wic_create_usage = """ usage: wic create <wks file or image name> [-o <DIRNAME> | --outdir<DIRNAME>]
[-e | --image-name] [-s, --skip-build-check] [-D, --debug] [-r, --rootfs-dir] [-b, --bootimg-dir]- [-k, --kernel-dir] [-n, --native-sysroot] [-f,
--build-rootfs]
Quoted 4 lines
Quoted 4 lines
+ [-k, --kernel-dir] [-n, --native-sysroot] [--sector-size
<bytes>] [-f, --build-rootfs][-c, --compress-with] [-m, --bmap]Quoted 8 lines
scripts/lib/wic/help.py
Quoted 8 lines
This command creates an OpenEmbedded image based on the 'OE kickstart
scripts/lib/wic/help.py +0
-0@@ -139,13 +139,16 @@ SYNOPSIS wic create <wks file or image name> [-o <DIRNAME> | --outdir<DIRNAME>]
[-e | --image-name] [-s, --skip-build-check] [-D, --debug] [-r, --rootfs-dir] [-b, --bootimg-dir]scripts/lib/wic/help.py +1
-1- [-k, --kernel-dir] [-n, --native-sysroot] [-f, --build-rootfs] + [-k, --kernel-dir] [-n, --native-sysroot] [--sector-size<bytes>]
Quoted 21 lines
Quoted 21 lines
[-f, --build-rootfs]
[-c, --compress-with] [-m, --bmap] [--no-fstab-update]DESCRIPTION
This command creates an OpenEmbedded image based on the 'OE kickstart commands' found in the <wks file>.scripts/lib/wic/help.py +4
-1+ Use the --sector-size option to select the sector size (in bytes) + used for partition layout calculations (default is 512). + In order to do this, wic needs to know the locations of the various build artifacts required to build the image.@@ -278,7 +281,7 @@ wic_ls_usage = """ List content of a partitioned image - usage: wic ls <image>[:<partition>[<path>]] [--native-sysroot <path>] + usage: wic ls <image>[:<partition>[<path>]] [--native-sysroot <path>][--sector-size <bytes>]
Quoted 8 lines
scripts/lib/wic/help.py SYNOPSIS · line 299
Quoted 8 lines
This command outputs either list of image partitions or directory
contents
of vfat and ext* partitions.scripts/lib/wic/help.py +0
-1@@ -296,7 +299,7 @@ SYNOPSIS wic ls <image> wic ls <image>:<vfat or ext* partition> wic ls <image>:<vfat or ext* partition><path> - wic ls <image>:<vfat or ext* partition><path> --native-sysroot<path>
Quoted 1 line
scripts/lib/wic/help.py SYNOPSIS · line 302
Quoted 1 line
scripts/lib/wic/help.py +1
-0+ wic ls <image>:<vfat or ext* partition><path> --native-sysroot<path>
Quoted 10 lines
scripts/lib/wic/help.py DESCRIPTION · line 342
Quoted 10 lines
[--sector-size <bytes>]
DESCRIPTION
This command lists either partitions of the image or directory
contentsscripts/lib/wic/help.py +1
-0@@ -336,6 +339,8 @@ DESCRIPTION The -n option is used to specify the path to the native sysroot containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used for partitionmath
Quoted 12 lines
Quoted 12 lines
scripts/lib/wic/help.py +2
-1+ (default is 512 bytes). """@@ -343,7 +348,7 @@ wic_cp_usage = """ Copy files and directories to/from the vfat or ext* partition - usage: wic cp <src> <dest> [--native-sysroot <path>] + usage: wic cp <src> <dest> [--native-sysroot <path>] [--sector-size<bytes>]
Quoted 7 lines
scripts/lib/wic/help.py SYNOPSIS · line 367
Quoted 7 lines
source/destination image in format <image>:<partition>[<path>]
scripts/lib/wic/help.py +0
-1@@ -364,7 +369,7 @@ SYNOPSIS wic cp <src> <dest>:<partition> wic cp <src>:<partition> <dest> wic cp <src> <dest-image>:<partition><path> - wic cp <src> <dest-image>:<partition><path> --native-sysroot<path>
Quoted 1 line
scripts/lib/wic/help.py SYNOPSIS · line 372
Quoted 1 line
scripts/lib/wic/help.py +1
-0+ wic cp <src> <dest-image>:<partition><path> --native-sysroot<path>
Quoted 9 lines
scripts/lib/wic/help.py DESCRIPTION · line 416
Quoted 9 lines
[--sector-size <bytes>]
DESCRIPTION
This command copies files or directories eitherscripts/lib/wic/help.py +1
-0@@ -408,13 +413,15 @@ DESCRIPTION The -n option is used to specify the path to the native sysroot containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used for partitionmath
Quoted 11 lines
Quoted 11 lines
scripts/lib/wic/help.py +2
-1+ (default is 512 bytes). """ wic_rm_usage = """ Remove files or directories from the vfat or ext* partitions - usage: wic rm <image>:<partition><path> [--native-sysroot <path>] + usage: wic rm <image>:<partition><path> [--native-sysroot <path>][--sector-size <bytes>]
Quoted 8 lines
scripts/lib/wic/help.py DESCRIPTION · line 476
Quoted 8 lines
This command removes files or directories from the vfat or ext*
partitions of
the partitioned image.scripts/lib/wic/help.py +1
-0@@ -466,6 +473,8 @@ DESCRIPTION The -n option is used to specify the path to the native sysroot containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used for partitionmath
Quoted 5 lines
Review
Quoted 5 lines
scripts/lib/wic/help.py +1
-0+ (default is 512 bytes). The -r option is used to remove directories and their contents recursively,this only applies to ext* partition.(quoted diff) +0
-0
b/scripts/lib/wic/partition.pyQuoted 29 lines
Quoted 29 lines
index
8fed686e903e..df6e3271649b100644scripts/lib/wic/partition.py +5
-0@@ -65,6 +65,50 @@ class Partition(): self.lineno = lineno self.source_file = "" + self.sector_size = 512 + + def _mkdosfs_extraopts(self): + """ + Build mkdosfs extra options ensuring the CLI sector size isapplied.
scripts/lib/wic/partition.py +16
-0+ """ + extraopts = self.mkfs_extraopts or '' + tokens = [] + skip_next = False + for tok in extraopts.split(): + if skip_next: + skip_next = False + continue + if tok == '-S': + skip_next = True + continue + if tok.startswith('-S'): + continue + tokens.append(tok) + tokens.extend(['-S', str(self.sector_size)]) + return ' '.join(tokens).strip()Quoted 8 lines
scripts/lib/wic/partition.py class Partition():
Quoted 8 lines
scripts/lib/wic/partition.py +4
-0+ + def _mkfs_ext_extraopts(self, base_opts): + """ + Build mkfs.ext* extra options ensuring the CLI sector size isapplied.
scripts/lib/wic/partition.py +3
-0+ """ + extraopts = self.mkfs_extraopts or base_opts + # Only add an explicit block size when a non-default sectorsize
Quoted 18 lines
Quoted 18 lines
is requested.
scripts/lib/wic/partition.py +16
-0+ if self.sector_size and self.sector_size != 512: + tokens = [] + skip_next = False + for tok in extraopts.split(): + if skip_next: + skip_next = False + continue + if tok == '-b': + skip_next = True + continue + if tok.startswith('-b'): + continue + tokens.append(tok) + tokens.extend(['-b', str(self.sector_size)]) + return ' '.join(tokens).strip() + return extraoptsQuoted 11 lines
Quoted 11 lines
def
get_extra_block_count(self, current_blocks):
"""scripts/lib/wic/partition.py +1
-0@@ -138,6 +182,8 @@ class Partition(): Prepare content for individual partitions, depending on partition command parameters. """ + # capture the sector size requested on the CLI for mkdosfsinvocations
+ self.sector_size =getattr(creator, 'sector_size', 512)or 512
self.updated_fstab_path =updated_fstab_pathif self.updated_fstab_path and not(
self.fstype.startswith("ext")Quoted 11 lines
scripts/lib/wic/partition.py class Partition(): · line 345
Quoted 11 lines
or self.fstype == "msdos"):
self.update_fstab_in_rootfs = Truescripts/lib/wic/partition.py +1
-1@@ -293,7 +339,7 @@ class Partition(): with open(rootfs, 'w') as sparse: os.ftruncate(sparse.fileno(), rootfs_size * 1024) - extraopts = self.mkfs_extraopts or "-F -i 8192" + extraopts = self._mkfs_ext_extraopts("-F -i 8192") # use hash_seed to generate reproducible ext4 images (extraopts, pseudo) = self.get_hash_seed_ext4(extraopts,pseudo)
Quoted 9 lines
scripts/lib/wic/partition.py class Partition(): · line 453
Quoted 9 lines
scripts/lib/wic/partition.py +1
-1@@ -401,7 +447,7 @@ class Partition(): size_str = "" - extraopts = self.mkfs_extraopts or '-S 512' + extraopts = self._mkdosfs_extraopts() dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \ (label_str, self.fsuuid, size_str, extraopts,rootfs,
Quoted 11 lines
Quoted 11 lines
scripts/lib/wic/partition.py +1
-1@@ -452,7 +498,7 @@ class Partition(): with open(rootfs, 'w') as sparse: os.ftruncate(sparse.fileno(), size * 1024) - extraopts = self.mkfs_extraopts or "-i 8192" + extraopts = self._mkfs_ext_extraopts("-i 8192") # use hash_seed to generate reproducible ext4 images (extraopts, pseudo) = self.get_hash_seed_ext4(extraopts, None)@@ -498,7 +544,7 @@ class Partition():Quoted 7 lines
scripts/lib/wic/partition.py class Partition():
Quoted 7 lines
scripts/lib/wic/partition.py +1
-1size_str = "" - extraopts = self.mkfs_extraopts or '-S 512' + extraopts = self._mkdosfs_extraopts() dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \ (label_str, self.fsuuid, extraopts, size_str,rootfs,
Quoted 2 lines
scripts/lib/wic/partition.py class Partition(): · line 605
Quoted 2 lines
scripts/lib/wic/partition.py +0
-0@@ -559,4 +605,3 @@ class Partition(): logger.warn("%s Inodes (of size %d) are toosmall." %
Quoted 14 lines
Quoted 14 lines
scripts/lib/wic/partition.py +0
-1(get_err_str(self), size)) break -scripts/lib/wic/plugins/imager/direct.py +1
-0@@ -67,6 +67,7 @@ class DirectPlugin(ImagerPlugin): self._image = None self.ptable_format = self.ks.bootloader.ptable self.parts = self.ks.partitions + self.sector_size = options.sector_size or 512Quoted 8 lines
scripts/lib/wic/plugins/imager/direct.py class DirectPlugin(ImagerPlugin): · line 83
Quoted 8 lines
scripts/lib/wic/plugins/imager/direct.py +0
-0# as a convenience, set source to the boot partition source # instead of forcing it to be set via bootloader --source@@ -78,7 +79,7 @@ class DirectPlugin(ImagerPlugin): image_path = self._full_path(self.workdir, self.parts[0].disk, "direct") self._image = PartitionedImage(image_path, self.ptable_format, self.ks.bootloader.diskid, self.parts,self.native_sysroot,
Quoted 18 lines
Quoted 18 lines
scripts/lib/wic/plugins/imager/direct.py +1
-1- options.extra_space) + options.extra_space, self.sector_size)def
setup_workdir(self, workdir):
if workdir:scripts/lib/wic/plugins/imager/direct.py +0
-3@@ -294,15 +295,13 @@ MBR_OVERHEAD = 1 # Overhead of the GPT partitioning scheme GPT_OVERHEAD = 34 -# Size of a sector in bytes -SECTOR_SIZE = 512 - class PartitionedImage(): """ Partitioned image in a file. """Quoted 8 lines
Quoted 8 lines
scripts/lib/wic/plugins/imager/direct.py +0
-1- def __init__(self, path, ptable_format, disk_id, partitions,native_sysroot=None, extra_space=0):
+ def __init__(self, path,ptable_format,disk_id, partitions,
native_sysroot=None, extra_space=0,
+ sector_size=512):
self.path = path # Path to the image file self.numpart = 0 # Number of allocated partitions self.realpart = 0 # Number of partitions in the partitiontable
Quoted 34 lines
Quoted 34 lines
scripts/lib/wic/plugins/imager/direct.py +1
-8@@ -332,14 +331,7 @@ class PartitionedImage(): self.partitions = partitions self.partimages = [] # Size of a sector used in calculations - sector_size_str = get_bitbake_var('WIC_SECTOR_SIZE') - if sector_size_str is not None: - try: - self.sector_size = int(sector_size_str) - except ValueError: - self.sector_size = SECTOR_SIZE - else: - self.sector_size = SECTOR_SIZE + self.sector_size = sector_size or 512 self.native_sysroot = native_sysroot num_real_partitions = len([p for p in self.partitions if notp.no_table])
scripts/lib/wic/plugins/source/bootimg_efi.py +3
-2@@ -415,8 +415,9 @@ class BootimgEFIPlugin(SourcePlugin): label = part.label if part.label else "ESP" - dosfs_cmd = "mkdosfs -v -n %s -i %s -C %s %d" % \ - (label, part.fsuuid, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or 512 + dosfs_cmd = "mkdosfs -v -n %s -i %s -S %d -C %s %d" % \ + (label, part.fsuuid, sector_size, bootimg, blocks) exec_native_cmd(dosfs_cmd, native_sysroot) logger.debug("mkdosfs:\n%s" % (str(out)))Quoted 8 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin): · line 133
Quoted 8 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-0@@ -132,7 +132,7 @@ class BootimgPcbiosPlugin(SourcePlugin): cls._do_prepare_grub(part, cr_workdir, oe_builddir, kernel_dir, rootfs_dir,
native_sysroot)Quoted 2 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin): · line 135
Quoted 2 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-1elif source_params['loader-bios'] == 'syslinux': - cls._do_prepare_syslinux(part, cr_workdir,
bootimg_dir,Quoted 5 lines
Quoted 5 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +1
-0+ cls._do_prepare_syslinux(part, creator, cr_workdir, bootimg_dir, kernel_dir, native_sysroot) else:raise WicError("unrecognized
bootimg_pcbiosloader:%s" %
Quoted 10 lines
Quoted 10 lines
source_params['loader-bios'])
scripts/lib/wic/plugins/source/bootimg_pcbios.py +1
-1@@ -142,7 +142,7 @@ class BootimgPcbiosPlugin(SourcePlugin): except KeyError: # Required by do_install_disk cls.loader = 'syslinux' - cls._do_prepare_syslinux(part, cr_workdir, bootimg_dir, + cls._do_prepare_syslinux(part, creator, cr_workdir, bootimg_dir, kernel_dir, native_sysroot)Quoted 7 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin): · line 243
Quoted 7 lines
@classmethod
scripts/lib/wic/plugins/source/bootimg_pcbios.py +1
-1@@ -240,7 +240,7 @@ class BootimgPcbiosPlugin(SourcePlugin): cfg.close() @classmethod - def _do_prepare_syslinux(cls, part, cr_workdir, bootimg_dir, + def _do_prepare_syslinux(cls, part, creator, cr_workdir,
bootimg_dir,Quoted 3 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin):
Quoted 3 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-0kernel_dir, native_sysroot): """ Called to do the actual content population for a partitioni.e. it
Quoted 28 lines
Quoted 28 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +3
-2@@ -292,8 +292,9 @@ class BootimgPcbiosPlugin(SourcePlugin): label = part.label if part.label else "boot" - dosfs_cmd = "mkdosfs -n %s -i %s -S 512 -C %s %d" % \ - (label, part.fsuuid, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or 512 + dosfs_cmd = "mkdosfs -n %s -i %s -S %d -C %s %d" % \ + (label, part.fsuuid, sector_size, bootimg, blocks) exec_native_cmd(dosfs_cmd, native_sysroot) mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir)scripts/lib/wic/plugins/source/isoimage_isohybrid.py +3
-2@@ -367,8 +367,9 @@ class IsoImagePlugin(SourcePlugin): esp_label = source_params.get('esp_label', 'EFIimg') - dosfs_cmd = 'mkfs.vfat -n \'%s\' -S 512 -C %s %d' \ - % (esp_label, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or 512 + dosfs_cmd = "mkfs.vfat -n '%s' -S %d -C %s %d" % \ + (esp_label, sector_size, bootimg, blocks) exec_native_cmd(dosfs_cmd, native_sysroot)Quoted 8 lines
scripts/wic def wic_init_parser_create(subparser): · line 377
Quoted 8 lines
scripts/lib/wic/plugins/source/isoimage_isohybrid.py +0
-0mmd_cmd = "mmd -i %s ::/EFI" % bootimgscripts/wic +0
-0@@ -376,6 +376,8 @@ def wic_init_parser_create(subparser): default="direct", help="the wic imager plugin") subparser.add_argument("--extra-space", type=int,dest="extra_space",
Quoted 1 line
scripts/wic def wic_init_parser_create(subparser): · line 378
Quoted 1 line
scripts/wic +0
-0default=0, help="additional free disk space toadd
Quoted 2 lines
scripts/wic def wic_init_parser_create(subparser): · line 380
Quoted 2 lines
scripts/wic +1
-0to the image") + subparser.add_argument("--sector-size", dest="sector_size",type=int,
Quoted 11 lines
scripts/wic def imgtype(arg): · line 419
Quoted 11 lines
scripts/wic +2
-0default=512, + help="sector size in bytes (default: 512)") return@@ -413,6 +415,8 @@ def imgtype(arg): def wic_init_parser_ls(subparser): subparser.add_argument("path", type=imgtype, help="image spec: <image>[:<vfat partition>[<path>]]") + subparser.add_argument("--sector-size", dest="sector_size",type=int,
Quoted 4 lines
Quoted 4 lines
scripts/wic +1
-0default=512, + help="sector size in bytes (default: 512)") subparser.add_argument("-n", "--native-sysroot",help="path to the native sysroot containing
the
Quoted 9 lines
scripts/wic def wic_init_parser_cp(subparser): · line 442
Quoted 9 lines
tools")
subparser.add_argument("-e", "--image-name", dest="image_name",scripts/wic +1
-0@@ -433,6 +437,8 @@ def wic_init_parser_cp(subparser): help="image spec: <image>:<vfat partition>[<path>] or <file>") subparser.add_argument("dest", help="image spec: <image>:<vfat partition>[<path>] or <file>") + subparser.add_argument("--sector-size", dest="sector_size",type=int,
Quoted 4 lines
Quoted 4 lines
scripts/wic +1
-0default=512, + help="sector size in bytes (default: 512)")subparser.add_argument("-n", "--native-sysroot",
help="path to the native sysroot containingthe
Quoted 7 lines
scripts/wic def wic_init_parser_cp(subparser): · line 454
Quoted 7 lines
tools")
subparser.add_argument("-e", "--image-name", dest="image_name",scripts/wic +1
-0@@ -445,6 +451,8 @@ def wic_init_parser_cp(subparser): def wic_init_parser_rm(subparser): subparser.add_argument("path", type=imgpathtype, help="path: <image>:<vfat partition><path>") + subparser.add_argument("--sector-size", dest="sector_size",type=int,
Quoted 4 lines
scripts/wic def imgtype(arg):
Quoted 4 lines
scripts/wic +1
-0default=512, + help="sector size in bytes (default: 512)") subparser.add_argument("-n", "--native-sysroot", help="path to the native sysroot containingthe
Quoted 7 lines
Quoted 7 lines
tools")
subparser.add_argument("-r", dest="recursive_delete",
action="store_true", default=False,
--
2.51.0Quoted 7 lines
Quoted 7 lines
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#231176):
https://lists.openembedded.org/g/openembedded-core/message/231176
Mute This Topic: https://lists.openembedded.org/mt/117833550/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub[
Quoted 7 lines
Quoted 4 lines
[email protected]]
-=-=-=-=-=-=-=-=-=-=-=---
- Thou shalt not follow the NULL pointer, for chaos and madness awaitthee
Quoted 2 lines
at its end
- "Use the force Harry" - Gandalf, Star Trek IISignature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end - "Use the force Harry" - Gandalf, Star Trek II
Quoted 96 lines · Trevor Woerner
Quoted 1 line · Bruce Ashfield
On Mon, Feb 16, 2026 at 10:37 AM Trevor Woerner <[email protected]>
Quoted 10 lines · wrote:
Quoted 10 lines · Bruce Ashfield
Quoted 1 line
On Sun, Feb 15, 2026 at 9:32 PM Trevor Woerner via
lists.openembedded.org
Quoted 6 lines
Quoted 4 lines · <[email protected]> wrote:
The previous implementation to add variable sector-size support:
- required the variableWIC_SECTOR_SIZEeither be defined in a configuration file or be defined in a --vars file
- this means that every invocation of "wic ls", "wic cp", or "wicrm"
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
needed this variable defined (config or --vars)
- required the user to create separate *wks files for every sectorsize
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
they wanted to use
- required the user to specify the mkfs-extraopts by hand tospecify
Quoted 7 lines
Quoted 7 lines
the
Quoted 3 lines
Quoted 3 lines
correct sector size: e.g. bootloader --ptable gpt part --fstype ext4 --source rootfs --label rofs-a--mkfs-extraopts
Quoted 2 lines
Quoted 2 lines
"-b 4096"
part --fstype ext4 --source rootfs --use-uuid--mkfs-extraopts
Quoted 8 lines
Quoted 8 lines
"-b
Quoted 7 lines
Quoted 7 lines
4096"
- specifying --mkfs-extraopts replaces the defaults with the user-supplied values
- only provided details to support using variable sector-sizes with ext[234] filesystems
- it would not be possible to generate images with different sector sizes in the same build since the configuration and *wks fileswould
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
need to change and the build re-run for each size
Update the sector-size handling so that:
- the sector-size will now be provided on the cmdline to the "wicls",
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
"wic cp", "wic rm", and "wic create" commands: default = 512
- this means the configuration and/or --vars file does not need tobe
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
changed in order to perform those operations on images with
different
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
sector sizes
- support is provided implicitly for mkdosfs and ext[234]partitions
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
- the user no longer needs to know and supply the sector-size
magic in
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
--mkfs-extraopts (thereby clobbering the other defaults)
It wasn't clear to me when scanning the patch. For configuration files with a sector size, is it now completely ignored ?
Yes.
While trying to use the existing implementation in actual production workflows we found a number of shortcomings that are addressed with
this
Quoted 5 lines
Quoted 5 lines
update. Additionally, the ultimate goal is to make wic an independent utility from oe-core so it can be easily used by external tools post-build.
If sector-size is not available on the cmdline, then a --vars file
would
Quoted 5 lines
Quoted 5 lines
be needed for every simple wic invocation such as "wic cp", "wic ls", and "wic rm"... which would be silly. Take a look at the patch I submitted a week or so ago to see how the oe-selftests would have to be updated to support this.
Quoted 7 lines
Quoted 7 lines
If sector-size is available both on the cmdline and in a --vars file then which one wins? Ultimately having it specified in both places is only going to lead to confusion as people will be changing it in one place and not realizing it's also defined (and taking precedence) from somewhere else. I believe this is currently the case with --native-sysroot, which probably needs fixing as well since several oe-selftests are trying to use it, but I doubt it is working the way
the
Quoted 14 lines
Quoted 8 lines
test writers expect.
One parameter specified in one place so a user would not need multiple sets of configuration files to perform a simple "wic ls" of images with different sector sizes; simply specify it on the cmdline if you want something other than 512.
That's not a good migration path. You can't simply throw away someone's existing configuration and ask them to update to a new one. I didn't even see an error thrown with migration instructions.
Quoted 9 lines
Quoted 2 lines
There's many different users of things like this, we can't simply change the interface without some way to migrate.
I don't disagree with you entirely.
But if the user specifies --sector-size <N> on the cmdline, they will expect the sector-size to be N. If they don't specify this on the cmdline, they would rightfully expect the default of 512 to be used...
At a thought:
If they specify it on the command line. use it.
If they don't specify it on the command line, but there's a variable set (the old way), use it and output a message that it was taken from the variable.
If they don't specify it on the command line and no variable is set, use the default
You don't really even need to fully support the variable everywhere, just read it once, and then convert it to a command line argument (if there's a place to do that, you know the code better than I do, maybe that's not possible).
If someone is migrating to the new way, they can just remove that variable once they know things are working.
Bruce
Quoted 831 lines
...unless some configuration file anywhere in their build specifies
WIC_SECTOR_SIZE, in which case wic is supposed to use that value?I could print a warning if sector size is set via
WIC_SECTOR_SIZE?Quoted 27 lines
Bruce
Quoted 22 lines
Quoted 22 lines
Apologies if I missed where existing configs were used to prime the parameters to the functions.
Bruce
Quoted 14 lines
AI-Generated: codex/gpt-5.1-codex-max
Signed-off-by Trevor Woerner <[email protected]>---
changes since v2:
- nonechanges since v1:
- none--- meta/lib/oeqa/selftest/cases/wic.py | 39 ++++--------- scripts/lib/wic/engine.py | 45 +++++++-------- scripts/lib/wic/help.py | 23 +++++--- scripts/lib/wic/partition.py | 55+++++++++++++++++--
Quoted 46 lines
Quoted 46 lines
Quoted 32 lines
Quoted 32 lines
scripts/lib/wic/plugins/imager/direct.py | 18 ++---- scripts/lib/wic/plugins/source/bootimg_efi.py | 5 +- .../lib/wic/plugins/source/bootimg_pcbios.py | 11 ++-- .../wic/plugins/source/isoimage_isohybrid.py | 5 +- scripts/wic | 8 +++ 9 files changed, 125 insertions(+), 84 deletions(-)meta/lib/oeqa/selftest/cases/wic.py +3
-7@@ -935,33 +935,22 @@ bootloader --ptable gpt""") finally: os.remove(wks_file) - def test_wic_sector_size(self): - """Test generation image sector size""" - + def test_wic_sector_size_cli(self): + """Test sector size handling via CLI option.""" + oldpath = os.environ['PATH'] os.environ['PATH'] = get_bb_var("PATH", "wic-tools") try: - # Add WIC_SECTOR_SIZE into config - config = 'WIC_SECTOR_SIZE = "4096"\n'\ - 'WICVARS:append = " WIC_SECTOR_SIZE"\n' - self.append_config(config) bitbake('core-image-minimal')Quoted 13 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""")
Quoted 13 lines
meta/lib/oeqa/selftest/cases/wic.py +0
-8- # Check WIC_SECTOR_SIZE apply to bitbake variable - wic_sector_size_str = get_bb_var('WIC_SECTOR_SIZE', 'core-image-minimal') - wic_sector_size = int(wic_sector_size_str) - self.assertEqual(4096, wic_sector_size) - - self.logger.info("Test wic_sector_size: %d \n" % wic_sector_size) - with NamedTemporaryFile("w", suffix=".wks") as wks: wks.writelines( ['bootloader --ptable gpt\n', - 'part --fstype ext4 --source rootfs --labelrofs-a
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""") · line 965
Quoted 2 lines
meta/lib/oeqa/selftest/cases/wic.py +0
-2--mkfs-extraopts "-b 4096"\n', - 'part --fstype ext4 --source rootfs--use-uuid
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""") · line 954
Quoted 4 lines
meta/lib/oeqa/selftest/cases/wic.py +2
-1--mkfs-extraopts "-b 4096"\n']) + 'part --fstype ext4 --source rootfs --label rofs-a\n', + 'part --fstype ext4 --source rootfs--use-uuid\n'])
Quoted 2 lines
Quoted 2 lines
wks.flush()- cmd = "wic create %s -e core-image-minimal -o %s"
% (
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
wks.name, self.resultdir)
+ cmd = "wic create %s -e core-image-minimal -o %s
--sector-size 4096" % (wks.name, self.resultdir)runCmd(cmd) wksname = os.path.splitext(os.path.basename(wks.name
Quoted 7 lines
Quoted 7 lines
))[0]
Quoted 1 line
Quoted 1 line
images = glob(os.path.join(self.resultdir,
"%s-*direct" %
Quoted 4 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""") · line 959
Quoted 4 lines
wksname))
meta/lib/oeqa/selftest/cases/wic.py +0
-0@@ -969,24 +958,18 @@ bootloader --ptable gpt""") sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE','wic-tools')
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""") · line 972
Quoted 2 lines
meta/lib/oeqa/selftest/cases/wic.py +0
-1# list partitions - result = runCmd("wic ls %s -n %s" % (images[0],sysroot))
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""")
Quoted 6 lines
meta/lib/oeqa/selftest/cases/wic.py +1
-2+ result = runCmd("wic ls %s -n %s --sector-size 4096" % (images[0], sysroot)) self.assertEqual(3, len(result.output.split('\n'))) - # verify partition size with wic - res = runCmd("export PARTED_SECTOR_SIZE=%d; parted -m%s
Quoted 4 lines
Quoted 4 lines
unit
Quoted 3 lines
Quoted 3 lines
meta/lib/oeqa/selftest/cases/wic.py +2
-0b p" % (wic_sector_size, images[0]), + # verify partition size with parted output + res = runCmd("export PARTED_SECTOR_SIZE=%d; parted -m%s
Quoted 9 lines
Quoted 9 lines
unit
Quoted 7 lines
Quoted 7 lines
meta/lib/oeqa/selftest/cases/wic.py +0
-3b p" % (4096, images[0]), stderr=subprocess.PIPE) - # parse parted output which looks like this: - # BYT;\n - #/var/tmp/wic/build/tmpgjzzefdd-202410281021-sda.direct:78569472B:file:4096:4096:gpt::;\n
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
meta/lib/oeqa/selftest/cases/wic.py +0
-4- # 1:139264B:39284735B:39145472B:ext4:rofs-a:;\n - # 2:39284736B:78430207B:39145472B:ext4:primary:;\n disk_info = res.output.splitlines()[1] - # Check sector sizes sector_size_logical = int(disk_info.split(":")[3]) sector_size_physical = int(disk_info.split(":")[4]) - self.assertEqual(wic_sector_size, sector_size_logical,"Logical sector size is not %d." %
wic_sector_size)
- self.assertEqual(wic_sector_size,
sector_size_physical,Quoted 48 lines
Quoted 48 lines
Quoted 2 lines
Quoted 2 lines
"Physical sector size is not %d." %
wic_sector_size)
+ self.assertEqual(4096,sector_size_logical, "Logicalsector
Quoted 2 lines
Quoted 2 lines
size is not 4096.")
+ self.assertEqual(4096,sector_size_physical, "Physicalsector
Quoted 11 lines
Quoted 11 lines
size is not 4096.")
finally:
os.environ['PATH'] = oldpathscripts/lib/wic/engine.py +0
-0@@ -224,7 +224,7 @@ def wic_list(args, scripts_path):Quoted 2 lines
scripts/lib/wic/engine.py def wic_list(args, scripts_path): · line 227
Quoted 2 lines
scripts/lib/wic/engine.py +0
-1class Disk: - def __init__(self, imagepath, native_sysroot, fstypes=('fat','ext')):
Quoted 1 line
scripts/lib/wic/engine.py def wic_list(args, scripts_path): · line 227
Quoted 1 line
scripts/lib/wic/engine.py +1
-0+ def __init__(self, imagepath, native_sysroot, fstypes=('fat','ext'),
Quoted 26 lines
Quoted 26 lines
sector_size=512):
self.imagepath = imagepath
self.native_sysroot =native_sysroot
self.fstypes = fstypesscripts/lib/wic/engine.py +1
-10@@ -233,16 +233,7 @@ class Disk: self._lsector_size = None self._psector_size = None self._ptable_format = None - - # define sector size - sector_size_str = get_bitbake_var('WIC_SECTOR_SIZE') - if sector_size_str is not None: - try: - self.sector_size = int(sector_size_str) - except ValueError: - self.sector_size = None - else: - self.sector_size = None + self.sector_size = sector_size # find parted # read paths from $PATH environment variable@@ -271,7 +262,7 @@ class Disk: if self._partitions is None: self._partitions = OrderedDict()Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
scripts/lib/wic/engine.py class Disk:
Quoted 3 lines
scripts/lib/wic/engine.py +1
-1- if self.sector_size is not None: + if self.sector_size: out = exec_cmd("export PARTED_SECTOR_SIZE=%d; %s-sm
Quoted 7 lines
Quoted 7 lines
%s
Quoted 6 lines
scripts/lib/wic/engine.py class Disk: · line 303
Quoted 6 lines
scripts/lib/wic/engine.py +0
-0unit B print" % \ (self.sector_size, self.parted,self.imagepath), True)
else:scripts/lib/wic/engine.py +0
-0@@ -312,11 +303,15 @@ class Disk: raise WicError("Partition %s is not in the image" %pnum)
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
scripts/lib/wic/engine.py class Disk:
Quoted 3 lines
scripts/lib/wic/engine.py +1
-0part = self.partitions[pnum] # check if fstype is supported + # NOTE: parted is unable to identify dos-type partitionswith
Quoted 3 lines
Quoted 3 lines
a
Quoted 2 lines
Quoted 2 lines
4k sector-size
+ # if the type is empty and a non-default sectorsize is
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
scripts/lib/wic/engine.py
Quoted 3 lines
used, assume 'fat'
scripts/lib/wic/engine.py +2
-0+ # fdisk identifies them without issue + part_fstype = part.fstype if part.fstype orself.sector_size
Quoted 9 lines
Quoted 9 lines
==
Quoted 7 lines
scripts/lib/wic/engine.py class Disk:
Quoted 7 lines
512 else 'fat'
for fstype in self.fstypes:scripts/lib/wic/engine.py +1
-2- if part.fstype.startswith(fstype): + if part_fstype.startswith(fstype): break else: - raise WicError("Not supported fstype:{}".format(part.fstype))
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line
+ raise WicError("Not supported fstype:
{}".format(part_fstype))
Quoted 6 lines
scripts/lib/wic/engine.py class Disk: · line 582
Quoted 6 lines
if pnum not in self._partimages:
tmpf =tempfile.NamedTemporaryFile(prefix="wic-part")dst_fname= tmpf.namescripts/lib/wic/engine.py +0
-0@@ -586,8 +581,9 @@ class Disk: label = part.get("name") label_str = "-n {}".format(label) iflabel
Quoted 31 lines
Quoted 31 lines
Quoted 3 lines
Quoted 3 lines
else ''
- cmd = "{} {} -C {}
{}".format(self.mkdosfs,
Quoted 2 lines
Quoted 2 lines
label_str, partfname,
-part['size'])
Quoted 1 line
Quoted 1 line
+
sector_str= "-S{}".format(self.sector_size)
Quoted 4 lines
Quoted 4 lines
if self.sector_size else ''
+ cmd = "{} {} {} -C {}
{}".format(self.mkdosfs,label_str,sector_str, partfname, +part['size'])
Quoted 2 lines
Quoted 2 lines
exec_cmd(cmd)
# copy content from the temporarydirectory
Quoted 5 lines
Quoted 5 lines
to the new partition
cmd = "{} -snompi {} {}/*::".format(self.mcopy, partfname, tmpdir)
scripts/lib/wic/engine.py +0
-0@@ -609,14 +605,19 @@ class Disk:Quoted 8 lines
scripts/lib/wic/engine.py class Disk:
Quoted 8 lines
scripts/lib/wic/engine.py +1
-1def wic_ls(args, native_sysroot): """List contents of partitioned image or vfat partition.""" - disk = Disk(args.path.image, native_sysroot) + disk = Disk(args.path.image, native_sysroot, sector_size=args.sector_size) if not args.path.part: if disk.partitions: print('Num Start End SizeFstype')
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
scripts/lib/wic/engine.py class Disk:
Quoted 11 lines
scripts/lib/wic/engine.py +1
-0for part in disk.partitions.values(): + # size values are in bytes from parted; convert tosectors if a custom sector size was requested
scripts/lib/wic/engine.py +2
-0+ display_size = part.size + if args.sector_size and args.sector_size !=disk._lsector_size:
scripts/lib/wic/engine.py +2
-2+ display_size = part.size // args.sector_size print("{:2d} {:12d} {:12d} {:12d} {}".format(\ - part.pnum, part.start, part.end, - part.size, part.fstype)) + part.pnum, part.start //args.sector_size,
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
scripts/lib/wic/engine.py +4
-2+ part.end // args.sector_size, + display_size, part.fstype)) else: path = args.path.path or '/' print(disk.dir(args.path.part, path))@@ -627,9 +628,9 @@ def wic_cp(args, native_sysroot): partitioned image. """ if isinstance(args.dest, str): - disk = Disk(args.src.image, native_sysroot) + disk = Disk(args.src.image, native_sysroot, sector_size=args.sector_size) else: - disk = Disk(args.dest.image, native_sysroot) + disk = Disk(args.dest.image, native_sysroot, sector_size=args.sector_size) disk.copy(args.src, args.dest)Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
scripts/lib/wic/engine.py def wic_rm(args, native_sysroot): · line 644
Quoted 8 lines
scripts/lib/wic/engine.py +1
-1@@ -638,7 +639,7 @@ def wic_rm(args, native_sysroot): Remove files or directories from the vfat partition of partitioned image. """ - disk = Disk(args.path.image, native_sysroot) + disk = Disk(args.path.image, native_sysroot, sector_size=args.sector_size) disk.remove(args.path.part, args.path.path,args.recursive_delete)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
scripts/lib/wic/help.py wic_create_usage = """ · line 118
Quoted 8 lines
scripts/lib/wic/engine.py +0
-0def wic_write(args, native_sysroot):scripts/lib/wic/help.py +0
-0@@ -118,7 +118,7 @@ wic_create_usage = """ usage: wic create <wks file or image name> [-o <DIRNAME> |--outdir
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
<DIRNAME>]
[-e | --image-name] [-s, --skip-build-check] [-D,--debug]
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
[-r, --rootfs-dir] [-b, --bootimg-dir]- [-k, --kernel-dir] [-n, --native-sysroot] [-f,
--build-rootfs]
Quoted 1 line
Quoted 1 line
+ [-k, --kernel-dir] [-n, --native-sysroot]
[--sector-size
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
<bytes>] [-f, --build-rootfs]
[-c, --compress-with] [-m, --bmap]This command creates an OpenEmbedded image based on the 'OE
kickstart
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
scripts/lib/wic/help.py +0
-0@@ -139,13 +139,16 @@ SYNOPSIS wic create <wks file or image name> [-o <DIRNAME> | --outdir<DIRNAME>]
[-e | --image-name] [-s, --skip-build-check] [-D, --debug] [-r, --rootfs-dir] [-b, --bootimg-dir]- [-k, --kernel-dir] [-n, --native-sysroot] [-f,
--build-rootfs]
Quoted 10 lines
Quoted 10 lines
Quoted 1 line
Quoted 1 line
+ [-k, --kernel-dir] [-n, --native-sysroot] [--sector-size
<bytes>]
Quoted 8 lines
Quoted 8 lines
[-f, --build-rootfs]
[-c, --compress-with] [-m, --bmap] [--no-fstab-update]DESCRIPTION
This command creates an OpenEmbedded image based on the 'OE kickstart commands' found in the <wks file>.+ Use the --sector-size option to select the sector size (in
bytes)
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
scripts/lib/wic/help.py wic_ls_usage = """ · line 281
Quoted 10 lines
scripts/lib/wic/help.py +2
-1+ used for partition layout calculations (default is 512). + In order to do this, wic needs to know the locations of the various build artifacts required to build the image.@@ -278,7 +281,7 @@ wic_ls_usage = """ List content of a partitioned image - usage: wic ls <image>[:<partition>[<path>]] [--native-sysroot<path>]
Quoted 1 line
Quoted 1 line
Quoted 1 line
scripts/lib/wic/help.py wic_ls_usage = """ · line 284
Quoted 1 line
scripts/lib/wic/help.py +1
-0+ usage: wic ls <image>[:<partition>[<path>]] [--native-sysroot<path>]
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
[--sector-size <bytes>]
This command outputs either list of image partitions or
directory
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
scripts/lib/wic/help.py SYNOPSIS · line 299
Quoted 7 lines
contents
of vfat and ext* partitions.scripts/lib/wic/help.py +0
-1@@ -296,7 +299,7 @@ SYNOPSIS wic ls <image> wic ls <image>:<vfat or ext* partition> wic ls <image>:<vfat or ext* partition><path> - wic ls <image>:<vfat or ext* partition><path> --native-sysroot<path>
Quoted 1 line
scripts/lib/wic/help.py SYNOPSIS · line 302
Quoted 1 line
scripts/lib/wic/help.py +1
-0+ wic ls <image>:<vfat or ext* partition><path> --native-sysroot<path>
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
scripts/lib/wic/help.py DESCRIPTION · line 340
Quoted 8 lines
[--sector-size <bytes>]
DESCRIPTION
This command lists either partitions of the image or directory
contentsscripts/lib/wic/help.py +0
-0@@ -336,6 +339,8 @@ DESCRIPTION The -n option is used to specify the path to the nativesysroot
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
scripts/lib/wic/help.py DESCRIPTION · line 342
Quoted 2 lines
scripts/lib/wic/help.py +1
-0containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used forpartition
Quoted 11 lines
Quoted 11 lines
math
Quoted 10 lines
scripts/lib/wic/help.py wic_cp_usage = """ · line 351
Quoted 10 lines
scripts/lib/wic/help.py +2
-1+ (default is 512 bytes). """@@ -343,7 +348,7 @@ wic_cp_usage = """ Copy files and directories to/from the vfat or ext* partition - usage: wic cp <src> <dest> [--native-sysroot <path>] + usage: wic cp <src> <dest> [--native-sysroot <path>][--sector-size
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
scripts/lib/wic/help.py SYNOPSIS · line 367
Quoted 9 lines
<bytes>]
source/destination image in format <image>:<partition>[<path>]
scripts/lib/wic/help.py +0
-1@@ -364,7 +369,7 @@ SYNOPSIS wic cp <src> <dest>:<partition> wic cp <src>:<partition> <dest> wic cp <src> <dest-image>:<partition><path> - wic cp <src> <dest-image>:<partition><path> --native-sysroot<path>
Quoted 1 line
Quoted 1 line
scripts/lib/wic/help.py +1
-0+ wic cp <src> <dest-image>:<partition><path> --native-sysrootQuoted 8 lines
Quoted 8 lines
<path>
Quoted 7 lines
scripts/lib/wic/help.py DESCRIPTION · line 414
Quoted 7 lines
[--sector-size <bytes>]
DESCRIPTION
This command copies files or directories eitherscripts/lib/wic/help.py +0
-0@@ -408,13 +413,15 @@ DESCRIPTION The -n option is used to specify the path to the nativesysroot
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
scripts/lib/wic/help.py DESCRIPTION · line 416
Quoted 2 lines
scripts/lib/wic/help.py +1
-0containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used forpartition
Quoted 12 lines
Quoted 12 lines
math
Quoted 11 lines
Quoted 11 lines
scripts/lib/wic/help.py +2
-1+ (default is 512 bytes). """ wic_rm_usage = """ Remove files or directories from the vfat or ext* partitions - usage: wic rm <image>:<partition><path> [--native-sysroot <path>] + usage: wic rm <image>:<partition><path> [--native-sysroot <path>][--sector-size <bytes>]
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
scripts/lib/wic/help.py DESCRIPTION · line 474
Quoted 6 lines
This command removes files or directories from the vfat or ext*
partitions of
the partitioned image.scripts/lib/wic/help.py +0
-0@@ -466,6 +473,8 @@ DESCRIPTION The -n option is used to specify the path to the nativesysroot
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
scripts/lib/wic/help.py DESCRIPTION · line 476
Quoted 2 lines
scripts/lib/wic/help.py +1
-0containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used forpartition
Quoted 12 lines
Quoted 12 lines
math
Quoted 5 lines
Review
Quoted 5 lines
scripts/lib/wic/help.py +1
-0+ (default is 512 bytes). The -r option is used to remove directories and their contents recursively,this only applies to ext* partition.(quoted diff) +0
-0
b/scripts/lib/wic/partition.pyQuoted 5 lines
Quoted 5 lines
index
8fed686e903e..df6e3271649b100644scripts/lib/wic/partition.py +0
-0@@ -65,6 +65,50 @@ class Partition():Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
scripts/lib/wic/partition.py class Partition():
Quoted 7 lines
scripts/lib/wic/partition.py +5
-0self.lineno = lineno self.source_file = "" + self.sector_size = 512 + + def _mkdosfs_extraopts(self): + """ + Build mkdosfs extra options ensuring the CLI sector sizeis
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
applied.
scripts/lib/wic/partition.py +12
-0+ """ + extraopts = self.mkfs_extraopts or '' + tokens = [] + skip_next = False + for tok in extraopts.split(): + if skip_next: + skip_next = False + continue + if tok == '-S': + skip_next = True + continue + if tok.startswith('-S'):Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
scripts/lib/wic/partition.py class Partition():
Quoted 8 lines
scripts/lib/wic/partition.py +8
-0+ continue + tokens.append(tok) + tokens.extend(['-S', str(self.sector_size)]) + return ' '.join(tokens).strip() + + def _mkfs_ext_extraopts(self, base_opts): + """ + Build mkfs.ext* extra options ensuring the CLI sectorsize is
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
scripts/lib/wic/partition.py class Partition():
Quoted 4 lines
applied.
scripts/lib/wic/partition.py +3
-0+ """ + extraopts = self.mkfs_extraopts or base_opts + # Only add an explicit block size when a non-defaultsector
Quoted 19 lines
Quoted 19 lines
size
Quoted 18 lines
Quoted 18 lines
is requested.
scripts/lib/wic/partition.py +16
-0+ if self.sector_size and self.sector_size != 512: + tokens = [] + skip_next = False + for tok in extraopts.split(): + if skip_next: + skip_next = False + continue + if tok == '-b': + skip_next = True + continue + if tok.startswith('-b'): + continue + tokens.append(tok) + tokens.extend(['-b', str(self.sector_size)]) + return ' '.join(tokens).strip() + return extraoptsQuoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
def
get_extra_block_count(self, current_blocks):
"""scripts/lib/wic/partition.py +1
-0@@ -138,6 +182,8 @@ class Partition(): Prepare content for individual partitions, depending on partition command parameters. """ + # capture the sector size requested on the CLI for mkdosfsinvocations
+ self.sector_size =getattr(creator, 'sector_size', 512)or 512
Quoted 29 lines
Quoted 29 lines
Quoted 2 lines
Quoted 2 lines
self.updated_fstab_path =
updated_fstab_pathif self.updated_fstab_path and not(
self.fstype.startswith("ext")Quoted 11 lines
scripts/lib/wic/partition.py class Partition(): · line 345
Quoted 11 lines
or self.fstype == "msdos"):
self.update_fstab_in_rootfs = Truescripts/lib/wic/partition.py +1
-1@@ -293,7 +339,7 @@ class Partition(): with open(rootfs, 'w') as sparse: os.ftruncate(sparse.fileno(), rootfs_size * 1024) - extraopts = self.mkfs_extraopts or "-F -i 8192" + extraopts = self._mkfs_ext_extraopts("-F -i 8192") # use hash_seed to generate reproducible ext4 images (extraopts, pseudo) = self.get_hash_seed_ext4(extraopts,pseudo)
Quoted 9 lines
scripts/lib/wic/partition.py class Partition(): · line 453
Quoted 9 lines
scripts/lib/wic/partition.py +1
-1@@ -401,7 +447,7 @@ class Partition(): size_str = "" - extraopts = self.mkfs_extraopts or '-S 512' + extraopts = self._mkdosfs_extraopts() dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \ (label_str, self.fsuuid, size_str, extraopts,rootfs,
Quoted 4 lines
Quoted 4 lines
scripts/lib/wic/partition.py +0
-0@@ -452,7 +498,7 @@ class Partition(): with open(rootfs, 'w') as sparse: os.ftruncate(sparse.fileno(), size * 1024)Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
scripts/lib/wic/partition.py class Partition():
Quoted 5 lines
scripts/lib/wic/partition.py +1
-1- extraopts = self.mkfs_extraopts or "-i 8192" + extraopts = self._mkfs_ext_extraopts("-i 8192") # use hash_seed to generate reproducible ext4 images (extraopts, pseudo) = self.get_hash_seed_ext4(extraopts,None)
Quoted 27 lines
Quoted 27 lines
Quoted 9 lines
scripts/lib/wic/partition.py class Partition(): · line 550
Quoted 9 lines
scripts/lib/wic/partition.py +1
-1@@ -498,7 +544,7 @@ class Partition(): size_str = "" - extraopts = self.mkfs_extraopts or '-S 512' + extraopts = self._mkdosfs_extraopts() dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \ (label_str, self.fsuuid, extraopts, size_str,rootfs,
Quoted 2 lines
scripts/lib/wic/partition.py class Partition(): · line 605
Quoted 2 lines
scripts/lib/wic/partition.py +0
-0@@ -559,4 +605,3 @@ class Partition(): logger.warn("%s Inodes (of size %d) are toosmall." %
Quoted 14 lines
Quoted 14 lines
scripts/lib/wic/partition.py +0
-1(get_err_str(self), size)) break -scripts/lib/wic/plugins/imager/direct.py +1
-0@@ -67,6 +67,7 @@ class DirectPlugin(ImagerPlugin): self._image = None self.ptable_format = self.ks.bootloader.ptable self.parts = self.ks.partitions + self.sector_size = options.sector_size or 512Quoted 1 line
Quoted 1 line
Quoted 1 line
scripts/lib/wic/plugins/imager/direct.py class DirectPlugin(ImagerPlugin): · line 72
Quoted 1 line
scripts/lib/wic/plugins/imager/direct.py +0
-0# as a convenience, set source to the boot partitionsource
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
scripts/lib/wic/plugins/imager/direct.py class DirectPlugin(ImagerPlugin): · line 79
Quoted 3 lines
scripts/lib/wic/plugins/imager/direct.py +0
-0# instead of forcing it to be set via bootloader --source@@ -78,7 +79,7 @@ class DirectPlugin(ImagerPlugin): image_path = self._full_path(self.workdir,self.parts[0].disk,
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
scripts/lib/wic/plugins/imager/direct.py class DirectPlugin(ImagerPlugin): · line 81
Quoted 2 lines
scripts/lib/wic/plugins/imager/direct.py +0
-0"direct") self._image = PartitionedImage(image_path,self.ptable_format,
Quoted 44 lines
Quoted 44 lines
Quoted 2 lines
scripts/lib/wic/plugins/imager/direct.py class DirectPlugin(ImagerPlugin): · line 83
Quoted 2 lines
scripts/lib/wic/plugins/imager/direct.py +0
-0self.ks.bootloader.diskid, self.parts,self.native_sysroot,
Quoted 18 lines
Quoted 18 lines
scripts/lib/wic/plugins/imager/direct.py +1
-1- options.extra_space) + options.extra_space, self.sector_size)def
setup_workdir(self, workdir):
if workdir:scripts/lib/wic/plugins/imager/direct.py +0
-3@@ -294,15 +295,13 @@ MBR_OVERHEAD = 1 # Overhead of the GPT partitioning scheme GPT_OVERHEAD = 34 -# Size of a sector in bytes -SECTOR_SIZE = 512 - class PartitionedImage(): """ Partitioned image in a file. """Quoted 8 lines
Quoted 8 lines
scripts/lib/wic/plugins/imager/direct.py +0
-1- def __init__(self, path, ptable_format, disk_id, partitions,native_sysroot=None, extra_space=0):
+ def __init__(self, path,ptable_format,disk_id, partitions,
native_sysroot=None, extra_space=0,
+ sector_size=512):
self.path = path # Path to the image file self.numpart = 0 # Number of allocated partitions self.realpart = 0 # Number of partitions in the partitiontable
Quoted 14 lines
Quoted 14 lines
scripts/lib/wic/plugins/imager/direct.py +1
-8@@ -332,14 +331,7 @@ class PartitionedImage(): self.partitions = partitions self.partimages = [] # Size of a sector used in calculations - sector_size_str = get_bitbake_var('WIC_SECTOR_SIZE') - if sector_size_str is not None: - try: - self.sector_size = int(sector_size_str) - except ValueError: - self.sector_size = SECTOR_SIZE - else: - self.sector_size = SECTOR_SIZE + self.sector_size = sector_size or 512Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
scripts/lib/wic/plugins/imager/direct.py class PartitionedImage(): · line 337
Quoted 2 lines
scripts/lib/wic/plugins/imager/direct.py +0
-0self.native_sysroot = native_sysroot num_real_partitions = len([p for p in self.partitions ifnot
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
p.no_table])
scripts/lib/wic/plugins/source/bootimg_efi.py +0
-0@@ -415,8 +415,9 @@ class BootimgEFIPlugin(SourcePlugin):Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
scripts/lib/wic/plugins/source/bootimg_efi.py class BootimgEFIPlugin(SourcePlugin):
Quoted 7 lines
scripts/lib/wic/plugins/source/bootimg_efi.py +3
-2label = part.label if part.label else "ESP" - dosfs_cmd = "mkdosfs -v -n %s -i %s -C %s %d" % \ - (label, part.fsuuid, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or 512 + dosfs_cmd = "mkdosfs -v -n %s -i %s -S %d -C %s %d" % \ + (label, part.fsuuid, sector_size, bootimg,blocks)
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin): · line 132
Quoted 10 lines
scripts/lib/wic/plugins/source/bootimg_efi.py +0
-0exec_native_cmd(dosfs_cmd, native_sysroot) logger.debug("mkdosfs:\n%s" % (str(out)))scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-0@@ -132,7 +132,7 @@ class BootimgPcbiosPlugin(SourcePlugin): cls._do_prepare_grub(part, cr_workdir,
oe_builddir,Quoted 6 lines
Quoted 6 lines
Quoted 1 line
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin): · line 133
Quoted 1 line
scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-0kernel_dir, rootfs_dir,
native_sysroot)Quoted 2 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin): · line 135
Quoted 2 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-1elif source_params['loader-bios'] == 'syslinux': - cls._do_prepare_syslinux(part, cr_workdir,
bootimg_dir,Quoted 1 line
Quoted 1 line
scripts/lib/wic/plugins/source/bootimg_pcbios.py +1
-0+ cls._do_prepare_syslinux(part, creator,
cr_workdir,Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-0bootimg_dir, kernel_dir, native_sysroot) else:raise WicError("unrecognized
bootimg_pcbiosloader:
Quoted 7 lines
Quoted 7 lines
%s" %
Quoted 6 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin): · line 145
Quoted 6 lines
source_params['loader-bios'])
scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-1@@ -142,7 +142,7 @@ class BootimgPcbiosPlugin(SourcePlugin): except KeyError: # Required by do_install_disk cls.loader = 'syslinux' - cls._do_prepare_syslinux(part, cr_workdir,
bootimg_dir,Quoted 18 lines
Quoted 18 lines
Quoted 11 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin): · line 243
Quoted 11 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +1
-0+ cls._do_prepare_syslinux(part, creator, cr_workdir, bootimg_dir, kernel_dir, native_sysroot)@classmethod
scripts/lib/wic/plugins/source/bootimg_pcbios.py +1
-1@@ -240,7 +240,7 @@ class BootimgPcbiosPlugin(SourcePlugin): cfg.close() @classmethod - def _do_prepare_syslinux(cls, part, cr_workdir, bootimg_dir, + def _do_prepare_syslinux(cls, part, creator, cr_workdir,
bootimg_dir,Quoted 3 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin):
Quoted 3 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-0kernel_dir, native_sysroot): """ Called to do the actual content population for a partitioni.e. it
Quoted 2 lines
Quoted 2 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-0@@ -292,8 +292,9 @@ class BootimgPcbiosPlugin(SourcePlugin):Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin):
Quoted 7 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +3
-2label = part.label if part.label else "boot" - dosfs_cmd = "mkdosfs -n %s -i %s -S 512 -C %s %d" % \ - (label, part.fsuuid, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or 512 + dosfs_cmd = "mkdosfs -n %s -i %s -S %d -C %s %d" % \ + (label, part.fsuuid, sector_size, bootimg,blocks)
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-0exec_native_cmd(dosfs_cmd, native_sysroot) mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir)scripts/lib/wic/plugins/source/isoimage_isohybrid.py +0
-0@@ -367,8 +367,9 @@ class IsoImagePlugin(SourcePlugin):Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
scripts/lib/wic/plugins/source/isoimage_isohybrid.py class IsoImagePlugin(SourcePlugin):
Quoted 5 lines
scripts/lib/wic/plugins/source/isoimage_isohybrid.py +1
-2esp_label = source_params.get('esp_label', 'EFIimg') - dosfs_cmd = 'mkfs.vfat -n \'%s\' -S 512 -C %s %d' \ - % (esp_label, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or512
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
scripts/wic def wic_init_parser_create(subparser): · line 376
Quoted 11 lines
scripts/lib/wic/plugins/source/isoimage_isohybrid.py +2
-0+ dosfs_cmd = "mkfs.vfat -n '%s' -S %d -C %s %d" % \ + (esp_label, sector_size, bootimg, blocks) exec_native_cmd(dosfs_cmd, native_sysroot) mmd_cmd = "mmd -i %s ::/EFI" % bootimgscripts/wic +0
-0@@ -376,6 +376,8 @@ def wic_init_parser_create(subparser): default="direct", help="the wic imagerplugin")
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
scripts/wic def wic_init_parser_create(subparser): · line 377
Quoted 1 line
scripts/wic +0
-0subparser.add_argument("--extra-space", type=int,dest="extra_space",
Quoted 1 line
Quoted 1 line
scripts/wic +0
-0default=0, help="additional free disk spaceto
Quoted 16 lines
Quoted 16 lines
add
Quoted 2 lines
scripts/wic def wic_init_parser_create(subparser): · line 380
Quoted 2 lines
scripts/wic +1
-0to the image") + subparser.add_argument("--sector-size", dest="sector_size",type=int,
Quoted 11 lines
scripts/wic def imgtype(arg): · line 419
Quoted 11 lines
scripts/wic +2
-0default=512, + help="sector size in bytes (default: 512)") return@@ -413,6 +415,8 @@ def imgtype(arg): def wic_init_parser_ls(subparser): subparser.add_argument("path", type=imgtype, help="image spec: <image>[:<vfat partition>[<path>]]") + subparser.add_argument("--sector-size", dest="sector_size",type=int,
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
scripts/wic def imgtype(arg): · line 421
Quoted 2 lines
scripts/wic +1
-0default=512, + help="sector size in bytes (default:512)")
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
scripts/wic +0
-0subparser.add_argument("-n", "--native-sysroot",help="path to the native sysroot
containing
Quoted 3 lines
Quoted 3 lines
the
Quoted 2 lines
Quoted 2 lines
tools")
subparser.add_argument("-e", "--image-name",dest="image_name",
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
scripts/wic def wic_init_parser_cp(subparser): · line 442
Quoted 7 lines
scripts/wic +1
-0@@ -433,6 +437,8 @@ def wic_init_parser_cp(subparser): help="image spec: <image>:<vfat partition>[<path>] or <file>") subparser.add_argument("dest", help="image spec: <image>:<vfat partition>[<path>] or <file>") + subparser.add_argument("--sector-size", dest="sector_size",type=int,
Quoted 2 lines
Quoted 2 lines
scripts/wic +1
-0default=512, + help="sector size in bytes (default:512)")
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
subparser.add_argument("-n", "--native-sysroot",
help="path to the native sysrootcontaining
Quoted 3 lines
Quoted 3 lines
the
Quoted 2 lines
Quoted 2 lines
tools")
subparser.add_argument("-e", "--image-name",dest="image_name",
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
scripts/wic def wic_init_parser_cp(subparser): · line 453
Quoted 4 lines
scripts/wic +0
-0@@ -445,6 +451,8 @@ def wic_init_parser_cp(subparser): def wic_init_parser_rm(subparser): subparser.add_argument("path", type=imgpathtype, help="path: <image>:<vfatpartition><path>")
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
scripts/wic def wic_init_parser_cp(subparser): · line 454
Quoted 1 line
scripts/wic +1
-0+ subparser.add_argument("--sector-size", dest="sector_size",type=int,
Quoted 2 lines
Quoted 2 lines
scripts/wic +1
-0default=512, + help="sector size in bytes (default:512)")
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
scripts/wic def wic_init_parser_cp(subparser): · line 458
Quoted 2 lines
scripts/wic +0
-0subparser.add_argument("-n", "--native-sysroot", help="path to the native sysrootcontaining
Quoted 8 lines
Quoted 8 lines
the
Quoted 7 lines
Quoted 7 lines
tools")
subparser.add_argument("-r", dest="recursive_delete",
action="store_true", default=False,
--
2.51.0Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#231176):
https://lists.openembedded.org/g/openembedded-core/message/231176
Mute This Topic:https://lists.openembedded.org/mt/117833550/1050810
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Group Owner: [email protected] Unsubscribe:
https://lists.openembedded.org/g/openembedded-core/unsub
Quoted 8 lines
Quoted 8 lines
[
Quoted 7 lines
Quoted 4 lines
[email protected]]
-=-=-=-=-=-=-=-=-=-=-=---
- Thou shalt not follow the NULL pointer, for chaos and madness awaitQuoted 8 lines
Quoted 4 lines
thee
Quoted 2 lines
at its end
- "Use the force Harry" - Gandalf, Star Trek II--
- Thou shalt not follow the NULL pointer, for chaos and madness awaitthee
Quoted 2 lines
at its end
- "Use the force Harry" - Gandalf, Star Trek II
Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end - "Use the force Harry" - Gandalf, Star Trek II
Quoted 117 lines · Bruce Ashfield
Quoted 96 lines · Trevor Woerner
Quoted 1 line · Bruce Ashfield
On Mon, Feb 16, 2026 at 10:37 AM Trevor Woerner <[email protected]>
Quoted 10 lines · wrote:
Quoted 10 lines · Bruce Ashfield
Quoted 1 line
On Sun, Feb 15, 2026 at 9:32 PM Trevor Woerner via
lists.openembedded.org
Quoted 6 lines
Quoted 4 lines · <[email protected]> wrote:
The previous implementation to add variable sector-size support:
- required the variableWIC_SECTOR_SIZEeither be defined in a configuration file or be defined in a --vars file
- this means that every invocation of "wic ls", "wic cp", or "wicrm"
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
needed this variable defined (config or --vars)
- required the user to create separate *wks files for every sectorsize
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
they wanted to use
- required the user to specify the mkfs-extraopts by hand tospecify
Quoted 7 lines
Quoted 7 lines
the
Quoted 3 lines
Quoted 3 lines
correct sector size: e.g. bootloader --ptable gpt part --fstype ext4 --source rootfs --label rofs-a--mkfs-extraopts
Quoted 2 lines
Quoted 2 lines
"-b 4096"
part --fstype ext4 --source rootfs --use-uuid--mkfs-extraopts
Quoted 8 lines
Quoted 8 lines
"-b
Quoted 7 lines
Quoted 7 lines
4096"
- specifying --mkfs-extraopts replaces the defaults with the user-supplied values
- only provided details to support using variable sector-sizes with ext[234] filesystems
- it would not be possible to generate images with different sector sizes in the same build since the configuration and *wks fileswould
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
need to change and the build re-run for each size
Update the sector-size handling so that:
- the sector-size will now be provided on the cmdline to the "wicls",
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
"wic cp", "wic rm", and "wic create" commands: default = 512
- this means the configuration and/or --vars file does not need tobe
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
changed in order to perform those operations on images with
different
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
sector sizes
- support is provided implicitly for mkdosfs and ext[234]partitions
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
- the user no longer needs to know and supply the sector-size
magic in
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
--mkfs-extraopts (thereby clobbering the other defaults)
It wasn't clear to me when scanning the patch. For configuration files with a sector size, is it now completely ignored ?
Yes.
While trying to use the existing implementation in actual production workflows we found a number of shortcomings that are addressed with
this
Quoted 5 lines
Quoted 5 lines
update. Additionally, the ultimate goal is to make wic an independent utility from oe-core so it can be easily used by external tools post-build.
If sector-size is not available on the cmdline, then a --vars file
would
Quoted 5 lines
Quoted 5 lines
be needed for every simple wic invocation such as "wic cp", "wic ls", and "wic rm"... which would be silly. Take a look at the patch I submitted a week or so ago to see how the oe-selftests would have to be updated to support this.
Quoted 7 lines
Quoted 7 lines
If sector-size is available both on the cmdline and in a --vars file then which one wins? Ultimately having it specified in both places is only going to lead to confusion as people will be changing it in one place and not realizing it's also defined (and taking precedence) from somewhere else. I believe this is currently the case with --native-sysroot, which probably needs fixing as well since several oe-selftests are trying to use it, but I doubt it is working the way
the
Quoted 14 lines
Quoted 8 lines
test writers expect.
One parameter specified in one place so a user would not need multiple sets of configuration files to perform a simple "wic ls" of images with different sector sizes; simply specify it on the cmdline if you want something other than 512.
That's not a good migration path. You can't simply throw away someone's existing configuration and ask them to update to a new one. I didn't even see an error thrown with migration instructions.
Quoted 9 lines
Quoted 2 lines
There's many different users of things like this, we can't simply change the interface without some way to migrate.
I don't disagree with you entirely.
But if the user specifies --sector-size <N> on the cmdline, they will expect the sector-size to be N. If they don't specify this on the cmdline, they would rightfully expect the default of 512 to be used...
At a thought:
If they specify it on the command line. use it.
If they don't specify it on the command line, but there's a variable set (the old way), use it and output a message that it was taken from the variable.
If they don't specify it on the command line and no variable is set, use the default
Quoted 7 lines
You don't really even need to fully support the variable everywhere, just read it once, and then convert it to a command line argument (if there's a place to do that, you know the code better than I do, maybe that's not possible).
If someone is migrating to the new way, they can just remove that variable once they know things are working.
Perfect! This is what my v4 will do :-)
Quoted 842 lines
Bruce
Quoted 831 lines
...unless some configuration file anywhere in their build specifies
WIC_SECTOR_SIZE, in which case wic is supposed to use that value?I could print a warning if sector size is set via
WIC_SECTOR_SIZE?Quoted 27 lines
Bruce
Quoted 22 lines
Quoted 22 lines
Apologies if I missed where existing configs were used to prime the parameters to the functions.
Bruce
Quoted 14 lines
AI-Generated: codex/gpt-5.1-codex-max
Signed-off-by Trevor Woerner <[email protected]>---
changes since v2:
- nonechanges since v1:
- none--- meta/lib/oeqa/selftest/cases/wic.py | 39 ++++--------- scripts/lib/wic/engine.py | 45 +++++++-------- scripts/lib/wic/help.py | 23 +++++--- scripts/lib/wic/partition.py | 55+++++++++++++++++--
Quoted 46 lines
Quoted 46 lines
Quoted 32 lines
Quoted 32 lines
scripts/lib/wic/plugins/imager/direct.py | 18 ++---- scripts/lib/wic/plugins/source/bootimg_efi.py | 5 +- .../lib/wic/plugins/source/bootimg_pcbios.py | 11 ++-- .../wic/plugins/source/isoimage_isohybrid.py | 5 +- scripts/wic | 8 +++ 9 files changed, 125 insertions(+), 84 deletions(-)meta/lib/oeqa/selftest/cases/wic.py +3
-7@@ -935,33 +935,22 @@ bootloader --ptable gpt""") finally: os.remove(wks_file) - def test_wic_sector_size(self): - """Test generation image sector size""" - + def test_wic_sector_size_cli(self): + """Test sector size handling via CLI option.""" + oldpath = os.environ['PATH'] os.environ['PATH'] = get_bb_var("PATH", "wic-tools") try: - # Add WIC_SECTOR_SIZE into config - config = 'WIC_SECTOR_SIZE = "4096"\n'\ - 'WICVARS:append = " WIC_SECTOR_SIZE"\n' - self.append_config(config) bitbake('core-image-minimal')Quoted 13 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""")
Quoted 13 lines
meta/lib/oeqa/selftest/cases/wic.py +0
-8- # Check WIC_SECTOR_SIZE apply to bitbake variable - wic_sector_size_str = get_bb_var('WIC_SECTOR_SIZE', 'core-image-minimal') - wic_sector_size = int(wic_sector_size_str) - self.assertEqual(4096, wic_sector_size) - - self.logger.info("Test wic_sector_size: %d \n" % wic_sector_size) - with NamedTemporaryFile("w", suffix=".wks") as wks: wks.writelines( ['bootloader --ptable gpt\n', - 'part --fstype ext4 --source rootfs --labelrofs-a
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""") · line 965
Quoted 2 lines
meta/lib/oeqa/selftest/cases/wic.py +0
-2--mkfs-extraopts "-b 4096"\n', - 'part --fstype ext4 --source rootfs--use-uuid
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""") · line 954
Quoted 4 lines
meta/lib/oeqa/selftest/cases/wic.py +2
-1--mkfs-extraopts "-b 4096"\n']) + 'part --fstype ext4 --source rootfs --label rofs-a\n', + 'part --fstype ext4 --source rootfs--use-uuid\n'])
Quoted 2 lines
Quoted 2 lines
wks.flush()- cmd = "wic create %s -e core-image-minimal -o %s"
% (
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
wks.name, self.resultdir)
+ cmd = "wic create %s -e core-image-minimal -o %s
--sector-size 4096" % (wks.name, self.resultdir)runCmd(cmd) wksname = os.path.splitext(os.path.basename(wks.name
Quoted 7 lines
Quoted 7 lines
))[0]
Quoted 1 line
Quoted 1 line
images = glob(os.path.join(self.resultdir,
"%s-*direct" %
Quoted 4 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""") · line 959
Quoted 4 lines
wksname))
meta/lib/oeqa/selftest/cases/wic.py +0
-0@@ -969,24 +958,18 @@ bootloader --ptable gpt""") sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE','wic-tools')
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""") · line 972
Quoted 2 lines
meta/lib/oeqa/selftest/cases/wic.py +0
-1# list partitions - result = runCmd("wic ls %s -n %s" % (images[0],sysroot))
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
meta/lib/oeqa/selftest/cases/wic.py bootloader --ptable gpt""")
Quoted 6 lines
meta/lib/oeqa/selftest/cases/wic.py +1
-2+ result = runCmd("wic ls %s -n %s --sector-size 4096" % (images[0], sysroot)) self.assertEqual(3, len(result.output.split('\n'))) - # verify partition size with wic - res = runCmd("export PARTED_SECTOR_SIZE=%d; parted -m%s
Quoted 4 lines
Quoted 4 lines
unit
Quoted 3 lines
Quoted 3 lines
meta/lib/oeqa/selftest/cases/wic.py +2
-0b p" % (wic_sector_size, images[0]), + # verify partition size with parted output + res = runCmd("export PARTED_SECTOR_SIZE=%d; parted -m%s
Quoted 9 lines
Quoted 9 lines
unit
Quoted 7 lines
Quoted 7 lines
meta/lib/oeqa/selftest/cases/wic.py +0
-3b p" % (4096, images[0]), stderr=subprocess.PIPE) - # parse parted output which looks like this: - # BYT;\n - #/var/tmp/wic/build/tmpgjzzefdd-202410281021-sda.direct:78569472B:file:4096:4096:gpt::;\n
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
meta/lib/oeqa/selftest/cases/wic.py +0
-4- # 1:139264B:39284735B:39145472B:ext4:rofs-a:;\n - # 2:39284736B:78430207B:39145472B:ext4:primary:;\n disk_info = res.output.splitlines()[1] - # Check sector sizes sector_size_logical = int(disk_info.split(":")[3]) sector_size_physical = int(disk_info.split(":")[4]) - self.assertEqual(wic_sector_size, sector_size_logical,"Logical sector size is not %d." %
wic_sector_size)
- self.assertEqual(wic_sector_size,
sector_size_physical,Quoted 48 lines
Quoted 48 lines
Quoted 2 lines
Quoted 2 lines
"Physical sector size is not %d." %
wic_sector_size)
+ self.assertEqual(4096,sector_size_logical, "Logicalsector
Quoted 2 lines
Quoted 2 lines
size is not 4096.")
+ self.assertEqual(4096,sector_size_physical, "Physicalsector
Quoted 11 lines
Quoted 11 lines
size is not 4096.")
finally:
os.environ['PATH'] = oldpathscripts/lib/wic/engine.py +0
-0@@ -224,7 +224,7 @@ def wic_list(args, scripts_path):Quoted 2 lines
scripts/lib/wic/engine.py def wic_list(args, scripts_path): · line 227
Quoted 2 lines
scripts/lib/wic/engine.py +0
-1class Disk: - def __init__(self, imagepath, native_sysroot, fstypes=('fat','ext')):
Quoted 1 line
scripts/lib/wic/engine.py def wic_list(args, scripts_path): · line 227
Quoted 1 line
scripts/lib/wic/engine.py +1
-0+ def __init__(self, imagepath, native_sysroot, fstypes=('fat','ext'),
Quoted 26 lines
Quoted 26 lines
sector_size=512):
self.imagepath = imagepath
self.native_sysroot =native_sysroot
self.fstypes = fstypesscripts/lib/wic/engine.py +1
-10@@ -233,16 +233,7 @@ class Disk: self._lsector_size = None self._psector_size = None self._ptable_format = None - - # define sector size - sector_size_str = get_bitbake_var('WIC_SECTOR_SIZE') - if sector_size_str is not None: - try: - self.sector_size = int(sector_size_str) - except ValueError: - self.sector_size = None - else: - self.sector_size = None + self.sector_size = sector_size # find parted # read paths from $PATH environment variable@@ -271,7 +262,7 @@ class Disk: if self._partitions is None: self._partitions = OrderedDict()Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
scripts/lib/wic/engine.py class Disk:
Quoted 3 lines
scripts/lib/wic/engine.py +1
-1- if self.sector_size is not None: + if self.sector_size: out = exec_cmd("export PARTED_SECTOR_SIZE=%d; %s-sm
Quoted 7 lines
Quoted 7 lines
%s
Quoted 6 lines
scripts/lib/wic/engine.py class Disk: · line 303
Quoted 6 lines
scripts/lib/wic/engine.py +0
-0unit B print" % \ (self.sector_size, self.parted,self.imagepath), True)
else:scripts/lib/wic/engine.py +0
-0@@ -312,11 +303,15 @@ class Disk: raise WicError("Partition %s is not in the image" %pnum)
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
scripts/lib/wic/engine.py class Disk:
Quoted 3 lines
scripts/lib/wic/engine.py +1
-0part = self.partitions[pnum] # check if fstype is supported + # NOTE: parted is unable to identify dos-type partitionswith
Quoted 3 lines
Quoted 3 lines
a
Quoted 2 lines
Quoted 2 lines
4k sector-size
+ # if the type is empty and a non-default sectorsize is
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
scripts/lib/wic/engine.py
Quoted 3 lines
used, assume 'fat'
scripts/lib/wic/engine.py +2
-0+ # fdisk identifies them without issue + part_fstype = part.fstype if part.fstype orself.sector_size
Quoted 9 lines
Quoted 9 lines
==
Quoted 7 lines
scripts/lib/wic/engine.py class Disk:
Quoted 7 lines
512 else 'fat'
for fstype in self.fstypes:scripts/lib/wic/engine.py +1
-2- if part.fstype.startswith(fstype): + if part_fstype.startswith(fstype): break else: - raise WicError("Not supported fstype:{}".format(part.fstype))
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line
+ raise WicError("Not supported fstype:
{}".format(part_fstype))
Quoted 6 lines
scripts/lib/wic/engine.py class Disk: · line 582
Quoted 6 lines
if pnum not in self._partimages:
tmpf =tempfile.NamedTemporaryFile(prefix="wic-part")dst_fname= tmpf.namescripts/lib/wic/engine.py +0
-0@@ -586,8 +581,9 @@ class Disk: label = part.get("name") label_str = "-n {}".format(label) iflabel
Quoted 31 lines
Quoted 31 lines
Quoted 3 lines
Quoted 3 lines
else ''
- cmd = "{} {} -C {}
{}".format(self.mkdosfs,
Quoted 2 lines
Quoted 2 lines
label_str, partfname,
-part['size'])
Quoted 1 line
Quoted 1 line
+
sector_str= "-S{}".format(self.sector_size)
Quoted 4 lines
Quoted 4 lines
if self.sector_size else ''
+ cmd = "{} {} {} -C {}
{}".format(self.mkdosfs,label_str,sector_str, partfname, +part['size'])
Quoted 2 lines
Quoted 2 lines
exec_cmd(cmd)
# copy content from the temporarydirectory
Quoted 5 lines
Quoted 5 lines
to the new partition
cmd = "{} -snompi {} {}/*::".format(self.mcopy, partfname, tmpdir)
scripts/lib/wic/engine.py +0
-0@@ -609,14 +605,19 @@ class Disk:Quoted 8 lines
scripts/lib/wic/engine.py class Disk:
Quoted 8 lines
scripts/lib/wic/engine.py +1
-1def wic_ls(args, native_sysroot): """List contents of partitioned image or vfat partition.""" - disk = Disk(args.path.image, native_sysroot) + disk = Disk(args.path.image, native_sysroot, sector_size=args.sector_size) if not args.path.part: if disk.partitions: print('Num Start End SizeFstype')
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
scripts/lib/wic/engine.py class Disk:
Quoted 11 lines
scripts/lib/wic/engine.py +1
-0for part in disk.partitions.values(): + # size values are in bytes from parted; convert tosectors if a custom sector size was requested
scripts/lib/wic/engine.py +2
-0+ display_size = part.size + if args.sector_size and args.sector_size !=disk._lsector_size:
scripts/lib/wic/engine.py +2
-2+ display_size = part.size // args.sector_size print("{:2d} {:12d} {:12d} {:12d} {}".format(\ - part.pnum, part.start, part.end, - part.size, part.fstype)) + part.pnum, part.start //args.sector_size,
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
scripts/lib/wic/engine.py +4
-2+ part.end // args.sector_size, + display_size, part.fstype)) else: path = args.path.path or '/' print(disk.dir(args.path.part, path))@@ -627,9 +628,9 @@ def wic_cp(args, native_sysroot): partitioned image. """ if isinstance(args.dest, str): - disk = Disk(args.src.image, native_sysroot) + disk = Disk(args.src.image, native_sysroot, sector_size=args.sector_size) else: - disk = Disk(args.dest.image, native_sysroot) + disk = Disk(args.dest.image, native_sysroot, sector_size=args.sector_size) disk.copy(args.src, args.dest)Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
scripts/lib/wic/engine.py def wic_rm(args, native_sysroot): · line 644
Quoted 8 lines
scripts/lib/wic/engine.py +1
-1@@ -638,7 +639,7 @@ def wic_rm(args, native_sysroot): Remove files or directories from the vfat partition of partitioned image. """ - disk = Disk(args.path.image, native_sysroot) + disk = Disk(args.path.image, native_sysroot, sector_size=args.sector_size) disk.remove(args.path.part, args.path.path,args.recursive_delete)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
scripts/lib/wic/help.py wic_create_usage = """ · line 118
Quoted 8 lines
scripts/lib/wic/engine.py +0
-0def wic_write(args, native_sysroot):scripts/lib/wic/help.py +0
-0@@ -118,7 +118,7 @@ wic_create_usage = """ usage: wic create <wks file or image name> [-o <DIRNAME> |--outdir
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
<DIRNAME>]
[-e | --image-name] [-s, --skip-build-check] [-D,--debug]
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
[-r, --rootfs-dir] [-b, --bootimg-dir]- [-k, --kernel-dir] [-n, --native-sysroot] [-f,
--build-rootfs]
Quoted 1 line
Quoted 1 line
+ [-k, --kernel-dir] [-n, --native-sysroot]
[--sector-size
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
<bytes>] [-f, --build-rootfs]
[-c, --compress-with] [-m, --bmap]This command creates an OpenEmbedded image based on the 'OE
kickstart
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
scripts/lib/wic/help.py +0
-0@@ -139,13 +139,16 @@ SYNOPSIS wic create <wks file or image name> [-o <DIRNAME> | --outdir<DIRNAME>]
[-e | --image-name] [-s, --skip-build-check] [-D, --debug] [-r, --rootfs-dir] [-b, --bootimg-dir]- [-k, --kernel-dir] [-n, --native-sysroot] [-f,
--build-rootfs]
Quoted 10 lines
Quoted 10 lines
Quoted 1 line
Quoted 1 line
+ [-k, --kernel-dir] [-n, --native-sysroot] [--sector-size
<bytes>]
Quoted 8 lines
Quoted 8 lines
[-f, --build-rootfs]
[-c, --compress-with] [-m, --bmap] [--no-fstab-update]DESCRIPTION
This command creates an OpenEmbedded image based on the 'OE kickstart commands' found in the <wks file>.+ Use the --sector-size option to select the sector size (in
bytes)
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
scripts/lib/wic/help.py wic_ls_usage = """ · line 281
Quoted 10 lines
scripts/lib/wic/help.py +2
-1+ used for partition layout calculations (default is 512). + In order to do this, wic needs to know the locations of the various build artifacts required to build the image.@@ -278,7 +281,7 @@ wic_ls_usage = """ List content of a partitioned image - usage: wic ls <image>[:<partition>[<path>]] [--native-sysroot<path>]
Quoted 1 line
Quoted 1 line
Quoted 1 line
scripts/lib/wic/help.py wic_ls_usage = """ · line 284
Quoted 1 line
scripts/lib/wic/help.py +1
-0+ usage: wic ls <image>[:<partition>[<path>]] [--native-sysroot<path>]
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
[--sector-size <bytes>]
This command outputs either list of image partitions or
directory
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
scripts/lib/wic/help.py SYNOPSIS · line 299
Quoted 7 lines
contents
of vfat and ext* partitions.scripts/lib/wic/help.py +0
-1@@ -296,7 +299,7 @@ SYNOPSIS wic ls <image> wic ls <image>:<vfat or ext* partition> wic ls <image>:<vfat or ext* partition><path> - wic ls <image>:<vfat or ext* partition><path> --native-sysroot<path>
Quoted 1 line
scripts/lib/wic/help.py SYNOPSIS · line 302
Quoted 1 line
scripts/lib/wic/help.py +1
-0+ wic ls <image>:<vfat or ext* partition><path> --native-sysroot<path>
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
scripts/lib/wic/help.py DESCRIPTION · line 340
Quoted 8 lines
[--sector-size <bytes>]
DESCRIPTION
This command lists either partitions of the image or directory
contentsscripts/lib/wic/help.py +0
-0@@ -336,6 +339,8 @@ DESCRIPTION The -n option is used to specify the path to the nativesysroot
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
scripts/lib/wic/help.py DESCRIPTION · line 342
Quoted 2 lines
scripts/lib/wic/help.py +1
-0containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used forpartition
Quoted 11 lines
Quoted 11 lines
math
Quoted 10 lines
scripts/lib/wic/help.py wic_cp_usage = """ · line 351
Quoted 10 lines
scripts/lib/wic/help.py +2
-1+ (default is 512 bytes). """@@ -343,7 +348,7 @@ wic_cp_usage = """ Copy files and directories to/from the vfat or ext* partition - usage: wic cp <src> <dest> [--native-sysroot <path>] + usage: wic cp <src> <dest> [--native-sysroot <path>][--sector-size
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
scripts/lib/wic/help.py SYNOPSIS · line 367
Quoted 9 lines
<bytes>]
source/destination image in format <image>:<partition>[<path>]
scripts/lib/wic/help.py +0
-1@@ -364,7 +369,7 @@ SYNOPSIS wic cp <src> <dest>:<partition> wic cp <src>:<partition> <dest> wic cp <src> <dest-image>:<partition><path> - wic cp <src> <dest-image>:<partition><path> --native-sysroot<path>
Quoted 1 line
Quoted 1 line
scripts/lib/wic/help.py +1
-0+ wic cp <src> <dest-image>:<partition><path> --native-sysrootQuoted 8 lines
Quoted 8 lines
<path>
Quoted 7 lines
scripts/lib/wic/help.py DESCRIPTION · line 414
Quoted 7 lines
[--sector-size <bytes>]
DESCRIPTION
This command copies files or directories eitherscripts/lib/wic/help.py +0
-0@@ -408,13 +413,15 @@ DESCRIPTION The -n option is used to specify the path to the nativesysroot
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
scripts/lib/wic/help.py DESCRIPTION · line 416
Quoted 2 lines
scripts/lib/wic/help.py +1
-0containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used forpartition
Quoted 12 lines
Quoted 12 lines
math
Quoted 11 lines
Quoted 11 lines
scripts/lib/wic/help.py +2
-1+ (default is 512 bytes). """ wic_rm_usage = """ Remove files or directories from the vfat or ext* partitions - usage: wic rm <image>:<partition><path> [--native-sysroot <path>] + usage: wic rm <image>:<partition><path> [--native-sysroot <path>][--sector-size <bytes>]
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
scripts/lib/wic/help.py DESCRIPTION · line 474
Quoted 6 lines
This command removes files or directories from the vfat or ext*
partitions of
the partitioned image.scripts/lib/wic/help.py +0
-0@@ -466,6 +473,8 @@ DESCRIPTION The -n option is used to specify the path to the nativesysroot
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
scripts/lib/wic/help.py DESCRIPTION · line 476
Quoted 2 lines
scripts/lib/wic/help.py +1
-0containing the tools(parted and mtools) to use. + The --sector-size option sets the sector size used forpartition
Quoted 12 lines
Quoted 12 lines
math
Quoted 5 lines
Review
Quoted 5 lines
scripts/lib/wic/help.py +1
-0+ (default is 512 bytes). The -r option is used to remove directories and their contents recursively,this only applies to ext* partition.(quoted diff) +0
-0
b/scripts/lib/wic/partition.pyQuoted 5 lines
Quoted 5 lines
index
8fed686e903e..df6e3271649b100644scripts/lib/wic/partition.py +0
-0@@ -65,6 +65,50 @@ class Partition():Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
scripts/lib/wic/partition.py class Partition():
Quoted 7 lines
scripts/lib/wic/partition.py +5
-0self.lineno = lineno self.source_file = "" + self.sector_size = 512 + + def _mkdosfs_extraopts(self): + """ + Build mkdosfs extra options ensuring the CLI sector sizeis
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
applied.
scripts/lib/wic/partition.py +12
-0+ """ + extraopts = self.mkfs_extraopts or '' + tokens = [] + skip_next = False + for tok in extraopts.split(): + if skip_next: + skip_next = False + continue + if tok == '-S': + skip_next = True + continue + if tok.startswith('-S'):Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
scripts/lib/wic/partition.py class Partition():
Quoted 8 lines
scripts/lib/wic/partition.py +8
-0+ continue + tokens.append(tok) + tokens.extend(['-S', str(self.sector_size)]) + return ' '.join(tokens).strip() + + def _mkfs_ext_extraopts(self, base_opts): + """ + Build mkfs.ext* extra options ensuring the CLI sectorsize is
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
scripts/lib/wic/partition.py class Partition():
Quoted 4 lines
applied.
scripts/lib/wic/partition.py +3
-0+ """ + extraopts = self.mkfs_extraopts or base_opts + # Only add an explicit block size when a non-defaultsector
Quoted 19 lines
Quoted 19 lines
size
Quoted 18 lines
Quoted 18 lines
is requested.
scripts/lib/wic/partition.py +16
-0+ if self.sector_size and self.sector_size != 512: + tokens = [] + skip_next = False + for tok in extraopts.split(): + if skip_next: + skip_next = False + continue + if tok == '-b': + skip_next = True + continue + if tok.startswith('-b'): + continue + tokens.append(tok) + tokens.extend(['-b', str(self.sector_size)]) + return ' '.join(tokens).strip() + return extraoptsQuoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
def
get_extra_block_count(self, current_blocks):
"""scripts/lib/wic/partition.py +1
-0@@ -138,6 +182,8 @@ class Partition(): Prepare content for individual partitions, depending on partition command parameters. """ + # capture the sector size requested on the CLI for mkdosfsinvocations
+ self.sector_size =getattr(creator, 'sector_size', 512)or 512
Quoted 29 lines
Quoted 29 lines
Quoted 2 lines
Quoted 2 lines
self.updated_fstab_path =
updated_fstab_pathif self.updated_fstab_path and not(
self.fstype.startswith("ext")Quoted 11 lines
scripts/lib/wic/partition.py class Partition(): · line 345
Quoted 11 lines
or self.fstype == "msdos"):
self.update_fstab_in_rootfs = Truescripts/lib/wic/partition.py +1
-1@@ -293,7 +339,7 @@ class Partition(): with open(rootfs, 'w') as sparse: os.ftruncate(sparse.fileno(), rootfs_size * 1024) - extraopts = self.mkfs_extraopts or "-F -i 8192" + extraopts = self._mkfs_ext_extraopts("-F -i 8192") # use hash_seed to generate reproducible ext4 images (extraopts, pseudo) = self.get_hash_seed_ext4(extraopts,pseudo)
Quoted 9 lines
scripts/lib/wic/partition.py class Partition(): · line 453
Quoted 9 lines
scripts/lib/wic/partition.py +1
-1@@ -401,7 +447,7 @@ class Partition(): size_str = "" - extraopts = self.mkfs_extraopts or '-S 512' + extraopts = self._mkdosfs_extraopts() dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \ (label_str, self.fsuuid, size_str, extraopts,rootfs,
Quoted 4 lines
Quoted 4 lines
scripts/lib/wic/partition.py +0
-0@@ -452,7 +498,7 @@ class Partition(): with open(rootfs, 'w') as sparse: os.ftruncate(sparse.fileno(), size * 1024)Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
scripts/lib/wic/partition.py class Partition():
Quoted 5 lines
scripts/lib/wic/partition.py +1
-1- extraopts = self.mkfs_extraopts or "-i 8192" + extraopts = self._mkfs_ext_extraopts("-i 8192") # use hash_seed to generate reproducible ext4 images (extraopts, pseudo) = self.get_hash_seed_ext4(extraopts,None)
Quoted 27 lines
Quoted 27 lines
Quoted 9 lines
scripts/lib/wic/partition.py class Partition(): · line 550
Quoted 9 lines
scripts/lib/wic/partition.py +1
-1@@ -498,7 +544,7 @@ class Partition(): size_str = "" - extraopts = self.mkfs_extraopts or '-S 512' + extraopts = self._mkdosfs_extraopts() dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \ (label_str, self.fsuuid, extraopts, size_str,rootfs,
Quoted 2 lines
scripts/lib/wic/partition.py class Partition(): · line 605
Quoted 2 lines
scripts/lib/wic/partition.py +0
-0@@ -559,4 +605,3 @@ class Partition(): logger.warn("%s Inodes (of size %d) are toosmall." %
Quoted 14 lines
Quoted 14 lines
scripts/lib/wic/partition.py +0
-1(get_err_str(self), size)) break -scripts/lib/wic/plugins/imager/direct.py +1
-0@@ -67,6 +67,7 @@ class DirectPlugin(ImagerPlugin): self._image = None self.ptable_format = self.ks.bootloader.ptable self.parts = self.ks.partitions + self.sector_size = options.sector_size or 512Quoted 1 line
Quoted 1 line
Quoted 1 line
scripts/lib/wic/plugins/imager/direct.py class DirectPlugin(ImagerPlugin): · line 72
Quoted 1 line
scripts/lib/wic/plugins/imager/direct.py +0
-0# as a convenience, set source to the boot partitionsource
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
scripts/lib/wic/plugins/imager/direct.py class DirectPlugin(ImagerPlugin): · line 79
Quoted 3 lines
scripts/lib/wic/plugins/imager/direct.py +0
-0# instead of forcing it to be set via bootloader --source@@ -78,7 +79,7 @@ class DirectPlugin(ImagerPlugin): image_path = self._full_path(self.workdir,self.parts[0].disk,
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
scripts/lib/wic/plugins/imager/direct.py class DirectPlugin(ImagerPlugin): · line 81
Quoted 2 lines
scripts/lib/wic/plugins/imager/direct.py +0
-0"direct") self._image = PartitionedImage(image_path,self.ptable_format,
Quoted 44 lines
Quoted 44 lines
Quoted 2 lines
scripts/lib/wic/plugins/imager/direct.py class DirectPlugin(ImagerPlugin): · line 83
Quoted 2 lines
scripts/lib/wic/plugins/imager/direct.py +0
-0self.ks.bootloader.diskid, self.parts,self.native_sysroot,
Quoted 18 lines
Quoted 18 lines
scripts/lib/wic/plugins/imager/direct.py +1
-1- options.extra_space) + options.extra_space, self.sector_size)def
setup_workdir(self, workdir):
if workdir:scripts/lib/wic/plugins/imager/direct.py +0
-3@@ -294,15 +295,13 @@ MBR_OVERHEAD = 1 # Overhead of the GPT partitioning scheme GPT_OVERHEAD = 34 -# Size of a sector in bytes -SECTOR_SIZE = 512 - class PartitionedImage(): """ Partitioned image in a file. """Quoted 8 lines
Quoted 8 lines
scripts/lib/wic/plugins/imager/direct.py +0
-1- def __init__(self, path, ptable_format, disk_id, partitions,native_sysroot=None, extra_space=0):
+ def __init__(self, path,ptable_format,disk_id, partitions,
native_sysroot=None, extra_space=0,
+ sector_size=512):
self.path = path # Path to the image file self.numpart = 0 # Number of allocated partitions self.realpart = 0 # Number of partitions in the partitiontable
Quoted 14 lines
Quoted 14 lines
scripts/lib/wic/plugins/imager/direct.py +1
-8@@ -332,14 +331,7 @@ class PartitionedImage(): self.partitions = partitions self.partimages = [] # Size of a sector used in calculations - sector_size_str = get_bitbake_var('WIC_SECTOR_SIZE') - if sector_size_str is not None: - try: - self.sector_size = int(sector_size_str) - except ValueError: - self.sector_size = SECTOR_SIZE - else: - self.sector_size = SECTOR_SIZE + self.sector_size = sector_size or 512Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
scripts/lib/wic/plugins/imager/direct.py class PartitionedImage(): · line 337
Quoted 2 lines
scripts/lib/wic/plugins/imager/direct.py +0
-0self.native_sysroot = native_sysroot num_real_partitions = len([p for p in self.partitions ifnot
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
p.no_table])
scripts/lib/wic/plugins/source/bootimg_efi.py +0
-0@@ -415,8 +415,9 @@ class BootimgEFIPlugin(SourcePlugin):Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
scripts/lib/wic/plugins/source/bootimg_efi.py class BootimgEFIPlugin(SourcePlugin):
Quoted 7 lines
scripts/lib/wic/plugins/source/bootimg_efi.py +3
-2label = part.label if part.label else "ESP" - dosfs_cmd = "mkdosfs -v -n %s -i %s -C %s %d" % \ - (label, part.fsuuid, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or 512 + dosfs_cmd = "mkdosfs -v -n %s -i %s -S %d -C %s %d" % \ + (label, part.fsuuid, sector_size, bootimg,blocks)
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin): · line 132
Quoted 10 lines
scripts/lib/wic/plugins/source/bootimg_efi.py +0
-0exec_native_cmd(dosfs_cmd, native_sysroot) logger.debug("mkdosfs:\n%s" % (str(out)))scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-0@@ -132,7 +132,7 @@ class BootimgPcbiosPlugin(SourcePlugin): cls._do_prepare_grub(part, cr_workdir,
oe_builddir,Quoted 6 lines
Quoted 6 lines
Quoted 1 line
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin): · line 133
Quoted 1 line
scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-0kernel_dir, rootfs_dir,
native_sysroot)Quoted 2 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin): · line 135
Quoted 2 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-1elif source_params['loader-bios'] == 'syslinux': - cls._do_prepare_syslinux(part, cr_workdir,
bootimg_dir,Quoted 1 line
Quoted 1 line
scripts/lib/wic/plugins/source/bootimg_pcbios.py +1
-0+ cls._do_prepare_syslinux(part, creator,
cr_workdir,Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-0bootimg_dir, kernel_dir, native_sysroot) else:raise WicError("unrecognized
bootimg_pcbiosloader:
Quoted 7 lines
Quoted 7 lines
%s" %
Quoted 6 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin): · line 145
Quoted 6 lines
source_params['loader-bios'])
scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-1@@ -142,7 +142,7 @@ class BootimgPcbiosPlugin(SourcePlugin): except KeyError: # Required by do_install_disk cls.loader = 'syslinux' - cls._do_prepare_syslinux(part, cr_workdir,
bootimg_dir,Quoted 18 lines
Quoted 18 lines
Quoted 11 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin): · line 243
Quoted 11 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +1
-0+ cls._do_prepare_syslinux(part, creator, cr_workdir, bootimg_dir, kernel_dir, native_sysroot)@classmethod
scripts/lib/wic/plugins/source/bootimg_pcbios.py +1
-1@@ -240,7 +240,7 @@ class BootimgPcbiosPlugin(SourcePlugin): cfg.close() @classmethod - def _do_prepare_syslinux(cls, part, cr_workdir, bootimg_dir, + def _do_prepare_syslinux(cls, part, creator, cr_workdir,
bootimg_dir,Quoted 3 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin):
Quoted 3 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-0kernel_dir, native_sysroot): """ Called to do the actual content population for a partitioni.e. it
Quoted 2 lines
Quoted 2 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-0@@ -292,8 +292,9 @@ class BootimgPcbiosPlugin(SourcePlugin):Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py class BootimgPcbiosPlugin(SourcePlugin):
Quoted 7 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +3
-2label = part.label if part.label else "boot" - dosfs_cmd = "mkdosfs -n %s -i %s -S 512 -C %s %d" % \ - (label, part.fsuuid, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or 512 + dosfs_cmd = "mkdosfs -n %s -i %s -S %d -C %s %d" % \ + (label, part.fsuuid, sector_size, bootimg,blocks)
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
scripts/lib/wic/plugins/source/bootimg_pcbios.py +0
-0exec_native_cmd(dosfs_cmd, native_sysroot) mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir)scripts/lib/wic/plugins/source/isoimage_isohybrid.py +0
-0@@ -367,8 +367,9 @@ class IsoImagePlugin(SourcePlugin):Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
scripts/lib/wic/plugins/source/isoimage_isohybrid.py class IsoImagePlugin(SourcePlugin):
Quoted 5 lines
scripts/lib/wic/plugins/source/isoimage_isohybrid.py +1
-2esp_label = source_params.get('esp_label', 'EFIimg') - dosfs_cmd = 'mkfs.vfat -n \'%s\' -S 512 -C %s %d' \ - % (esp_label, bootimg, blocks) + sector_size = getattr(creator, 'sector_size', 512) or512
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
scripts/wic def wic_init_parser_create(subparser): · line 376
Quoted 11 lines
scripts/lib/wic/plugins/source/isoimage_isohybrid.py +2
-0+ dosfs_cmd = "mkfs.vfat -n '%s' -S %d -C %s %d" % \ + (esp_label, sector_size, bootimg, blocks) exec_native_cmd(dosfs_cmd, native_sysroot) mmd_cmd = "mmd -i %s ::/EFI" % bootimgscripts/wic +0
-0@@ -376,6 +376,8 @@ def wic_init_parser_create(subparser): default="direct", help="the wic imagerplugin")
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
scripts/wic def wic_init_parser_create(subparser): · line 377
Quoted 1 line
scripts/wic +0
-0subparser.add_argument("--extra-space", type=int,dest="extra_space",
Quoted 1 line
Quoted 1 line
scripts/wic +0
-0default=0, help="additional free disk spaceto
Quoted 16 lines
Quoted 16 lines
add
Quoted 2 lines
scripts/wic def wic_init_parser_create(subparser): · line 380
Quoted 2 lines
scripts/wic +1
-0to the image") + subparser.add_argument("--sector-size", dest="sector_size",type=int,
Quoted 11 lines
scripts/wic def imgtype(arg): · line 419
Quoted 11 lines
scripts/wic +2
-0default=512, + help="sector size in bytes (default: 512)") return@@ -413,6 +415,8 @@ def imgtype(arg): def wic_init_parser_ls(subparser): subparser.add_argument("path", type=imgtype, help="image spec: <image>[:<vfat partition>[<path>]]") + subparser.add_argument("--sector-size", dest="sector_size",type=int,
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
scripts/wic def imgtype(arg): · line 421
Quoted 2 lines
scripts/wic +1
-0default=512, + help="sector size in bytes (default:512)")
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
scripts/wic +0
-0subparser.add_argument("-n", "--native-sysroot",help="path to the native sysroot
containing
Quoted 3 lines
Quoted 3 lines
the
Quoted 2 lines
Quoted 2 lines
tools")
subparser.add_argument("-e", "--image-name",dest="image_name",
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
scripts/wic def wic_init_parser_cp(subparser): · line 442
Quoted 7 lines
scripts/wic +1
-0@@ -433,6 +437,8 @@ def wic_init_parser_cp(subparser): help="image spec: <image>:<vfat partition>[<path>] or <file>") subparser.add_argument("dest", help="image spec: <image>:<vfat partition>[<path>] or <file>") + subparser.add_argument("--sector-size", dest="sector_size",type=int,
Quoted 2 lines
Quoted 2 lines
scripts/wic +1
-0default=512, + help="sector size in bytes (default:512)")
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
subparser.add_argument("-n", "--native-sysroot",
help="path to the native sysrootcontaining
Quoted 3 lines
Quoted 3 lines
the
Quoted 2 lines
Quoted 2 lines
tools")
subparser.add_argument("-e", "--image-name",dest="image_name",
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
scripts/wic def wic_init_parser_cp(subparser): · line 453
Quoted 4 lines
scripts/wic +0
-0@@ -445,6 +451,8 @@ def wic_init_parser_cp(subparser): def wic_init_parser_rm(subparser): subparser.add_argument("path", type=imgpathtype, help="path: <image>:<vfatpartition><path>")
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
scripts/wic def wic_init_parser_cp(subparser): · line 454
Quoted 1 line
scripts/wic +1
-0+ subparser.add_argument("--sector-size", dest="sector_size",type=int,
Quoted 2 lines
Quoted 2 lines
scripts/wic +1
-0default=512, + help="sector size in bytes (default:512)")
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
scripts/wic def wic_init_parser_cp(subparser): · line 458
Quoted 2 lines
scripts/wic +0
-0subparser.add_argument("-n", "--native-sysroot", help="path to the native sysrootcontaining
Quoted 8 lines
Quoted 8 lines
the
Quoted 7 lines
Quoted 7 lines
tools")
subparser.add_argument("-r", dest="recursive_delete",
action="store_true", default=False,
--
2.51.0Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#231176):
https://lists.openembedded.org/g/openembedded-core/message/231176
Mute This Topic:https://lists.openembedded.org/mt/117833550/1050810
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Group Owner: [email protected] Unsubscribe:
https://lists.openembedded.org/g/openembedded-core/unsub
Quoted 8 lines
Quoted 8 lines
[
Quoted 7 lines
Quoted 4 lines
[email protected]]
-=-=-=-=-=-=-=-=-=-=-=---
- Thou shalt not follow the NULL pointer, for chaos and madness awaitQuoted 8 lines
Quoted 4 lines
thee
Quoted 2 lines
at its end
- "Use the force Harry" - Gandalf, Star Trek II--
- Thou shalt not follow the NULL pointer, for chaos and madness awaitthee
Quoted 2 lines
at its end
- "Use the force Harry" - Gandalf, Star Trek IISignature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end - "Use the force Harry" - Gandalf, Star Trek II