Merge lp:~zyga/snapcraft/custom-plugin into lp:~snappy-dev/snapcraft/core

Proposed by Zygmunt Krynicki
Status: Rejected
Rejected by: Sergio Schvezov
Proposed branch: lp:~zyga/snapcraft/custom-plugin
Merge into: lp:~snappy-dev/snapcraft/core
Diff against target: 103 lines (+84/-0)
3 files modified
.bzrignore (+1/-0)
plugins/custom.yaml (+9/-0)
snapcraft/plugins/custom.py (+74/-0)
To merge this branch: bzr merge lp:~zyga/snapcraft/custom-plugin
Reviewer Review Type Date Requested Status
Sergio Schvezov Disapprove
Review via email: mp+270994@code.launchpad.net
To post a comment you must log in.
lp:~zyga/snapcraft/custom-plugin updated
159. By Sergio Schvezov

Filesets based filtering for stage and snap by sergiusens approved by sergiusens,mvo

160. By Sergio Schvezov

snapcraft init with templated values by sergiusens approved by mvo

161. By Sergio Schvezov

regex for binary and service names by sergiusens approved by mvo

162. By Sergio Schvezov

docs refresh by sergiusens approved by chipaca

163. By Sergio Schvezov

Collision logic updates with an introduction of _BUILTIN_OPTIONS so all parts have a certain set of options by default even if not declared. by sergiusens approved by mvo

164. By Daniel Holbach

fix crash when stage_packages is defined in the yaml for the plugin, but empty (getattr does not use [] as default return value in that case) by dholbach approved by sergiusens

165. By Daniel Holbach

Fix small typo. by dholbach approved by sergiusens

166. By Sergio Schvezov

Support config by sergiusens approved by sergiusens,chipaca

167. By Sergio Schvezov

Try to use wiki when after in part is not local by sergiusens approved by sergiusens,chipaca,dholbach

168. By Zygmunt Krynicki

Explicitly ignore __pycache__

Signed-off-by: Zygmunt Krynicki <email address hidden>

169. By Zygmunt Krynicki

Symlink .bzrignore to .gitignore

Signed-off-by: Zygmunt Krynicki <email address hidden>

170. By Zygmunt Krynicki

Add custom part type

This part type allows developers to integrate arbitrary projects with
arbitrary build commands. It is especially well suited for the long tail
of various projects that don't quite match the strict requirements of
autotools projects and that require custom sprinkle of magic in each
case.

Each custom project requires one definition in the snapcraft yaml file,
the list / string of custom commands. Those are invoked at part build
time. Three variables are interpolated into those commands, those are
$PART_{NAME,{INSTALL,BUILD}_DIR}.

Signed-off-by: Zygmunt Krynicki <email address hidden>

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

Thanks for your contribution, but this doesn't go in the desired direction for plugins we desire. Thanks

review: Disapprove

Unmerged revisions

170. By Zygmunt Krynicki

Add custom part type

This part type allows developers to integrate arbitrary projects with
arbitrary build commands. It is especially well suited for the long tail
of various projects that don't quite match the strict requirements of
autotools projects and that require custom sprinkle of magic in each
case.

Each custom project requires one definition in the snapcraft yaml file,
the list / string of custom commands. Those are invoked at part build
time. Three variables are interpolated into those commands, those are
$PART_{NAME,{INSTALL,BUILD}_DIR}.

Signed-off-by: Zygmunt Krynicki <email address hidden>

169. By Zygmunt Krynicki

Symlink .bzrignore to .gitignore

Signed-off-by: Zygmunt Krynicki <email address hidden>

168. By Zygmunt Krynicki

Explicitly ignore __pycache__

Signed-off-by: Zygmunt Krynicki <email address hidden>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2015-08-27 21:33:21 +0000
3+++ .bzrignore 2015-09-16 06:45:26 +0000
4@@ -10,3 +10,4 @@
5 *.egg-info
6 .coverage**
7 htmlcov
8+__pycache__
9
10=== added symlink '.gitignore'
11=== target is u'.bzrignore'
12=== added file 'plugins/custom.yaml'
13--- plugins/custom.yaml 1970-01-01 00:00:00 +0000
14+++ plugins/custom.yaml 2015-09-16 06:45:26 +0000
15@@ -0,0 +1,9 @@
16+module: custom
17+options:
18+ source:
19+ required: true
20+ source-type:
21+ source-tag:
22+ source-branch:
23+ custom-cmds:
24+ required: true
25
26=== added file 'snapcraft/plugins/custom.py'
27--- snapcraft/plugins/custom.py 1970-01-01 00:00:00 +0000
28+++ snapcraft/plugins/custom.py 2015-09-16 06:45:26 +0000
29@@ -0,0 +1,74 @@
30+# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
31+#
32+# Copyright (C) 2015 Canonical Ltd
33+#
34+# This program is free software: you can redistribute it and/or modify
35+# it under the terms of the GNU General Public License version 3 as
36+# published by the Free Software Foundation.
37+#
38+# This program is distributed in the hope that it will be useful,
39+# but WITHOUT ANY WARRANTY; without even the implied warranty of
40+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41+# GNU General Public License for more details.
42+#
43+# You should have received a copy of the GNU General Public License
44+# along with this program. If not, see <http://www.gnu.org/licenses/>.
45+
46+
47+"""Implementation of the "custom" part type."""
48+
49+import shlex
50+
51+import snapcraft
52+
53+
54+class CustomPlugin(snapcraft.BasePlugin):
55+
56+ """
57+ Snapcraft plugin for custom builds.
58+
59+ This plugin is closer to Debian packaging than to "we know better" canned
60+ environments. It is most useful with parts that are close but not quite
61+ entirely supported by other part types.
62+
63+ This plugin/type exposes one mandatory command (or list of commands):
64+
65+ custom-cmds:
66+ This command must configure the source tree for building. The commands
67+ have access to quasi variables for the name of the part being built
68+ $SNAPCRAFT_PART_NAME, build directory $SNAPCRAFT_BUILD_DIR and the
69+ installation directory $SNAPCRAFT_PART_INSTALL_DIR. Those are not real
70+ shell variables, instead they are expanded before the command is
71+ executed. This is a limitation of the current version of snapcraft.
72+ """
73+
74+ def build(self):
75+ """Build a custom snap part."""
76+ def make_cmd_list(cmd):
77+ if isinstance(cmd, list):
78+ return [[
79+ cmd_split_part.replace(
80+ '$SNAPCRAFT_PART_INSTALL_DIR', self.installdir
81+ ).replace(
82+ '$SNAPCRAFT_PART_BUILD_DIR', self.builddir
83+ ).replace(
84+ '$SNAPCRAFT_PART_NAME', self.name
85+ )
86+ for cmd_split_part in shlex.split(cmd_part)
87+ ] for cmd_part in cmd]
88+ elif isinstance(cmd, str):
89+ return make_cmd_list([cmd])
90+ elif isinstance(cmd, None):
91+ return []
92+
93+ def dispatch_cmd_list(cmd_list):
94+ for cmd in cmd_list:
95+ if not self.run(cmd):
96+ return False
97+ return True
98+
99+ return dispatch_cmd_list(make_cmd_list(self.options.custom_cmds))
100+
101+ def pull(self):
102+ """Pull the source of a custom snap part."""
103+ return self.handle_source_options()

Subscribers

People subscribed via source and target branches