summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/plugins
Commit message (Collapse)AuthorAgeFilesLines
* wic: bootimg-efi: fix error handlingEnrico Jörns10 days1-2/+2
| | | | | | | | | | | | | | | If we check for empty variables, it does not make sense to print their content in case they are empty. Additionally, the error message in the 'kernel' check attempted to print the wrong variable ('target') which was not even defined, yet. Also, raising WicError doesn't require an extra newline. (From OE-Core rev: f31cf475d0235f42d73aeec07694f79b9937fd76) Signed-off-by: Enrico Jörns <ejo@pengutronix.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* rootfs.py: Fix logger error message formatJohn Ripple2024-04-251-1/+1
| | | | | | | | | | | | | | | | --_000_PH7PR17MB61307CB6690EC00DEB4ED9B39C0F2PH7PR17MB6130namp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable This patch adds a missing "%s" format in a logger.error call. Without this addition the logger itself would error out and not print a useful message. (From OE-Core rev: 2c892e5dd9ba72a51c0a8fb851599cc2dc3a8b5c) Signed-off-by: John Ripple <john.ripple@keysight.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: bootimg-partition allow to set var to get boot filesAnibal Limon2024-03-261-2/+3
| | | | | | | | | | | | This is a generic functionality that takes a set of files and create a boot parition based on IMAGE_BOOT_FILES var, allow to sepcify the variable name so a BSP plugin can extend this and re-use the functionality. (From OE-Core rev: 3a2339455be29a6ff65c8c5f6865a4cd35dd7f63) Signed-off-by: Anibal Limon <anibal@limonsoftware.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: 'empty' plugin: fix typo in commentEnrico Jörns2024-02-271-1/+1
| | | | | | | (From OE-Core rev: 1a9013c3767d174a970d31e80748bc8d73af0dba) Signed-off-by: Enrico Jorns <ejo@pengutronix.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: implement reproducible Disk GUIDAdithya Balakumar2024-02-081-0/+11
| | | | | | | | | | | GPT based disks have a disk guid apart from the 32-bit disk identifier. This commit implements reproducible disk guid by using SOURCE_DATE_EPOCH (if available) value as a random seed (From OE-Core rev: 150e079589e207fe174d2dceb40cd8f3d3972c5a) Signed-off-by: Adithya Balakumar <Adithya.Balakumar@toshiba-tsip.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: extend empty plugin with options to write zeros to partitonMalte Schmidt2023-12-061-1/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | Adds features to explicitly write zeros to the start of the partition. This is useful to overwrite old content like filesystem signatures which may be re-recognized otherwise. The new features can be enabled with '--soucreparams="[fill|size=<N>[S|s|K|k|M|G]][,][bs=<N>[S|s|K|k|M|G]]"' Conflicting or missing options throw errors. The features are: - fill Fill the entire partition with zeros. Requires '--fixed-size' option to be set. - size=<N>[S|s|K|k|M|G] Set the first N bytes of the partition to zero. Default unit is 'K'. - bs=<N>[S|s|K|k|M|G] Write at most N bytes at a time during source file creation. Defaults to '1M'. Default unit is 'K'. (From OE-Core rev: d19d4529e7a2056caeb526fed980cc1df19a5f6e) Signed-off-by: Malte Schmidt <malte.schmidt@weidmueller.com> Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: bootimg-efi: Make kernel image installation configurableKareem Zarka2023-12-041-3/+4
| | | | | | | | | | | | | | | | | | | | | The issue with installing the kernel image to both rootfs and boot partition is that some systems rely on the kernel image in rootfs and not in the boot partition. This leads to duplication of the kernel image, which can cause unnecessary storage usage. This patch provides a solution to the problem by adding a new parameter "install-kernel-into-boot-dir" to the wic kickstart file. If this parameter is set to 'true', the plugin will install the kernel image to the boot partition. If the parameter is set to 'false', the plugin will skip installing the kernel image, avoiding duplication. (From OE-Core rev: d3599afe5f604ea5afd9411e114934dcb52b2d48) Signed-off-by: Kareem Zarka <kareem.zarka@huawei.com> Signed-off-by: Christian Taedcke <christian.taedcke@weidmueller.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: rawcopy: add support for zstd decompressionMalte Schmidt2023-11-271-1/+2
| | | | | | | | | | | Add support for zstd decompression in rawcopy plugin. zstd claims to reach higher, uniform decompression rates. (From OE-Core rev: 707471b71a417187f1e581d0c540e058825f7242) Signed-off-by: Malte Schmidt <malte.schmidt@weidmueller.com> Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: bootimg-partition: Fix file name in debug messageDaniel Semkowicz2023-10-011-1/+1
| | | | | | | | | | Debug message about using custom configuration file includes file name with incorrect extension. Correct file name to "extlinux.conf". (From OE-Core rev: dd63e1520454b2d53a48b72eaae126059af9809b) Signed-off-by: Daniel Semkowicz <dse@thaumatec.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: Add gpt-hybrid partition layoutJoshua Watt2023-09-021-16/+66
| | | | | | | | | | | | | | | | | | | | | | | Add support for formatting a disk with a hybrid MBR & GPT partition scheme. In this scheme, the primary partitioning method is GPT, but a valid MBR header is also written than can point to a subset of the GPT partitions on the disk (any partitions marked with the `--mbr` flag will be included in this MBR). The primary purpose of this method is to allow for SoCs that can only find a bootloader in an MBR partition to use GPT once the bootloader is running. As an example, older versions of the Raspberry Pi firmware can only parse MBR partitions to find a kernel (or other bootloader like u-boot), but once those have booted GPT partitions can be used. In addition to the partitions annotated with the `--mbr`, a "protective" GPT partition of type 0xEE is added, as the existence of such a partition is the indication to tooling that this a hybrid MBR and that the GPT partition table should be parsed instead. (From OE-Core rev: e50e4c2a5ada6947b3503ca4d8e9c30d359e8a5d) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: bootimg-efi: Stop hardcoding VMA offsetsAlexandre Belloni2023-08-091-14/+49
| | | | | | | | | | | | | | | | Section VMA's are currently hardcoded. This doesn't work anymore starting with systemd-boot v254. Follow the actually solution to this which is documented here: https://wiki.archlinux.org/title/Unified_kernel_image#Manually This is also used by dracut. Later on, we may want to switch to ukify instead but this is not ready yet. (From OE-Core rev: 3abf99a6c6bde2fb8770f54dba609b35f6c6ee5a) Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* image_types: Fix reproducible builds for initramfs and UKI imgFrieder Paape2023-06-061-0/+2
| | | | | | | | | | | | | | | | | | | I've encountered issues reproducing initramfs and UKI image builds, which will be fixed with this patch. 1. initramfs There's a symbolic link to /sbin/init, which is appended to the cpio archive after creation. The links timestamp needs to be static and the cpio append command needs the '--reproducible' flag to produce deterministic outcomes. 2. Unified Kernel Image '--preserve-dates' is required for a static 'Time/Date' entry. I've added '--enable-deterministic-archives' although in my case this didn't change anything. (From OE-Core rev: fd027729bafb4e085ba0949e38e724f3a8cad102) Signed-off-by: Frieder Paape <frieder@konvera.io> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: Add argument --hidden to default imagerLeon Anavi2023-05-251-0/+7
| | | | | | | | | | | | | | | | | | | Add argument --hidden to avoid MS Windows prompting to format partition after flashing to a USB stick, SD card on another media. Set Bit 0 (RequiredPartition) to mark that the partition is required for the platform to function on GUID Partition Table (GPT). The new argument simplifies setting RequiredPartition on GPT through a WKS file and the default imager plugin. Otherwise, without this feature, to achieve the same result a new imager plugin has to be implemented and set in WIC_CREATE_EXTRA_ARGS. (From OE-Core rev: 7a111ff58d7390b79e2e63c8059f6c25f40f8977) Signed-off-by: Leon Anavi <leon.anavi@konsulko.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: add support for proper kernel name to bootimg-pcbiosSergei Zhmylev2023-05-041-3/+3
| | | | | | | | | | Use appropriate kernel image name instead of hard-coded vmlinuz for bootimg-pcbios plugin. (From OE-Core rev: 8d9f00ba456fe76e0f4ef0e68ec64fc538c90d89) Signed-off-by: Sergei Zhmylev <s.zhmylev@yadro.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic/bootimg-efi: if fixed-size is set then use that for mkdosfsRandolph Sapp2023-04-271-0/+7
| | | | | | | | | | | | | | | This is a bit of a compatibility issue more than anything. Some devices get upset if the FAT file system contains less blocks than the partition. The fixed-size argument is currently respected by the partition creation step but not by the file system creation step. Let's make it so the file system respects this value as well. (From OE-Core rev: 38e1a235f5eceade7c871f96dc97f6c384384c7b) Signed-off-by: Randolph Sapp <rs@ti.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: use part_name when definedDit Kozmaj2023-04-131-10/+4
| | | | | | | | | | | | | | | So far part.label has been used to define GPT partition label even if part.part_name was defined. Fix the code to use part.part_name whenever available, as it makes sense to have a GPT partition label which is different from the contained filesystem label. (From OE-Core rev: 7704d5fc36eb065224792bf4d5543814eaa5fed3) Signed-off-by: Dit Kozmaj <dit.kozmaj@kynetics.com> Signed-off-by: Diego Rondini <diego.rondini@kynetics.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: Fix populating of IMAGE_EFI_BOOT_FILES with uefi-kernelPavel Zhukov2023-02-261-1/+1
| | | | | | | | | | | | | | | | wic plugin crashed if IMAGE_EFI_BOOT_FILES is not empty and uefi-kernel loader specified because of preliminary return from the function. [Yocto #15033] Fixes: | File "/mnt/builds/yocto/sources/scripts/lib/wic/plugins/source/bootimg-efi.py", line 371, in do_prepare_partition | for src_path, dst_path in cls.install_task: | ^^^^^^^^^^^^^^^^ | AttributeError: type object 'BootimgEFIPlugin' has no attribute 'install_task'. Did you mean: 'do_install_disk'? (From OE-Core rev: a6372f70f31b39ce9867b705d02205621d7a8685) Signed-off-by: Pavel Zhukov <pavel@zhukoff.net> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: swap partitions are not added to fstabciarancourtney2022-10-291-1/+1
| | | | | | | | | | - Regression in 7aa678ce804c21dc1dc51b9be442671bc33c4041 (From OE-Core rev: f1243572ad6b6303fe562e4eb7a9826fd51ea3c3) Signed-off-by: Ciaran Courtney <ciaran.courtney@activeenergy.ie> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: honor the SOURCE_DATE_EPOCH in case of updated fstabSergei Zhmylev2022-10-262-1/+4
| | | | | | | | | | | | | In case user requested to build a binary repeatable package, it's required to honor the SOURCE_DATE_EPOCH environment variable. So forcefully set mtime inside all the routines which modify fstab in case it is updated. (From OE-Core rev: 99719a3712a88dce8450994d995803e126e49115) Signed-off-by: Sergei Zhmylev <s.zhmylev@yadro.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: implement binary repeatable disk identifiersSergei Zhmylev2022-10-261-1/+4
| | | | | | | | | | | | When SOURCE_DATE_EPOCH variable is set, binary repeatable build is expected. This commit implements reproducable disk identifiers in such a case using its value as a Random seed. (From OE-Core rev: 2c0c54e12169e76f16fb3398904bc897a9190397) Signed-off-by: Sergei Zhmylev <s.zhmylev@yadro.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: bootimg-efi: implement --include-pathMaxim Uvarov2022-10-261-0/+5
| | | | | | | | | | | | --include-path can be used for placing files on ESP, like dtbs. (From OE-Core rev: 46ca73f504b0792766dc4d4bbad38beb04ef4ed0) Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: add UEFI kernel as UEFI stubMaxim Uvarov2022-10-261-0/+24
| | | | | | | | | | | | | | | | | | | Linux kernel can be compiled as UEFI stub and loaded directly with UEFI firmware without grub or other UEFI shell. Tested with wic file: bootloader --ptable gpt --timeout=0 --append="rootwait" part /boot --source bootimg-efi --sourceparams="loader=uefi-kernel" \ --ondisk sda --fstype=vfat --label bootfs \ --active --align 1024 --use-uuid part / --source rootfs --fstype=ext4 --label rootfs \ --align 1024 --exclude-path boot/ --use-label (From OE-Core rev: b18025fc8a2dad963b6f4b697e24455f2511b279) Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* Revert "wic/plugins/images/direct: Allow changes in fstab on rootfs"Ross Burton2022-09-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Commit 20d43a2 allows changes in fstab for the / mount. However, if the fstab contains / already then this results in two entries for / in the fstab, which is confusing and results in systemd producing errors on boot: systemd-fstab-generator[11101]: Failed to create unit file /run/systemd/generator/-.mount, as it already exists. Duplicate entry in /etc/fstab? Wic should be extended to support merging mount points in fstab, but as we're about to release revert the patch that introduced this change as it hasn't been in a release yet, and the issue which prompted the patch in the first place can be revisited post-release. [ YOCTO #14865 ] (From OE-Core rev: 4a7b3ef0a69b7e08030519b712a6fe4dd199c571) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: add 'none' fstype for custom imageJeongBong Seo2022-08-121-0/+4
| | | | | | | | | | | | | | | | | It's not possible to set the label (of gpt entry) normally when I want to use non-listed fstype as a rawcopy. Example) part ? --source rawcopy --ondisk mmcblk0 --label mypart --sourceparams file=mypart.raw To resolve this problem, this patch addes a 'none' fstype and ignore do_image_label on rawcopy (that actually set the partition label.) (From OE-Core rev: 949cf797eb54f3d22a093910087e937633ce9b23) Signed-off-by: JeongBong Seo <jb.seo@lge.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* scripts: Add copyright statements to files without oneRichard Purdie2022-08-124-0/+8
| | | | | | | | | | Where there isn't a copyright statement, add one to make it explicit. Also drop editor config lines where they were present and add license identifiers as MIT if there isn't one. (From OE-Core rev: deb3ccec53e0bd63bc4235cf2b0d3fc781687361) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic/bootimg-efi: Add support for loading devicetree filesJan Kiszka2022-08-021-7/+31
| | | | | | | | | | | | | | | | | | | | For device tree using systems, add support to set a custom devices tree during UEFI boot. This requires to copy the DTB file to the boot partition and to add the respective loader entries to the configuration files. Both grub and systemd-boot support only loading a specific device tree. Therefore refuse to work if the 'dtb' parameter contains more than one entry. Out of scope for now are overlays (only supported by systemd-boot). (From OE-Core rev: c5a14f39a6717a99b510cb97aa2fb403d4b98d99) Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> [Luca: rebased on commit 98e9d435b278 ("wic/bootimg-efi: use cross objcopy when building unified kernel image")] Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic/bootimg-efi: Factor out some common bitsJan Kiszka2022-08-021-25/+21
| | | | | | | | | | | | | | | | The paths for configuring grub and systemd-boot have some common bits around copying the initrd files. This will even grow when adding dtb support. Factor this out into a class function. Along this, avoid evaluating 'create-unified-kernel-image' multiple times in do_configure_systemdboot and suppress a bogus warning about "Ignoring missing initrd" when it is turned on. (From OE-Core rev: c700cfd88473b9ed4e12a6620fb089f41bd95a9e) Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic/bootimg-efi: use cross objcopy when building unified kernel imageRoss Burton2022-08-021-13/+12
| | | | | | | | | | | | | | We can't rely on the host objcopy knowing how to process target binaries, so use the cross objcopy in the sysroot instead. Also construct the command argument-by-argument as the format expression was getting unwieldy. (From OE-Core rev: 0264aeedbf21e9e7a104243c11b3b57f00e38bda) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic/plugins/rootfs: Fix NameError for 'orig_path'Mihai Lindner2022-07-231-1/+1
| | | | | | | | | | | Fix "NameError: name 'orig_path' is not defined". It's a typo from when this error was handled outside this function. (From OE-Core rev: 2124ec0d9f9de2da476f0024a0ccf70da987420f) Signed-off-by: Mihai Lindner <mihai.lindner@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic/plugins/images/direct: Allow changes in fstab on rootfsTobias Schmidl2022-05-271-1/+1
| | | | | | | | | | | | | | Allow wic to also manipulate the rootfs entry in fstab, which it currently refuses to write. Reasons one might want to do that include using systemd-growfs via --fsoptions on / With this change / is now handled exactly the same as other mountpoints, the former exception seemingly was not even documented. (From OE-Core rev: 20d43a2599d7622b96e2fb0da87a886da1a3794a) Signed-off-by: Tobias Schmidl <tobiasschmidl@siemens.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: added fspassno parameter to partitionClaudius Heine2022-05-161-1/+2
| | | | | | | | | | | | | The `fspassno` parameter allows to overwrite the value of the last column (`fs_passno`) in the /etc/fstab of the target root file system. This allows to have periodic file system checks. (From OE-Core rev: b9b9f71e6f37bfbf954ade518391b242669481e3) Signed-off-by: Claudius Heine <ch@denx.de> Signed-off-by: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic/plugins/rootfs: Fix permissions when splitting rootfs folders across ↵Felix Moessbauer2022-05-081-1/+4
| | | | | | | | | | | | | | | | | | partitions This patches makes locating the file database containing the file and folder usernames and permissions more reliable. In addition to locating it relative to the partition directory, we also try to locate it relative to the IMAGE_ROOTFS. Prior to this patch, the database was not found when using --rootfs-dir=${IMAGE_ROOTFS}/<x> in the WIC script, leading to erronous file permissions and ownership. (From OE-Core rev: 09e18ee246da8b56f446c4db548fb9c7e895142b) Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: do not use PARTLABEL for msdos partition tablesHenning Schild2022-04-221-1/+1
| | | | | | | | | | | | | | | When using "msdos" partition tables and "--label" but not "--use-uuid" one can generate images which will not find their root, because PARTLABEL does not work for "msdos". Fix that by simply not going the PARTLABEL path in case of "msdos". Fixes: 2fb247c5ecf0 ("wic: support rootdev identified by partition label") (From OE-Core rev: 9ea1a838b946020e026edc032039552b723fcaa4) Signed-off-by: Henning Schild <henning.schild@siemens.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: rawcopy: Add support for packed imagesStefan Herbrechtsmeier2022-02-161-1/+28
| | | | | | | | | | | | | | | Add support for packed images to wic rawcopy handler do minimize disk usage in deploy directory and reuse of packed images between wic and swupdate. Add `unpack` to sourceparams to unpack an bz2, gz and xz archives. Example: part / --source rawcopy --sourceparams="file=core-image-minimal-qemu.ext4.gz,unpack" (From OE-Core rev: 4c97d25791389ece041565981ba3207ce9949a1a) Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: support rootdev identified by partition labelSchmidt, Adriaan2021-11-241-0/+2
| | | | | | | | | | We already support specifying the rootfs by PARTUUID. This adds general support for letting the kernel find the rootfs by PARTLABEL. (From OE-Core rev: 2fb247c5ecf057bb96649a3c0234794b4991c050) Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: Use os.rename instead of bb.utils.renameKhem Raj2021-11-101-1/+1
| | | | | | | | | | | | | | | This is not invoked with bitbake context as a result bb.utils is not visible when this function is called during image creation and builds fail e.g. NameError: name 'bb' is not defined (From OE-Core rev: df9dca9fe4dd1abfe5f3986389a8e8ff524da5d7) Signed-off-by: Khem Raj <raj.khem@gmail.com> Cc: Joshua Watt <JPEWhacker@gmail.com> Cc: Devendra Tewari <devendra.tewari@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic/bootimg-efi: Add Unified Kernel Image optionKristian Klausen2021-10-041-10/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "A unified kernel image is a single EFI PE executable combining an EFI stub loader, a kernel image, an initramfs image, and the kernel command line. [...] Images of this type have the advantage that all metadata and payload that makes up the boot entry is monopolized in a single PE file that can be signed cryptographically as one for the purpose of EFI SecureBoot."[1] This commit adds a create-unified-kernel-image=true option to the bootimg-efi plugin for creating a Unified Kernel Image[1] and installing it into $BOOT/EFI/Linux/ with a .efi extension per the the Boot Loader Specification[1][2]. This is useful for implementing Secure Boot. systemd-boot is the only mainstream bootloader implementing the specification, but GRUB should be able to boot the EFI binary, this commit however doesn't implement the necessary changes to the GRUB config generation logic to boot the Unified Kernel Image. [1] https://systemd.io/BOOT_LOADER_SPECIFICATION/#type-2-efi-unified-kernel-images [2] https://systemd.io/BOOT_LOADER_SPECIFICATION/ (From OE-Core rev: b0573f240525df561ddef6e47cb285b217d38487) Signed-off-by: Kristian Klausen <kristian@klausen.dk> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic:direct.py: ignore invalid mountpoints during fstab updateMarkus Volk2021-09-261-1/+1
| | | | | | | | | | | | | | | | | | | | | wic fstab-update creates invalid entries for partitons that are not supposed to be mounted from userspace eg u-boot partitions. The following lines were added to fstab on a rock-pi-4: /dev/mmcblk1p1 loader1 vfat defaults 0 0 /dev/mmcblk1p2 reserved1 vfat defaults 0 0 /dev/mmcblk1p3 reserved2 vfat defaults 0 0 /dev/mmcblk1p4 loader2 vfat defaults 0 0 /dev/mmcblk1p5 atf vfat defaults 0 0 /dev/mmcblk1p6 /boot vfat defaults 0 0 With this patch only valid entries should be added /dev/mmcblk1p6 /boot vfat defaults 0 0 (From OE-Core rev: 7aa678ce804c21dc1dc51b9be442671bc33c4041) Signed-off-by: MarkusVolk <f_l_k@t-online.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: Add extra-space argumentKristian Klausen2021-09-061-2/+5
| | | | | | | | | | | | | This allows extra space to be added after the last partition and is especially useful when free space is needed for ex: adding partitions on first boot with ex: systemd-repart[1] and the image is tested in QEMU. [1] https://www.freedesktop.org/software/systemd/man/systemd-repart.html (From OE-Core rev: f81b188bcf5aa18746fd622eb7b5c0dcb0b5c93d) Signed-off-by: Kristian Klausen <kristian@klausen.dk> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: Add --no-fstab-update part optionDaniel Gomez2021-08-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | When embedding a rootfs image (e.g. 'rootfs-dir') as a partition we might want to keep the stock fstab for that image. In such a case, use this option to not update the fstab and use the stock one instead. This option allows you to specify which partitions get the fstab updated and which get the stock fstab. The option matches the argument you can pass to wic itself where the same action is performed but for all the partitions. Example: part /export --source rootfs --rootfs-dir=hockeycam-image --fstype=ext4 --label export --align 1024 --no-fstab-update part / --source rootfs --fstype=ext4 --label rootfs --align 1024 (From OE-Core rev: ab4c95af8ecd15dc136194ab761afae756db5803) Signed-off-by: Daniel Gomez <daniel@qtec.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* Use the label provided when formating a dos partitionjbouchard2021-06-291-2/+4
| | | | | | | | | | | | | | Previously the bootimg-pcbios wic plugin was not respecting the --label option provided from the wks file. The plugin was setting the label to 'boot'. With this fix, the --label option is use. If no option are specified, then the default is 'boot'. (From OE-Core rev: 0fd7a73c1bd2486b7a022f0f69bbcb2e0d9cb141) Signed-off-by: jbouchard <jeanbouch418@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* Add support for erofs filesystemsRichard Weinberger2021-05-311-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since Linux 5.4 a new read-only filesystem is available, erofs. Compared to squashfs it offers much better read performance with and without compression enabled. It suppports two optional compressors, lz4 and lz4hc. >From the mkfs.erofs man page: EROFS is a new enhanced lightweight linux read-only filesystem with modern designs (eg. no buffer head, reduced metadata, inline xattrs/data, etc.) for scenarios which need high-performance read-only requirements, e.g. Android OS for smartphones and LIVECDs. It also provides fixed-sized output compression support, which improves storage density, keeps relatively higher compression ratios, which is more useful to achieve high performance for embedded devices with limited memory since it has unnoticable memory overhead and page cache thrashing. This commit adds support for three new filesystem targets: erofs: erofs without compression erofs-lz4: erofs with lz4 compresssion enabled erofs-lz4hc: erofs with lz4hc compression enabled (From OE-Core rev: 41dead1ff8ccc49e6cd6e6f5d41a59d164693e0d) Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* classes/lib/scripts: Use bb.utils.rename() instead of os.rename()Devendra Tewari2021-05-061-1/+1
| | | | | | | | | | | | | | | | | | Incremental build in Docker fails with: OSError: [Errno 18] Invalid cross-device link when source and destination are on different overlay filesystems. Rather than adding fallback code to every call site, use a new wrapper in bitbake which detects this case and falls back to shutil.move which is slower but will handtle the overlay docker filesystems correctly. [YOCTO #14301] (From OE-Core rev: 656a65b2b84e7d529b89cf5de7eb838f902d84a2) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: debug mode to keep tmp directoryLee Chee Yang2021-02-091-2/+4
| | | | | | | | | | | | | | | files in wic tmp directory can be usefull for debugging, so do not remove tmp directory when wic create run with debugging mode (-D or --debug). also update wic.Wic.test_debug_short and wic.Wic.test_debug_long to check for tmp directory. [YOCTO#14216] (From OE-Core rev: a122e2418b67d38f691edcf8dd846c167d6b4fa9) Signed-off-by: Lee Chee Yang <Chee.Yang.Lee@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: Optimise fstab modification for ext2/3/4 and msdos partitionsPaul Barker2021-01-201-3/+6
| | | | | | | | | | | | | | | | | | The fix for [Yocto #13994] required the rootfs directory to be copied (using hardlinks if possible) when modifying the fstab file under wic. We can optimise this copy away for filesystems where we have the tools to modify the contents of the partition image after it is created. For ext2/3/4 filesystems we have the debugfs tool and for msdos/vfat filesystems we have the mcopy tool. So for any of these filesystems we skip the modification of the fstab file in the rootfs directory (and skip the associated copy unless it is otherwise necessary) and update the contents of fstab directly in the partition image. (From OE-Core rev: 5fb8ae0e9159597d7eaa9307a3a8543800bf9405) Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: Copy rootfs dir if fstab needs updatingPaul Barker2021-01-202-28/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By default, wic updates the /etc/fstab in the rootfs to include details of additional partitions described in the selected wks file. If this modification is performed in place, other tasks which create an image file from the rootfs directory (e.g. do_image_tar and do_image_ext4) will pick up the modified fstab file which would not be appropriate for those images as they do not include the additional partitions described in the wks file. wic does undo modifications to the fstab file once it has finished creating the filesystem image, however this leaves open a race condition if one of the other tasks reads the contents of the fstab file from the rootfs directory between the point where wic modifies the fstab file and the point where wic restores the files original content. This could be solved by adding a lockfile for tasks which use the rootfs directory to ensure that no other such task is reading the rootfs directory while do_image_wic is running. This would serialize several do_image_* tasks and result in slower builds, especially for large images. Another drawback of this solution is that it is hard to selectively optimise - adding lockfiles to do_image_* tasks would result in these tasks always being serialized even if no fstab modification will take place. An alternative solution is to copy the rootfs directory when fstab needs to be modified. The code to do this in wic already exists as it is needed when including or excluding content in the rootfs. This still results in an impact on build times but the copy uses hardlinks if possible (so little data is actually copied) and we can make selective optimisations to improve things. The rootfs copy will only take place if fstab modification is required (or if it was already needed to include or exclude rootfs content). We can also follow up with further optimisations after this commit. So this second solution is chosen. Fixes [Yocto #13994] (From OE-Core rev: ce682a73b7447652f898ce1d1d0416a456df5416) Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: Update pseudo db when excluding content from rootfsPaul Barker2021-01-201-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | To exclude content from the rootfs, wic makes a copy (using hardlinks if possible) of the rootfs directory and associated pseudo db, then removes files & directories as needed. However if these files and directories are removed using the python functions os.remove and shutil.rmtree, the copied pseudo db will not be updated correctly. For files copied from the original rootfs, if hardlinks were used successfully when copying the rootfs this should mean that the relevant inodes can't be reused and so the risk of pseudo aborts should be avoided. However, this logic doesn't apply for directories (as they can't be hardlinked) or for files added via the '--include-path' argument (as they weren't present in the original rootfs) and so there remains some risk of inodes being reused and the pseudo db becoming corrupted. To fix this, use the 'rm' command under pseudo when removing files & directories from the copied rootfs to ensure that the copied pseudo db is updated. (From OE-Core rev: d5db7e268947f0392c2126137571a44acd29ccd6) Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: Ensure internal workdir is not reusedPaul Barker2021-01-201-1/+11
| | | | | | | | | | | | If a path is specified for the internal wic working directory using the -w/--workdir argument then it must not already exist. Re-using a previous workdir could easily result in rootfs and intermediate files from a previous build being added to the current image. (From OE-Core rev: 2e40c8d4109024ff704c5ce40d98050ca7f34dd5) Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic: Add workdir argumentPaul Barker2021-01-131-1/+1
| | | | | | | | | | This allows the path for the temporary workdir used by wic to be set when running wic from bitbake or directly from the command line. (From OE-Core rev: 2e7314ac3a3cab89de93c932e8efc75de0feb0a7) Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* wic/direct/kparser: ensure fsuuid for vfat and msdos align with formatLee Chee Yang2021-01-011-0/+7
| | | | | | | | | | | | | | | | | | | | | | vfat/msdos filesystem should have fsuuid in format 0xYYYYYYYY where "0x" in front follow with 8 hexadecimal number in uppercase. In wic, when using custom fsuuid for vfat/msdos partition in wks, it is able to set the value in any length, with or without leading "0x". This can cause fsuuid missaligned when fstab updates, fstab expect exactly 10 character fsuuid for vfat/msdos partition and all in uppercase. if custom fsuuid for vfat/msdos is set, check the length and format, error if it exceed the format size. Amend it so it is align with format 0xYYYYYYYY. This is done before image create and fstab update to ensure the fsuuid are same in all followup process. if custom fsuuid length less than expected, fill in "0". [YOCTO #14161] (From OE-Core rev: d9686ae511ef10a504becfd81bfe296b788e1456) Signed-off-by: Lee Chee Yang <chee.yang.lee@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>