Why is this staged file not primed?

I’m trying to get iHD_drv_video.so into my snap, but it seems to always escape prime.

In my override-stage I’m even making sure it is below $SNAPCRAFT_STAGE with

stagelibs="$SNAPCRAFT_STAGE/usr/lib/$SNAPCRAFT_ARCH_TRIPLET"
find "$SNAPCRAFT_STAGE" -name iHD_drv_video.so -exec strip {} \; -exec mv {} "$stagelibs/dri/" \;

And the log confirms it is there:

+ find /build/chromium/stage -name iHD_drv_video.so -exec strip '{}' ';' -exec mv '{}' /build/chromium/stage/usr/lib/x86_64-linux-gnu/dri/ ';'
mv: '/build/chromium/stage/usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so' and '/build/chromium/stage/usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so' are the same file

However it is not present in the final snap (because in the unsquashed snap find squashfs-root -name 'iHD*' prints nothing).

The prime statement is:

    prime:
      - usr/**/iHD_drv_video.so
      - usr/**/libigfxcmrt.so*
      - usr/**/libvulkan_*.so
      - usr/**/libVkLayer_*.so

and all those other *.so* files are present in the final snap. Why not the iHD_drv_video.so though?

I wonder if it could be related with this warning about the part:

This part is missing libraries that cannot be satisfied with any available stage-packages known to snapcraft:
- libxcb-randr.so.0

which I also don’t understand, since I’m staging libxcb-randr0, that provides that file.

Snapcraft should migrate files correctly if you use organize instead of moving files by hand.

I though Snapcraft would migrate all that is under $SNAPCRAFT_STAGE and is matched by a prime rule.

The fact that the file isn’t even moved (mv:: '... are the same file') means organize would also be out of place here, correct?

This library isn’t present because you are explicitly excluding it by not having it in your prime list. When prime is specified for a part, ONLY the files listed will be included (OR if you only use negations then ONLY the negations will be excluded - if you use both then the exclusions aren’t really used because the inclusions will exclude everything not in the include list anyway - both are helpful if you use wildcards, however).

1 Like

It will migrate files it already knows about. If you create new files or move them around directly in the stage area they won’t be migrated to prime. For that to work, you need to do these adjustments in the part install directory.

If the source and destination are the same file, it should have been primed. I created a smaller reproducer containing only the gmmlib, libva, and va-drivers parts, and found that the file was moved around and in stage it’s not in the same place it was installed:

snapcraft-chromium # find parts/va-drivers/install/ -name "iHD*.so"
parts/va-drivers/install/root/stage/usr/lib/dri/iHD_drv_video.so

But in stage we have:

snapcraft-chromium # find stage/ -name "iHD*.so"
stage/usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so

When the part is primed, Snapcraft expects to find files in the same place they were installed. That’s because it must know file locations in order to be able to remove files from specific parts when cleaning. So, if you must change file locations, do it in $SNAPCRAFT_PART_INSTALL in override-build, or use organize.

1 Like