snapcraft should setup search paths/flags for parts built after parts

Bug #1531481 reported by Andreas Pokorny
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
Status tracked in Trunk
1.x
Undecided
Unassigned
Trunk
High
Sergio Schvezov

Bug Description

When building multiple parts from source that depend on each other in a snapcraft session it would be useful if snapcraft would setup the environment for each part in a way that autotools/pkg-config/cmake can find the build results from 'after:'-parts.

Or instead of setting up search paths it might just build & install in a dedicated chroot environment and build each part in the same environment..

Assume this snapcraft.yaml:

name: nfs-server # the name of the snap
version: 0.1 # the version of the snap
# The vendor for the snap (replace 'Vendor <email address hidden>')
vendor: Andreas Pokorny <email address hidden>
summary: Simple NFS Server
description: Simple NFS Server setup for home server use, with manual user and exports setup
icon: folder-remote-nfs.png
architectures: [armhf]

parts:
    libtirpc:
        plugin: autotools
        source: git://github.com/APokorny/libtirpc.git
        source-branch: use-snappy-env
        stage-packages:
            - libkrb5-dev
        filesets:
            tir-files:
                - lib/libtirpc.so*
        snap:
            - $tir-files
    rpcbind:
        plugin: autotools
        source: git://git.linux-nfs.org/projects/steved/rpcbind.git
        stage-packages:
            - libwrap0-dev
        after:
            - libtirpc
    nfs-utils:
        plugin: autotools
        source: git://github.com/APokorny/nfs-utils.git
        source-branch: use-snappy-env
        stage-packages:
            - libcomerr2
            - libnfsidmap2
        after:
            - libtirpc

After building libtirpc when building rpcbind configure fails because it cannot find libtirpc. The configure script uses pkg-config here. I assume snapcraft would use PKG_CONFIG_PATH and PKG_CONFIG_SYSROOT_DIR.

...

description: updated
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Thank for reporting this, since this is supposed to work, I'd like to request an example where it doesn't to add to our harness and fix with.

Changed in snapcraft:
status: New → Incomplete
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

Ok I am still nearly done with my nfs path changes. I will try it again. This evening or tomorrow. It being .. building a modified libtirpc, rpcbind and nfs-utils with the remaining deps coming from ubuntu archive..

description: updated
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

OK, PKG_CONFIG_SYSROOT_DIR is setup incorrectly

Changed in snapcraft:
status: Incomplete → Triaged
importance: Undecided → High
milestone: none → 2.0
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

After changing PKG_CONFIG_SYSROOT_DIR to the stagedir I now see this:
checking /usr/include/tirpc/netconfig.h usability... no
checking /usr/include/tirpc/netconfig.h presence... no
checking for /usr/include/tirpc/netconfig.h... no
configure: error: libtirpc not found.

Which was there before the change too, it seems PKG_CHECK_MODULES is not following PKG_CONFIG_SYSROOT_DIR. Is that the right assumption?

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

That looks like the output from nfs-utils, the third part of that snap. That thing uses handcrafted autoconf ma4 macros to detect libraries. I am going to change that to PKG_CHECK_MODULES.. but there is some more conditional magic that causes other problems. For testing this bug just ignore the third part ..

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Ok, so I changed the `after` in `nfs-utils` to be `rpcbind` instead of `libtirpc` and now get
`configure: error: libsystemd support requested but found

But before that

checking pkg-config is at least version 0.9.0... yes
checking for TIRPC... yes

Thank you for finally pushing me to fix this fundamental problem that I always procrastinated to fix (use stagedir instead of each parts installdir breaking the privacy of the part).

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

awesome - so it is meant to work like that!

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers