Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snapcraft doesn't honor ${pcfiledir} in pkgconfig files #5158

Open
sergio-costas opened this issue Nov 27, 2024 · 2 comments
Open

Snapcraft doesn't honor ${pcfiledir} in pkgconfig files #5158

sergio-costas opened this issue Nov 27, 2024 · 2 comments

Comments

@sergio-costas
Copy link
Contributor

Bug Description

Pkgconfig defines the ${pcfiledir} variable as "the path of the .pc file". It is designed to allow to create relocatable .pc files. For example, the .pc file for librsvg library version 2.59.1 begins with:

prefix=${pcfiledir}/../../..

Since the file is stored at /usr/lib/x86_64-linux-gnu/pkg-config, the result is that prefix is /usr.

Unfortunately, snapcraft doesn't honor it, and prepends the $CRAFT_STAGE path during build, which breaks it. When the prefix begins with ${pcfiledir}, it should be kept unmodified.

I tried to do a patch #5157 but didn't work.

To Reproduce

Just downloading the current stable version of gnome-46-2404 shows it.

Environment

Using LXD on Ubuntu 24.10.

snapcraft.yaml

librsvg:
    after: [ gdk-pixbuf, vala, meson-deps ]
    source: https://gitlab.gnome.org/GNOME/librsvg.git
    source-tag: '2.59.1' # they left the odd->unstable even->stable scheme, and now tags are stable
# ext:updatesnap
#   version-format:
#     no-9x-revisions: true
    source-depth: 1
    plugin: meson
    meson-parameters:
      - --prefix=/usr
      - -Doptimization=3
      - -Ddebug=true
      - -Dintrospection=enabled
      - -Dvala=enabled
      - -Dpixbuf=enabled
      - -Dpixbuf-loader=enabled
      - -Ddocs=disabled
      - -Dtests=false
    build-environment: *buildenv
    build-packages:
      - libssl-dev
      - curl
    override-pull: |
      craftctl default
      # cargo version in .deb is too old
      curl https://sh.rustup.rs -sSf > cargo.sh
      sh ./cargo.sh -y
      export PATH=$PATH:$HOME/.cargo/bin
      ~/.cargo/bin/cargo install cargo-c
      cp ~/.cargo/bin/* /usr/local/bin

Relevant log output

This is the generated .pc file

prefix=/root/stage${pcfiledir}/../../..
includedir=${prefix}/include
libdir=${prefix}/lib/x86_64-linux-gnu

Name: librsvg
Description: library that renders svg files
Version: 2.59.1
Requires: cairo >=  1.18.0, cairo-gobject >=  1.18.0, cairo-png >=  1.18.0, freetype2 >=  20.0.14, gdk-pixbuf-2.0 >=  2.20, gio-2.0 >=  2.24.0, glib-2.0 >=  2.50.0, harfbuzz >=  2.0.0, libxml-2.0 >=  2.9.0, pangocairo >=  1.50.0, pangoft2 >=  1.50.0, gmodule-2.0 >=  2.50.0
Libs: -L${libdir} -lrsvg-2
Libs.private: -lm
Cflags: -I${includedir}/librsvg-2.0

Additional context

No response

@frenchwr
Copy link

frenchwr commented Dec 3, 2024

Just a note that this bug is affecting the GIMP snap as described here: snapcrafters/gimp#300

There is a workaround in the PR to hard-code the librsvg header file search path in the build-environment section of a part that is impacted by this bug.

@sergio-costas
Copy link
Contributor Author

sergio-costas commented Dec 3, 2024

I prepared a patch for gnome-46-2404-sdk which should fix the problem ubuntu/gnome-sdk#264 but it's just a workaround until this is fixed in snapcraft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants