Merge lp:~sergiusens/snapcraft/mono into lp:~snappy-dev/snapcraft/core

Proposed by Sergio Schvezov on 2015-08-13
Status: Needs review
Proposed branch: lp:~sergiusens/snapcraft/mono
Merge into: lp:~snappy-dev/snapcraft/core
Diff against target: 169 lines (+128/-0)
8 files modified
examples/mono-project/hello-google.cs (+29/-0)
examples/mono-project/meta/package.yaml (+6/-0)
examples/mono-project/meta/readme.md (+1/-0)
examples/mono-project/snapcraft.yaml (+9/-0)
plugins/mono.yaml (+3/-0)
plugins/mono_project.yaml (+11/-0)
snapcraft/plugins/mono.py (+34/-0)
snapcraft/plugins/mono_project.py (+35/-0)
To merge this branch: bzr merge lp:~sergiusens/snapcraft/mono
Reviewer Review Type Date Requested Status
Ricardo Salveti 2015-08-13 Pending
Michael Vogt 2015-08-13 Pending
Jamie Strandboge 2015-08-13 Pending
Snappy Developers 2015-08-13 Pending
Review via email: mp+267894@code.launchpad.net

Commit message

Simple mono project

Description of the change

This is a practice MP that can be turned into a mergeable one.

The current example builds fine, but fails to run due to:
[27737.707903] audit: type=1400 audit(1439434887.243:723): apparmor="DENIED" operation="mknod" profile="mono-hello-google.sideload_run_0.1" name="/dev/shm/mono.2131" pid=2131 comm="hello-google" requested_mask="c" denied_mask="c" fsuid=1000 ouid=1000

Not sure if a general apparmor rule is warranted:

  /dev/shm/mono.** rmw, # adding pid is desired.

I'm also not sure how to reuse assembly parts as that is tied to cmd (common.env) and does not allow me to easily -r:[assembly] .. IOW, setting the env (involving knowledge of the other parts) from the plugin would be nice.

A simple hello world works fine.

To post a comment you must log in.
Jamie Strandboge (jdstrand) wrote :

If we were to add a rule, we could use this:

  /dev/shm/mono.${pid} rw,

${pid} today just expands to something approaching [0-9]* but the plan is to some day have kernel side variables such that ${pid} would correspond to the running process.

That said, we already have these rules:
/{dev,run}/shm/snaps/@{APP_PKGNAME}/ r,
/{dev,run}/shm/snaps/@{APP_PKGNAME}/** rk,
/{dev,run}/shm/snaps/@{APP_PKGNAME}/@{APP_VERSION}/ r,
/{dev,run}/shm/snaps/@{APP_PKGNAME}/@{APP_VERSION}/** mrwlkix,

Is there an environment variable that can be set in the launcher so that mono will just put the file in /dev/shm/snaps/@{APP_PKGNAME}/@{APP_VERSION}/ ?

Unmerged revisions

132. By Sergio Schvezov on 2015-08-13

Simple mono project

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'examples/mono-project'
2=== added file 'examples/mono-project/hello-google.cs'
3--- examples/mono-project/hello-google.cs 1970-01-01 00:00:00 +0000
4+++ examples/mono-project/hello-google.cs 2015-08-13 03:08:40 +0000
5@@ -0,0 +1,29 @@
6+using System;
7+using System.Net;
8+using System.Web;
9+using System.Text;
10+using System.Text.RegularExpressions;
11+
12+namespace Hello
13+{
14+ class GoogleSearch
15+ {
16+ static void Main(string[] args)
17+ {
18+ Console.Write("Google for: ");
19+ string searchString = HttpUtility.UrlEncode(Console.ReadLine());
20+
21+ Console.WriteLine();
22+ Console.Write("Please wait...\r");
23+
24+ WebClient webClient = new WebClient();
25+ byte[] response =
26+ webClient.DownloadData("http://www.google.com/search?&num=5&q="
27+ + searchString);
28+
29+ // Output results
30+ Console.WriteLine("===== Results =====");
31+ Console.WriteLine(response);
32+ }
33+ }
34+}
35
36=== added directory 'examples/mono-project/meta'
37=== added file 'examples/mono-project/meta/package.yaml'
38--- examples/mono-project/meta/package.yaml 1970-01-01 00:00:00 +0000
39+++ examples/mono-project/meta/package.yaml 2015-08-13 03:08:40 +0000
40@@ -0,0 +1,6 @@
41+name: mono-hello-google
42+version: 0.1
43+vendor: "Sergio Schvezov <sergio.schvezov@canonical.com>"
44+binaries:
45+ - name: run
46+ exec: hello-google
47
48=== added file 'examples/mono-project/meta/readme.md'
49--- examples/mono-project/meta/readme.md 1970-01-01 00:00:00 +0000
50+++ examples/mono-project/meta/readme.md 2015-08-13 03:08:40 +0000
51@@ -0,0 +1,1 @@
52+Galileo syncs with fitbit devices
53
54=== added file 'examples/mono-project/snapcraft.yaml'
55--- examples/mono-project/snapcraft.yaml 1970-01-01 00:00:00 +0000
56+++ examples/mono-project/snapcraft.yaml 2015-08-13 03:08:40 +0000
57@@ -0,0 +1,9 @@
58+parts:
59+ hello-google:
60+ plugin: mono_project
61+ source-files:
62+ - "*.cs"
63+ assemblies:
64+ - System.Web.dll
65+ source: .
66+snappy-metadata: meta
67
68=== added file 'plugins/mono.yaml'
69--- plugins/mono.yaml 1970-01-01 00:00:00 +0000
70+++ plugins/mono.yaml 2015-08-13 03:08:40 +0000
71@@ -0,0 +1,3 @@
72+module: mono
73+build-tools:
74+ - mono-complete
75
76=== added file 'plugins/mono_project.yaml'
77--- plugins/mono_project.yaml 1970-01-01 00:00:00 +0000
78+++ plugins/mono_project.yaml 2015-08-13 03:08:40 +0000
79@@ -0,0 +1,11 @@
80+module: mono_project
81+requires:
82+ - mono
83+options:
84+ source:
85+ required: true
86+ source-type:
87+ source-tag:
88+ source-branch:
89+ source-files:
90+ assemblies:
91
92=== added file 'snapcraft/plugins/mono.py'
93--- snapcraft/plugins/mono.py 1970-01-01 00:00:00 +0000
94+++ snapcraft/plugins/mono.py 2015-08-13 03:08:40 +0000
95@@ -0,0 +1,34 @@
96+# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
97+#
98+# Copyright (C) 2015 Canonical Ltd
99+#
100+# This program is free software: you can redistribute it and/or modify
101+# it under the terms of the GNU General Public License version 3 as
102+# published by the Free Software Foundation.
103+#
104+# This program is distributed in the hope that it will be useful,
105+# but WITHOUT ANY WARRANTY; without even the implied warranty of
106+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
107+# GNU General Public License for more details.
108+#
109+# You should have received a copy of the GNU General Public License
110+# along with this program. If not, see <http://www.gnu.org/licenses/>.
111+
112+import snapcraft
113+from snapcraft.plugins import ubuntu
114+
115+
116+class MonoPlugin(snapcraft.BasePlugin):
117+
118+ def __init__(self, name, options):
119+ super().__init__(name, options)
120+
121+ class MonoPackageOptions:
122+ packages = ["libmonoboehm-2.0-1", ]
123+ self.ubuntu = ubuntu.UbuntuPlugin(name, MonoPackageOptions())
124+
125+ def pull(self):
126+ return self.ubuntu.pull()
127+
128+ def build(self):
129+ return self.ubuntu.build()
130
131=== added file 'snapcraft/plugins/mono_project.py'
132--- snapcraft/plugins/mono_project.py 1970-01-01 00:00:00 +0000
133+++ snapcraft/plugins/mono_project.py 2015-08-13 03:08:40 +0000
134@@ -0,0 +1,35 @@
135+# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
136+#
137+# Copyright (C) 2015 Canonical Ltd
138+#
139+# This program is free software: you can redistribute it and/or modify
140+# it under the terms of the GNU General Public License version 3 as
141+# published by the Free Software Foundation.
142+#
143+# This program is distributed in the hope that it will be useful,
144+# but WITHOUT ANY WARRANTY; without even the implied warranty of
145+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
146+# GNU General Public License for more details.
147+#
148+# You should have received a copy of the GNU General Public License
149+# along with this program. If not, see <http://www.gnu.org/licenses/>.
150+
151+from os import path
152+
153+import snapcraft
154+
155+
156+class MonoProjectPlugin(snapcraft.BasePlugin):
157+
158+ def pull(self):
159+ return self.handle_source_options()
160+
161+ def build(self):
162+ assemblies = ["-r:{}".format(a) for a in self.options.assemblies]
163+ out_build = path.join(self.builddir, self.name)
164+ out_install = path.join(self.installdir, self.name)
165+ if not self.run(["mcs", "-out:{}".format(out_build)] +
166+ assemblies + self.options.source_files):
167+ return False
168+
169+ return self.run(["mkbundle", "--deps", out_build, "-o", out_install])

Subscribers

People subscribed via source and target branches