siemens / meta-efibootguard

Yocto layer for EFI Boot Guard
GNU General Public License v2.0
7 stars 10 forks source link

Improve support for dunfell #5

Closed mferland closed 2 years ago

mferland commented 4 years ago

Got the following error message while trying to create an image with wic on dunfell:

Wic failed to find a recipe to build native bg_setenv. Please file a bug against wic.

Adding a dependency to bg_setenv-native fixed to issue.

Signed-off-by: Marc Ferland ferlandm@amotus.ca

jan-kiszka commented 4 years ago

Thanks, but please rebase over master.

mferland commented 4 years ago

Thanks, but please rebase over master.

rebase done

jan-kiszka commented 4 years ago

Thanks, merged to next as first step.

jan-kiszka commented 4 years ago

Played with that now, and I do not see what exactly it solves.

First of all, we already have efibootguard-native - why adding bg_setenv-native?

And then, you should usually extend your image dependencies by that tool like we do in https://github.com/siemens/meta-iot2000/blob/master/meta-iot2000-bsp/recipes-core/images/core-image-iot2000.inc, or probably better via WKS_FILE_DEPENDS += "efibootguard-native".

Can you clarify?

mferland commented 4 years ago

To make it clear here's how to reproduce the issue using your iot2000 layer:

pip3 install kas
git clone https://github.com/siemens/meta-iot2000
kas build meta-iot2000/kas-example.yml
source poky/oe-init-build-env ./build/
wic create wic-image.iot2000 -e iot2000-example-image

Result:

NOTE: Executing Tasks
NOTE: Tasks Summary: Attempted 2240 tasks of which 2228 didn't need to be rerun and all succeeded.
INFO: Creating image(s)...

Traceback (most recent call last):
  File "/home/marc/mnt/projet/test/poky/scripts/lib/wic/plugins/imager/direct.py", line 86, in do_create
    self.create()
  File "/home/marc/mnt/projet/test/poky/scripts/lib/wic/plugins/imager/direct.py", line 179, in create
    self._image.prepare(self)
  File "/home/marc/mnt/projet/test/poky/scripts/lib/wic/plugins/imager/direct.py", line 352, in prepare
    part.prepare(imager, imager.workdir, imager.oe_builddir,
  File "/home/marc/mnt/projet/test/poky/scripts/lib/wic/partition.py", line 167, in prepare
    plugin.do_configure_partition(self, srcparams_dict, creator,
  File "/home/marc/mnt/projet/test/meta-efibootguard/scripts/lib/wic/plugins/source/efibootguard-boot.py", line 73, in do_configure_partition
    exec_native_cmd(config_cmd, native_sysroot)
  File "/home/marc/mnt/projet/test/poky/scripts/lib/wic/misc.py", line 158, in exec_native_cmd
    raise WicError(msg)
wic.WicError: A native program bg_setenv required to build the image was not found (see details above).

Wic failed to find a recipe to build native bg_setenv. Please file a bug against wic.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/marc/mnt/projet/test/poky/scripts/wic", line 540, in <module>
    sys.exit(main(sys.argv[1:]))
  File "/home/marc/mnt/projet/test/poky/scripts/wic", line 535, in main
    return hlp.invoke_subcommand(args, parser, hlp.wic_help_usage, subcommands)
  File "/home/marc/mnt/projet/test/poky/scripts/lib/wic/help.py", line 83, in invoke_subcommand
    subcmd[0](args, usage)
  File "/home/marc/mnt/projet/test/poky/scripts/wic", line 219, in wic_create_subcommand
    engine.wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir,
  File "/home/marc/mnt/projet/test/poky/scripts/lib/wic/engine.py", line 190, in wic_create
    plugin.do_create()
  File "/home/marc/mnt/projet/test/poky/scripts/lib/wic/plugins/imager/direct.py", line 91, in do_create
    self.cleanup()
  File "/home/marc/mnt/projet/test/poky/scripts/lib/wic/plugins/imager/direct.py", line 271, in cleanup
    for fname in os.listdir(self.workdir):
FileNotFoundError: [Errno 2] No such file or directory: './tmp.wic.ejqexii2'
jan-kiszka commented 4 years ago

Why are you calling wic outside of the image recipe? It's part of it, and that works - otherwise you couldn't have called it in the first place as kas would have failed.

There are two issues:

mferland commented 4 years ago

This was just a minimal example to show the failure/reproduce. Just to be clear, I'm only using meta-efibootguard in my project and not the other layers (I'm not targeting the IOT2000).

You are right saying efibootguard-native is the correct dependency for the image and it does work when building the image.

What happens, from my understanding, is that when wic is called from the image scripts (i.e.: run.do_image_wic) the NATIVE_SYSROOT will point to the image's native sysroot (which contains bg_setenv because of the dependency) but when calling the command externally, it'll use the wic-tools NATIVE_SYSROOT (as shown when calling wic externally) which is populated by the wic-tools recipe. Relevant code in wic.

Example of a successful run:

$ wic create wic-image.iot2000 -e iot2000-example-image
INFO: Building wic-tools...

Loading cache: 100% |##############################################################################################################################################################################################| Time: 0:00:00
Loaded 3218 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION           = "1.46.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "i586-poky-linux"
MACHINE              = "iot2000"
DISTRO               = "poky-iot2000"
DISTRO_VERSION       = "V2.6.0"
TUNE_FEATURES        = "m32 i586-nlp"
TARGET_FPU           = ""
                     = "HEAD:e13f038bb362a6c086be50359f1bf31cf770e151"
meta-iot2000-bsp     
meta-iot2000-example = "master:48bb08941dcbc53db831cb75fb7f66cb6801538b"
meta-networking      
meta-oe              
meta-python          = "HEAD:cc6fc6b1641ab23089c1e3bba11e0c6394f0867c"
                     = "HEAD:1886350dacb63d931b3d1a3809b27795b0a5c306"
meta                 
meta-poky            
meta-yocto-bsp       = "HEAD:febbe2944c0c4a04b85fa98fdc261186115954d8"

Initialising tasks: 100% |#########################################################################################################################################################################################| Time: 0:00:00
Sstate summary: Wanted 0 Found 0 Missed 0 Current 711 (0% match, 100% complete)
NOTE: Executing Tasks
NOTE: Tasks Summary: Attempted 2259 tasks of which 2259 didn't need to be rerun and all succeeded.
INFO: Creating image(s)...

INFO: The new image(s) can be found here:
  ./wic-image.iot2000-202011051105-mmcblk0.direct

The following build artifacts were used to create the image(s):
  ROOTFS_DIR:                   /home/marc/mnt/projet/test/build/tmp/work/iot2000-poky-linux/iot2000-example-image/1.0-r0/rootfs
  BOOTIMG_DIR:                  /home/marc/mnt/projet/test/build/tmp/work/iot2000-poky-linux/iot2000-example-image/1.0-r0/recipe-sysroot/usr/share
  KERNEL_DIR:                   /home/marc/mnt/projet/test/build/tmp/deploy/images/iot2000
  NATIVE_SYSROOT:               /home/marc/mnt/projet/test/build/tmp/work/i586-nlp-32-poky-linux/wic-tools/1.0-r0/recipe-sysroot-native

INFO: The image(s) were created using OE kickstart file:
  /home/marc/mnt/projet/test/meta-iot2000/meta-iot2000-bsp/scripts/lib/wic/canned-wks/wic-image.iot2000.wks

I also think it shouldn't be conditional, since we can't really know in advance which wks will be used to build the final images. See this commit as an example. They added dependencies on btrfs-tools and squashfs-tools even though only a fraction of images will actually use these tools.

jan-kiszka commented 4 years ago

OK, convinced. Then please update your PR to use efibootguard-native instead.

jan-kiszka commented 2 years ago

Was merged.