Created
December 5, 2019 23:06
-
-
Save NickZ/828be7ad23cd9d9c88b9ab0b3624bf44 to your computer and use it in GitHub Desktop.
How to stage packages from a third-party repository in snapcraft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import snapcraft | |
import os | |
import textwrap | |
# Just edit this to put in your repo. | |
# For examples sake, I've used the official mono repo | |
# Once edited, put this in your "snap/plugins" directory, create a part using this plugin, then stage your packages. | |
_BASE_TO_UBUNTU_RELEASE_MAP = {"core16": "xenial", "core18": "bionic"} | |
class MonoStagingPlugin(snapcraft.BasePlugin): | |
@classmethod | |
def schema(cls): | |
return { | |
'$schema': 'http://json-schema.org/draft-04/schema#', | |
'type': 'object', | |
'additionalProperties': False, | |
'properties': {}, | |
} | |
def enable_cross_compilation(self): | |
pass | |
@property | |
def PLUGIN_STAGE_SOURCES(self): | |
#Replace 'mono_repo' with whatever repo that you want. | |
mono_repo = "https://download.mono-project.com/repo/ubuntu/" | |
ubuntu_repo = "http://${prefix}.ubuntu.com/${suffix}/" | |
security_repo = "http://${security}.ubuntu.com/${suffix}/" | |
return textwrap.dedent( | |
""" | |
deb {mono_repo} {codename} main | |
deb {ubuntu_repo} {codename} main universe | |
deb {ubuntu_repo} {codename}-updates main universe | |
deb {ubuntu_repo} {codename}-security main universe | |
deb {security_repo} {codename}-security main universe | |
""".format( | |
mono_repo=mono_repo, | |
ubuntu_repo=ubuntu_repo, | |
security_repo=security_repo, | |
codename=_BASE_TO_UBUNTU_RELEASE_MAP[self.project.info.base], | |
) | |
) | |
def __init__(self, name, options, project): | |
super().__init__(name, options, project) | |
#Add the repo's key here. | |
super().run(cmd = ["/usr/bin/apt-key", | |
"adv", | |
"--keyserver", | |
"hkp://keyserver.ubuntu.com:80", | |
"--recv-keys", | |
"3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"], | |
cwd=None) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment