Snapcraft build-snaps using private snaps

We are trying to use snapcraft to create a snap for our application (lets call this “main-private-snap”). We have modularise our application into multiple snaps, where “main-private-snap” depends on “private-snap1” and “private-snap2”. Both “private-snap1” and “private-snap2” are built before hand, and is published on snapstore with Private visibility.

Is there a way to pull these private snaps when building the main private snap? What is the method/best practice to pass in our snap store credentials?

Note: We would not want to use a multi parts approach as “private-snap-1” is also a dependency for our other applications.

parts:
  main-private-snap:
    plugin: cmake
    source: <some-repo>
    build-packages:
      - <some dependencies>
   build-snaps:
      - private-snap1
      - private-snap2

I don’t think we have any tool-level support for this scenario yet. @sergiusens, any suggestion on how to work around this limitation?

@cmatsuoka based on this link https://snapcraft.io/docs/snapcraft-authentication, i have manage to use snapcraft export-login <credentials-filename> to export credentials into a file , and use this credentials to authenticate into snapcraft.

However, this only allows us to publish snaps, and we will need snap login to install any private snaps using snap install private-snap1. (based on this link Snap login, snapcraft login, and Ubuntu Core).

Copying the ~/.snap/auth.json into the container when building doesnt work either, as the snap login command is not able to find the auth.json file, and there is no /home directory during build.

We have a found a dirty solution by doing the following, in the container

export UBUNTU_STORE_AUTH_DATA_FILENAME=<credentials-filename>
snap download private-snap1
snap ack private-snap1_1.assert
snap install private-snap1_1.snap

Surprisingly snap download doesnt require a snap login.

Please let us know if there is a better way.

1 Like