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

Proposed by Sergio Schvezov
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 Pending
Michael Vogt Pending
Jamie Strandboge Pending
Snappy Developers 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.
Revision history for this message
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

Simple mono project

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'examples/mono-project'
=== added file 'examples/mono-project/hello-google.cs'
--- examples/mono-project/hello-google.cs 1970-01-01 00:00:00 +0000
+++ examples/mono-project/hello-google.cs 2015-08-13 03:08:40 +0000
@@ -0,0 +1,29 @@
1using System;
2using System.Net;
3using System.Web;
4using System.Text;
5using System.Text.RegularExpressions;
6
7namespace Hello
8{
9 class GoogleSearch
10 {
11 static void Main(string[] args)
12 {
13 Console.Write("Google for: ");
14 string searchString = HttpUtility.UrlEncode(Console.ReadLine());
15
16 Console.WriteLine();
17 Console.Write("Please wait...\r");
18
19 WebClient webClient = new WebClient();
20 byte[] response =
21 webClient.DownloadData("http://www.google.com/search?&num=5&q="
22 + searchString);
23
24 // Output results
25 Console.WriteLine("===== Results =====");
26 Console.WriteLine(response);
27 }
28 }
29}
030
=== added directory 'examples/mono-project/meta'
=== added file 'examples/mono-project/meta/package.yaml'
--- examples/mono-project/meta/package.yaml 1970-01-01 00:00:00 +0000
+++ examples/mono-project/meta/package.yaml 2015-08-13 03:08:40 +0000
@@ -0,0 +1,6 @@
1name: mono-hello-google
2version: 0.1
3vendor: "Sergio Schvezov <sergio.schvezov@canonical.com>"
4binaries:
5 - name: run
6 exec: hello-google
07
=== added file 'examples/mono-project/meta/readme.md'
--- examples/mono-project/meta/readme.md 1970-01-01 00:00:00 +0000
+++ examples/mono-project/meta/readme.md 2015-08-13 03:08:40 +0000
@@ -0,0 +1,1 @@
1Galileo syncs with fitbit devices
02
=== added file 'examples/mono-project/snapcraft.yaml'
--- examples/mono-project/snapcraft.yaml 1970-01-01 00:00:00 +0000
+++ examples/mono-project/snapcraft.yaml 2015-08-13 03:08:40 +0000
@@ -0,0 +1,9 @@
1parts:
2 hello-google:
3 plugin: mono_project
4 source-files:
5 - "*.cs"
6 assemblies:
7 - System.Web.dll
8 source: .
9snappy-metadata: meta
010
=== added file 'plugins/mono.yaml'
--- plugins/mono.yaml 1970-01-01 00:00:00 +0000
+++ plugins/mono.yaml 2015-08-13 03:08:40 +0000
@@ -0,0 +1,3 @@
1module: mono
2build-tools:
3 - mono-complete
04
=== added file 'plugins/mono_project.yaml'
--- plugins/mono_project.yaml 1970-01-01 00:00:00 +0000
+++ plugins/mono_project.yaml 2015-08-13 03:08:40 +0000
@@ -0,0 +1,11 @@
1module: mono_project
2requires:
3 - mono
4options:
5 source:
6 required: true
7 source-type:
8 source-tag:
9 source-branch:
10 source-files:
11 assemblies:
012
=== added file 'snapcraft/plugins/mono.py'
--- snapcraft/plugins/mono.py 1970-01-01 00:00:00 +0000
+++ snapcraft/plugins/mono.py 2015-08-13 03:08:40 +0000
@@ -0,0 +1,34 @@
1# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
2#
3# Copyright (C) 2015 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17import snapcraft
18from snapcraft.plugins import ubuntu
19
20
21class MonoPlugin(snapcraft.BasePlugin):
22
23 def __init__(self, name, options):
24 super().__init__(name, options)
25
26 class MonoPackageOptions:
27 packages = ["libmonoboehm-2.0-1", ]
28 self.ubuntu = ubuntu.UbuntuPlugin(name, MonoPackageOptions())
29
30 def pull(self):
31 return self.ubuntu.pull()
32
33 def build(self):
34 return self.ubuntu.build()
035
=== added file 'snapcraft/plugins/mono_project.py'
--- snapcraft/plugins/mono_project.py 1970-01-01 00:00:00 +0000
+++ snapcraft/plugins/mono_project.py 2015-08-13 03:08:40 +0000
@@ -0,0 +1,35 @@
1# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
2#
3# Copyright (C) 2015 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17from os import path
18
19import snapcraft
20
21
22class MonoProjectPlugin(snapcraft.BasePlugin):
23
24 def pull(self):
25 return self.handle_source_options()
26
27 def build(self):
28 assemblies = ["-r:{}".format(a) for a in self.options.assemblies]
29 out_build = path.join(self.builddir, self.name)
30 out_install = path.join(self.installdir, self.name)
31 if not self.run(["mcs", "-out:{}".format(out_build)] +
32 assemblies + self.options.source_files):
33 return False
34
35 return self.run(["mkbundle", "--deps", out_build, "-o", out_install])

Subscribers

People subscribed via source and target branches