How to add a custom PPA to snapcraft

I want to be able to use some shared libraries, that should be fetched before cmake step(plugin) from a custom PPA.

snapcraft.yaml:

name: mraa-blink-example
version: 'Latest' 
summary: mraa for snapcraft
description: |
  Blink Example from MRAA lib

grade: stable #devel # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots

apps:
  blinkapp:
    command: bin/blink    

parts:
  blink:
    plugin: cmake
    build-packages:
      - libmraa1 
      - libmraa-dev 
      - mraa-tools 
      - python-mraa 
      - python3-mraa

CMakeLists.txt

cmake_minimum_required(VERSION 2.8.9)
project (MRAA)

file(GLOB SOURCES "src/*.cpp")

#For the shared library:
set ( PROJECT_LINK_LIBS libmraa.so )
add_executable(blink ${SOURCES})
target_link_libraries(blink ${PROJECT_LINK_LIBS} )
install(TARGETS blink DESTINATION /bin)

Because the build-packages are from a custom PPA, i get the error:

> Could not find a required package in 'build-packages': "The cache has no package named 'libmraa-dev'"

Is there a way to solve this problem?

Currently not through snapcraft.yaml itself. You would need to add the PPA to your system or the launchpad builders during build setup.

I still want to ask, why don’t you set it up as a part instead?

1 Like

I have done this in different ways in order to give a user friendly experience on using mraa/upm libs on Ubuntu Core(eventually for Intel joule board):

  • First we have made a part that builds from sources the libs, and we don’t have any issues on that, we could also add them as in the wiki/parts when we are ready/decided and well tested.

  • Second, on the idea of being efficient, we wanted to not build the libs, to have them available fast. So, we came up with a snap/part that gets the libs from a .tar external source and will put them in the appropriate location before entering a cmake step.

    parts:
    mraa:
    plugin: dump
    source: /home/maneaflavian/mraa_lib_archive.tar
    source-type: tar
    organize:
    .so’: usr/lib/
    blink:
    plugin: cmake
    after: [mraa]

  • Last, we thought that it would be more easy if it were possible to do it as stated above, and the problems came with the PPA.

If I am missing the philosophy around snaps, or if there are other ways to achieve this, I am open for suggestions (links etc)

Thank you!

SideNode:
Also, on Ubuntu Core, while running snap classic, you don’t have the possibility to do sudo add-apt-repository.

(classic)maneaflavian@localhost:~/PPA/fetch_shared_library_ppa_example$ sudo add-apt-repository ppa:mraa/mraa
sudo: add-apt-repository: command not found

you can install software-properties-common to get add-apt-repository.

1 Like

You can use a deb as source in a part, like

parts:
    part:
        source: https://.../.../.../my-deb.deb
        plugin: dump
1 Like

I have done that, but other problem have arrised (problems only on Ubuntu Core in Classic Snap, on a regular distribution is not reproducible - in my case Linux Mint 18.1 64-bit ):

The repository 'http://ppa.launchpad.net/mraa/mraa/ubuntu zesty Release' does not have a Release file., W:Data from such a repository can't be authenticated and is therefore potentially dangerous to use., W:See apt-secure(8) manpage for repository creation and user configuration details., E:Failed to fetch http://ppa.launchpad.net/mraa/mraa/ubuntu/dists/zesty/main/binary-amd64/Packages 404 Not Found, E:Some index files failed to download. They have been ignored, or old ones used instead.

Is it that under Ubuntu Core in Classic Snap, when doing apt-get install, it is saw as a ubuntu zesty distribution, and tries to get zesty specific install from this location “http://ppa.launchpad.net/mraa/mraa/ubuntu/dists/”?

https://bugs.launchpad.net/bugs/1670475 i’ll get to that one after easter, sorry for the inconvenience …

though that doesnt explain why there is no Release file, are you sure that PPA has packages built for zesty ?

1 Like

I saw now that they aren’t, but I was not sure if for Ubuntu Core all the packages should be build for zesty, or I did something wrong when installing software-properties-common.

no, in fact they should be built for xenial, i wonder how you get zesty into your sources.list inside the classic snap env …

After looking in sources.list in .cache/snapcraft/… I saw that it added:

deb http://ppa.launchpad.net/mraa/mraa/ubuntu zesty main

Maybe it was triggered by the add-apt-repository from software-properties-common which were installed inside Snap Classic, maybe some additional arguments should be given when installing software-properties-common (I don’t have knowledge on this aspect)

I have fixed this issue by manually adding “xenial” to this file: ./var/snap/classic/common/classic/etc/apt/sources.list.d/mraa-ubuntu-mraa-zesty.list (but I don’t kow how it got zesty in the first place )