What sources are used for stage-packages?

Hi,

I am trying to make a snap out of the realsense_samples_ros repository, which has dependencies that can be installed with apt after adding the correct apt repo to the sources list:

sudo apt-key adv --keyserver keys.gnupg.net --recv-key D6FB2970 
sudo sh -c 'echo "deb http://realsense-alm-public.s3.amazonaws.com/apt-repo xenial main" > /etc/apt/sources.list.d/realsense-latest.list' 

I executed the above commands on my host, and tried to build a snap with the following part in my snapcraft.yml:

parts:
  samples:
    source: .
    plugin: catkin
    rosdistro: kinetic
    include-roscore: false
    catkin-packages: []
    stage-packages: [
      ros-kinetic-desktop-full,
      librealsense-object-recognition-dev,
      librealsense-persontracking-dev,
      librealsense-slam-dev,
      libopencv-dev
    ]

but I got this error:

Error downloading stage packages for part 'samples': The package 'librealsense-object-recognition-dev' was not found.

I thought that snapcraft could find the packages by looking at the repos in my host’s sources list, but I was clearly mistaken.

What sources are used to find the stage-packages? Are we only allowed to list packages from the main Ubuntu repo?
Is it possible to specify new which package repos to use in snapcraft.yml?

Thanks.

James.

1 Like

I suspect you were building with cleanbuild. Your host’s sources will not
be used in a cleanbuild, which will use a clean container to do the build
in.

Cheers,
Ken

OK, I understand why it won’t use my host’s sources, thanks. But how can I specify sources to use?

I don’t think there’s a way to do that on snapcraft.yaml itself yet. See this topic for details:

1 Like

You can surely use a “prepare” shell script snippet that calls “add-apt-repository…” and apt update as workaround until this is properly implemented in snapcraft …

1 Like

You can try that, but it won’t work for build-packages. It might work for stage-packages because they’re pulled differently. The problem with build-packages is that they are pulled upfront by snapcraft before the prepare script is ran, so you can’t reference packages that are in your PPA/alternative repo. I have managed to fudge this by running apt install in addition to the add-apt-repository but it means we’re not being declarative anymore.

4 Likes

I noticed that there is room to “define alternative sources.list” when writing a plugin, which seems like another sort of overkill method.

So calling add-apt-repository etc. under prepare: would have the same effect of such commands when run on the host, but just write to the snap filesystem?

using the prepare step to call add-apt-repository will not by itself affect the snap filesystem. It will add the repository configuration into the build system’s /etc/apt/repos.list.d, which might mean it adds the repo into your host if you aren’t using a container to build. The repos added via prepare do not get used to provide build-packages because those are pulled up-front before the prepare script(s) are run, so you need to install any build requirements which are in an added repo separately in the prepare script.

I had a similar issue. I found out that the catkin plugin is using the PLUGIN_STAGE_SOURCES property. The stage phase will then use the sources provided by this property instead of the sources from the system.

What I did for the moment, until I find a better solution, is to fork the catkin.py plugin (I put it inside snap/plugins/custom_catkin.py).
Then add my custom repository around line 255:

Then change “plugin: catkin” in snapcraft.yaml by “plugin: custom-catkin”.
Btw, I add the key of the repo with a “nil” plugin and a prepare script.

parts:
  prepare-apt:
    plugin: nil
    prepare: |
      sudo apt-key ...
      sudo apt-get update
  my-part:
    plugin: custom-catkin
    rosdistro: kinetic
    ...
    after: [prepare-apt]

An extra property to add custom repositories in the catkin plugin would probably be a good idea.
When and if I have some time, I could try to create a PR for that.

Hello Team,

I tried to build kernel-snap natively for DB410C on raspberry pi3 B+ running ubuntu-server arm64 but it come up with an error that device are running out of memory.

Then i tried to build the snap on host machine (Ubuntu 16.04) for target arch arm64.

During build cycle I found that snapcraft unable to find stage package “linux-firmware-snapdragon” on the host machine where as it was accessible from raspberry pi3.


Is it good idea to make this as a local source in yaml file?

Let me reframe my question -

Actually i am bit confuse to add WLAN Firmware in kernel snap, which will drastically increase the kernel image size.

What if i include the same in initramfs?
It will save some time to rebuild the kernel snap if there were some changes in WLAN Firmware or if i say there were some additional firmware which is underdevelopment for customize SBC based on Qualcom SOC .
And i will guide my kernel about initramfs through bootarg.

Someone please correct my understanding here.
I appreciate any help :slight_smile:

since the initramfs is shipped inside the kernel snap i doubt you would gain any size benefit here … beyond this, the wlan module would not find its firmware on the rootfs running system in case something unloads/reloads the module.

the firmware is alredy in a separate snapcraft part in your yaml above, if you have the tree from the last build around only cleaning the firmware part and having snapcraft rebuild just that part will give you exactly that … just make sure there is no after: statement in your yaml that adds an interdependency between the parts.

1 Like