Skip to content

Commit

Permalink
snapcraft.yaml: add minimal snapcraft.yaml with custom build
Browse files Browse the repository at this point in the history
This adds a minimal snapcraft.yaml and a custom build plugin.
The snapcraft.yaml only puts the bits into the snapd snap
for now. This means we can start testing the core18/snapd
interplay.

The plugin will just reuse the deb building (which we have to
maintain anyway). The plugin should probably be cleaned up and
pushed upstream as this seems to be useful for projects that
already have a (complicated) deb based build setup.

One issue with the current snapcraft is that it does not deal with
a source dir called "snap" well. We have code located there but
snapcraft will ignore this dir when pulling code or when setting
up the build tree: https://bugs.launchpad.net/bugs/1772584
  • Loading branch information
mvo5 committed May 23, 2018
1 parent 86c958c commit 9f2782f
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
41 changes: 41 additions & 0 deletions parts/plugins/x_builddeb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright (C) 2018 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import glob
import os

import snapcraft

# cowboy baby, see https://bugs.launchpad.net/snapcraft/+bug/1772584
def patch_snapcraft():
import snapcraft.internal.common
# very hacky but gets the job done for now, right now
# SNAPCRAFT_FILES is only used to know what to exclude
snapcraft.internal.common.SNAPCRAFT_FILES.remove("snap")
patch_snapcraft()



class XBuildDeb(snapcraft.BasePlugin):

def build(self):
self.run(["sudo", "apt-get", "build-dep", "-y", "./"])
# XXX: get this from "debian/gbp.conf:postexport"
self.run(["./get-deps.sh"])
# run the real build
self.run(["dpkg-buildpackage", "--no-sign"])
# and "install" into the right place
snapd_deb = glob.glob("../snapd_*.deb")[0]
self.run(["dpkg-deb", "-x", os.path.abspath(snapd_deb), self.installdir])

32 changes: 32 additions & 0 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: snapd
summary: Daemon and tooling that enable snap packages
description: |
Install, configure, refresh and remove snap packages. Snaps are
'universal' packages that work across many different Linux systems,
enabling secure distribution of the latest apps and utilities for
cloud, servers, desktops and the internet of things.
This is the CLI for snapd, a background service that takes care of
snaps on the system. Start with 'snap list' to see installed snaps.
version: set-by-version-script-thxbye
version-script: |
# extract the version from the debian/changelog
dpkg-parsechangelog -Sversion
grade: devel

parts:
snapd:
# FIXME: this should probably go upstream
plugin: x-builddeb
source: .

# Note that this snap is unusual in that it has no "apps" section.
#
# It is started via re-exec on classic systems and via special
# handling in the core18 snap on Ubuntu Core Systems.
#
# Because snapd itself manages snaps it must currently run totally
# unconfined (even devmode is not enough).
#
# See the comments from jdstrand in
# https://forum.snapcraft.io/t/5547/10

0 comments on commit 9f2782f

Please sign in to comment.