Merge lp:~sergiusens/snapcraft/1500758 into lp:~dholbach/snapcraft/1498347
- 1500758
- Merge into 1498347
Proposed by
Sergio Schvezov
Status: | Superseded | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~sergiusens/snapcraft/1500758 | ||||
Merge into: | lp:~dholbach/snapcraft/1498347 | ||||
Diff against target: |
1710 lines (+706/-274) 46 files modified
debian/changelog (+55/-2) debian/control (+11/-0) debian/rules (+3/-0) debian/snapcraft-examples.examples (+1/-0) debian/snapcraft.install (+3/-0) debian/source/options (+0/-5) debian/tests/control (+3/-2) debian/tests/runexamples (+2/-0) debian/tests/runtests (+2/-0) docs/intro.md (+1/-1) docs/your-first-snap.md (+2/-2) examples/downloader-with-wiki-parts/snapcraft.yaml (+1/-0) integration-tests/data/build-tools/Makefile (+6/-0) integration-tests/data/build-tools/icon.svg (+1/-0) integration-tests/data/build-tools/snapcraft.yaml (+14/-0) integration-tests/data/pip-requirements/snapcraft.yaml (+2/-2) integration-tests/data/simple-scons/SConstruct (+14/-0) integration-tests/data/simple-scons/main.c (+5/-0) integration-tests/data/simple-scons/snapcraft.yaml (+11/-0) integration-tests/data/simple-tar/snapcraft.yaml (+3/-0) integration-tests/runtests.sh (+44/-17) integration-tests/units/examples.pxu (+10/-0) integration-tests/units/jobs.pxu (+40/-0) integration-tests/units/testplans.pxu (+6/-1) plugins/python2-project.yaml (+3/-3) plugins/python2.yaml (+0/-3) plugins/python3-project.yaml (+3/-3) plugins/python3.yaml (+0/-3) plugins/scons-project.yaml (+8/-0) runtests.sh (+67/-35) snapcraft/__init__.py (+19/-0) snapcraft/cmds.py (+2/-0) snapcraft/common.py (+11/-0) snapcraft/plugin.py (+15/-19) snapcraft/plugins/go_project.py (+3/-1) snapcraft/plugins/python2.py (+0/-59) snapcraft/plugins/python2_project.py (+65/-5) snapcraft/plugins/python3.py (+0/-61) snapcraft/plugins/python3_project.py (+62/-5) snapcraft/plugins/scons_project.py (+31/-0) snapcraft/repo.py (+83/-26) snapcraft/sources.py (+7/-1) snapcraft/tests/test_base_plugin.py (+13/-0) snapcraft/tests/test_plugin.py (+0/-14) snapcraft/tests/test_repo.py (+38/-0) snapcraft/yaml.py (+36/-4) |
||||
To merge this branch: | bzr merge lp:~sergiusens/snapcraft/1500758 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel Holbach | Pending | ||
Review via email: mp+272727@code.launchpad.net |
Commit message
Adding a simple scons plugin
Description of the change
To post a comment you must log in.
Unmerged revisions
- 216. By Sergio Schvezov
-
Adding tests for scons
- 215. By Sergio Schvezov
-
Simple scons plugin
- 214. By Sergio Schvezov
-
Detect tars in sources automatically
- 213. By Sergio Schvezov
-
Mask tar files so they are writable and set an extraction parameter to start with a clean build dir.
- 212. By Leo Arias
-
Fixed the heading on the build section of the docs. by elopio approved by dholbach
- 211. By Daniel Holbach
-
Reopen 0.3 for development (after 0.2.1 brown paperbag release). by dholbach approved by sergiusens
- 210. By Daniel Holbach
-
Brown paperbag release (install examples into the right directory). by dholbach approved by mvo
- 209. By Daniel Holbach
-
Open 0.3 for development. by dholbach approved by sergiusens
- 208. By Sergio Schvezov
-
Allow using local sources through an env var (mostly useful for launchpad building) by sergiusens approved by mvo,dholbach,
cjwatson - 207. By Sergio Schvezov
-
preparing a changelog by sergiusens approved by sergiusens,dholbach
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/changelog' |
2 | --- debian/changelog 2015-08-18 12:37:44 +0000 |
3 | +++ debian/changelog 2015-09-29 10:44:16 +0000 |
4 | @@ -1,8 +1,61 @@ |
5 | -snapcraft (0.2) UNRELEASED; urgency=medium |
6 | +snapcraft (0.3) UNRELEASED; urgency=medium |
7 | |
8 | * |
9 | |
10 | - -- Daniel Holbach <daniel.holbach@ubuntu.com> Tue, 18 Aug 2015 14:23:24 +0200 |
11 | + -- Daniel Holbach <daniel.holbach@ubuntu.com> Fri, 25 Sep 2015 12:46:23 +0200 |
12 | + |
13 | +snapcraft (0.2.1) wily; urgency=medium |
14 | + |
15 | + * New upstream release (LP: #1499265) |
16 | + * Brown-paper bag release: |
17 | + - Fix install path of examples. Thanks Martin Pitt for noticing. |
18 | + - Allow using local sources through an env var (mostly useful for |
19 | + Launchpad building). |
20 | + |
21 | + -- Daniel Holbach <daniel.holbach@ubuntu.com> Thu, 24 Sep 2015 11:37:36 +0200 |
22 | + |
23 | +snapcraft (0.2) wily; urgency=medium |
24 | + |
25 | + * Better setuptools support: |
26 | + - Better support python-setuptools (LP: #1481864), |
27 | + - Used builddir as a base for setup.py overrides (LP: #1498212), |
28 | + - Fix build (LP: #1494825), |
29 | + * Plugin fixes: |
30 | + - Add demo.qml back to the snapcraft.yaml for the QML Demo (LP: #1491301), |
31 | + - stage package libgudev-1.0-0, which makes the godd snap actually |
32 | + work (LP: #1498347), |
33 | + - Wrap setup.py calls to configure the shebang writer (LP: #1486680), |
34 | + - Update tomcat upstream URL, fixes example again (LP: #1491303), |
35 | + - Add libgudev-1.0-dev as build-tools for godd example, |
36 | + Ensure C library configuration tools don't use system |
37 | + paths (LP: #1496789), |
38 | + * Snapcraft cli: |
39 | + - On clean, check the contents of the parts dir only if it |
40 | + exists. (LP: #1497371) |
41 | + - Load the config before trying to run (LP: #1498140), |
42 | + - Notify user why the password is being requested (LP: #1481499), |
43 | + - Fix numerous issues in snapcraft run (LP: #1486659), |
44 | + * Snapcraft stage-packages: |
45 | + - Enable ports for architectures that are not amd64 or |
46 | + i386 (LP: #1498157), |
47 | + - Improving stage-package handling (LP: #1497453, LP: #1497582) |
48 | + - Fetch all packages in a single download run with proper |
49 | + progress (LP: #1498333), |
50 | + * Snapcraft wiki queries excessive (LP: #1496381), |
51 | + * Snapcraft internals: |
52 | + - Add 'simple' and 'has-leftovers' flags to all integration tests job |
53 | + units. (LP: #1484596), |
54 | + - Regex for binary and service names (LP: #1495662), |
55 | + - Provide a nice error when tabs found in snapcraft.yaml (LP: #1477875), |
56 | + - Use relative paths for image creation (LP: #1497108), |
57 | + - Use the python logger (LP: #1476452), |
58 | + - snapcraft now has less exit points (LP: #1477639), |
59 | + - Depend and Build-Depend on python3-requests (LP: #1496363), |
60 | + - Add autopkgtest, reshuffle build-deps accordingly (LP: #1496392), |
61 | + - Fix "snapcraft run" (LP: #1484720), |
62 | + * Examples packaged (LP: #1498189). |
63 | + |
64 | + -- Sergio Schvezov <sergio.schvezov@canonical.com> Wed, 24 Sep 2015 14:23:24 -0300 |
65 | |
66 | snapcraft (0.1) wily; urgency=low |
67 | |
68 | |
69 | === modified file 'debian/control' |
70 | --- debian/control 2015-09-16 14:26:10 +0000 |
71 | +++ debian/control 2015-09-29 10:44:16 +0000 |
72 | @@ -39,3 +39,14 @@ |
73 | a single toolset, but instead is a collection of tools that enable the |
74 | natural workflow of an upstream to be extended with a simple release step |
75 | into Snappy. |
76 | + |
77 | +Package: snapcraft-examples |
78 | +Architecture: all |
79 | +Depends: snapcraft (= ${binary:Version}), ${misc:Depends}, ${python3:Depends} |
80 | +Description: examples for snapcraft |
81 | + Snapcraft aims to make upstream developers' lives easier and as such is not |
82 | + a single toolset, but instead is a collection of tools that enable the |
83 | + natural workflow of an upstream to be extended with a simple release step |
84 | + into Snappy. |
85 | + . |
86 | + This package contains examples for snapcraft. |
87 | |
88 | === modified file 'debian/rules' |
89 | --- debian/rules 2015-09-16 14:26:10 +0000 |
90 | +++ debian/rules 2015-09-29 10:44:16 +0000 |
91 | @@ -3,3 +3,6 @@ |
92 | |
93 | %: |
94 | dh $@ --with python3 --buildsystem=pybuild |
95 | + |
96 | +override_dh_compress: |
97 | + dh_compress -Xusr/share/doc/snapcraft-examples/examples |
98 | |
99 | === added file 'debian/snapcraft-examples.examples' |
100 | --- debian/snapcraft-examples.examples 1970-01-01 00:00:00 +0000 |
101 | +++ debian/snapcraft-examples.examples 2015-09-29 10:44:16 +0000 |
102 | @@ -0,0 +1,1 @@ |
103 | +examples/* |
104 | |
105 | === added file 'debian/snapcraft.install' |
106 | --- debian/snapcraft.install 1970-01-01 00:00:00 +0000 |
107 | +++ debian/snapcraft.install 2015-09-29 10:44:16 +0000 |
108 | @@ -0,0 +1,3 @@ |
109 | +/usr/bin |
110 | +/usr/lib/python* |
111 | +/usr/share/snapcraft |
112 | |
113 | === modified file 'debian/source/options' |
114 | --- debian/source/options 2015-07-06 16:48:22 +0000 |
115 | +++ debian/source/options 2015-09-29 10:44:16 +0000 |
116 | @@ -1,7 +1,2 @@ |
117 | # Ignore standard files (like .bzr) |
118 | tar-ignore |
119 | - |
120 | -# Ignore examples folder because it likely contains a bunch of stuff we don't |
121 | -# care about (like downloaded go1.4 binaries and such). It's not important |
122 | -# for it to be distributed with the source. |
123 | -tar-ignore = "examples" |
124 | |
125 | === modified file 'debian/tests/control' |
126 | --- debian/tests/control 2015-09-17 14:56:20 +0000 |
127 | +++ debian/tests/control 2015-09-29 10:44:16 +0000 |
128 | @@ -1,5 +1,6 @@ |
129 | -Test-Command: ./runtests.sh |
130 | -Restrictions: allow-stderr, isolation-container |
131 | +Tests: runtests |
132 | + runexamples |
133 | +Restrictions: allow-stderr, isolation-container, rw-build-tree |
134 | Depends: @, |
135 | build-essential, |
136 | pep8, |
137 | |
138 | === added file 'debian/tests/runexamples' |
139 | --- debian/tests/runexamples 1970-01-01 00:00:00 +0000 |
140 | +++ debian/tests/runexamples 2015-09-29 10:44:16 +0000 |
141 | @@ -0,0 +1,2 @@ |
142 | +#!/bin/sh |
143 | +./runtests.sh plainbox examples |
144 | |
145 | === added file 'debian/tests/runtests' |
146 | --- debian/tests/runtests 1970-01-01 00:00:00 +0000 |
147 | +++ debian/tests/runtests 2015-09-29 10:44:16 +0000 |
148 | @@ -0,0 +1,2 @@ |
149 | +#!/bin/sh |
150 | +./runtests.sh |
151 | |
152 | === modified file 'docs/intro.md' |
153 | --- docs/intro.md 2015-09-11 13:51:27 +0000 |
154 | +++ docs/intro.md 2015-09-29 10:44:16 +0000 |
155 | @@ -51,7 +51,7 @@ |
156 | sub-directories like `parts/part-name/src` for each part that contains |
157 | the downloaded content. |
158 | |
159 | -#### Build |
160 | +### Build |
161 | |
162 | The next step is that each part is built in its `parts/part-name/build` |
163 | directory and installs itself into `parts/part-name/install`. |
164 | |
165 | === modified file 'docs/your-first-snap.md' |
166 | --- docs/your-first-snap.md 2015-09-14 20:53:28 +0000 |
167 | +++ docs/your-first-snap.md 2015-09-29 10:44:16 +0000 |
168 | @@ -268,8 +268,8 @@ |
169 | description: Exposes your webcam over a web UI |
170 | icon: icon.png |
171 | services: |
172 | - - name: webcam-webui |
173 | - start: bin/webcam-webui |
174 | + webcam-webui: |
175 | + start: bin/webcam-webui |
176 | |
177 | parts: |
178 | golang-static-http: |
179 | |
180 | === modified file 'examples/downloader-with-wiki-parts/snapcraft.yaml' |
181 | --- examples/downloader-with-wiki-parts/snapcraft.yaml 2015-09-21 05:04:31 +0000 |
182 | +++ examples/downloader-with-wiki-parts/snapcraft.yaml 2015-09-29 10:44:16 +0000 |
183 | @@ -14,3 +14,4 @@ |
184 | source: . |
185 | after: |
186 | - curl |
187 | +build-packages: [libssl-dev] |
188 | |
189 | === added directory 'integration-tests/data/build-tools' |
190 | === added file 'integration-tests/data/build-tools/Makefile' |
191 | --- integration-tests/data/build-tools/Makefile 1970-01-01 00:00:00 +0000 |
192 | +++ integration-tests/data/build-tools/Makefile 2015-09-29 10:44:16 +0000 |
193 | @@ -0,0 +1,6 @@ |
194 | + |
195 | +all: |
196 | + @echo "Makin' like a Makefile" |
197 | + |
198 | +install: |
199 | + @echo "Installin' like a Makefile" |
200 | |
201 | === added file 'integration-tests/data/build-tools/icon.svg' |
202 | --- integration-tests/data/build-tools/icon.svg 1970-01-01 00:00:00 +0000 |
203 | +++ integration-tests/data/build-tools/icon.svg 2015-09-29 10:44:16 +0000 |
204 | @@ -0,0 +1,1 @@ |
205 | +<svg/> |
206 | |
207 | === added file 'integration-tests/data/build-tools/snapcraft.yaml' |
208 | --- integration-tests/data/build-tools/snapcraft.yaml 1970-01-01 00:00:00 +0000 |
209 | +++ integration-tests/data/build-tools/snapcraft.yaml 2015-09-29 10:44:16 +0000 |
210 | @@ -0,0 +1,14 @@ |
211 | +name: build-tools-test |
212 | +version: 0.1 |
213 | +vendor: Napoleon Bonaparte <napoleon@short-guys-rock.co.fr> |
214 | +summary: one line summary |
215 | +description: a longer description |
216 | +icon: icon.svg |
217 | + |
218 | +parts: |
219 | + make-project: |
220 | + source: . |
221 | + stage-packages: |
222 | + - libxml2-dev |
223 | + - libxslt1-dev |
224 | + - libglib2.0-dev |
225 | |
226 | === modified file 'integration-tests/data/pip-requirements/snapcraft.yaml' |
227 | --- integration-tests/data/pip-requirements/snapcraft.yaml 2015-09-09 20:19:12 +0000 |
228 | +++ integration-tests/data/pip-requirements/snapcraft.yaml 2015-09-29 10:44:16 +0000 |
229 | @@ -7,8 +7,8 @@ |
230 | |
231 | parts: |
232 | python2: |
233 | - type: python2 |
234 | + type: python2-project |
235 | requirements: requirements.txt |
236 | python3: |
237 | - type: python3 |
238 | + type: python3-project |
239 | requirements: requirements.txt |
240 | |
241 | === added directory 'integration-tests/data/simple-scons' |
242 | === added file 'integration-tests/data/simple-scons/SConstruct' |
243 | --- integration-tests/data/simple-scons/SConstruct 1970-01-01 00:00:00 +0000 |
244 | +++ integration-tests/data/simple-scons/SConstruct 2015-09-29 10:44:16 +0000 |
245 | @@ -0,0 +1,14 @@ |
246 | +import os.path |
247 | + |
248 | +env = Environment() |
249 | +hello = env.Program('main.c') |
250 | +DESTDIR = os.environ.get('DESTDIR', '') |
251 | +install_dir = os.path.join('usr', 'bin') |
252 | + |
253 | +if DESTDIR: |
254 | + install_dir = os.path.join(DESTDIR, install_dir) |
255 | +else: |
256 | + install_dir = os.path.join(os.path.sep, install_dir) |
257 | + |
258 | +env.Install(install_dir, hello) |
259 | +env.Alias('install', install_dir) |
260 | |
261 | === added file 'integration-tests/data/simple-scons/icon.png' |
262 | === added file 'integration-tests/data/simple-scons/main.c' |
263 | --- integration-tests/data/simple-scons/main.c 1970-01-01 00:00:00 +0000 |
264 | +++ integration-tests/data/simple-scons/main.c 2015-09-29 10:44:16 +0000 |
265 | @@ -0,0 +1,5 @@ |
266 | +#include <stdio.h> |
267 | + |
268 | +int main(int argc, char** argv) { |
269 | + printf("Hello world\n"); |
270 | +} |
271 | |
272 | === added file 'integration-tests/data/simple-scons/snapcraft.yaml' |
273 | --- integration-tests/data/simple-scons/snapcraft.yaml 1970-01-01 00:00:00 +0000 |
274 | +++ integration-tests/data/simple-scons/snapcraft.yaml 2015-09-29 10:44:16 +0000 |
275 | @@ -0,0 +1,11 @@ |
276 | +name: test-package |
277 | +version: 0.1 |
278 | +vendor: Sergio Schvezov <sergio.schvezov@canonical.com> |
279 | +summary: test a simple scons project |
280 | +description: a longer description |
281 | +icon: icon.png |
282 | + |
283 | +parts: |
284 | + scons-project: |
285 | + type: scons-project |
286 | + source: . |
287 | |
288 | === added file 'integration-tests/data/simple-tar/readonly-files.tar.gz' |
289 | Binary files integration-tests/data/simple-tar/readonly-files.tar.gz 1970-01-01 00:00:00 +0000 and integration-tests/data/simple-tar/readonly-files.tar.gz 2015-09-29 10:44:16 +0000 differ |
290 | === modified file 'integration-tests/data/simple-tar/snapcraft.yaml' |
291 | --- integration-tests/data/simple-tar/snapcraft.yaml 2015-09-08 11:48:30 +0000 |
292 | +++ integration-tests/data/simple-tar/snapcraft.yaml 2015-09-29 10:44:16 +0000 |
293 | @@ -27,6 +27,9 @@ |
294 | evil-slash: |
295 | type: tar-content |
296 | source: evil-slash.tar.gz |
297 | + readonly-files: |
298 | + type: tar-content |
299 | + source: readonly-files.tar.gz |
300 | project: |
301 | type: make-project |
302 | source: project.tar.xz |
303 | |
304 | === modified file 'integration-tests/runtests.sh' |
305 | --- integration-tests/runtests.sh 2015-08-04 23:46:54 +0000 |
306 | +++ integration-tests/runtests.sh 2015-09-29 10:44:16 +0000 |
307 | @@ -17,24 +17,43 @@ |
308 | |
309 | set -e |
310 | |
311 | -if [ -z "$SNAPCRAFT" ]; then |
312 | - export SNAPCRAFT=snapcraft |
313 | -fi |
314 | +run_test_plan(){ |
315 | + TEST_PLAN=$1 |
316 | + |
317 | + if [ -z "$SNAPCRAFT" ]; then |
318 | + export SNAPCRAFT=snapcraft |
319 | + fi |
320 | |
321 | -# Create a temporary directory so that we can run 'manage.py develop' and |
322 | -# create the .provider file there |
323 | -temp_dir=$(mktemp -d) |
324 | -# Develop the provider, this will let us run tests on it |
325 | -./manage.py develop -d $temp_dir |
326 | -# Set PROVIDERPATH (see plainbox(1)) so that we can see the provider |
327 | -# without installing it. |
328 | -export PROVIDERPATH=$PROVIDERPATH:$temp_dir |
329 | -# Run the 'normal' test plan |
330 | -plainbox run \ |
331 | - -T 2015.com.canonical.snapcraft::normal \ |
332 | - -f json -o $temp_dir/result.json |
333 | -# Analyze the result and fail if there are any failures |
334 | -python3 - << __PYTHON__ |
335 | + # Create a temporary directory so that we can run 'manage.py develop' and |
336 | + # create the .provider file there |
337 | + temp_dir=$(mktemp -d) |
338 | + # Develop the provider, this will let us run tests on it |
339 | + ./manage.py develop -d $temp_dir |
340 | + # Set PROVIDERPATH (see plainbox(1)) so that we can see the provider |
341 | + # without installing it. |
342 | + export PROVIDERPATH=$PROVIDERPATH:$temp_dir |
343 | + # create symlink from the provider's data directory to examples for them to |
344 | + # be available to the tests |
345 | + if [ "$TEST_PLAN" = "examples" ]; then |
346 | + BASEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd ) |
347 | + TARGET_PATH=${BASEDIR}/integration-tests/data/examples |
348 | + if [ -z $ADT_ARTIFACTS ]; then |
349 | + EXAMPLES_PATH=${BASEDIR}/examples |
350 | + else |
351 | + EXAMPLES_PATH=/usr/share/snapcraft/examples |
352 | + fi |
353 | + ln -fs ${EXAMPLES_PATH} ${TARGET_PATH} |
354 | + fi |
355 | + # Run the test plan |
356 | + plainbox run \ |
357 | + -T 2015.com.canonical.snapcraft::"$TEST_PLAN" \ |
358 | + -f json -o $temp_dir/result.json |
359 | + # remove the examples symlink |
360 | + if [ "$TEST_PLAN" = "examples" ]; then |
361 | + rm ${TARGET_PATH} |
362 | + fi |
363 | + # Analyze the result and fail if there are any failures |
364 | + python3 - << __PYTHON__ |
365 | import json |
366 | with open("$temp_dir/result.json", "rt", encoding="utf-8") as stream: |
367 | results = json.load(stream) |
368 | @@ -46,3 +65,11 @@ |
369 | print("Overall: {0}".format("fail" if failed else "pass")) |
370 | raise SystemExit(failed) |
371 | __PYTHON__ |
372 | +} |
373 | + |
374 | +if [ -z "$1" ]; then |
375 | + echo "need test plan as first argument" |
376 | + exit 1 |
377 | +fi |
378 | + |
379 | +run_test_plan "$@" |
380 | |
381 | === added file 'integration-tests/units/examples.pxu' |
382 | --- integration-tests/units/examples.pxu 1970-01-01 00:00:00 +0000 |
383 | +++ integration-tests/units/examples.pxu 2015-09-29 10:44:16 +0000 |
384 | @@ -0,0 +1,10 @@ |
385 | +id: snapcraft/examples/build |
386 | +plugin: shell |
387 | +command: |
388 | + set -e |
389 | + for example in ${PLAINBOX_PROVIDER_DATA}/examples/* |
390 | + do |
391 | + cp -rT ${example//:} ${PLAINBOX_SESSION_SHARE} |
392 | + cd ${PLAINBOX_SESSION_SHARE} && ${SNAPCRAFT} |
393 | + rm -rf ${PLAINBOX_SESSION_SHARE}/* |
394 | + done |
395 | |
396 | === modified file 'integration-tests/units/jobs.pxu' |
397 | --- integration-tests/units/jobs.pxu 2015-09-21 19:20:43 +0000 |
398 | +++ integration-tests/units/jobs.pxu 2015-09-29 10:44:16 +0000 |
399 | @@ -6,6 +6,7 @@ |
400 | OUTPUT=$(${SNAPCRAFT} pull 2>&1) |
401 | test $? = 1 || exit 1 |
402 | echo $OUTPUT | grep "Could not find snapcraft\.yaml\." |
403 | +flags: simple has-leftovers |
404 | |
405 | id: snapcraft/normal/no-yaml-run |
406 | plugin: shell |
407 | @@ -26,6 +27,7 @@ |
408 | # care where (and you don't need snappy-metadata to find it) |
409 | touch copy-meta # instructs Makefile to copy snappy/ itself |
410 | ${SNAPCRAFT} assemble |
411 | +flags: simple has-leftovers |
412 | |
413 | id: snapcraft/normal/assemble-meta |
414 | plugin: shell |
415 | @@ -48,6 +50,7 @@ |
416 | if [ -e ./snap/bin/not-wrapped.wrapper ]; then |
417 | exit 1 |
418 | fi |
419 | +flags: simple has-leftovers |
420 | |
421 | id: snapcraft/normal/local-source |
422 | plugin: shell |
423 | @@ -60,6 +63,7 @@ |
424 | test "$(readlink parts/make-project/build)" = "$(pwd)" |
425 | ${SNAPCRAFT} stage |
426 | test -e stamp-install |
427 | +flags: simple has-leftovers |
428 | |
429 | id: snapcraft/normal/local-plugin |
430 | plugin: shell |
431 | @@ -69,6 +73,7 @@ |
432 | cp -rT $PLAINBOX_PROVIDER_DATA/local-plugin . |
433 | ${SNAPCRAFT} stage |
434 | test -e stage/build-stamp |
435 | +flags: simple has-leftovers |
436 | |
437 | id: snapcraft/normal/simple-tar |
438 | plugin: shell |
439 | @@ -88,7 +93,11 @@ |
440 | test -e stage/notopdir |
441 | test -e stage/parent |
442 | test -e stage/slash |
443 | + test -e stage/readonly_file |
444 | test "$(./stage/bin/test)" = "tarproject" |
445 | + # Regression test for https://bugs.launchpad.net/snapcraft/+bug/1500728 |
446 | + ${SNAPCRAFT} pull --force |
447 | +flags: simple has-leftovers |
448 | |
449 | id: snapcraft/normal/pypi-config |
450 | plugin: shell |
451 | @@ -103,6 +112,7 @@ |
452 | test -f ./snap/usr/bin/python3 |
453 | test -f ./snap/meta/hooks/config |
454 | grep -q 'exec "usr/bin/config.py" $*' ./snap/meta/hooks/config |
455 | +flags: simple has-leftovers |
456 | |
457 | id: snapcraft/normal/simple-make |
458 | plugin: shell |
459 | @@ -112,6 +122,7 @@ |
460 | cp -rT $PLAINBOX_PROVIDER_DATA/simple-make . |
461 | ${SNAPCRAFT} stage |
462 | test "$(./stage/bin/test)" = "Hello world" |
463 | +flags: simple has-leftovers |
464 | |
465 | id: snapcraft/normal/simple-make-filesets |
466 | plugin: shell |
467 | @@ -130,6 +141,7 @@ |
468 | grep -q 'file1' ./snap/share/file1 |
469 | grep -q 'file2' ./snap/share/file2 |
470 | grep -q 'file1' ./snap/new/dir2/file1 |
471 | +flags: simple has-leftovers |
472 | |
473 | id: snapcraft/normal/simple-make-clean |
474 | plugin: shell |
475 | @@ -149,6 +161,7 @@ |
476 | # Clean a second time doesn't fail. |
477 | # Regression test for https://bugs.launchpad.net/snapcraft/+bug/1497371 |
478 | ${SNAPCRAFT} clean |
479 | +flags: simple has-leftovers |
480 | |
481 | id: snapcraft/normal/simple-cmake |
482 | plugin: shell |
483 | @@ -158,6 +171,7 @@ |
484 | cp -rT $PLAINBOX_PROVIDER_DATA/simple-cmake . |
485 | ${SNAPCRAFT} stage |
486 | test "$(./stage/bin/simple-cmake)" = "It's a CMake world" |
487 | +flags: simple has-leftovers |
488 | |
489 | id: snapcraft/normal/simple-copy |
490 | plugin: shell |
491 | @@ -167,6 +181,7 @@ |
492 | cp -rT $PLAINBOX_PROVIDER_DATA/simple-copy . |
493 | ${SNAPCRAFT} stage |
494 | test "$(cat ./stage/dst)" = "I got copied" |
495 | +flags: simple has-leftovers |
496 | |
497 | id: snapcraft/normal/conflicts |
498 | plugin: shell |
499 | @@ -177,6 +192,7 @@ |
500 | OUTPUT=$(${SNAPCRAFT} stage 2>&1) |
501 | test $? = 1 || exit 1 |
502 | echo $OUTPUT | grep "Error: parts p1 and p2 have the following file paths in common which have different contents: bin/test" # squished output by bash |
503 | +flags: simple has-leftovers |
504 | |
505 | id: snapcraft/normal/dependencies |
506 | plugin: shell |
507 | @@ -189,6 +205,7 @@ |
508 | test "$(${SNAPCRAFT} shell p3)" = 'p1 |
509 | p1 |
510 | p2' |
511 | +flags: simple has-leftovers |
512 | |
513 | id: snapcraft/normal/dependencies-circular |
514 | plugin: shell |
515 | @@ -200,6 +217,7 @@ |
516 | OUTPUT=$(${SNAPCRAFT} pull 2>&1) |
517 | test $? = 1 || exit 1 |
518 | echo $OUTPUT | grep -i "circular dependency" |
519 | +flags: simple has-leftovers |
520 | |
521 | id: snapcraft/normal/dependencies-fail |
522 | plugin: shell |
523 | @@ -210,6 +228,7 @@ |
524 | sed -i '/after/d' snapcraft.yaml |
525 | ${SNAPCRAFT} build |
526 | test $? = 1 || exit 1 |
527 | +flags: simple has-leftovers |
528 | |
529 | id: snapcraft/normal/bzr-head |
530 | plugin: shell |
531 | @@ -225,6 +244,7 @@ |
532 | test "$(bzr revno -r -1 parts/bzr/src)" = "2" |
533 | ${SNAPCRAFT} pull # test pull doesn't fail |
534 | test "$(bzr revno -r -1 parts/bzr/src)" = "2" |
535 | +flags: simple has-leftovers |
536 | |
537 | id: snapcraft/normal/bzr-tag |
538 | plugin: shell |
539 | @@ -241,6 +261,7 @@ |
540 | test "$(bzr revno -r -1 parts/bzr/src)" = "1" |
541 | ${SNAPCRAFT} pull # test pull doesn't fail |
542 | test "$(bzr revno -r -1 parts/bzr/src)" = "1" |
543 | +flags: simple has-leftovers |
544 | |
545 | id: snapcraft/normal/git-head |
546 | plugin: shell |
547 | @@ -257,6 +278,7 @@ |
548 | test "$(git -C parts/git/src log -1 --oneline | cut -d' ' -f2)" = "2" |
549 | ${SNAPCRAFT} pull |
550 | test "$(git -C parts/git/src log -1 --oneline | cut -d' ' -f2)" = "2" |
551 | +flags: simple has-leftovers |
552 | |
553 | id: snapcraft/normal/git-tag |
554 | plugin: shell |
555 | @@ -274,6 +296,7 @@ |
556 | test "$(git -C parts/git/src log -1 --oneline | cut -d' ' -f2)" = "1" |
557 | ${SNAPCRAFT} pull |
558 | test "$(git -C parts/git/src log -1 --oneline | cut -d' ' -f2)" = "1" |
559 | +flags: simple has-leftovers |
560 | |
561 | id: snapcraft/normal/git-branch |
562 | plugin: shell |
563 | @@ -294,6 +317,7 @@ |
564 | test "$(git -C parts/git/src log -2 --oneline | cut -d' ' -f2 | tr '\n' ' ')" = "3 1 " |
565 | ${SNAPCRAFT} pull |
566 | test "$(git -C parts/git/src log -2 --oneline | cut -d' ' -f2 | tr '\n' ' ')" = "3 1 " |
567 | +flags: simple has-leftovers |
568 | |
569 | id: snapcraft/normal/hg-head |
570 | plugin: shell |
571 | @@ -310,6 +334,7 @@ |
572 | test "$(hg log --cwd parts/mercurial/src --template "{desc}" -r -1)" = "2" |
573 | ${SNAPCRAFT} pull |
574 | test "$(hg log --cwd parts/mercurial/src --template "{desc}" -r -1)" = "2" |
575 | +flags: simple has-leftovers |
576 | |
577 | id: snapcraft/normal/hg-tag |
578 | plugin: shell |
579 | @@ -327,6 +352,7 @@ |
580 | test "$(ls -1 parts/mercurial/src/ | wc -l )" = "1" |
581 | ${SNAPCRAFT} pull |
582 | test "$(ls -1 parts/mercurial/src/ | wc -l )" = "1" |
583 | +flags: simple has-leftovers |
584 | |
585 | id: snapcraft/normal/hg-branch |
586 | plugin: shell |
587 | @@ -345,6 +371,7 @@ |
588 | test -e parts/mercurial/src/second |
589 | ${SNAPCRAFT} pull |
590 | test -e parts/mercurial/src/second |
591 | +flags: simple has-leftovers |
592 | |
593 | id: snapcraft/normal/pip-requirements |
594 | plugin: shell |
595 | @@ -355,3 +382,16 @@ |
596 | ${SNAPCRAFT} pull |
597 | test -f parts/python2/install/usr/lib/python2.7/argparse.py |
598 | test -f parts/python3/install/usr/lib/python3.4/argparse.py |
599 | +flags: simple has-leftovers |
600 | + |
601 | +id: snapcraft/normal/build-tool-paths |
602 | +plugin: shell |
603 | +estimated_duration: 30 |
604 | +command: |
605 | + set -ex |
606 | + cp -rT $PLAINBOX_PROVIDER_DATA/build-tools . |
607 | + ${SNAPCRAFT} stage |
608 | + ${SNAPCRAFT} shell pkg-config --cflags glib-2.0 | grep -q `pwd` |
609 | + ${SNAPCRAFT} shell xml2-config --cflags | grep -q `pwd` |
610 | + ${SNAPCRAFT} shell xslt-config --cflags | grep -q `pwd` |
611 | +flags: simple has-leftovers |
612 | |
613 | === modified file 'integration-tests/units/testplans.pxu' |
614 | --- integration-tests/units/testplans.pxu 2015-07-02 18:29:47 +0000 |
615 | +++ integration-tests/units/testplans.pxu 2015-09-29 10:44:16 +0000 |
616 | @@ -1,4 +1,9 @@ |
617 | unit: test plan |
618 | id: normal |
619 | -name: Tests for Snapcraft |
620 | +name: Tests for Snapcraft |
621 | include: snapcraft/normal/.* |
622 | + |
623 | +unit: test plan |
624 | +id: examples |
625 | +name: Test for building Snapcraft examples |
626 | +include: snapcraft/examples/.* |
627 | |
628 | === modified file 'plugins/python2-project.yaml' |
629 | --- plugins/python2-project.yaml 2015-09-22 03:08:07 +0000 |
630 | +++ plugins/python2-project.yaml 2015-09-29 10:44:16 +0000 |
631 | @@ -1,8 +1,8 @@ |
632 | -requires: |
633 | - - python2 |
634 | options: |
635 | + requirements: |
636 | + required: false |
637 | source: |
638 | - required: true |
639 | + required: false |
640 | source-type: |
641 | source-tag: |
642 | source-branch: |
643 | |
644 | === removed file 'plugins/python2.yaml' |
645 | --- plugins/python2.yaml 2015-09-01 14:10:18 +0000 |
646 | +++ plugins/python2.yaml 1970-01-01 00:00:00 +0000 |
647 | @@ -1,3 +0,0 @@ |
648 | -options: |
649 | - requirements: |
650 | - required: false |
651 | |
652 | === modified file 'plugins/python3-project.yaml' |
653 | --- plugins/python3-project.yaml 2015-09-22 03:08:07 +0000 |
654 | +++ plugins/python3-project.yaml 2015-09-29 10:44:16 +0000 |
655 | @@ -1,8 +1,8 @@ |
656 | -requires: |
657 | - - python3 |
658 | options: |
659 | + requirements: |
660 | + required: false |
661 | source: |
662 | - required: true |
663 | + required: false |
664 | source-type: |
665 | source-tag: |
666 | source-branch: |
667 | |
668 | === removed file 'plugins/python3.yaml' |
669 | --- plugins/python3.yaml 2015-09-09 21:35:18 +0000 |
670 | +++ plugins/python3.yaml 1970-01-01 00:00:00 +0000 |
671 | @@ -1,3 +0,0 @@ |
672 | -options: |
673 | - requirements: |
674 | - required: false |
675 | |
676 | === added file 'plugins/scons-project.yaml' |
677 | --- plugins/scons-project.yaml 1970-01-01 00:00:00 +0000 |
678 | +++ plugins/scons-project.yaml 2015-09-29 10:44:16 +0000 |
679 | @@ -0,0 +1,8 @@ |
680 | +build-packages: |
681 | + - scons |
682 | +options: |
683 | + source: |
684 | + required: true |
685 | + source-type: |
686 | + source-tag: |
687 | + source-branch: |
688 | |
689 | === modified file 'runtests.sh' |
690 | --- runtests.sh 2015-09-17 07:31:24 +0000 |
691 | +++ runtests.sh 2015-09-29 10:44:16 +0000 |
692 | @@ -20,39 +20,62 @@ |
693 | export PATH=$(pwd)/bin:$PATH |
694 | export PYTHONPATH=$(pwd):$PYTHONPATH |
695 | |
696 | -SRC_PATHS="bin snapcraft snapcraft/tests" |
697 | - |
698 | -# These three checks could easily be done with flake8 in one shot if |
699 | -# we had python3-flake8 provide flake8 |
700 | -# Ignore 501 (line-too-long) |
701 | -pep8 $SRC_PATHS --ignore=E501 |
702 | - |
703 | -pyflakes3 $SRC_PATHS |
704 | - |
705 | -# mccabe in 'warning' mode as we have high complexity |
706 | -mccabe_list= |
707 | -for unit in $(find snapcraft -type f -name '*.py') |
708 | -do |
709 | - output=$(python3 -m mccabe --min 10 "$unit") |
710 | - [ -n "$output" ] && mccabe_list="- $unit:\n $output\n$mccabe_list" |
711 | -done |
712 | - |
713 | -if [ -n "$mccabe_list" ]; then |
714 | - echo -e "\e[1;31mThe project has gotten complex\e[0m." |
715 | - echo "Here's the list of units exceeding 10:" |
716 | - echo -e "$mccabe_list" |
717 | -fi |
718 | - |
719 | -if which python3-coverage >/dev/null 2>&1; then |
720 | - python3-coverage erase |
721 | - python3-coverage run --branch --source snapcraft -m unittest |
722 | - mv .coverage .coverage.unit |
723 | -else |
724 | - python3 -m unittest |
725 | -fi |
726 | - |
727 | -if [ -z "$SNAPCRAFT_TESTS_SKIP_PLAINBOX" ]; then |
728 | -( |
729 | +parseargs(){ |
730 | + if [[ "$#" -eq 0 ]] || [[ "$1" == "all" ]]; then |
731 | + export RUN_UNIT="true" |
732 | + export RUN_PLAINBOX="true" |
733 | + export PLAINBOX_TEST_PLANS="normal" |
734 | + else |
735 | + if [ "$1" == "unit" ] ; then |
736 | + export RUN_UNIT="true" |
737 | + elif [ "$1" == "plainbox" ] ; then |
738 | + export RUN_PLAINBOX="true" |
739 | + if [ "$#" -gt 1 ]; then |
740 | + export PLAINBOX_TEST_PLANS="$2" |
741 | + else |
742 | + export PLAINBOX_TEST_PLANS="normal" |
743 | + fi |
744 | + else |
745 | + echo "Not recognized option, should be one of all, unit or plainbox" |
746 | + exit 1 |
747 | + fi |
748 | + fi |
749 | +} |
750 | + |
751 | +run_unit_tests(){ |
752 | + SRC_PATHS="bin snapcraft snapcraft/tests" |
753 | + |
754 | + # These three checks could easily be done with flake8 in one shot if |
755 | + # we had python3-flake8 provide flake8 |
756 | + # Ignore 501 (line-too-long) |
757 | + pep8 $SRC_PATHS --ignore=E501 |
758 | + |
759 | + pyflakes3 $SRC_PATHS |
760 | + |
761 | + # mccabe in 'warning' mode as we have high complexity |
762 | + mccabe_list= |
763 | + for unit in $(find snapcraft -type f -name '*.py') |
764 | + do |
765 | + output=$(python3 -m mccabe --min 10 "$unit") |
766 | + [ -n "$output" ] && mccabe_list="- $unit:\n $output\n$mccabe_list" |
767 | + done |
768 | + |
769 | + if [ -n "$mccabe_list" ]; then |
770 | + echo -e "\e[1;31mThe project has gotten complex\e[0m." |
771 | + echo "Here's the list of units exceeding 10:" |
772 | + echo -e "$mccabe_list" |
773 | + fi |
774 | + |
775 | + if which python3-coverage >/dev/null 2>&1; then |
776 | + python3-coverage erase |
777 | + python3-coverage run --branch --source snapcraft -m unittest |
778 | + mv .coverage .coverage.unit |
779 | + else |
780 | + python3 -m unittest |
781 | + fi |
782 | +} |
783 | + |
784 | +run_plainbox(){ |
785 | # well, well, what can we do |
786 | if ! which plainbox >/dev/null; then |
787 | cat <<EOF |
788 | @@ -73,8 +96,17 @@ |
789 | |
790 | # Go to the plainbox provider of snapcraft tests |
791 | cd integration-tests |
792 | - ./runtests.sh |
793 | -) |
794 | + ./runtests.sh $PLAINBOX_TEST_PLANS |
795 | +} |
796 | + |
797 | +parseargs "$@" |
798 | + |
799 | +if [ ! -z "$RUN_UNIT" ]; then |
800 | + run_unit_tests |
801 | +fi |
802 | + |
803 | +if [ -z "$SNAPCRAFT_TESTS_SKIP_PLAINBOX" ] && [ ! -z "$RUN_PLAINBOX" ] ; then |
804 | + run_plainbox |
805 | fi |
806 | |
807 | if which python3-coverage >/dev/null 2>&1; then |
808 | |
809 | === modified file 'snapcraft/__init__.py' |
810 | --- snapcraft/__init__.py 2015-09-21 14:16:55 +0000 |
811 | +++ snapcraft/__init__.py 2015-09-29 10:44:16 +0000 |
812 | @@ -16,6 +16,7 @@ |
813 | |
814 | import logging |
815 | import os |
816 | +import re |
817 | |
818 | import snapcraft.common |
819 | import snapcraft.sources |
820 | @@ -69,8 +70,17 @@ |
821 | cwd = self.builddir |
822 | if True: |
823 | print(' '.join(cmd)) |
824 | + self.makedirs(cwd) |
825 | return snapcraft.common.run(cmd, cwd=cwd, **kwargs) |
826 | |
827 | + def run_output(self, cmd, cwd=None, **kwargs): |
828 | + if cwd is None: |
829 | + cwd = self.builddir |
830 | + if True: |
831 | + print(' '.join(cmd)) |
832 | + self.makedirs(cwd) |
833 | + return snapcraft.common.run_output(cmd, cwd=cwd, **kwargs) |
834 | + |
835 | def isurl(self, url): |
836 | return snapcraft.common.isurl(url) |
837 | |
838 | @@ -108,6 +118,13 @@ |
839 | ubuntu = snapcraft.repo.Ubuntu(self.ubuntudir, sources=self.PLUGIN_STAGE_SOURCES) |
840 | ubuntu.get(self.PLUGIN_STAGE_PACKAGES + part_stage_packages) |
841 | ubuntu.unpack(self.installdir) |
842 | + self._fixup(self.installdir) |
843 | + |
844 | + def _fixup(self, root): |
845 | + if os.path.isfile(os.path.join(root, 'usr', 'bin', 'xml2-config')): |
846 | + self.run(['sed', '-i', '-e', 's|prefix=/usr|prefix={}/usr|'.format(root), os.path.join(root, 'usr', 'bin', 'xml2-config')]) |
847 | + if os.path.isfile(os.path.join(root, 'usr', 'bin', 'xslt-config')): |
848 | + self.run(['sed', '-i', '-e', 's|prefix=/usr|prefix={}/usr|'.format(root), os.path.join(root, 'usr', 'bin', 'xslt-config')]) |
849 | |
850 | |
851 | def _get_source_handler(source_type, source): |
852 | @@ -134,6 +151,8 @@ |
853 | source_type = 'bzr' |
854 | elif source.startswith("git:"): |
855 | source_type = 'git' |
856 | + elif re.compile(r'.*\.((tar\.(xz|gz|bz2))|tgz)$').match(source): |
857 | + source_type = 'tar' |
858 | elif snapcraft.common.isurl(source): |
859 | raise ValueError() |
860 | |
861 | |
862 | === modified file 'snapcraft/cmds.py' |
863 | --- snapcraft/cmds.py 2015-09-21 19:20:43 +0000 |
864 | +++ snapcraft/cmds.py 2015-09-29 10:44:16 +0000 |
865 | @@ -267,6 +267,8 @@ |
866 | for f in common: |
867 | this = os.path.join(part.installdir, f) |
868 | other = os.path.join(parts_files[other_part_name]['installdir'], f) |
869 | + if os.path.islink(this) and os.path.islink(other): |
870 | + continue |
871 | if not filecmp.cmp(this, other, shallow=False): |
872 | conflict_files.append(f) |
873 | |
874 | |
875 | === modified file 'snapcraft/common.py' |
876 | --- snapcraft/common.py 2015-09-17 18:02:05 +0000 |
877 | +++ snapcraft/common.py 2015-09-29 10:44:16 +0000 |
878 | @@ -49,6 +49,17 @@ |
879 | return subprocess.call(['/bin/sh', f.name] + cmd, **kwargs) == 0 |
880 | |
881 | |
882 | +def run_output(cmd, **kwargs): |
883 | + assert isinstance(cmd, list), "run command must be a list" |
884 | + # FIXME: This is gross to keep writing this, even when env is the same |
885 | + with tempfile.NamedTemporaryFile(mode='w+') as f: |
886 | + f.write(assemble_env()) |
887 | + f.write('\n') |
888 | + f.write('exec $*') |
889 | + f.flush() |
890 | + return subprocess.check_output(['/bin/sh', f.name] + cmd, **kwargs).decode('utf8').strip() |
891 | + |
892 | + |
893 | def fatal(): |
894 | sys.exit(1) |
895 | |
896 | |
897 | === modified file 'snapcraft/plugin.py' |
898 | --- snapcraft/plugin.py 2015-09-22 03:08:07 +0000 |
899 | +++ snapcraft/plugin.py 2015-09-29 10:44:16 +0000 |
900 | @@ -39,15 +39,8 @@ |
901 | } |
902 | |
903 | |
904 | -def is_local_plugin(name): |
905 | - return name.startswith("x-") |
906 | - |
907 | - |
908 | -def plugindir(name): |
909 | - if is_local_plugin(name): |
910 | - return os.path.abspath(os.path.join('parts', 'plugins')) |
911 | - else: |
912 | - return common.get_plugindir() |
913 | +def _local_plugindir(): |
914 | + return os.path.abspath(os.path.join('parts', 'plugins')) |
915 | |
916 | |
917 | class PluginError(Exception): |
918 | @@ -87,10 +80,12 @@ |
919 | return |
920 | |
921 | def _load_config(self, name): |
922 | - configPath = os.path.join(plugindir(name), name + ".yaml") |
923 | - if not os.path.exists(configPath): |
924 | + config_path = os.path.join(common.get_plugindir(), name + ".yaml") |
925 | + if not os.path.exists(config_path): |
926 | + config_path = os.path.join(_local_plugindir(), name + ".yaml") |
927 | + if not os.path.exists(config_path): |
928 | raise PluginError('Unknown plugin: {}'.format(name)) |
929 | - with open(configPath, 'r') as fp: |
930 | + with open(config_path, 'r') as fp: |
931 | self.config = yaml.load(fp) or {} |
932 | |
933 | def _make_options(self, name, properties): |
934 | @@ -121,14 +116,15 @@ |
935 | options = self._make_options(name, properties) |
936 | module_name = name.replace('-', '_') |
937 | |
938 | - # Load code from local plugin dir if it is there |
939 | - if is_local_plugin(name): |
940 | - sys.path = [plugindir(name)] + sys.path |
941 | - else: |
942 | - module_name = 'snapcraft.plugins.' + module_name |
943 | + try: |
944 | + module = importlib.import_module('snapcraft.plugins.' + module_name) |
945 | + except ImportError: |
946 | + module = None |
947 | |
948 | - module = importlib.import_module(module_name) |
949 | - if is_local_plugin(name): |
950 | + if not module: |
951 | + logger.info('Searching for local plugin for %s', name) |
952 | + sys.path = [_local_plugindir()] + sys.path |
953 | + module = importlib.import_module(module_name) |
954 | sys.path.pop(0) |
955 | |
956 | for prop_name in dir(module): |
957 | |
958 | === modified file 'snapcraft/plugins/go_project.py' |
959 | --- snapcraft/plugins/go_project.py 2015-07-31 15:16:47 +0000 |
960 | +++ snapcraft/plugins/go_project.py 2015-09-29 10:44:16 +0000 |
961 | @@ -27,7 +27,9 @@ |
962 | self.fullname = self.options.source.split("://")[1] |
963 | |
964 | def pull(self): |
965 | - return self.run(['go', 'get', '-t', self.fullname]) |
966 | + # use -d to only download (build will happen later) |
967 | + # use -t to also get the test-deps |
968 | + return self.run(['go', 'get', '-t', '-d', self.fullname]) |
969 | |
970 | def build(self): |
971 | if not self.run(['go', 'build', self.fullname]): |
972 | |
973 | === removed file 'snapcraft/plugins/python2.py' |
974 | --- snapcraft/plugins/python2.py 2015-09-17 15:14:49 +0000 |
975 | +++ snapcraft/plugins/python2.py 1970-01-01 00:00:00 +0000 |
976 | @@ -1,59 +0,0 @@ |
977 | -# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- |
978 | -# |
979 | -# Copyright (C) 2015 Canonical Ltd |
980 | -# |
981 | -# This program is free software: you can redistribute it and/or modify |
982 | -# it under the terms of the GNU General Public License version 3 as |
983 | -# published by the Free Software Foundation. |
984 | -# |
985 | -# This program is distributed in the hope that it will be useful, |
986 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
987 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
988 | -# GNU General Public License for more details. |
989 | -# |
990 | -# You should have received a copy of the GNU General Public License |
991 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. |
992 | - |
993 | -import os |
994 | -import snapcraft |
995 | - |
996 | - |
997 | -class Python2Plugin(snapcraft.BasePlugin): |
998 | - |
999 | - _PLUGIN_STAGE_PACKAGES = [ |
1000 | - 'python-dev', |
1001 | - 'python-setuptools', |
1002 | - ] |
1003 | - |
1004 | - def __init__(self, name, options): |
1005 | - if options.requirements: |
1006 | - self.requirements = options.requirements |
1007 | - self._PLUGIN_STAGE_PACKAGES.extend(['python-pkg-resources', 'python-setuptools']) |
1008 | - else: |
1009 | - self.requirements = None |
1010 | - super().__init__(name, options) |
1011 | - |
1012 | - def snap_fileset(self): |
1013 | - return [ |
1014 | - '-usr/share', |
1015 | - ] |
1016 | - |
1017 | - # note that we don't need to set PYTHONHOME here, |
1018 | - # python discovers this automatically from it installed |
1019 | - # location. And PATH is automatically set by snapcraft. |
1020 | - |
1021 | - def env(self, root): |
1022 | - return ["PYTHONPATH=%s" % os.path.join( |
1023 | - root, 'usr', 'lib', 'python2.7', 'dist-packages')] |
1024 | - |
1025 | - def pull(self): |
1026 | - # A nice idea here would be to be asking setup tools |
1027 | - # to use the deb layout, but that doesn't work with |
1028 | - # prefix sadly |
1029 | - |
1030 | - if self.requirements and not (self.run( |
1031 | - ['ln', '-s', os.path.join(self.installdir, 'usr', 'lib', 'python2.7', 'dist-packages'), os.path.join(self.installdir, 'usr', 'lib', 'python2.7', 'site-packages')]) and self.run( |
1032 | - ['python2', os.path.join(self.installdir, 'usr', 'bin', 'easy_install'), '--prefix', os.path.join(self.installdir, 'usr'), 'pip']) and self.run( |
1033 | - ['python2', os.path.join(self.installdir, 'usr', 'bin', 'pip2'), 'install', '--target', os.path.join(self.installdir, 'usr', 'lib', 'python2.7', 'site-packages'), '--requirement', os.path.join(os.getcwd(), self.requirements)])): |
1034 | - return False |
1035 | - return True |
1036 | |
1037 | === modified file 'snapcraft/plugins/python2_project.py' |
1038 | --- snapcraft/plugins/python2_project.py 2015-09-21 22:22:36 +0000 |
1039 | +++ snapcraft/plugins/python2_project.py 2015-09-29 10:44:16 +0000 |
1040 | @@ -22,20 +22,76 @@ |
1041 | |
1042 | class Python2ProjectPlugin(snapcraft.BasePlugin): |
1043 | |
1044 | - # note that we don't need to setup env(), python figures it out |
1045 | - # see python2.py for more details |
1046 | + _PLUGIN_STAGE_PACKAGES = [ |
1047 | + 'python-dev', |
1048 | + 'python-pkg-resources', |
1049 | + 'python-setuptools', |
1050 | + ] |
1051 | + |
1052 | + def __init__(self, name, options): |
1053 | + super().__init__(name, options) |
1054 | + self.requirements = options.requirements |
1055 | + self.source = options.source |
1056 | + |
1057 | + def env(self, root): |
1058 | + return ["PYTHONPATH=%s" % os.path.join( |
1059 | + root, 'usr', 'lib', self.python_version, 'dist-packages')] |
1060 | |
1061 | def pull(self): |
1062 | - return self.handle_source_options() |
1063 | + if self.source and not self.handle_source_options(): |
1064 | + return False |
1065 | + |
1066 | + return self._pip() |
1067 | + |
1068 | + def _pip(self): |
1069 | + setup = 'setup.py' |
1070 | + if os.listdir(self.sourcedir): |
1071 | + setup = os.path.join(self.sourcedir, 'setup.py') |
1072 | + |
1073 | + if self.requirements: |
1074 | + requirements = os.path.join(os.getcwd(), self.requirements) |
1075 | + |
1076 | + if not os.path.exists(setup) and not self.requirements: |
1077 | + return True |
1078 | + |
1079 | + easy_install = os.path.join( |
1080 | + self.installdir, 'usr', 'bin', 'easy_install') |
1081 | + prefix = os.path.join(self.installdir, 'usr') |
1082 | + site_packages_dir = os.path.join( |
1083 | + prefix, 'lib', self.python_version, 'site-packages') |
1084 | + |
1085 | + if not os.path.exists(site_packages_dir): |
1086 | + os.symlink( |
1087 | + os.path.join(prefix, 'lib', self.python_version, 'dist-packages'), |
1088 | + site_packages_dir) |
1089 | + |
1090 | + if not self.run(['python2', easy_install, '--prefix', prefix, 'pip']): |
1091 | + return False |
1092 | + |
1093 | + pip2 = os.path.join(self.installdir, 'usr', 'bin', 'pip2') |
1094 | + pip_install = ['python2', pip2, 'install', '--target', |
1095 | + site_packages_dir] |
1096 | + |
1097 | + if self.requirements and not self.run( |
1098 | + pip_install + ['--requirement', requirements]): |
1099 | + return False |
1100 | + |
1101 | + if os.path.exists(setup) and not self.run(pip_install + ['.', ]): |
1102 | + return False |
1103 | + |
1104 | + return True |
1105 | |
1106 | def build(self): |
1107 | # If setuptools is used, it tries to create files in the |
1108 | # dist-packages dir and import from there, so it needs to exist |
1109 | # and be in the PYTHONPATH. It's harmless if setuptools isn't |
1110 | # used. |
1111 | + |
1112 | + if not os.path.exists(os.path.join(self.builddir, 'setup.py')): |
1113 | + return True |
1114 | + |
1115 | os.makedirs(self.dist_packages_dir, exist_ok=True) |
1116 | setuptemp = self.copy_setup() |
1117 | - |
1118 | return self.run( |
1119 | ['python2', setuptemp.name, 'install', '--install-layout=deb', |
1120 | '--prefix={}/usr'.format(self.installdir)], cwd=self.builddir) |
1121 | @@ -43,7 +99,11 @@ |
1122 | @property |
1123 | def dist_packages_dir(self): |
1124 | return os.path.join( |
1125 | - self.installdir, 'usr', 'lib', 'python2.7', 'dist-packages') |
1126 | + self.installdir, 'usr', 'lib', self.python_version, 'dist-packages') |
1127 | + |
1128 | + @property |
1129 | + def python_version(self): |
1130 | + return self.run_output(['pyversions', '-i']) |
1131 | |
1132 | # Takes the setup.py file and puts a couple little gems on the |
1133 | # front to make things work better. |
1134 | |
1135 | === removed file 'snapcraft/plugins/python3.py' |
1136 | --- snapcraft/plugins/python3.py 2015-09-17 15:14:49 +0000 |
1137 | +++ snapcraft/plugins/python3.py 1970-01-01 00:00:00 +0000 |
1138 | @@ -1,61 +0,0 @@ |
1139 | -# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- |
1140 | -# |
1141 | -# Copyright (C) 2015 Canonical Ltd |
1142 | -# |
1143 | -# This program is free software: you can redistribute it and/or modify |
1144 | -# it under the terms of the GNU General Public License version 3 as |
1145 | -# published by the Free Software Foundation. |
1146 | -# |
1147 | -# This program is distributed in the hope that it will be useful, |
1148 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1149 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1150 | -# GNU General Public License for more details. |
1151 | -# |
1152 | -# You should have received a copy of the GNU General Public License |
1153 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. |
1154 | - |
1155 | -import os |
1156 | -import snapcraft |
1157 | - |
1158 | - |
1159 | -class Python3Plugin(snapcraft.BasePlugin): |
1160 | - |
1161 | - _PLUGIN_STAGE_PACKAGES = [ |
1162 | - 'python3-dev', |
1163 | - 'python3-setuptools', |
1164 | - ] |
1165 | - |
1166 | - def __init__(self, name, options): |
1167 | - if options.requirements: |
1168 | - self.requirements = options.requirements |
1169 | - self._PLUGIN_STAGE_PACKAGES.extend(['python3-pkg-resources', 'python3-setuptools']) |
1170 | - else: |
1171 | - self.requirements = None |
1172 | - super().__init__(name, options) |
1173 | - |
1174 | - def snap_fileset(self): |
1175 | - return [ |
1176 | - '-usr/share', |
1177 | - ] |
1178 | - |
1179 | - # note that we don't need to set PYTHONHOME here, |
1180 | - # python discovers this automatically from it installed |
1181 | - # location, see https://code.launchpad.net/~mvo/snapcraft/python3-project/+merge/264521/comments/664308 |
1182 | - # |
1183 | - # PATH is automatically set by snapcraft |
1184 | - |
1185 | - def env(self, root): |
1186 | - return ["PYTHONPATH=%s" % os.path.join( |
1187 | - root, 'usr', 'lib', 'python3', 'dist-packages')] |
1188 | - |
1189 | - def pull(self): |
1190 | - # A nice idea here would be to be asking setup tools |
1191 | - # to use the deb layout, but that doesn't work with |
1192 | - # prefix sadly |
1193 | - |
1194 | - if self.requirements and not (self.run( |
1195 | - ['ln', '-s', os.path.join(self.installdir, 'usr', 'lib', 'python3', 'dist-packages'), os.path.join(self.installdir, 'usr', 'lib', 'python3.4', 'site-packages')]) and self.run( |
1196 | - ['python3', os.path.join(self.installdir, 'usr', 'bin', 'easy_install3'), '--prefix', os.path.join(self.installdir, 'usr'), 'pip']) and self.run( |
1197 | - ['python3', os.path.join(self.installdir, 'usr', 'bin', 'pip3'), 'install', '--target', os.path.join(self.installdir, 'usr', 'lib', 'python3.4', 'site-packages'), '--requirement', os.path.join(os.getcwd(), self.requirements)])): |
1198 | - return False |
1199 | - return True |
1200 | |
1201 | === modified file 'snapcraft/plugins/python3_project.py' |
1202 | --- snapcraft/plugins/python3_project.py 2015-09-21 22:22:36 +0000 |
1203 | +++ snapcraft/plugins/python3_project.py 2015-09-29 10:44:16 +0000 |
1204 | @@ -22,21 +22,74 @@ |
1205 | |
1206 | class Python3ProjectPlugin(snapcraft.BasePlugin): |
1207 | |
1208 | - # note that we don't need to setup env(), python figures it out |
1209 | - # see python3.py for more details |
1210 | + _PLUGIN_STAGE_PACKAGES = [ |
1211 | + 'python3-dev', |
1212 | + 'python3-pkg-resources', |
1213 | + 'python3-setuptools', |
1214 | + ] |
1215 | + |
1216 | + def __init__(self, name, options): |
1217 | + super().__init__(name, options) |
1218 | + self.requirements = options.requirements |
1219 | + self.source = options.source |
1220 | |
1221 | def env(self, root): |
1222 | return ["PYTHONPATH=%s" % os.path.join( |
1223 | - root, 'usr', 'lib', 'python3', 'dist-packages')] |
1224 | + root, 'usr', 'lib', self.python_version, 'dist-packages')] |
1225 | |
1226 | def pull(self): |
1227 | - return self.handle_source_options() |
1228 | + if self.source and not self.handle_source_options(): |
1229 | + return False |
1230 | + |
1231 | + return self._pip() |
1232 | + |
1233 | + def _pip(self): |
1234 | + setup = 'setup.py' |
1235 | + if os.listdir(self.sourcedir): |
1236 | + setup = os.path.join(self.sourcedir, 'setup.py') |
1237 | + |
1238 | + if self.requirements: |
1239 | + requirements = os.path.join(os.getcwd(), self.requirements) |
1240 | + |
1241 | + if not os.path.exists(setup) and not self.requirements: |
1242 | + return True |
1243 | + |
1244 | + easy_install = os.path.join( |
1245 | + self.installdir, 'usr', 'bin', 'easy_install3') |
1246 | + prefix = os.path.join(self.installdir, 'usr') |
1247 | + site_packages_dir = os.path.join( |
1248 | + prefix, 'lib', self.python_version, 'site-packages') |
1249 | + |
1250 | + if not os.path.exists(site_packages_dir): |
1251 | + os.symlink( |
1252 | + os.path.join(prefix, 'lib', 'python3', 'dist-packages'), |
1253 | + site_packages_dir) |
1254 | + |
1255 | + if not self.run(['python3', easy_install, '--prefix', prefix, 'pip']): |
1256 | + return False |
1257 | + |
1258 | + pip3 = os.path.join(self.installdir, 'usr', 'bin', 'pip3') |
1259 | + pip_install = ['python3', pip3, 'install', '--target', |
1260 | + site_packages_dir] |
1261 | + |
1262 | + if self.requirements and not self.run( |
1263 | + pip_install + ['--requirement', requirements]): |
1264 | + return False |
1265 | + |
1266 | + if os.path.exists(setup) and not self.run(pip_install + ['.', ]): |
1267 | + return False |
1268 | + |
1269 | + return True |
1270 | |
1271 | def build(self): |
1272 | # If setuptools is used, it tries to create files in the |
1273 | # dist-packages dir and import from there, so it needs to exist |
1274 | # and be in the PYTHONPATH. It's harmless if setuptools isn't |
1275 | # used. |
1276 | + |
1277 | + if not os.path.exists(os.path.join(self.builddir, 'setup.py')): |
1278 | + return True |
1279 | + |
1280 | os.makedirs(self.dist_packages_dir, exist_ok=True) |
1281 | setuptemp = self.copy_setup() |
1282 | return self.run( |
1283 | @@ -46,7 +99,11 @@ |
1284 | @property |
1285 | def dist_packages_dir(self): |
1286 | return os.path.join( |
1287 | - self.installdir, 'usr', 'lib', 'python3', 'dist-packages') |
1288 | + self.installdir, 'usr', 'lib', self.python_version, 'dist-packages') |
1289 | + |
1290 | + @property |
1291 | + def python_version(self): |
1292 | + return self.run_output(['py3versions', '-i']) |
1293 | |
1294 | # Takes the setup.py file and puts a couple little gems on the |
1295 | # front to make things work better. |
1296 | |
1297 | === added file 'snapcraft/plugins/scons_project.py' |
1298 | --- snapcraft/plugins/scons_project.py 1970-01-01 00:00:00 +0000 |
1299 | +++ snapcraft/plugins/scons_project.py 2015-09-29 10:44:16 +0000 |
1300 | @@ -0,0 +1,31 @@ |
1301 | +# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- |
1302 | +# |
1303 | +# Copyright (C) 2015 Canonical Ltd |
1304 | +# |
1305 | +# This program is free software: you can redistribute it and/or modify |
1306 | +# it under the terms of the GNU General Public License version 3 as |
1307 | +# published by the Free Software Foundation. |
1308 | +# |
1309 | +# This program is distributed in the hope that it will be useful, |
1310 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1311 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1312 | +# GNU General Public License for more details. |
1313 | +# |
1314 | +# You should have received a copy of the GNU General Public License |
1315 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
1316 | + |
1317 | +import os |
1318 | + |
1319 | +import snapcraft |
1320 | + |
1321 | + |
1322 | +class SconsPlugin(snapcraft.BasePlugin): |
1323 | + |
1324 | + def pull(self): |
1325 | + return self.handle_source_options() |
1326 | + |
1327 | + def build(self): |
1328 | + env = os.environ.copy() |
1329 | + env['DESTDIR'] = self.installdir |
1330 | + return self.run(['scons', 'prefix=/usr']) and \ |
1331 | + self.run(['scons', 'install'], env=env) |
1332 | |
1333 | === modified file 'snapcraft/repo.py' |
1334 | --- snapcraft/repo.py 2015-09-21 15:21:15 +0000 |
1335 | +++ snapcraft/repo.py 2015-09-29 10:44:16 +0000 |
1336 | @@ -14,6 +14,7 @@ |
1337 | # You should have received a copy of the GNU General Public License |
1338 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1339 | |
1340 | +import apt |
1341 | import glob |
1342 | import itertools |
1343 | import os |
1344 | @@ -22,18 +23,19 @@ |
1345 | import urllib |
1346 | import urllib.request |
1347 | |
1348 | -import apt |
1349 | from xml.etree import ElementTree |
1350 | |
1351 | -_DEFAULT_SOURCES = '''deb http://${mirror}archive.ubuntu.com/ubuntu/ vivid main restricted |
1352 | -deb http://${mirror}archive.ubuntu.com/ubuntu/ vivid-updates main restricted |
1353 | -deb http://${mirror}archive.ubuntu.com/ubuntu/ vivid universe |
1354 | -deb http://${mirror}archive.ubuntu.com/ubuntu/ vivid-updates universe |
1355 | -deb http://${mirror}archive.ubuntu.com/ubuntu/ vivid multiverse |
1356 | -deb http://${mirror}archive.ubuntu.com/ubuntu/ vivid-updates multiverse |
1357 | -deb http://security.ubuntu.com/ubuntu vivid-security main restricted |
1358 | -deb http://security.ubuntu.com/ubuntu vivid-security universe |
1359 | -deb http://security.ubuntu.com/ubuntu vivid-security multiverse |
1360 | +import snapcraft.common |
1361 | + |
1362 | +_DEFAULT_SOURCES = '''deb http://${prefix}.ubuntu.com/${suffix}/ ${release} main restricted |
1363 | +deb http://${prefix}.ubuntu.com/${suffix}/ ${release}-updates main restricted |
1364 | +deb http://${prefix}.ubuntu.com/${suffix}/ ${release} universe |
1365 | +deb http://${prefix}.ubuntu.com/${suffix}/ ${release}-updates universe |
1366 | +deb http://${prefix}.ubuntu.com/${suffix}/ ${release} multiverse |
1367 | +deb http://${prefix}.ubuntu.com/${suffix}/ ${release}-updates multiverse |
1368 | +deb http://${security}.ubuntu.com/${suffix} ${release}-security main restricted |
1369 | +deb http://${security}.ubuntu.com/${suffix} ${release}-security universe |
1370 | +deb http://${security}.ubuntu.com/${suffix} ${release}-security multiverse |
1371 | ''' |
1372 | _GEOIP_SERVER = "http://geoip.ubuntu.com/lookup" |
1373 | |
1374 | @@ -61,11 +63,16 @@ |
1375 | class Ubuntu: |
1376 | |
1377 | def __init__(self, rootdir, recommends=False, sources=_DEFAULT_SOURCES): |
1378 | - sources = sources or _DEFAULT_SOURCES |
1379 | self.downloaddir = os.path.join(rootdir, 'download') |
1380 | self.rootdir = rootdir |
1381 | - self.apt_cache = _setup_apt_cache(rootdir, sources) |
1382 | self.recommends = recommends |
1383 | + sources = sources or _DEFAULT_SOURCES |
1384 | + local = False |
1385 | + if 'SNAPCRAFT_LOCAL_SOURCES' in os.environ: |
1386 | + print('using local sources') |
1387 | + sources = _get_local_sources_list() |
1388 | + local = True |
1389 | + self.apt_cache = _setup_apt_cache(rootdir, sources, local) |
1390 | |
1391 | def get(self, package_names): |
1392 | os.makedirs(self.downloaddir, exist_ok=True) |
1393 | @@ -78,18 +85,35 @@ |
1394 | except KeyError: |
1395 | raise PackageNotFoundError(name) |
1396 | |
1397 | + skipped_essential = [] |
1398 | + skipped_blacklisted = [] |
1399 | + |
1400 | + # unmark some base packages here |
1401 | + # note that this will break the consistency check inside apt_cache |
1402 | + # (self.apt_cache.broken_count will be > 0) |
1403 | + # but that is ok as it was consistent before we excluded |
1404 | + # these base package |
1405 | for pkg in self.apt_cache: |
1406 | # those should be already on each system, it also prevents |
1407 | # diving into downloading libc6 |
1408 | if (pkg.candidate.priority in 'essential' and |
1409 | pkg.name not in package_names): |
1410 | - print('Skipping priority essential/imporant %s' % pkg.name) |
1411 | + skipped_essential.append(pkg.name) |
1412 | + pkg.mark_keep() |
1413 | continue |
1414 | if (pkg.name in manifest_dep_names and pkg.name not in package_names): |
1415 | - print('Skipping blacklisted from manifest package %s' % pkg.name) |
1416 | + skipped_blacklisted.append(pkg.name) |
1417 | + pkg.mark_keep() |
1418 | continue |
1419 | - if pkg.marked_install: |
1420 | - pkg.candidate.fetch_binary(destdir=self.downloaddir) |
1421 | + |
1422 | + if skipped_essential: |
1423 | + print('Skipping priority essential packages:', skipped_essential) |
1424 | + if skipped_blacklisted: |
1425 | + print('Skipping blacklisted from manifest packages:', skipped_blacklisted) |
1426 | + |
1427 | + # download the remaining ones with proper progress |
1428 | + apt.apt_pkg.config.set("Dir::Cache::Archives", self.downloaddir) |
1429 | + self.apt_cache.fetch_archives() |
1430 | |
1431 | def unpack(self, rootdir): |
1432 | pkgs_abs_path = glob.glob(os.path.join(self.downloaddir, '*.deb')) |
1433 | @@ -114,7 +138,19 @@ |
1434 | return manifest_dep_names |
1435 | |
1436 | |
1437 | -def get_geoip_country_code_prefix(): |
1438 | +def _get_local_sources_list(): |
1439 | + sources_list = glob.glob('/etc/apt/sources.list.d/*.list') |
1440 | + sources_list.append('/etc/apt/sources.list') |
1441 | + |
1442 | + sources = '' |
1443 | + for source in sources_list: |
1444 | + with open(source) as f: |
1445 | + sources += f.read() |
1446 | + |
1447 | + return sources |
1448 | + |
1449 | + |
1450 | +def _get_geoip_country_code_prefix(): |
1451 | try: |
1452 | with urllib.request.urlopen(_GEOIP_SERVER) as f: |
1453 | xml_data = f.read() |
1454 | @@ -122,20 +158,41 @@ |
1455 | cc = et.find("CountryCode") |
1456 | if cc is None: |
1457 | return "" |
1458 | - return cc.text.lower() + "." |
1459 | + return cc.text.lower() |
1460 | except (ElementTree.ParseError, urllib.error.URLError): |
1461 | pass |
1462 | - return "" |
1463 | - |
1464 | - |
1465 | -def _setup_apt_cache(rootdir, sources): |
1466 | + return '' |
1467 | + |
1468 | + |
1469 | +def _format_sources_list(sources, arch, release='vivid'): |
1470 | + if arch in ('amd64', 'i386'): |
1471 | + geoip_prefix = _get_geoip_country_code_prefix() |
1472 | + prefix = geoip_prefix + '.archive' if geoip_prefix else 'archive' |
1473 | + suffix = 'ubuntu' |
1474 | + security = 'security' |
1475 | + else: |
1476 | + prefix = 'ports' |
1477 | + suffix = 'ubuntu-ports' |
1478 | + security = 'ports' |
1479 | + |
1480 | + return string.Template(sources).substitute({ |
1481 | + 'prefix': prefix, |
1482 | + 'release': release, |
1483 | + 'suffix': suffix, |
1484 | + 'security': security, |
1485 | + }) |
1486 | + |
1487 | + |
1488 | +def _setup_apt_cache(rootdir, sources, local=False): |
1489 | os.makedirs(os.path.join(rootdir, 'etc', 'apt'), exist_ok=True) |
1490 | srcfile = os.path.join(rootdir, 'etc', 'apt', 'sources.list') |
1491 | + |
1492 | + if not local: |
1493 | + sources = _format_sources_list(sources, snapcraft.common.get_arch()) |
1494 | + |
1495 | with open(srcfile, 'w') as f: |
1496 | - mirror_prefix = get_geoip_country_code_prefix() |
1497 | - sources_list = string.Template(sources).substitute( |
1498 | - {"mirror": mirror_prefix}) |
1499 | - f.write(sources_list) |
1500 | + f.write(sources) |
1501 | + |
1502 | progress = apt.progress.text.AcquireProgress() |
1503 | apt_cache = apt.Cache(rootdir=rootdir, memonly=True) |
1504 | apt_cache.update(fetch_progress=progress, sources_list=srcfile) |
1505 | |
1506 | === modified file 'snapcraft/sources.py' |
1507 | --- snapcraft/sources.py 2015-09-15 05:17:14 +0000 |
1508 | +++ snapcraft/sources.py 2015-09-29 10:44:16 +0000 |
1509 | @@ -17,6 +17,7 @@ |
1510 | import logging |
1511 | import os |
1512 | import os.path |
1513 | +import shutil |
1514 | import tarfile |
1515 | import re |
1516 | |
1517 | @@ -130,13 +131,17 @@ |
1518 | else: |
1519 | return True |
1520 | |
1521 | - def provision(self, dst): |
1522 | + def provision(self, dst, clean_target=True): |
1523 | # TODO add unit tests. |
1524 | if snapcraft.common.isurl(self.source): |
1525 | tarball = os.path.join(self.source_dir, os.path.basename(self.source)) |
1526 | else: |
1527 | tarball = os.path.abspath(self.source) |
1528 | |
1529 | + if clean_target: |
1530 | + shutil.rmtree(dst) |
1531 | + os.makedirs(dst) |
1532 | + |
1533 | with tarfile.open(tarball) as tar: |
1534 | def filter_members(tar): |
1535 | """Filters members and member names: |
1536 | @@ -163,6 +168,7 @@ |
1537 | m.name = m.name[len(common + "/"):] |
1538 | # strip leading "/", "./" or "../" as many times as needed |
1539 | m.name = re.sub(r'^(\.{0,2}/)*', r'', m.name) |
1540 | + m.mode = m.mode | 0o222 |
1541 | yield m |
1542 | |
1543 | tar.extractall(members=filter_members(tar), path=dst) |
1544 | |
1545 | === modified file 'snapcraft/tests/test_base_plugin.py' |
1546 | --- snapcraft/tests/test_base_plugin.py 2015-08-28 20:26:41 +0000 |
1547 | +++ snapcraft/tests/test_base_plugin.py 2015-09-29 10:44:16 +0000 |
1548 | @@ -57,6 +57,19 @@ |
1549 | plugin.makedirs(path) |
1550 | self.assertTrue(os.path.exists(path)) |
1551 | |
1552 | + def test_get_tar_source_from_uri(self): |
1553 | + sources = [ |
1554 | + 'https://golang.tar.gz', |
1555 | + 'https://golang.tar.xz', |
1556 | + 'https://golang.tar.bz2', |
1557 | + 'https://golang.tar.tgz', |
1558 | + ] |
1559 | + |
1560 | + for source in sources: |
1561 | + with self.subTest(key=source): |
1562 | + self.assertEqual( |
1563 | + snapcraft._get_source_type_from_uri(source), 'tar') |
1564 | + |
1565 | |
1566 | class GetSourceWithBranches(tests.TestCase): |
1567 | |
1568 | |
1569 | === modified file 'snapcraft/tests/test_plugin.py' |
1570 | --- snapcraft/tests/test_plugin.py 2015-09-22 03:08:07 +0000 |
1571 | +++ snapcraft/tests/test_plugin.py 2015-09-29 10:44:16 +0000 |
1572 | @@ -16,7 +16,6 @@ |
1573 | |
1574 | import logging |
1575 | import os |
1576 | -import sys |
1577 | import tempfile |
1578 | |
1579 | import fixtures |
1580 | @@ -210,19 +209,6 @@ |
1581 | |
1582 | self.assertEqual('test stage mock-part\n', fake_logger.output) |
1583 | |
1584 | - def test_local_plugins(self): |
1585 | - """Ensure local plugins are loaded from parts/plugins""" |
1586 | - def mock_import_modules(module_name): |
1587 | - # called with the name only and sys.path set |
1588 | - self.assertEqual(module_name, "x_mock") |
1589 | - self.assertTrue(sys.path[0].endswith("parts/plugins")) |
1590 | - return mock_plugin |
1591 | - with patch("importlib.import_module", side_effect=mock_import_modules): |
1592 | - plugin.PluginHandler( |
1593 | - "x-mock", "mock-part", {}, load_config=False, load_code=True) |
1594 | - # sys.path is cleaned afterwards |
1595 | - self.assertFalse(sys.path[0].endswith("parts/plugins")) |
1596 | - |
1597 | def test_non_local_plugins(self): |
1598 | """Ensure regular plugins are loaded from snapcraft only""" |
1599 | def mock_import_modules(module_name): |
1600 | |
1601 | === modified file 'snapcraft/tests/test_repo.py' |
1602 | --- snapcraft/tests/test_repo.py 2015-09-21 15:14:29 +0000 |
1603 | +++ snapcraft/tests/test_repo.py 2015-09-29 10:44:16 +0000 |
1604 | @@ -16,6 +16,7 @@ |
1605 | |
1606 | import os |
1607 | import tempfile |
1608 | +import unittest.mock |
1609 | |
1610 | from snapcraft import repo |
1611 | from snapcraft import tests |
1612 | @@ -23,6 +24,43 @@ |
1613 | |
1614 | class UbuntuTestCase(tests.TestCase): |
1615 | |
1616 | + @unittest.mock.patch('snapcraft.repo._get_geoip_country_code_prefix') |
1617 | + def test_sources_amd64_vivid(self, mock_cc): |
1618 | + mock_cc.return_value = 'ar' |
1619 | + |
1620 | + sources_list = repo._format_sources_list( |
1621 | + repo._DEFAULT_SOURCES, 'amd64', 'vivid') |
1622 | + |
1623 | + expected_sources_list = '''deb http://ar.archive.ubuntu.com/ubuntu/ vivid main restricted |
1624 | +deb http://ar.archive.ubuntu.com/ubuntu/ vivid-updates main restricted |
1625 | +deb http://ar.archive.ubuntu.com/ubuntu/ vivid universe |
1626 | +deb http://ar.archive.ubuntu.com/ubuntu/ vivid-updates universe |
1627 | +deb http://ar.archive.ubuntu.com/ubuntu/ vivid multiverse |
1628 | +deb http://ar.archive.ubuntu.com/ubuntu/ vivid-updates multiverse |
1629 | +deb http://security.ubuntu.com/ubuntu vivid-security main restricted |
1630 | +deb http://security.ubuntu.com/ubuntu vivid-security universe |
1631 | +deb http://security.ubuntu.com/ubuntu vivid-security multiverse |
1632 | +''' |
1633 | + self.assertEqual(sources_list, expected_sources_list) |
1634 | + |
1635 | + @unittest.mock.patch('snapcraft.repo._get_geoip_country_code_prefix') |
1636 | + def test_sources_armhf_trusty(self, mock_cc): |
1637 | + sources_list = repo._format_sources_list( |
1638 | + repo._DEFAULT_SOURCES, 'armhf', 'trusty') |
1639 | + |
1640 | + expected_sources_list = '''deb http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted |
1641 | +deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates main restricted |
1642 | +deb http://ports.ubuntu.com/ubuntu-ports/ trusty universe |
1643 | +deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates universe |
1644 | +deb http://ports.ubuntu.com/ubuntu-ports/ trusty multiverse |
1645 | +deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates multiverse |
1646 | +deb http://ports.ubuntu.com/ubuntu-ports trusty-security main restricted |
1647 | +deb http://ports.ubuntu.com/ubuntu-ports trusty-security universe |
1648 | +deb http://ports.ubuntu.com/ubuntu-ports trusty-security multiverse |
1649 | +''' |
1650 | + self.assertEqual(sources_list, expected_sources_list) |
1651 | + self.assertFalse(mock_cc.called) |
1652 | + |
1653 | def test_fix_symlinks(self): |
1654 | tempdirObj = tempfile.TemporaryDirectory() |
1655 | self.addCleanup(tempdirObj.cleanup) |
1656 | |
1657 | === modified file 'snapcraft/yaml.py' |
1658 | --- snapcraft/yaml.py 2015-09-18 18:04:48 +0000 |
1659 | +++ snapcraft/yaml.py 2015-09-29 10:44:16 +0000 |
1660 | @@ -166,14 +166,46 @@ |
1661 | |
1662 | def runtime_env(self, root): |
1663 | env = [] |
1664 | - env.append('PATH="{0}/bin:{0}/usr/bin:$PATH"'.format(root)) |
1665 | - env.append('LD_LIBRARY_PATH="{0}/lib:{0}/usr/lib:{0}/lib/{1}:{0}/usr/lib/{1}:$LD_LIBRARY_PATH"'.format(root, snapcraft.common.get_arch_triplet())) |
1666 | + env.append('PATH="' + ':'.join([ |
1667 | + '{0}/bin', |
1668 | + '{0}/usr/bin', |
1669 | + '$PATH' |
1670 | + ]).format(root) + '"') |
1671 | + env.append('LD_LIBRARY_PATH="' + ':'.join([ |
1672 | + '{0}/lib', |
1673 | + '{0}/usr/lib', |
1674 | + '{0}/lib/{1}', |
1675 | + '{0}/usr/lib/{1}', |
1676 | + '$LD_LIBRARY_PATH' |
1677 | + ]).format(root, snapcraft.common.get_arch_triplet()) + '"') |
1678 | return env |
1679 | |
1680 | def build_env(self, root): |
1681 | env = [] |
1682 | - env.append('CFLAGS="-I{0}/include -I{0}/usr/include -I{0}/include/{1} -I{0}/usr/include/{1} $CFLAGS"'.format(root, snapcraft.common.get_arch_triplet())) |
1683 | - env.append('LDFLAGS="-L{0}/lib -L{0}/usr/lib -L{0}/lib/{1} -L{0}/usr/lib/{1} $LDFLAGS"'.format(root, snapcraft.common.get_arch_triplet())) |
1684 | + env.append('CFLAGS="' + ' '.join([ |
1685 | + '-I{0}/include', |
1686 | + '-I{0}/usr/include', |
1687 | + '-I{0}/include/{1}', |
1688 | + '-I{0}/usr/include/{1}', |
1689 | + '$CFLAGS' |
1690 | + ]).format(root, snapcraft.common.get_arch_triplet()) + '"') |
1691 | + env.append('LDFLAGS="' + ' '.join([ |
1692 | + '-L{0}/lib', |
1693 | + '-L{0}/usr/lib', |
1694 | + '-L{0}/lib/{1}', |
1695 | + '-L{0}/usr/lib/{1}', |
1696 | + '$LDFLAGS' |
1697 | + ]).format(root, snapcraft.common.get_arch_triplet()) + '"') |
1698 | + env.append('PKG_CONFIG_SYSROOT_DIR={0}'.format(root)) |
1699 | + env.append('PKG_CONFIG_PATH=' + ':'.join([ |
1700 | + '{0}/usr/lib/pkgconfig', |
1701 | + '{0}/usr/lib/{1}/pkgconfig', |
1702 | + '{0}/usr/share/pkgconfig', |
1703 | + '{0}/usr/local/lib/pkgconfig', |
1704 | + '{0}/usr/local/lib/{1}/pkgconfig', |
1705 | + '{0}/usr/local/share/pkgconfig', |
1706 | + '$PKG_CONFIG_PATH' |
1707 | + ]).format(root, snapcraft.common.get_arch_triplet())) |
1708 | return env |
1709 | |
1710 | def build_env_for_part(self, part): |