Snapcraft package repositories

When building a snap and constructing a part, package dependencies are listed as either package names or snaps for the snap’s build environment. This is covered in Build and staging dependencies.

For a default Snapcraft installation running Multipass, the build environment is invariably Ubuntu 18.04 LTS (Bionic Beaver). Consequently, dependencies are listed using their apt package names and are retrieved from the set of repositories officially supported by the distribution.

However, it’s also possible to add your own apt repositories as sources for build-packages and stage-packages, including those hosted provided on a PPA, the Personal Package Archive, which hosts personally hosted non-standard packages.

Adding repositories

Third-party apt repositories can be added to a snap’s snapcraft.yaml by using the top-level package-management keyword, followed by repositories listing each new source:

package-management:
  repositories:
    - source: ppa:<ppa-location>

Once configured, packages provided by these repositories will become available via stage-packages and build-packages.

source

The syntax for the repository source can be one of the following:

  1. short-form PPAs:

    • source: ppa:cjp256/test-ppa
    • source: ppa:mozillateam/ppa
  2. traditional deb repository line (as in sources.list):
    deb <url> <suite> <components...>

    • source: deb http://archive.canonical.com/ubuntu bionic partner
    • source: deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main
  3. repository URI, with suite assumed to match host:
    (such as “bionic” for core18 / 18.04 build environment) and optional component defaulting to “main”, e.g.:

    • source: http://archive.canonical.com/ubuntu partner
    • source: http://ppa.launchpad.net/cjp256/test-ppa/ubuntu

gpg-public-key

String specifying full ASCII-armored public key. Must include the PGP header/footer:

gpg-public-key: |
        -----BEGIN PGP PUBLIC KEY BLOCK-----
        <snipped>
        -----END PGP PUBLIC KEY BLOCK-----

gpg-public-key-id

String specifying the GPG public key identifier/fingerpint to fetch from a key server:

gpg-public-key-id: 590CA3D8E4826565BE3200526A634116E00F4C82

gpg-key-server

String specifying the key server to use for fetching GPG key (specified by gpg-public-key-id ). Defaults to keyserver.ubuntu.com:

gpg-public-key-id: 590CA3D8E4826565BE3200526A634116E00F4C82
gpg-key-server: keyserver.ubuntu.com

Examples

package-management:

  repositories:

    # Option 1: PPA shortcut (automatically imports PPA key from LP):
    - source: ppa:cjp256/test-ppa

    # Option 2: Enable apt repository via "deb" sources.list format using OS-installed keys:
    - source: deb http://archive.canonical.com/ubuntu bionic partner

    # Option 3: Enable repository with specified component using OS-installed keys:
    - source: http://archive.canonical.com/ubuntu partner

    # Option 4: Use repository with GPG key fetched from keyserver:
    - source: http://ppa.launchpad.net/cjp256/test-ppa/ubuntu
      gpg-public-key-id: 6A634116E00F4C82
      gpg-key-server: keyserver.ubuntu.com

    # Option 5: Use repository with provided GPG key:
    - source: http://ppa.launchpad.net/cjp256/test-ppa/ubuntu
      gpg-public-key: |
        -----BEGIN PGP PUBLIC KEY BLOCK-----
        mQINBF4y3MIBEAC6rYxrDtleK/OPftHKySm5nN8OIc+tBFnGr9pz4eu2CRukFxXc
        Ap07pj5EkRbzI60BeGVK/spLFtrU7PPxBXJ3DiaxEaWmOUW/7MdukSWTVk9EgEAZ
        dwKjbwNrrxmCif8RJzK9JFz1IqGqY/uzR7X90J2Wn4/+FvWNofE2kCQeGEpDQtmF
        bpcBdHZmcru8g/t3KQy11i4GJ5gLXqFdDF3T3YcVgLyoOx910VK0Y41Rsux7PwlR
        PmF3doZ+fjLBYVBo0l5ek56dc7p1Z6RL30IHgbwdSbDcYJ8d8dXR+gFUuB4xSYTk
        XRD2Uzc+jDcwXEaTGFvxQNxIXW4ELwwB5ceqbt/l1w4Yo+pQrSKDjOeG80kwRWsw
        bGnaAEa8ZKMHvQdr6wIGwiD6LfNAKGtr5xw4O7VzalF6KuzmrRt9RQc/bkso3DQV
        tCC/nkI55gXEM6zH3NiGQiz47SrjENXWOwJvGrBT36eHCsLZ984SwRHCOqubEAwE
        G7mkRcew/YC2xe6ic7ZMxVQ3DkmHKojO3qoS73KbuRgp6xwcBXxtPN2k/rAEmVTz
        aXIPp46mXbwAfcuo5gFRknGzgyOP8cG5KMbl/AGJjRRfiWlIC5RmCcguGsgC5p0n
        4cPX7+u0J9+pjyPdOntSm5WS1+2HYkd7vS0Qmio5/e7Sw1blCai1mxc7rQARAQAB
        tCFMYXVuY2hwYWQgUFBBIGZvciBDaHJpcyBQYXR0ZXJzb26JAjgEEwECACIFAl4y
        3MICGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEGpjQRbgD0yCanYP/001
        tx9sgjfGCsA2WNbHAcoqN5Di1dIo4js5inFHWhFFDte4qY1uAx3lKxpq5iyqzwtB
        rN/fbp3URd+ZqsVQ8IkfPf+lzMubf9YnKxbuBeXU+y5Kj8pmoL6sCpieobk9+3Go
        rtAkrlmFw7GmpPeCzaHhr5YzOO82T75EEb2a6FYduPv+ONGJqk8P2f20CzlK84ze
        G6ApSD7BdZ70iUvC0oy6AJoU8uSgoOfMdTIgT7NWXLfqzOIo+Fy5dlnmGS09y132
        hpjqvx3VCFdGH+NSfcmEVCTcLnqoPqD6InXoROqi30c2D4PmX2h1Endac6BF9uCB
        xdFBb8SKZ7mJ/dydAEV9KbUr+mQCAG5JO0+GnxgtKanHjMmDcF9BtmHMZsKDjILs
        7iyiWEsrk+QsUpV5gxOdpOFvL2FfSVTTYhmKgCI9h+KqesAPnJwIhCI5Gz94MaYo
        V8T+4ZjX36DNh5f7gzWLvajvKznOXGJkX6TgbqFo/wrijK75DPmuuR7m2Xa4AlAT
        J0JZFdHWXuJnYI3vSZ2OfgHJKsLePheLFtJvpFJTPC0nOFwWgg2JH//UDbEIk5md
        nLQl+agC5z32g+Qet+D/5y+xamJP/5HKgix8RhggPSIsaMi8ezNrF08jyollwDFk
        c24ABjaDjM0uWKllldFtmpnW7V0tOFxm+RIA6dCM
        =ulGo
        -----END PGP PUBLIC KEY BLOCK-----
1 Like

Is this stable? none of this is published on snapcraft.io stable documentation website.