Adding libraries to an apt package, and ship as a snap

Hi,

I’ve been using the messaging gateway bitlbee (from the apt package bitlbee-dev), with additional libraries such as telegram-purple, which I built from source. In a fresh system:

  • install bitlbee-dev (plus a few build dependencies)
  • build telegram-purple, make install

works just fine.

So I wanted to reproduce the process and bundle this into a snap.

My snapcraft.yaml is:

As you can see it is pretty simple, it uses stage-packages, and builds telegram-purple from the source.

The problem is, at runtime bitlebee can’t find the telegram plugin, and the library is built but not even shipped in the snap.

Excerpt from the snapcraft run logs:
install -m 0644 bin/telegram-purple.so /root/parts/telegram-purple/install/root/parts/telegram-purple/install/usr/lib/purple-2/telegram-purple.so

But in the snap:
ubuntu@juju-14d617-default-27:/snap/bitlbee-sajoupa/current$ ls -la /snap/bitlbee-sajoupa/current/usr/lib/purple-2/telegram-purple.so ls: cannot access '/snap/bitlbee-sajoupa/current/usr/lib/purple-2/telegram-purple.so': No such file or directory

I’m out of ideas, help would be most welcome.

Thanks,
sajoupa

Just a quick observation. It’s actually being included in the snap, but in a really weird location.

It appears to being copying the entire path into the snap’s root. Try this command, you’ll see where it got stored.
find /snap/bitlbee-sajoupa/current/ | grep telegram-purple.so

I’m not very familiar with the autotools plugin, but it might have some configurations to fix this. Alternatively, you might need to override-build or maybe just organize the files after it’s built?

Hi @sajoupa, you have a great start but it looks like you’re missing a bitlbee part. You need a bitlbee part becuase it’s the part that makes the app.

If you include telegram-purple (or any other library built from source) it will be available in the snap. You can explore the snap by entering the shell env of it either when the build fails:

$ snapcraft --debug

If you have a snap already built you can enter the shell with:

$ snap run --shell <mysnap>

Once you’re in the shell, you can do:

$ cd $SNAP
$ find . -iname telegram-purple.so

Then you could add that to the $PATH by setting that env var explicitly in the yaml (section):

build-environment:
    - PATH: /snap/gnome-3-34-1804-sdk/current/usr/bin:<wherever you find your missing library>:$PATH

I’m happy to help if you get stuck!

Thanks for the explanations.

A couple of questions:

  • should I add a ‘bitlbee’ part, and if so, what should I put in it ? Everything is already included in the other parts. Or maybe I should just rename “telegram-purple” to bitlbee ? (I tried both approachs, and got same results as before)
  • Shouldn’t I update the LD_LIBRARY_PATH instead of PATH ? And if so, isn’t snapd supposed to take care of that ? My understanding was that if a package normally installs a library in /usr/lib/mylib, then snapcraft will install it in $SNAP/usr/lib/mylib, and snapd will set the right LD_LIBRARY_PATH at runtime ?

I just reproduced a non-snapcraft install in a fresh VM, and to make this all work, it’s just:

  • apt-install the packages listed in the snapcraft.yaml’s “stage-packages” section
  • git clone the repo
  • ./configure ; make ; sudo make install
    I would have expected this basic scenario to be handled by the autotools plugin transparently…

Thanks.

Hi @hellsworth, would appreciate some help, as I’m still stuck, and would really like to get this snapped :slight_smile:

I think perhaps the issue you are hitting is your dev dependencies are included as “stage-packages”, but should likely in fact be “build-packages”… Can you give that a shot and see if it helps?