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

Proposed by Sergio Schvezov
Status: Merged
Approved by: John Lenton
Approved revision: 155
Merged at revision: 143
Proposed branch: lp:~sergiusens/snapcraft/icon-meta
Merge into: lp:~snappy-dev/snapcraft/core
Prerequisite: lp:~sergiusens/snapcraft/testing-fixes
Diff against target: 739 lines (+101/-21)
32 files modified
examples/godd/snapcraft.yaml (+1/-0)
examples/gopaste/snapcraft.yaml (+1/-0)
examples/java-hello-world/snapcraft.yaml (+1/-0)
examples/libpipeline/snapcraft.yaml (+1/-0)
examples/py2-project/snapcraft.yaml (+1/-0)
examples/py3-project/snapcraft.yaml (+1/-0)
examples/qmldemo/snapcraft.yaml (+1/-0)
examples/tomcat-maven-webapp/snapcraft.yaml (+1/-0)
examples/webcam-webui-snap/snapcraft.yaml (+1/-0)
examples/wget-deb/snapcraft.yaml (+1/-0)
integration-tests/data/assemble/snapcraft.yaml (+1/-0)
integration-tests/data/bzr-head/snapcraft.yaml (+1/-0)
integration-tests/data/bzr-tag/snapcraft.yaml (+1/-0)
integration-tests/data/conflicts/snapcraft.yaml (+1/-0)
integration-tests/data/dependencies/snapcraft.yaml (+1/-0)
integration-tests/data/git-branch/snapcraft.yaml (+1/-0)
integration-tests/data/git-head/snapcraft.yaml (+1/-0)
integration-tests/data/git-tag/snapcraft.yaml (+1/-0)
integration-tests/data/hg-branch/snapcraft.yaml (+1/-0)
integration-tests/data/hg-head/snapcraft.yaml (+1/-0)
integration-tests/data/hg-tag/snapcraft.yaml (+1/-0)
integration-tests/data/local-plugin/snapcraft.yaml (+1/-0)
integration-tests/data/local-source/snapcraft.yaml (+1/-0)
integration-tests/data/simple-cmake/snapcraft.yaml (+1/-0)
integration-tests/data/simple-copy/snapcraft.yaml (+1/-0)
integration-tests/data/simple-make/snapcraft.yaml (+1/-0)
integration-tests/data/simple-tar/snapcraft.yaml (+1/-0)
schema/snapcraft.yaml (+5/-0)
snapcraft/meta.py (+11/-0)
snapcraft/tests/test_meta.py (+20/-8)
snapcraft/tests/test_yaml.py (+30/-12)
snapcraft/yaml.py (+8/-1)
To merge this branch: bzr merge lp:~sergiusens/snapcraft/icon-meta
Reviewer Review Type Date Requested Status
John Lenton (community) Approve
Leo Arias (community) Needs Fixing
Review via email: mp+269446@code.launchpad.net

Commit message

icon support for snapcraft.yaml

To post a comment you must log in.
lp:~sergiusens/snapcraft/icon-meta updated
154. By Sergio Schvezov

oops moment

Revision history for this message
Leo Arias (elopio) wrote :

You forgot to add the icon.png files for the integration-tests. They all fail with:

Issues while validating snapcraft.yaml: 'icon.png' is not a 'icon-path'

And you are missing the assertion on the copy call:

+ icon_path = os.path.join(meta_dir, 'my-icon.png')
+ self.mock_copyfile.assert_called_once_with('my-icon.png', icon_path)

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

doh, thanks, done

On Thu, Aug 27, 2015 at 7:51 PM, Leo Arias <email address hidden> wrote:

> Review: Needs Fixing
>
> You forgot to add the icon.png files for the integration-tests. They all
> fail with:
>
> Issues while validating snapcraft.yaml: 'icon.png' is not a 'icon-path'
>
> And you are missing the assertion on the copy call:
>
> + icon_path = os.path.join(meta_dir, 'my-icon.png')
> + self.mock_copyfile.assert_called_once_with('my-icon.png',
> icon_path)
>
> --
> https://code.launchpad.net/~sergiusens/snapcraft/icon-meta/+merge/269446
> You are the owner of lp:~sergiusens/snapcraft/icon-meta.
>
> Launchpad-Message-Rationale: Owner
> Launchpad-Notification-Type: code-review
> Launchpad-Branch: ~sergiusens/snapcraft/icon-meta
> Launchpad-Project: snapcraft
>

lp:~sergiusens/snapcraft/icon-meta updated
155. By Sergio Schvezov

da icons

Revision history for this message
John Lenton (chipaca) wrote :

Awesome

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'examples/godd/icon.png'
2Binary files examples/godd/icon.png 1970-01-01 00:00:00 +0000 and examples/godd/icon.png 2015-08-28 00:36:51 +0000 differ
3=== modified file 'examples/godd/snapcraft.yaml'
4--- examples/godd/snapcraft.yaml 2015-08-25 18:53:18 +0000
5+++ examples/godd/snapcraft.yaml 2015-08-28 00:36:51 +0000
6@@ -5,6 +5,7 @@
7 - name: ./bin/godd
8 summary: Simple dd like tool
9 description: written in go so it is self contained and really portable, you would need to use hw-assign to access devices.
10+icon: icon.png
11
12 parts:
13 godd:
14
15=== added file 'examples/gopaste/icon.png'
16Binary files examples/gopaste/icon.png 1970-01-01 00:00:00 +0000 and examples/gopaste/icon.png 2015-08-28 00:36:51 +0000 differ
17=== modified file 'examples/gopaste/snapcraft.yaml'
18--- examples/gopaste/snapcraft.yaml 2015-08-25 18:53:18 +0000
19+++ examples/gopaste/snapcraft.yaml 2015-08-28 00:36:51 +0000
20@@ -7,6 +7,7 @@
21 start: bin/gopaste
22 summary: Simple pasting tool
23 description: Runs a service that allows you to paste to and share.
24+icon: icon.png
25
26 parts:
27 gopaste:
28
29=== added file 'examples/java-hello-world/icon.png'
30Binary files examples/java-hello-world/icon.png 1970-01-01 00:00:00 +0000 and examples/java-hello-world/icon.png 2015-08-28 00:36:51 +0000 differ
31=== modified file 'examples/java-hello-world/snapcraft.yaml'
32--- examples/java-hello-world/snapcraft.yaml 2015-08-25 18:53:18 +0000
33+++ examples/java-hello-world/snapcraft.yaml 2015-08-28 00:36:51 +0000
34@@ -6,6 +6,7 @@
35 exec: bin/wrapper
36 summary: A java exmaple
37 description: this is not much more than an example
38+icon: icon.png
39
40 parts:
41 local:
42
43=== added file 'examples/libpipeline/icon.png'
44Binary files examples/libpipeline/icon.png 1970-01-01 00:00:00 +0000 and examples/libpipeline/icon.png 2015-08-28 00:36:51 +0000 differ
45=== modified file 'examples/libpipeline/snapcraft.yaml'
46--- examples/libpipeline/snapcraft.yaml 2015-08-25 18:53:18 +0000
47+++ examples/libpipeline/snapcraft.yaml 2015-08-28 00:36:51 +0000
48@@ -5,6 +5,7 @@
49 - name: ./bin/pipelinetest
50 summary: Libpipeline example
51 description: this is an example package of an autotools project built with snapcraft using
52+icon: icon.png
53
54 parts:
55 pipelinetest:
56
57=== added file 'examples/py2-project/icon.png'
58Binary files examples/py2-project/icon.png 1970-01-01 00:00:00 +0000 and examples/py2-project/icon.png 2015-08-28 00:36:51 +0000 differ
59=== modified file 'examples/py2-project/snapcraft.yaml'
60--- examples/py2-project/snapcraft.yaml 2015-08-25 18:53:18 +0000
61+++ examples/py2-project/snapcraft.yaml 2015-08-28 00:36:51 +0000
62@@ -5,6 +5,7 @@
63 - name: ./bin/sha3sum
64 summary: A python sha3 implementation
65 description: A python2 project using snapcraft
66+icon: icon.png
67
68 parts:
69 spongeshaker:
70
71=== added file 'examples/py3-project/icon.png'
72Binary files examples/py3-project/icon.png 1970-01-01 00:00:00 +0000 and examples/py3-project/icon.png 2015-08-28 00:36:51 +0000 differ
73=== modified file 'examples/py3-project/snapcraft.yaml'
74--- examples/py3-project/snapcraft.yaml 2015-08-25 18:53:18 +0000
75+++ examples/py3-project/snapcraft.yaml 2015-08-28 00:36:51 +0000
76@@ -5,6 +5,7 @@
77 - name: bin/sha3sum
78 summary: A python sha3 implementation
79 description: A python2 project using snapcraft
80+icon: icon.png
81
82 parts:
83 spongeshaker:
84
85=== added file 'examples/qmldemo/icon.png'
86Binary files examples/qmldemo/icon.png 1970-01-01 00:00:00 +0000 and examples/qmldemo/icon.png 2015-08-28 00:36:51 +0000 differ
87=== modified file 'examples/qmldemo/snapcraft.yaml'
88--- examples/qmldemo/snapcraft.yaml 2015-08-25 18:53:18 +0000
89+++ examples/qmldemo/snapcraft.yaml 2015-08-28 00:36:51 +0000
90@@ -11,6 +11,7 @@
91 - network-client
92 summary: qml demo
93 description: An example of shipping a usable QML file in a snap using the QML plugin.
94+icon: icon.png
95
96 parts:
97 qml:
98
99=== added file 'examples/tomcat-maven-webapp/icon.png'
100Binary files examples/tomcat-maven-webapp/icon.png 1970-01-01 00:00:00 +0000 and examples/tomcat-maven-webapp/icon.png 2015-08-28 00:36:51 +0000 differ
101=== modified file 'examples/tomcat-maven-webapp/snapcraft.yaml'
102--- examples/tomcat-maven-webapp/snapcraft.yaml 2015-08-25 18:53:18 +0000
103+++ examples/tomcat-maven-webapp/snapcraft.yaml 2015-08-28 00:36:51 +0000
104@@ -11,6 +11,7 @@
105 - network-service
106 summary: Demo of Tomcat-hosted Webapp
107 description: This is a demo snap of a Tomcat-hosted webapp produced by snapcraft with maven.
108+icon: icon.png
109
110 parts:
111 webapp:
112
113=== added file 'examples/webcam-webui-snap/icon.png'
114Binary files examples/webcam-webui-snap/icon.png 1970-01-01 00:00:00 +0000 and examples/webcam-webui-snap/icon.png 2015-08-28 00:36:51 +0000 differ
115=== modified file 'examples/webcam-webui-snap/snapcraft.yaml'
116--- examples/webcam-webui-snap/snapcraft.yaml 2015-08-25 18:53:18 +0000
117+++ examples/webcam-webui-snap/snapcraft.yaml 2015-08-28 00:36:51 +0000
118@@ -7,6 +7,7 @@
119 security-template: unconfined
120 summary: Webcam web UI
121 description: Exposes your webcam over a web UI
122+icon: icon.png
123
124 parts:
125 golang-static-http:
126
127=== added file 'examples/wget-deb/icon.png'
128Binary files examples/wget-deb/icon.png 1970-01-01 00:00:00 +0000 and examples/wget-deb/icon.png 2015-08-28 00:36:51 +0000 differ
129=== modified file 'examples/wget-deb/snapcraft.yaml'
130--- examples/wget-deb/snapcraft.yaml 2015-08-25 18:53:18 +0000
131+++ examples/wget-deb/snapcraft.yaml 2015-08-28 00:36:51 +0000
132@@ -5,6 +5,7 @@
133 - name: usr/bin/wget
134 summary: wget for snappy
135 description: a basic example from ubuntu packages
136+icon: icon.png
137
138 parts:
139 wget:
140
141=== added file 'integration-tests/data/assemble/icon.png'
142Binary files integration-tests/data/assemble/icon.png 1970-01-01 00:00:00 +0000 and integration-tests/data/assemble/icon.png 2015-08-28 00:36:51 +0000 differ
143=== modified file 'integration-tests/data/assemble/snapcraft.yaml'
144--- integration-tests/data/assemble/snapcraft.yaml 2015-08-24 18:27:50 +0000
145+++ integration-tests/data/assemble/snapcraft.yaml 2015-08-28 00:36:51 +0000
146@@ -3,6 +3,7 @@
147 vendor: Sergio Schvezov <sergio.schvezov@canonical.com>
148 summary: one line summary
149 description: a longer description
150+icon: icon.png
151 binaries:
152 - exec: binary1
153 name: assemble-bin
154
155=== added file 'integration-tests/data/bzr-head/icon.png'
156Binary files integration-tests/data/bzr-head/icon.png 1970-01-01 00:00:00 +0000 and integration-tests/data/bzr-head/icon.png 2015-08-28 00:36:51 +0000 differ
157=== modified file 'integration-tests/data/bzr-head/snapcraft.yaml'
158--- integration-tests/data/bzr-head/snapcraft.yaml 2015-08-24 18:27:50 +0000
159+++ integration-tests/data/bzr-head/snapcraft.yaml 2015-08-28 00:36:51 +0000
160@@ -3,6 +3,7 @@
161 vendor: Sergio Schvezov <sergio.schvezov@canonical.com>
162 summary: one line summary
163 description: a longer description
164+icon: icon.png
165
166 parts:
167 bzr:
168
169=== added file 'integration-tests/data/bzr-tag/icon.png'
170Binary files integration-tests/data/bzr-tag/icon.png 1970-01-01 00:00:00 +0000 and integration-tests/data/bzr-tag/icon.png 2015-08-28 00:36:51 +0000 differ
171=== modified file 'integration-tests/data/bzr-tag/snapcraft.yaml'
172--- integration-tests/data/bzr-tag/snapcraft.yaml 2015-08-24 18:27:50 +0000
173+++ integration-tests/data/bzr-tag/snapcraft.yaml 2015-08-28 00:36:51 +0000
174@@ -3,6 +3,7 @@
175 vendor: Sergio Schvezov <sergio.schvezov@canonical.com>
176 summary: one line summary
177 description: a longer description
178+icon: icon.png
179
180 parts:
181 bzr:
182
183=== added file 'integration-tests/data/conflicts/icon.png'
184Binary files integration-tests/data/conflicts/icon.png 1970-01-01 00:00:00 +0000 and integration-tests/data/conflicts/icon.png 2015-08-28 00:36:51 +0000 differ
185=== modified file 'integration-tests/data/conflicts/snapcraft.yaml'
186--- integration-tests/data/conflicts/snapcraft.yaml 2015-08-24 18:27:50 +0000
187+++ integration-tests/data/conflicts/snapcraft.yaml 2015-08-28 00:36:51 +0000
188@@ -3,6 +3,7 @@
189 vendor: Sergio Schvezov <sergio.schvezov@canonical.com>
190 summary: one line summary
191 description: a longer description
192+icon: icon.png
193
194 parts:
195 p1:
196
197=== added file 'integration-tests/data/dependencies/icon.png'
198Binary files integration-tests/data/dependencies/icon.png 1970-01-01 00:00:00 +0000 and integration-tests/data/dependencies/icon.png 2015-08-28 00:36:51 +0000 differ
199=== modified file 'integration-tests/data/dependencies/snapcraft.yaml'
200--- integration-tests/data/dependencies/snapcraft.yaml 2015-08-24 18:27:50 +0000
201+++ integration-tests/data/dependencies/snapcraft.yaml 2015-08-28 00:36:51 +0000
202@@ -3,6 +3,7 @@
203 vendor: Sergio Schvezov <sergio.schvezov@canonical.com>
204 summary: one line summary
205 description: a longer description
206+icon: icon.png
207
208 parts:
209 p1:
210
211=== added file 'integration-tests/data/git-branch/icon.png'
212Binary files integration-tests/data/git-branch/icon.png 1970-01-01 00:00:00 +0000 and integration-tests/data/git-branch/icon.png 2015-08-28 00:36:51 +0000 differ
213=== modified file 'integration-tests/data/git-branch/snapcraft.yaml'
214--- integration-tests/data/git-branch/snapcraft.yaml 2015-08-24 18:27:50 +0000
215+++ integration-tests/data/git-branch/snapcraft.yaml 2015-08-28 00:36:51 +0000
216@@ -3,6 +3,7 @@
217 vendor: Sergio Schvezov <sergio.schvezov@canonical.com>
218 summary: one line summary
219 description: a longer description
220+icon: icon.png
221
222 parts:
223 git:
224
225=== added file 'integration-tests/data/git-head/icon.png'
226Binary files integration-tests/data/git-head/icon.png 1970-01-01 00:00:00 +0000 and integration-tests/data/git-head/icon.png 2015-08-28 00:36:51 +0000 differ
227=== modified file 'integration-tests/data/git-head/snapcraft.yaml'
228--- integration-tests/data/git-head/snapcraft.yaml 2015-08-24 18:27:50 +0000
229+++ integration-tests/data/git-head/snapcraft.yaml 2015-08-28 00:36:51 +0000
230@@ -3,6 +3,7 @@
231 vendor: Sergio Schvezov <sergio.schvezov@canonical.com>
232 summary: one line summary
233 description: a longer description
234+icon: icon.png
235
236 parts:
237 git:
238
239=== added file 'integration-tests/data/git-tag/icon.png'
240Binary files integration-tests/data/git-tag/icon.png 1970-01-01 00:00:00 +0000 and integration-tests/data/git-tag/icon.png 2015-08-28 00:36:51 +0000 differ
241=== modified file 'integration-tests/data/git-tag/snapcraft.yaml'
242--- integration-tests/data/git-tag/snapcraft.yaml 2015-08-24 18:27:50 +0000
243+++ integration-tests/data/git-tag/snapcraft.yaml 2015-08-28 00:36:51 +0000
244@@ -3,6 +3,7 @@
245 vendor: Sergio Schvezov <sergio.schvezov@canonical.com>
246 summary: one line summary
247 description: a longer description
248+icon: icon.png
249
250 parts:
251 git:
252
253=== added file 'integration-tests/data/hg-branch/icon.png'
254Binary files integration-tests/data/hg-branch/icon.png 1970-01-01 00:00:00 +0000 and integration-tests/data/hg-branch/icon.png 2015-08-28 00:36:51 +0000 differ
255=== modified file 'integration-tests/data/hg-branch/snapcraft.yaml'
256--- integration-tests/data/hg-branch/snapcraft.yaml 2015-08-24 18:27:50 +0000
257+++ integration-tests/data/hg-branch/snapcraft.yaml 2015-08-28 00:36:51 +0000
258@@ -3,6 +3,7 @@
259 vendor: Sergio Schvezov <sergio.schvezov@canonical.com>
260 summary: one line summary
261 description: a longer description
262+icon: icon.png
263
264 parts:
265 mercurial:
266
267=== added file 'integration-tests/data/hg-head/icon.png'
268Binary files integration-tests/data/hg-head/icon.png 1970-01-01 00:00:00 +0000 and integration-tests/data/hg-head/icon.png 2015-08-28 00:36:51 +0000 differ
269=== modified file 'integration-tests/data/hg-head/snapcraft.yaml'
270--- integration-tests/data/hg-head/snapcraft.yaml 2015-08-24 18:27:50 +0000
271+++ integration-tests/data/hg-head/snapcraft.yaml 2015-08-28 00:36:51 +0000
272@@ -3,6 +3,7 @@
273 vendor: Sergio Schvezov <sergio.schvezov@canonical.com>
274 summary: one line summary
275 description: a longer description
276+icon: icon.png
277
278 parts:
279 mercurial:
280
281=== added file 'integration-tests/data/hg-tag/icon.png'
282Binary files integration-tests/data/hg-tag/icon.png 1970-01-01 00:00:00 +0000 and integration-tests/data/hg-tag/icon.png 2015-08-28 00:36:51 +0000 differ
283=== modified file 'integration-tests/data/hg-tag/snapcraft.yaml'
284--- integration-tests/data/hg-tag/snapcraft.yaml 2015-08-24 18:27:50 +0000
285+++ integration-tests/data/hg-tag/snapcraft.yaml 2015-08-28 00:36:51 +0000
286@@ -3,6 +3,7 @@
287 vendor: Sergio Schvezov <sergio.schvezov@canonical.com>
288 summary: one line summary
289 description: a longer description
290+icon: icon.png
291
292 parts:
293 mercurial:
294
295=== added file 'integration-tests/data/local-plugin/icon.png'
296Binary files integration-tests/data/local-plugin/icon.png 1970-01-01 00:00:00 +0000 and integration-tests/data/local-plugin/icon.png 2015-08-28 00:36:51 +0000 differ
297=== modified file 'integration-tests/data/local-plugin/snapcraft.yaml'
298--- integration-tests/data/local-plugin/snapcraft.yaml 2015-08-25 20:40:26 +0000
299+++ integration-tests/data/local-plugin/snapcraft.yaml 2015-08-28 00:36:51 +0000
300@@ -3,6 +3,7 @@
301 vendor: Sergio Schvezov <sergio.schvezov@canonical.com>
302 summary: one line summary
303 description: a longer description
304+icon: icon.png
305
306 parts:
307 x-local-plugin:
308
309=== added file 'integration-tests/data/local-source/icon.png'
310Binary files integration-tests/data/local-source/icon.png 1970-01-01 00:00:00 +0000 and integration-tests/data/local-source/icon.png 2015-08-28 00:36:51 +0000 differ
311=== modified file 'integration-tests/data/local-source/snapcraft.yaml'
312--- integration-tests/data/local-source/snapcraft.yaml 2015-08-24 18:27:50 +0000
313+++ integration-tests/data/local-source/snapcraft.yaml 2015-08-28 00:36:51 +0000
314@@ -3,6 +3,7 @@
315 vendor: Sergio Schvezov <sergio.schvezov@canonical.com>
316 summary: one line summary
317 description: a longer description
318+icon: icon.png
319
320 parts:
321 make-project:
322
323=== added file 'integration-tests/data/simple-cmake/icon.png'
324Binary files integration-tests/data/simple-cmake/icon.png 1970-01-01 00:00:00 +0000 and integration-tests/data/simple-cmake/icon.png 2015-08-28 00:36:51 +0000 differ
325=== modified file 'integration-tests/data/simple-cmake/snapcraft.yaml'
326--- integration-tests/data/simple-cmake/snapcraft.yaml 2015-08-24 18:27:50 +0000
327+++ integration-tests/data/simple-cmake/snapcraft.yaml 2015-08-28 00:36:51 +0000
328@@ -3,6 +3,7 @@
329 vendor: Sergio Schvezov <sergio.schvezov@canonical.com>
330 summary: one line summary
331 description: a longer description
332+icon: icon.png
333
334 parts:
335 cmake-project:
336
337=== added file 'integration-tests/data/simple-copy/icon.png'
338Binary files integration-tests/data/simple-copy/icon.png 1970-01-01 00:00:00 +0000 and integration-tests/data/simple-copy/icon.png 2015-08-28 00:36:51 +0000 differ
339=== modified file 'integration-tests/data/simple-copy/snapcraft.yaml'
340--- integration-tests/data/simple-copy/snapcraft.yaml 2015-08-24 18:27:50 +0000
341+++ integration-tests/data/simple-copy/snapcraft.yaml 2015-08-28 00:36:51 +0000
342@@ -3,6 +3,7 @@
343 vendor: Sergio Schvezov <sergio.schvezov@canonical.com>
344 summary: one line summary
345 description: a longer description
346+icon: icon.png
347
348 parts:
349 copy-example:
350
351=== added file 'integration-tests/data/simple-make/icon.png'
352Binary files integration-tests/data/simple-make/icon.png 1970-01-01 00:00:00 +0000 and integration-tests/data/simple-make/icon.png 2015-08-28 00:36:51 +0000 differ
353=== modified file 'integration-tests/data/simple-make/snapcraft.yaml'
354--- integration-tests/data/simple-make/snapcraft.yaml 2015-08-24 18:27:50 +0000
355+++ integration-tests/data/simple-make/snapcraft.yaml 2015-08-28 00:36:51 +0000
356@@ -3,6 +3,7 @@
357 vendor: Sergio Schvezov <sergio.schvezov@canonical.com>
358 summary: one line summary
359 description: a longer description
360+icon: icon.png
361
362 parts:
363 make-project:
364
365=== added file 'integration-tests/data/simple-tar/icon.png'
366Binary files integration-tests/data/simple-tar/icon.png 1970-01-01 00:00:00 +0000 and integration-tests/data/simple-tar/icon.png 2015-08-28 00:36:51 +0000 differ
367=== modified file 'integration-tests/data/simple-tar/snapcraft.yaml'
368--- integration-tests/data/simple-tar/snapcraft.yaml 2015-08-24 18:27:50 +0000
369+++ integration-tests/data/simple-tar/snapcraft.yaml 2015-08-28 00:36:51 +0000
370@@ -3,6 +3,7 @@
371 vendor: Sergio Schvezov <sergio.schvezov@canonical.com>
372 summary: one line summary
373 description: a longer description
374+icon: icon.png
375
376 parts:
377 oneflat:
378
379=== modified file 'schema/snapcraft.yaml'
380--- schema/snapcraft.yaml 2015-08-26 18:33:20 +0000
381+++ schema/snapcraft.yaml 2015-08-28 00:36:51 +0000
382@@ -15,6 +15,10 @@
383 vendor:
384 type: string
385 format: email
386+ icon:
387+ type: string
388+ description: path to a 512x512 icon representing the package.
389+ format: icon-path
390 summary:
391 type: string
392 description: one line summary for the package
393@@ -86,4 +90,5 @@
394 - vendor
395 - summary
396 - description
397+ - icon
398 - parts
399
400=== modified file 'snapcraft/meta.py'
401--- snapcraft/meta.py 2015-08-26 12:11:33 +0000
402+++ snapcraft/meta.py 2015-08-28 00:36:51 +0000
403@@ -17,6 +17,7 @@
404 import os
405 import logging
406 import shlex
407+import shutil
408 import tempfile
409 import yaml
410
411@@ -29,6 +30,7 @@
412 'name',
413 'version',
414 'vendor',
415+ 'icon',
416 ]
417
418 _OPTIONAL_PACKAGE_KEYS = [
419@@ -50,6 +52,8 @@
420 meta_dir = os.path.join(common.get_snapdir(), 'meta')
421 os.makedirs(meta_dir, exist_ok=True)
422
423+ config_data['icon'] = _copy_icon(meta_dir, config_data['icon'])
424+
425 _write_package_yaml(meta_dir, config_data, arches)
426 _write_readme_md(meta_dir, config_data)
427
428@@ -72,6 +76,13 @@
429 f.write(readme_md)
430
431
432+def _copy_icon(meta_dir, icon_path):
433+ new_icon_path = os.path.join(meta_dir, os.path.basename(icon_path))
434+ shutil.copyfile(icon_path, new_icon_path)
435+
436+ return os.path.join('meta', os.path.basename(icon_path))
437+
438+
439 def _compose_package_yaml(config_data, arches):
440 '''
441 Creates a dictionary that can be used to yaml.dump a package.yaml using
442
443=== modified file 'snapcraft/tests/test_meta.py'
444--- snapcraft/tests/test_meta.py 2015-08-26 16:05:34 +0000
445+++ snapcraft/tests/test_meta.py 2015-08-28 00:36:51 +0000
446@@ -16,7 +16,6 @@
447
448 import os
449 from unittest.mock import (
450- Mock,
451 call,
452 mock_open,
453 patch,
454@@ -42,6 +41,7 @@
455 'name': 'my-package',
456 'version': '1.0',
457 'vendor': 'Sergio Schvezov <sergio.schvezov@canonical.com>',
458+ 'icon': 'my-icon.png',
459 }
460
461 def test_plain_no_binaries_or_services(self):
462@@ -52,6 +52,7 @@
463 'name': 'my-package',
464 'version': '1.0',
465 'vendor': 'Sergio Schvezov <sergio.schvezov@canonical.com>',
466+ 'icon': 'my-icon.png',
467 'architectures': ['armhf', 'amd64'],
468 }
469
470@@ -65,6 +66,7 @@
471 'name': 'my-package',
472 'version': '1.0',
473 'vendor': 'Sergio Schvezov <sergio.schvezov@canonical.com>',
474+ 'icon': 'my-icon.png',
475 }
476
477 self.assertEqual(y, expected)
478@@ -86,6 +88,7 @@
479 'name': 'my-package',
480 'version': '1.0',
481 'vendor': 'Sergio Schvezov <sergio.schvezov@canonical.com>',
482+ 'icon': 'my-icon.png',
483 'architectures': ['armhf', 'amd64'],
484 'binaries': [
485 {
486@@ -123,6 +126,7 @@
487 'name': 'my-package',
488 'version': '1.0',
489 'vendor': 'Sergio Schvezov <sergio.schvezov@canonical.com>',
490+ 'icon': 'my-icon.png',
491 'architectures': ['armhf', 'amd64'],
492 'services': [
493 {
494@@ -151,6 +155,7 @@
495 'name': 'my-package',
496 'version': '1.0',
497 'vendor': 'Sergio Schvezov <sergio.schvezov@canonical.com>',
498+ 'icon': 'my-icon.png',
499 'architectures': ['armhf', 'amd64'],
500 'frameworks': ['mir', ],
501 }
502@@ -173,7 +178,13 @@
503
504 def setUp(self):
505 super().setUp()
506- self.orig_os_makedirs = os.makedirs
507+ patcher_makedirs = patch('os.makedirs')
508+ self.mock_makedirs = patcher_makedirs.start()
509+ self.addCleanup(patcher_makedirs.stop)
510+
511+ patcher_copyfile = patch('shutil.copyfile')
512+ self.mock_copyfile = patcher_copyfile.start()
513+ self.addCleanup(patcher_copyfile.stop)
514
515 self.config_data = {
516 'name': 'my-package',
517@@ -181,14 +192,10 @@
518 'vendor': 'Sergio Schvezov <sergio.schvezov@canonical.com>',
519 'description': 'my description',
520 'summary': 'my summary',
521+ 'icon': 'my-icon.png',
522 }
523
524- def tearDown(self):
525- super().tearDown()
526- os.makedirs = self.orig_os_makedirs
527-
528 def test_create_meta(self):
529- os.makedirs = Mock()
530 mock_the_open = mock_open()
531
532 with patch('snapcraft.meta.open', mock_the_open, create=True):
533@@ -196,7 +203,7 @@
534
535 meta_dir = os.path.join(os.path.abspath(os.curdir), 'snap', 'meta')
536
537- os.makedirs.assert_called_once_with(meta_dir, exist_ok=True)
538+ self.mock_makedirs.assert_called_once_with(meta_dir, exist_ok=True)
539
540 mock_the_open.assert_has_calls([
541 call(os.path.join(meta_dir, 'package.yaml'), 'w'),
542@@ -208,6 +215,11 @@
543 call().write(' '),
544 call().write('amd64'),
545 call().write('\n'),
546+ call().write('icon'),
547+ call().write(':'),
548+ call().write(' '),
549+ call().write('meta/my-icon.png'),
550+ call().write('\n'),
551 call().write('name'),
552 call().write(':'),
553 call().write(' '),
554
555=== modified file 'snapcraft/tests/test_yaml.py'
556--- snapcraft/tests/test_yaml.py 2015-08-27 13:00:16 +0000
557+++ snapcraft/tests/test_yaml.py 2015-08-28 00:36:51 +0000
558@@ -31,6 +31,15 @@
559
560 class TestYaml(TestCase):
561
562+ def setUp(self):
563+ super().setUp()
564+ dirs.setup_dirs()
565+
566+ patcher = unittest.mock.patch('os.path.exists')
567+ mock_wrap_exe = patcher.start()
568+ mock_wrap_exe.return_value = True
569+ self.addCleanup(patcher.stop)
570+
571 def make_snapcraft_yaml(self, content):
572 tempdirObj = tempfile.TemporaryDirectory()
573 self.addCleanup(tempdirObj.cleanup)
574@@ -40,13 +49,12 @@
575
576 @unittest.mock.patch('snapcraft.yaml.Config.load_plugin')
577 def test_config_loads_plugins(self, mock_loadPlugin):
578- dirs.setup_dirs()
579-
580 self.make_snapcraft_yaml("""name: test
581 version: "1"
582 vendor: me <me@me.com>
583 summary: test
584 description: test
585+icon: my-icon.png
586
587 parts:
588 ubuntu:
589@@ -72,8 +80,6 @@
590 fake_logger.output)
591
592 def test_config_loop(self):
593- dirs.setup_dirs()
594-
595 fake_logger = fixtures.FakeLogger(level=logging.ERROR)
596 self.useFixture(fake_logger)
597
598@@ -82,6 +88,7 @@
599 vendor: me <me@me.com>
600 summary: test
601 description: test
602+icon: my-icon.png
603
604 parts:
605 p1:
606@@ -99,8 +106,6 @@
607
608 @unittest.mock.patch('snapcraft.yaml.Config.load_plugin')
609 def test_invalid_yaml_missing_name(self, mock_loadPlugin):
610- dirs.setup_dirs()
611-
612 fake_logger = fixtures.FakeLogger(level=logging.ERROR)
613 self.useFixture(fake_logger)
614
615@@ -109,6 +114,7 @@
616 vendor: me <me@me.com>
617 summary: test
618 description: nothing
619+icon: my-icon.png
620
621 parts:
622 ubuntu:
623@@ -124,8 +130,6 @@
624
625 @unittest.mock.patch('snapcraft.yaml.Config.load_plugin')
626 def test_invalid_yaml_invalid_name_as_number(self, mock_loadPlugin):
627- dirs.setup_dirs()
628-
629 fake_logger = fixtures.FakeLogger(level=logging.ERROR)
630 self.useFixture(fake_logger)
631
632@@ -134,6 +138,7 @@
633 vendor: me <me@me.com>
634 summary: test
635 description: nothing
636+icon: my-icon.png
637
638 parts:
639 ubuntu:
640@@ -149,8 +154,6 @@
641
642 @unittest.mock.patch('snapcraft.yaml.Config.load_plugin')
643 def test_invalid_yaml_invalid_name_chars(self, mock_loadPlugin):
644- dirs.setup_dirs()
645-
646 fake_logger = fixtures.FakeLogger(level=logging.ERROR)
647 self.useFixture(fake_logger)
648
649@@ -159,6 +162,7 @@
650 vendor: me <me@me.com>
651 summary: test
652 description: nothing
653+icon: my-icon.png
654
655 parts:
656 ubuntu:
657@@ -174,8 +178,6 @@
658
659 @unittest.mock.patch('snapcraft.yaml.Config.load_plugin')
660 def test_invalid_yaml_missing_description(self, mock_loadPlugin):
661- dirs.setup_dirs()
662-
663 fake_logger = fixtures.FakeLogger(level=logging.ERROR)
664 self.useFixture(fake_logger)
665
666@@ -183,6 +185,7 @@
667 version: "1"
668 vendor: me <me@me.com>
669 summary: test
670+icon: my-icon.png
671
672 parts:
673 ubuntu:
674@@ -203,12 +206,18 @@
675 super().setUp()
676 dirs.setup_dirs()
677
678+ patcher = unittest.mock.patch('os.path.exists')
679+ self.mock_path_exists = patcher.start()
680+ self.mock_path_exists.return_value = True
681+ self.addCleanup(patcher.stop)
682+
683 self.data = {
684 'name': 'my-package-1',
685 'version': '1.0-snapcraft1~ppa1',
686 'vendor': 'Me <me@me.com>',
687 'summary': 'my summary less that 79 chars',
688 'description': 'description which can be pretty long',
689+ 'icon': 'my-icon.png',
690 'parts': {
691 'part1': {
692 'type': 'project',
693@@ -324,3 +333,12 @@
694 mock_the_open.assert_called_once_with(expected_path)
695 expected_message = 'Schema is missing, could not validate snapcraft.yaml, check installation'
696 self.assertEqual(raised.exception.message, expected_message)
697+
698+ def test_icon_missing(self):
699+ self.mock_path_exists.return_value = False
700+
701+ with self.assertRaises(jsonschema.ValidationError) as raised:
702+ snapcraft.yaml._validate_snapcraft_yaml(self.data)
703+
704+ expected_message = '\'my-icon.png\' is not a \'icon-path\''
705+ self.assertEqual(raised.exception.message, expected_message, msg=self.data)
706
707=== modified file 'snapcraft/yaml.py'
708--- snapcraft/yaml.py 2015-08-27 16:37:32 +0000
709+++ snapcraft/yaml.py 2015-08-28 00:36:51 +0000
710@@ -20,6 +20,7 @@
711 import yaml
712 import jsonschema
713 import os
714+import os.path
715
716 import snapcraft.plugin
717 from snapcraft import common
718@@ -28,6 +29,11 @@
719 logger = logging.getLogger(__name__)
720
721
722+@jsonschema.FormatChecker.cls_checks('icon-path')
723+def _validate_file_exists(instance):
724+ return os.path.exists(instance)
725+
726+
727 class SchemaNotFoundError(Exception):
728
729 def __init__(self, message):
730@@ -43,7 +49,8 @@
731 except FileNotFoundError:
732 raise SchemaNotFoundError('Schema is missing, could not validate snapcraft.yaml, check installation')
733
734- jsonschema.validate(snapcraft_yaml, schema)
735+ format_check = jsonschema.FormatChecker()
736+ jsonschema.validate(snapcraft_yaml, schema, format_checker=format_check)
737
738
739 class Config:

Subscribers

People subscribed via source and target branches