Pkg-config issue

Anyone know why snapcraft changes the prefix of a staged pkg-config file to $SNAPCRAFT_STAGE$originally_configured_prefix_dir ? The new prefix doesn’t seem to be correct at all…

$ cat stage/lib/pkgconfig/hunspell.pc 

Name: hunspell
Description: Hunspell spellchecking library
Version: 1.3.4
Libs: -L${libdir} -lhunspell-1.3
Cflags: -I${includedir}/hunspell

This might be a side effect of setting --prefix, is that what you are doing? The reason for this, when --prefix is not set, is that pkconfig has no concept of multiple SYSROOTs so they get massaged so that they find the right path, it seems that it isn’t working particularly well with the build system/configuration you are using though. Mind logging a bug on for this?

As a workaround, in snapcraft.yaml you can try something like,

        override-stage: |
             snapcraftctl stage
             sed -i '$SNAPCRAFT_STAGE/lib/pkgconfig/hunspell.pc -e "s/^prefix=.*$/prefix=$SNAPCRAFT_STAGE/"

Fix prefix to whatever is correct.


Yes I’m currently trying to fix an issue possibly due to a non-relocatable part and thus setting the --prefix, I’ve using the same workaround for now. Thanks!

Here’s the filed bug report: Bug #1774254 “Wrong prefix is set in staged pkg-config files whe…” : Bugs : Snapcraft