Snap works on one machine but not on another

The stage-packages are not installed into the host system, but are unpacked into your snap’s filesystem so that the snap can find them at runtime. Blockquote

So, interestingly enough, when I add stage-packages: blah blah to the YAML, it consistently fails to build. When I remove it, all is well. Is it because I am placing it in the wrong part of the YAML? I am getting REALLY close to success with this snap, so I really appreciate all your help here.

name: clementine-snap # check to see if it's available
version: '1.3.1.7' # check the version number of clementine's packages
summary: Clementine is a modern music player. # 79 char long summary
description: |
  Clementine is a modern music player and library organizer for Windows, Linux and Mac OS X.
grade: stable # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots

apps:
  clementine: 
    command: desktop-launch $SNAP/bin/clementine
    plugs:
      - network
      - home
      - pulseaudio
      - unity7
      - x11
         
parts:
  my-part:
    # See 'snapcraft plugins'
    
    build-packages:
       [liblastfm-dev,libtag1-dev,gettext,libboost-dev,libboost-serialization-dev,libqt4-dev,qt4-dev-tools,libqt4-opengl-dev,cmake,libgstreamer1.0-dev,libgstreamer-plugins-base1.0-dev,libglew1.5-dev,libqjson-dev,libgpod-dev,libplist-dev,libusbmuxd-dev,libmtp-dev,libcdio-dev,protobuf-compiler,libprotobuf-dev,libcrypto++-dev,libfftw3-dev,libsparsehash-dev,libsqlite3-dev,libpulse-dev,libqtwebkit-dev,libechonest-dev,libchromaprint-dev,libqca2-dev]
    source-type: git
    source: https://github.com/clementine-player/Clementine
    after: [desktop-qt4]
    plugin: cmake
parts:
  my-part:
    # See 'snapcraft plugins'
    build-packages:
      - foo
      - foo
    stage-packages:
      - foo
      - foo
    source-type: git
    source: https://github.com/clementine-player/Clementine
    after: [desktop-qt4]
    plugin: cmake

Should look like that, I think (replacing foo with the relevant packages)
But the packages that are dependencies (rather than merely build dependencies) should be included as stage-packages rather than build-packages and you haven’t replaced your -dev packages with smaller ones yet.

Yeah, that’s the hard part…as the clementine dev calls those out for building from source.

Okay, switching gears here as this doesn’t seem to be getting me anywhere.

What if I were to use the actual source tarball? Like you’d see in some of the examples for “building my first snap”?

Opinions? TIA.

You need the -dev packages to build from source, because they install both the library and the .h header files so that a C compiler and linker can correctly target the library. Once you have a binary, though, you no-longer need those header files so they just waste space inside your snap. The thing to do, then, is to figure-out which apt package contains just the library you want and put those in the stage-packages instead of the -dev ones. You can use either packages.ubuntu.com referencing the xenial release when you’re building in cleanbuild or the build service, or you can on an active ubuntu system use apt show <package-name-dev>. Whichever way you choose, you’re looking for the “depends” line which tells you all the other deb packages the -dev package will install in addition to itself. One of those depended packages is likely the library you want so put that package name in the list of stage-packages.

For example, say I wanted to figure-out the package for libjpeg-dev:

$ apt show libjpeg-dev
Package: libjpeg-dev
Version: 8c-2ubuntu8
Priority: optional
Section: libdevel
Source: libjpeg8-empty
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 26.6 kB
Depends: libjpeg8-dev
Supported: 9m
Download-Size: 1,546 B
APT-Sources: http://gb.archive.ubuntu.com/ubuntu zesty/main amd64 Packages
Description: Independent JPEG Group's JPEG runtime library (dependency package)
 This package will always depend on the current default JPEG library
 development package version.

There is shows that the package depends on libjpeg8-dev which is another -dev, and the only dependency so the package probably got renamed at some point. We follow that and re-run the command to find out what that package depends on:

$ apt show libjpeg8-dev
Package: libjpeg8-dev
Version: 8c-2ubuntu8
Priority: optional
Section: libdevel
Source: libjpeg8-empty
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 26.6 kB
Depends: libjpeg-turbo8-dev (>= 1.1.90+svn722-1ubuntu6), libjpeg8 (= 8c-2ubuntu8)
Supported: 9m
Download-Size: 1,552 B
APT-Sources: http://gb.archive.ubuntu.com/ubuntu zesty/main amd64 Packages
Description: Independent JPEG Group's JPEG runtime library (dependency package)
 libjpeg8-dev dependency package, depending on libjpeg-turbo8-dev.

Here we see that the libjpeg8-dev package depends on both libjpeg-turbo8-dev and libjpeg8. With a bit of guesswork and we can conclude we probably wanted libjpeg8 or else we’d probably have been told to find the turbo variant specifically by upstream, so we put that libjpeg8 into our stage-packages list, and libjpeg-dev into build-packages.

1 Like

There should be little discernible difference between using a source tarball and using a git repository, other than the source tarball may have had some extra preparation to abstract things from the upstream repository. This might have been running for example autogen or ./autogen.sh on an autotools project git source tree to generate a configure script ready for the standard ./configure && make && make install.

I’m less sure what steps a cmake project may take in a similar vein so I would expect the source tarball to be almost identical to the source in git for the relevant tag/branch/commit-ref.

1 Like

This as far as I get…it ONLY happens when I add the build-packages. Prior to that, I get a successful build that doesn’t work (which is the opposite of success, I know!).

Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
Command '['/bin/sh', '/tmp/tmpdmcc1rlo', 'make', '-j4']' returned non-zero exit status 2

Man, learning is tough but your help is really very much appreciated!

There should be more errors further-up from (before) the line that says

Makefile:127: recipe for target 'all' failed

That specific line is saying that make aborted because there was an error in one of the commands that it called. The full log will include the errors somewhere within, though it can be difficult to find if it isn’t near the bottom.

In file included from /home/james/clementine/parts/my-part/src/gst/moodbar/gstfastspectrum.cpp:28:0:
/home/james/clementine/parts/my-part/src/gst/moodbar/gstfastspectrum.h:34:21: fatal error: gst/gst.h: No such file or directory
compilation terminated.
gst/moodbar/CMakeFiles/gstmoodbar.dir/build.make:62: recipe for target 'gst/moodbar/CMakeFiles/gstmoodbar.dir/gstfastspectrum.cpp.o' failed
make[2]: *** [gst/moodbar/CMakeFiles/gstmoodbar.dir/gstfastspectrum.cpp.o] Error 1
CMakeFiles/Makefile2:2373: recipe for target 'gst/moodbar/CMakeFiles/gstmoodbar.dir/all' failed
make[1]: *** [gst/moodbar/CMakeFiles/gstmoodbar.dir/all] Error 2

and this is sticking out to me:

  The dependency target "pot" of target "clementine_lib" does not exist.
This warning is for project developers.  Use -Wno-dev to suppress it.

gst/gst.h is a reference to a libgstreamer header. If you haven’t got libgstreamer1.0-dev as a build-package you might be needing it.

1 Like

Progress!!

tar: ./usr/share/doc/libwebp5/copyright: Cannot open: File exists
tar: ./usr/share/doc/libwebp5/changelog.Debian.gz: Cannot open: File exists
tar: ./usr/share/doc/libwebp5: Cannot utime: Operation not permitted
tar: ./usr/share/doc: Cannot utime: Operation not permitted
tar: ./usr/share: Cannot utime: Operation not permitted
tar: ./usr/lib/x86_64-linux-gnu/libwebp.so.5.0.4: Cannot open: File exists
tar: ./usr/lib/x86_64-linux-gnu/libwebp.so.5: Cannot create symlink to ‘libwebp.so.5.0.4’: File exists
tar: ./usr/lib/x86_64-linux-gnu: Cannot utime: Operation not permitted
tar: ./usr/lib: Cannot utime: Operation not permitted
tar: ./usr: Cannot utime: Operation not permitted
tar: .: Cannot utime: Operation not permitted
tar: Exiting with failure status due to previous errors
dpkg-deb: error: subprocess tar returned error exit status 2

Okay, progress is being made.

Here’s where it’s at as the snap has successfully been built, but when attempting to launch it via terminal, this is the result:

clementine: error while loading shared libraries: liblastfm.so.1: cannot open shared object file: No such file or directory

Additionally, building it via build.snapcraft.io is successful, but upon reviewing the reason it’s not being published to the store:

desktop interfaces (unity7,x11) specified without a corresponding meta/gui/*.desktop file. If using snapcraft, please see https://snapcraft.io/docs/build-snaps/metadata#fixed-assets. Otherwise, please provide a desktop file in meta/gui/*.desktop (it should reference one of the 'apps' from your snapcraft/snap.yaml). lint-snap-v2_meta_gui_desktop

So, it looks like I need to specify a gui desktop, but is that necessary since it’s meant to be used on …whatever (e.g. Cinnamon, Budgie, KDE, etc)?

BTW, I’d really like to credit you all for helping me with this. It’s inevitably gonna make a lot of Clementine users very happy once it’s done.

It’s not asking you to specify a “desktop” (Unity, KDE) it’s asking you to specify a desktop file which is a text file which tells all the standard Linux desktops use to present the application icon, description and executable location.

I’d also consider renaming the snap from clementine-snap to clementine. It doesn’t really make sense to have suffixes on the snaps.

1 Like

See the ever-helpful Arch wiki (in this case, their page on desktop entries).

3 Likes

I’m not sure how I feel about this…I’m afraid to try it…

EDIT: FAIL

bad system call

Okay, I’ve got it down to a problem with SHARED LIBS. I am having trouble finding documentation on this subject as it directly pertains to snap packages. Anyone know where to look?

I am not a dev so you have to talk to me like a dummy, lol. BTW, thanks for all the help so far. It’s been very much appreciated.

You’ll see the error below. So, just to test this out, I installed liblastfm1 via apt. Then I got ANOTHER shared library error (libqjson). These libs are in the YAML under stage-packages:

So, I am in doubt about needing anymore libs (I can be wrong).

Here’s a sample of what I’m facing:

clementine: error while loading shared libraries: liblastfm.so.1: cannot open shared object file: No such file or directory

Do you have the right liblastfm in your stage-packages ?

ogra@anubis:~$ apt-cache search liblastfm
...
liblastfm1 - Last.fm web services library (Qt4 build)
liblastfm5-1 - Last.fm web services library (Qt5 build)
...
ogra@anubis:~$

So, last night I discovered a terrible truth…

The snap is NOT including ANY libs at all. So, that’s where I’m at with this, learning how to include all the libs IN the snap. I can’t seem to find anything that can spell it out for a newb.

The snapcraft.yaml as in your git repository of a few minutes ago builds correctly including all the required libs. I haven’t tried running the snap yet, but all the libs look to be included properly.

Edit: It looks like you’re trying to call $SNAP/bin/clementine but that file is at $SNAP/bin/bin/clementine