Merge lp:~jocave/snapcraft/plainbox-provider-plugin into lp:~snappy-dev/snapcraft/core

Proposed by Jonathan Cave
Status: Work in progress
Proposed branch: lp:~jocave/snapcraft/plainbox-provider-plugin
Merge into: lp:~snappy-dev/snapcraft/core
Diff against target: 118 lines (+82/-0)
7 files modified
examples/plainbox-provider/integration-tests-runner (+7/-0)
examples/plainbox-provider/meta/package.yaml (+9/-0)
examples/plainbox-provider/meta/readme.md (+1/-0)
examples/plainbox-provider/plainbox-wrapper (+15/-0)
examples/plainbox-provider/snapcraft.yaml (+14/-0)
plugins/plainbox-provider.yaml (+5/-0)
snapcraft/plugins/plainbox_provider.py (+31/-0)
To merge this branch: bzr merge lp:~jocave/snapcraft/plainbox-provider-plugin
Reviewer Review Type Date Requested Status
Snappy Developers Pending
Review via email: mp+268221@code.launchpad.net

Commit message

Adds a plugin for building Plainbox Providers in to snaps.

Description of the change

Adds a plugin for building Plainbox Providers in to snaps.

Plainbox providers contain test definitions to be used with the Plainbox test
runner itself.

This plugin takes the a provider from the source location defined and runs the
appropriate commands to
 1. run the provider build step so any binaries are created
 2. run the provider install step to stage the provider in the desired layout

To post a comment you must log in.
134. By Jonathan Cave

Creating a plainbox-provider plugin

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

should this depend on the python3 module (in the yaml)?

On Mon, Aug 17, 2015 at 6:18 AM, Jonathan Cave <email address hidden>
wrote:

> Jonathan Cave has proposed merging
> lp:~jocave/snapcraft/plainbox-provider-plugin into lp:snapcraft.
>
> Requested reviews:
> Snappy Developers (snappy-dev)
>
> For more details, see:
>
> https://code.launchpad.net/~jocave/snapcraft/plainbox-provider-plugin/+merge/268221
>
> Adds a plugin for building Plainbox Providers in to snaps.
>
> Plainbox providers contain test definitions to be used with the Plainbox
> test
> runner itself.
>
> This plugin takes the a provider from the source location defined and runs
> the
> appropriate commands to
> 1. run the provider build step so any binaries are created
> 2. run the provider install step to stage the provider in the desired
> layout
>
> --
> Your team Snappy Developers is requested to review the proposed merge of
> lp:~jocave/snapcraft/plainbox-provider-plugin into lp:snapcraft.
>
> Launchpad-Message-Rationale: Reviewer @snappy-dev
> Launchpad-Notification-Type: code-review
> Launchpad-Branch: ~jocave/snapcraft/plainbox-provider-plugin
> Launchpad-Project: snapcraft
>
> === added file 'plugins/plainbox-provider.yaml'
> --- plugins/plainbox-provider.yaml 1970-01-01 00:00:00 +0000
> +++ plugins/plainbox-provider.yaml 2015-08-17 13:17:58 +0000
> @@ -0,0 +1,4 @@
> +module: plainbox_provider
> +options:
> + source:
> + required: true
>
> === added file 'snapcraft/plugins/plainbox_provider.py'
> --- snapcraft/plugins/plainbox_provider.py 1970-01-01 00:00:00 +0000
> +++ snapcraft/plugins/plainbox_provider.py 2015-08-17 13:17:58 +0000
> @@ -0,0 +1,34 @@
> +# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
> +#
> +# Copyright (C) 2015 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 snapcraft
> +
> +
> +class PlainboxProviderPlugin(snapcraft.BasePlugin):
> +
> + # note that we don't need to setup env(), python figures it out
> + # see python3.py for more details
> +
> + def pull(self):
> + return self.handle_source_options()
> +
> + def build(self):
> + return self.run(["python3", "manage.py", "build"])
> +
> + def stage(self):
> + return self.run(
> + ["python3", "manage.py", "install", "--layout=snappy",
> + "--root=%s" % self.installdir])
>
>
>

135. By Jonathan Cave

Adding requires: on python3 to yaml

Revision history for this message
Jonathan Cave (jocave) wrote :

Sergio - yes, thanks. Now added.

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Hey.

Sorry, I'm just wrapping my head around this. I think it should _not_ depend on python 3. A provider is just a collection of definitions. We need python and plainbox on the build machine but the target machine does not need python (plainbox is a framework).

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

(and what I mean by sorry is that I'm not sure if this pulls in python to the snap (wrong) or on the host to build the snap (correct but we then also require a >= version of plainbox to boot).

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

On Wed, Aug 19, 2015 at 8:19 AM, Zygmunt Krynicki <
<email address hidden>> wrote:

> (and what I mean by sorry is that I'm not sure if this pulls in python to
> the snap (wrong) or on the host to build the snap (correct but we then also
> require a >= version of plainbox to boot).

Hmm, maybe an example inside examples would clear things up with the
intentions of this plugin, but you need to either depend on the plugin
which would make it part of the final snap or add a build-depends to the
yaml for constructing this.

I guess in any case, for a plugin we need an E2E working example inside
'examples' to not have a half baked plugin.

Revision history for this message
Jonathan Cave (jocave) wrote :

Yep a request for an example is very reasonable.

Zyga - could you suggest a suitable provider to feature in the example? Or
would the integration-tests of snapcraft itself be a convenient example?!

On 19 August 2015 at 19:57, Sergio Schvezov <email address hidden>
wrote:

> On Wed, Aug 19, 2015 at 8:19 AM, Zygmunt Krynicki <
> <email address hidden>> wrote:
>
> > (and what I mean by sorry is that I'm not sure if this pulls in python to
> > the snap (wrong) or on the host to build the snap (correct but we then
> also
> > require a >= version of plainbox to boot).
>
>
> Hmm, maybe an example inside examples would clear things up with the
> intentions of this plugin, but you need to either depend on the plugin
> which would make it part of the final snap or add a build-depends to the
> yaml for constructing this.
>
> I guess in any case, for a plugin we need an E2E working example inside
> 'examples' to not have a half baked plugin.
>
> --
>
> https://code.launchpad.net/~jocave/snapcraft/plainbox-provider-plugin/+merge/268221
> You are the owner of lp:~jocave/snapcraft/plainbox-provider-plugin.
>

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

On Wed, Aug 19, 2015 at 8:18 AM, Zygmunt Krynicki <
<email address hidden>> wrote:

> Hey.
>
> Sorry, I'm just wrapping my head around this. I think it should _not_
> depend on python 3. A provider is just a collection of definitions. We need
> python and plainbox on the build machine but the target machine does not
> need python (plainbox is a framework).

Sorry (me too ;-) ), but I have to ask. What is the reasoning for the
plainbox runtime to be a framework?

Can't snapcraft just bundle it all together into one harmonious app snap?

Do you see any potential in keeping them separate at all?

136. By Jonathan Cave

Make the python3 depends a build dependency and add plainbox.
Add an example of the plainbox provider plugin usage.

Unmerged revisions

136. By Jonathan Cave

Make the python3 depends a build dependency and add plainbox.
Add an example of the plainbox provider plugin usage.

135. By Jonathan Cave

Adding requires: on python3 to yaml

134. By Jonathan Cave

Creating a plainbox-provider plugin

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'examples/plainbox-provider'
2=== added file 'examples/plainbox-provider/integration-tests-runner'
3--- examples/plainbox-provider/integration-tests-runner 1970-01-01 00:00:00 +0000
4+++ examples/plainbox-provider/integration-tests-runner 2015-08-24 17:24:20 +0000
5@@ -0,0 +1,7 @@
6+#!/bin/sh
7+# This wrapper runs plainbox with the integration-tests test plan. It lets the
8+# test operator pass any additional options so that some degree of freedom over
9+# result processing is retained.
10+#
11+# For a totally free-form use, just call plainbox directly.
12+exec plainbox-wrapper run -T 2015.com.canonical.snapcraft::normal "$@"
13
14=== added directory 'examples/plainbox-provider/meta'
15=== added file 'examples/plainbox-provider/meta/package.yaml'
16--- examples/plainbox-provider/meta/package.yaml 1970-01-01 00:00:00 +0000
17+++ examples/plainbox-provider/meta/package.yaml 2015-08-24 17:24:20 +0000
18@@ -0,0 +1,9 @@
19+name: snapcraft-integration-tests-provider
20+version: 1
21+vendor: Jonathan Cave <jonathan.cave@canonical.com>
22+binaries:
23+ - name: integration-tests-runner
24+ security-template: unconfined
25+ - name: plainbox
26+ exec: bin/plainbox-wrapper
27+ security-template: unconfined
28
29=== added file 'examples/plainbox-provider/meta/readme.md'
30--- examples/plainbox-provider/meta/readme.md 1970-01-01 00:00:00 +0000
31+++ examples/plainbox-provider/meta/readme.md 2015-08-24 17:24:20 +0000
32@@ -0,0 +1,1 @@
33+A snap package of snapcraft integration tests plainbox provider
34
35=== added file 'examples/plainbox-provider/plainbox-wrapper'
36--- examples/plainbox-provider/plainbox-wrapper 1970-01-01 00:00:00 +0000
37+++ examples/plainbox-provider/plainbox-wrapper 2015-08-24 17:24:20 +0000
38@@ -0,0 +1,15 @@
39+#!/bin/sh
40+# This wrapper, which is installed as $SNAP_APP_PATH/bin/plainbox
41+# (taking over $SNAP_APP_PATH/usr/bin/plainbox in priority) serves
42+# two purposes:
43+# - It sets a PROVIDERPATH that plainbox can find bundled providers:
44+# each provider is installed to /providers/$name, they are listed
45+# in a typical :-separated PATH-like variable.
46+# This is largely tracked as https://bugs.launchpad.net/plainbox/+bug/1473939
47+export PROVIDERPATH="$SNAP_APP_PATH/providers/plainbox-provider-snapcraft-integration-tests:"
48+# - It works around a bug in snapcraft which causes scripts to refer
49+# to the wrong (outside, not bundled) interpreter.
50+# https://bugs.launchpad.net/snapcraft/+bug/1486659
51+# NOTE: Here python3 is already the one from the snap, because we are running
52+# in altered environment and PATH is set accordingly.
53+exec python3 $(which plainbox) "$@"
54
55=== added file 'examples/plainbox-provider/snapcraft.yaml'
56--- examples/plainbox-provider/snapcraft.yaml 1970-01-01 00:00:00 +0000
57+++ examples/plainbox-provider/snapcraft.yaml 2015-08-24 17:24:20 +0000
58@@ -0,0 +1,14 @@
59+parts:
60+ # Note: this does not currently pull in all the dependencies
61+ # of the integration tests themselves i.e. hg, bzr, ...
62+ plainbox:
63+ plugin: ubuntu
64+ plainbox-provider-snapcraft-integration-tests:
65+ plugin: plainbox-provider
66+ source: ../../integration-tests
67+ launcher:
68+ plugin: copy
69+ files:
70+ plainbox-wrapper: bin/plainbox-wrapper
71+ integration-tests-runner: bin/integration-tests-runner
72+snappy-metadata: meta
73
74=== added file 'plugins/plainbox-provider.yaml'
75--- plugins/plainbox-provider.yaml 1970-01-01 00:00:00 +0000
76+++ plugins/plainbox-provider.yaml 2015-08-24 17:24:20 +0000
77@@ -0,0 +1,5 @@
78+module: plainbox_provider
79+build-tools: [python3, plainbox]
80+options:
81+ source:
82+ required: true
83
84=== added file 'snapcraft/plugins/plainbox_provider.py'
85--- snapcraft/plugins/plainbox_provider.py 1970-01-01 00:00:00 +0000
86+++ snapcraft/plugins/plainbox_provider.py 2015-08-24 17:24:20 +0000
87@@ -0,0 +1,31 @@
88+# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
89+#
90+# Copyright (C) 2015 Canonical Ltd
91+#
92+# This program is free software: you can redistribute it and/or modify
93+# it under the terms of the GNU General Public License version 3 as
94+# published by the Free Software Foundation.
95+#
96+# This program is distributed in the hope that it will be useful,
97+# but WITHOUT ANY WARRANTY; without even the implied warranty of
98+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
99+# GNU General Public License for more details.
100+#
101+# You should have received a copy of the GNU General Public License
102+# along with this program. If not, see <http://www.gnu.org/licenses/>.
103+
104+import snapcraft
105+
106+
107+class PlainboxProviderPlugin(snapcraft.BasePlugin):
108+
109+ # note that we don't need to setup env(), python figures it out
110+ # see python3.py for more details
111+
112+ def pull(self):
113+ return self.handle_source_options()
114+
115+ def build(self):
116+ return self.run(["python3", "manage.py", "build"]) and \
117+ self.run(["python3", "manage.py", "install", "--layout=relocatable",
118+ "--root=%s" % self.installdir])

Subscribers

People subscribed via source and target branches