Merge lp:~elopio/snapcraft/fix-pep8-and-doc-indentation into lp:~snappy-dev/snapcraft/core
- fix-pep8-and-doc-indentation
- Merge into core
Status: | Merged |
---|---|
Approved by: | Leo Arias |
Approved revision: | 240 |
Merged at revision: | 232 |
Proposed branch: | lp:~elopio/snapcraft/fix-pep8-and-doc-indentation |
Merge into: | lp:~snappy-dev/snapcraft/core |
Diff against target: |
1630 lines (+401/-193) 33 files modified
docs/snapcraft-advanced-features.md (+2/-2) examples/py2-project/sha3sum.py (+0/-1) examples/py3-project/sha3sum.py (+0/-1) examples/webcam-webui/config.py (+6/-3) integration-tests/data/pypi-config/config.py (+7/-3) runtests.sh (+1/-1) setup.py (+4/-2) snapcraft/__init__.py (+24/-9) snapcraft/cmds.py (+35/-15) snapcraft/common.py (+7/-3) snapcraft/main.py (+34/-16) snapcraft/meta.py (+16/-8) snapcraft/plugin.py (+29/-13) snapcraft/plugins/ant.py (+2/-1) snapcraft/plugins/autotools.py (+2/-2) snapcraft/plugins/cmake.py (+2/-2) snapcraft/plugins/copy.py (+2/-1) snapcraft/plugins/go.py (+2/-1) snapcraft/plugins/maven.py (+2/-1) snapcraft/plugins/python2.py (+4/-2) snapcraft/plugins/python3.py (+2/-1) snapcraft/plugins/qml.py (+10/-5) snapcraft/repo.py (+8/-4) snapcraft/sources.py (+37/-17) snapcraft/tests/test_base_plugin.py (+2/-1) snapcraft/tests/test_cmds.py (+2/-1) snapcraft/tests/test_copy_plugin.py (+2/-1) snapcraft/tests/test_meta.py (+26/-13) snapcraft/tests/test_plugin.py (+4/-2) snapcraft/tests/test_repo.py (+4/-2) snapcraft/tests/test_sources.py (+45/-22) snapcraft/tests/test_yaml.py (+60/-28) snapcraft/yaml.py (+18/-9) |
To merge this branch: | bzr merge lp:~elopio/snapcraft/fix-pep8-and-doc-indentation |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Leo Arias (community) | Approve | ||
Daniel Holbach | Pending | ||
Sergio Schvezov | Pending | ||
John Lenton | Pending | ||
Review via email:
|
This proposal supersedes a proposal from 2015-10-02.
Commit message
Fix markdown indentation, make pep8 and pyflakes3 happy.
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sergio Schvezov (sergiusens) wrote : Posted in a previous version of this proposal | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Daniel Holbach (dholbach) wrote : Posted in a previous version of this proposal | # |
Done.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
John Lenton (chipaca) wrote : Posted in a previous version of this proposal | # |
LGTM :)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Snappy Tarmac (snappydevtarmac) wrote : Posted in a previous version of this proposal | # |
Attempt to merge into lp:snapcraft failed due to conflicts:
text conflict in snapcraft/cmds.py
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Snappy Tarmac (snappydevtarmac) wrote : Posted in a previous version of this proposal | # |
The attempt to merge lp:~dholbach/snapcraft/fix-pep8-and-doc-indentation into lp:snapcraft failed. Below is the output from the failed tests.
snapcraft/
snapcraft/
snapcraft/
snapcraft/
snapcraft/
snapcraft/
snapcraft/
snapcraft/
snapcraft/
snapcraft/
snapcraft/
snapcraft/
snapcraft/
snapcraft/
snapcraft/
snapcraft/
snapcraft/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Daniel Holbach (dholbach) wrote : Posted in a previous version of this proposal | # |
Could this be tarmac is using an old pep8?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Daniel Holbach (dholbach) wrote : Posted in a previous version of this proposal | # |
<dholbach> elopio, do you know which version of pep8 is running on the tarmac instance? (https:/
<elopio> dholbach: let me check.
<elopio> dholbach: 1.4.6-1.1build1
<dholbach> ah, ok, so that's trusty's pep8...
<elopio> dholbach: yes, tarmac is trusty.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Snappy Tarmac (snappydevtarmac) wrote : Posted in a previous version of this proposal | # |
The attempt to merge lp:~dholbach/snapcraft/fix-pep8-and-doc-indentation into lp:snapcraft failed. Below is the output from the failed tests.
snapcraft/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Leo Arias (elopio) wrote : | # |
Sorry for stealing your branch, but it had a small typo and we need to land this asap to avoid big conflicts. Approving again.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Snappy Tarmac (snappydevtarmac) wrote : | # |
The attempt to merge lp:~elopio/snapcraft/fix-pep8-and-doc-indentation into lp:snapcraft failed. Below is the output from the failed tests.
snapcraft/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Snappy Tarmac (snappydevtarmac) wrote : | # |
The attempt to merge lp:~elopio/snapcraft/fix-pep8-and-doc-indentation into lp:snapcraft failed. Below is the output from the failed tests.
snapcraft/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Snappy Tarmac (snappydevtarmac) wrote : | # |
The attempt to merge lp:~elopio/snapcraft/fix-pep8-and-doc-indentation into lp:snapcraft failed. Below is the output from the failed tests.
snapcraft/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Snappy Tarmac (snappydevtarmac) wrote : | # |
The attempt to merge lp:~elopio/snapcraft/fix-pep8-and-doc-indentation into lp:snapcraft failed. Below is the output from the failed tests.
snapcraft/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Snappy Tarmac (snappydevtarmac) wrote : | # |
The attempt to merge lp:~elopio/snapcraft/fix-pep8-and-doc-indentation into lp:snapcraft failed. Below is the output from the failed tests.
name: # the name of the snap
version: # the version of the snap
# The vendor for the snap (replace 'Vendor <email address hidden>')
vendor: Vendor <email address hidden>
summary: # 79 char long summary
description: # A longer description for the snap
icon: # A path to an icon for the package
cp --preserve=all -R zzz /tmp/tmpu9u848i
cp --preserve=all -R src /tmp/tmp79huuwc
cp --preserve=all -R src /tmp/tmps1vpx7b
.......
.......
=======
FAIL: test_init_
-------
Traceback (most recent call last):
File "/tmp/tarmac/
self.
AssertionError: "can't specify both source-tag and source-branch for a mercurial source" != "can't specify both source-tag and source-branch "
- can't specify both source-tag and source-branch for a mercurial source
? -------
+ can't specify both source-tag and source-branch
=======
FAIL: test_invalid_names (snapcraft.
-------
Traceback (most recent call last):
File "/tmp/tarmac/
msg=data)
AssertionError: "'package@awesome' does not match '^[a-z0-
- 'package@awesome' does not match '^[a-z0-
+ '{}' does not match
: {'description': 'description which can be pretty long', 'version': '1.0-snapcraft1
=======
FAIL: test_invalid_names (snapcraft.
-------
Traceback (most recent call last):
File "/tmp/tarmac/
msg=data)
AssertionError: "'something.
- 'something.another' does not match '^[a-z0-
+ '{}' does not match
: {'description': 'description which can be pretty long', 'version': '1.0-snapcraft1
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Snappy Tarmac (snappydevtarmac) wrote : | # |
There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Leo Arias (elopio) wrote : | # |
oh come on!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Leo Arias (elopio) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Snappy Tarmac (snappydevtarmac) wrote : | # |
The attempt to merge lp:~elopio/snapcraft/fix-pep8-and-doc-indentation into lp:snapcraft failed. Below is the output from the failed tests.
snapcraft/
snapcraft/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Snappy Tarmac (snappydevtarmac) wrote : | # |
There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Leo Arias (elopio) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Leo Arias (elopio) wrote : | # |
spam spam spam spam.
Preview Diff
1 | === modified file 'docs/snapcraft-advanced-features.md' | |||
2 | --- docs/snapcraft-advanced-features.md 2015-10-01 08:54:15 +0000 | |||
3 | +++ docs/snapcraft-advanced-features.md 2015-10-05 19:37:43 +0000 | |||
4 | @@ -74,11 +74,11 @@ | |||
5 | 74 | assemble and build the snap: | 74 | assemble and build the snap: |
6 | 75 | 75 | ||
7 | 76 | parts: | 76 | parts: |
9 | 77 | spongeshaker: | 77 | spongeshaker: |
10 | 78 | plugin: python2 | 78 | plugin: python2 |
11 | 79 | source: git://github.com/markokr/spongeshaker.git | 79 | source: git://github.com/markokr/spongeshaker.git |
12 | 80 | make-project: | 80 | make-project: |
14 | 81 | plugin: make | 81 | plugin: make |
15 | 82 | source: . | 82 | source: . |
16 | 83 | 83 | ||
17 | 84 | The example above mixes and matches parts of different origin. Locally it | 84 | The example above mixes and matches parts of different origin. Locally it |
18 | 85 | 85 | ||
19 | === modified file 'examples/py2-project/sha3sum.py' | |||
20 | --- examples/py2-project/sha3sum.py 2015-07-17 14:44:45 +0000 | |||
21 | +++ examples/py2-project/sha3sum.py 2015-10-05 19:37:43 +0000 | |||
22 | @@ -12,4 +12,3 @@ | |||
23 | 12 | data = fp.read() | 12 | data = fp.read() |
24 | 13 | h.update(data) | 13 | h.update(data) |
25 | 14 | print(h.hexdigest()) | 14 | print(h.hexdigest()) |
26 | 15 | |||
27 | 16 | 15 | ||
28 | === modified file 'examples/py3-project/sha3sum.py' | |||
29 | --- examples/py3-project/sha3sum.py 2015-07-15 09:55:27 +0000 | |||
30 | +++ examples/py3-project/sha3sum.py 2015-10-05 19:37:43 +0000 | |||
31 | @@ -12,4 +12,3 @@ | |||
32 | 12 | data = fp.read() | 12 | data = fp.read() |
33 | 13 | h.update(data) | 13 | h.update(data) |
34 | 14 | print(h.hexdigest()) | 14 | print(h.hexdigest()) |
35 | 15 | |||
36 | 16 | 15 | ||
37 | === modified file 'examples/webcam-webui/config.py' | |||
38 | --- examples/webcam-webui/config.py 2015-09-15 20:53:36 +0000 | |||
39 | +++ examples/webcam-webui/config.py 2015-10-05 19:37:43 +0000 | |||
40 | @@ -17,7 +17,8 @@ | |||
41 | 17 | if config_yaml: | 17 | if config_yaml: |
42 | 18 | set_config(config_file, config_yaml) | 18 | set_config(config_file, config_yaml) |
43 | 19 | 19 | ||
45 | 20 | yaml.dump(get_config(config_file), stream=sys.stdout, default_flow_style=False) | 20 | yaml.dump(get_config(config_file), stream=sys.stdout, |
46 | 21 | default_flow_style=False) | ||
47 | 21 | 22 | ||
48 | 22 | 23 | ||
49 | 23 | def set_config(config_file, config_yaml={}): | 24 | def set_config(config_file, config_yaml={}): |
50 | @@ -37,9 +38,11 @@ | |||
51 | 37 | 38 | ||
52 | 38 | def _config(config_yaml={}): | 39 | def _config(config_yaml={}): |
53 | 39 | try: | 40 | try: |
55 | 40 | interval_value = config_yaml['config'][os.environ['SNAP_NAME']]['interval'] | 41 | interval_value = config_yaml['config'][ |
56 | 42 | os.environ['SNAP_NAME']]['interval'] | ||
57 | 41 | if not isinstance(interval_value, int): | 43 | if not isinstance(interval_value, int): |
59 | 42 | config_yaml['config'][os.environ['SNAP_NAME']]['interval'] = _DEFAULT_INTERVAL | 44 | config_yaml['config'][ |
60 | 45 | os.environ['SNAP_NAME']]['interval'] = _DEFAULT_INTERVAL | ||
61 | 43 | except KeyError: | 46 | except KeyError: |
62 | 44 | interval = { | 47 | interval = { |
63 | 45 | 'config': { | 48 | 'config': { |
64 | 46 | 49 | ||
65 | === modified file 'integration-tests/data/pypi-config/config.py' | |||
66 | --- integration-tests/data/pypi-config/config.py 2015-09-17 19:05:20 +0000 | |||
67 | +++ integration-tests/data/pypi-config/config.py 2015-10-05 19:37:43 +0000 | |||
68 | @@ -17,7 +17,9 @@ | |||
69 | 17 | if config_yaml: | 17 | if config_yaml: |
70 | 18 | set_config(config_file, config_yaml) | 18 | set_config(config_file, config_yaml) |
71 | 19 | 19 | ||
73 | 20 | yaml.dump(get_config(config_file), stream=sys.stdout, default_flow_style=False) | 20 | yaml.dump(get_config(config_file), |
74 | 21 | stream=sys.stdout, | ||
75 | 22 | default_flow_style=False) | ||
76 | 21 | 23 | ||
77 | 22 | 24 | ||
78 | 23 | def set_config(config_file, config_yaml={}): | 25 | def set_config(config_file, config_yaml={}): |
79 | @@ -37,9 +39,11 @@ | |||
80 | 37 | 39 | ||
81 | 38 | def _config(config_yaml={}): | 40 | def _config(config_yaml={}): |
82 | 39 | try: | 41 | try: |
84 | 40 | interval_value = config_yaml['config'][os.environ['SNAP_NAME']]['interval'] | 42 | interval_value = config_yaml['config'][ |
85 | 43 | os.environ['SNAP_NAME']]['interval'] | ||
86 | 41 | if not isinstance(interval_value, int): | 44 | if not isinstance(interval_value, int): |
88 | 42 | config_yaml['config'][os.environ['SNAP_NAME']]['interval'] = _DEFAULT_INTERVAL | 45 | config_yaml['config'][ |
89 | 46 | os.environ['SNAP_NAME']]['interval'] = _DEFAULT_INTERVAL | ||
90 | 43 | except KeyError: | 47 | except KeyError: |
91 | 44 | interval = { | 48 | interval = { |
92 | 45 | 'config': { | 49 | 'config': { |
93 | 46 | 50 | ||
94 | === modified file 'runtests.sh' | |||
95 | --- runtests.sh 2015-10-02 02:24:13 +0000 | |||
96 | +++ runtests.sh 2015-10-05 19:37:43 +0000 | |||
97 | @@ -48,7 +48,7 @@ | |||
98 | 48 | # These three checks could easily be done with flake8 in one shot if | 48 | # These three checks could easily be done with flake8 in one shot if |
99 | 49 | # we had python3-flake8 provide flake8 | 49 | # we had python3-flake8 provide flake8 |
100 | 50 | # Ignore 501 (line-too-long) | 50 | # Ignore 501 (line-too-long) |
102 | 51 | pep8 $SRC_PATHS --ignore=E501 | 51 | pep8 $SRC_PATHS |
103 | 52 | 52 | ||
104 | 53 | pyflakes3 $SRC_PATHS | 53 | pyflakes3 $SRC_PATHS |
105 | 54 | 54 | ||
106 | 55 | 55 | ||
107 | === modified file 'setup.py' | |||
108 | --- setup.py 2015-09-02 15:10:58 +0000 | |||
109 | +++ setup.py 2015-10-05 19:37:43 +0000 | |||
110 | @@ -37,8 +37,10 @@ | |||
111 | 37 | package_data={'snapcraft': ['manifest.txt']}, | 37 | package_data={'snapcraft': ['manifest.txt']}, |
112 | 38 | scripts=['bin/snapcraft'], | 38 | scripts=['bin/snapcraft'], |
113 | 39 | data_files=[ | 39 | data_files=[ |
116 | 40 | ('share/snapcraft/plugins', ['plugins/' + x for x in os.listdir('plugins')]), | 40 | ('share/snapcraft/plugins', |
117 | 41 | ('share/snapcraft/schema', ['schema/' + x for x in os.listdir('schema')]), | 41 | ['plugins/' + x for x in os.listdir('plugins')]), |
118 | 42 | ('share/snapcraft/schema', | ||
119 | 43 | ['schema/' + x for x in os.listdir('schema')]), | ||
120 | 42 | ], | 44 | ], |
121 | 43 | cmdclass={'test': TestCommand}, | 45 | cmdclass={'test': TestCommand}, |
122 | 44 | ) | 46 | ) |
123 | 45 | 47 | ||
124 | === modified file 'snapcraft/__init__.py' | |||
125 | --- snapcraft/__init__.py 2015-09-29 08:37:47 +0000 | |||
126 | +++ snapcraft/__init__.py 2015-10-05 19:37:43 +0000 | |||
127 | @@ -42,8 +42,10 @@ | |||
128 | 42 | self.partdir = os.path.join(os.getcwd(), "parts", self.name) | 42 | self.partdir = os.path.join(os.getcwd(), "parts", self.name) |
129 | 43 | self.sourcedir = os.path.join(os.getcwd(), "parts", self.name, "src") | 43 | self.sourcedir = os.path.join(os.getcwd(), "parts", self.name, "src") |
130 | 44 | self.builddir = os.path.join(os.getcwd(), "parts", self.name, "build") | 44 | self.builddir = os.path.join(os.getcwd(), "parts", self.name, "build") |
133 | 45 | self.ubuntudir = os.path.join(os.getcwd(), "parts", self.name, 'ubuntu') | 45 | self.ubuntudir = os.path.join(os.getcwd(), "parts", self.name, |
134 | 46 | self.installdir = os.path.join(os.getcwd(), "parts", self.name, "install") | 46 | 'ubuntu') |
135 | 47 | self.installdir = os.path.join(os.getcwd(), "parts", self.name, | ||
136 | 48 | "install") | ||
137 | 47 | self.stagedir = os.path.join(os.getcwd(), "stage") | 49 | self.stagedir = os.path.join(os.getcwd(), "stage") |
138 | 48 | self.snapdir = os.path.join(os.getcwd(), "snap") | 50 | self.snapdir = os.path.join(os.getcwd(), "snap") |
139 | 49 | 51 | ||
140 | @@ -84,17 +86,23 @@ | |||
141 | 84 | def isurl(self, url): | 86 | def isurl(self, url): |
142 | 85 | return snapcraft.common.isurl(url) | 87 | return snapcraft.common.isurl(url) |
143 | 86 | 88 | ||
145 | 87 | def get_source(self, source, source_type=None, source_tag=None, source_branch=None): | 89 | def get_source(self, source, source_type=None, source_tag=None, |
146 | 90 | source_branch=None): | ||
147 | 88 | try: | 91 | try: |
148 | 89 | handler_class = _get_source_handler(source_type, source) | 92 | handler_class = _get_source_handler(source_type, source) |
149 | 90 | except ValueError: | 93 | except ValueError: |
151 | 91 | logger.error("Unrecognized source '%s' for part '%s'.", source, self.name) | 94 | logger.error("Unrecognized source '%s' for part '%s'.", source, |
152 | 95 | self.name) | ||
153 | 92 | snapcraft.common.fatal() | 96 | snapcraft.common.fatal() |
154 | 93 | 97 | ||
155 | 94 | try: | 98 | try: |
157 | 95 | handler = handler_class(source, self.sourcedir, source_tag, source_branch) | 99 | handler = handler_class(source, self.sourcedir, source_tag, |
158 | 100 | source_branch) | ||
159 | 96 | except snapcraft.sources.IncompatibleOptionsError as e: | 101 | except snapcraft.sources.IncompatibleOptionsError as e: |
161 | 97 | logger.error('Issues while setting up sources for part \'%s\': %s.', self.name, e.message) | 102 | logger.error( |
162 | 103 | 'Issues while setting up sources for part \'%s\': %s.', | ||
163 | 104 | self.name, | ||
164 | 105 | e.message) | ||
165 | 98 | snapcraft.common.fatal() | 106 | snapcraft.common.fatal() |
166 | 99 | if not handler.pull(): | 107 | if not handler.pull(): |
167 | 100 | return False | 108 | return False |
168 | @@ -115,16 +123,23 @@ | |||
169 | 115 | def setup_stage_packages(self): | 123 | def setup_stage_packages(self): |
170 | 116 | part_stage_packages = getattr(self.options, 'stage_packages', []) or [] | 124 | part_stage_packages = getattr(self.options, 'stage_packages', []) or [] |
171 | 117 | if self.PLUGIN_STAGE_PACKAGES or part_stage_packages: | 125 | if self.PLUGIN_STAGE_PACKAGES or part_stage_packages: |
173 | 118 | ubuntu = snapcraft.repo.Ubuntu(self.ubuntudir, sources=self.PLUGIN_STAGE_SOURCES) | 126 | ubuntu = snapcraft.repo.Ubuntu(self.ubuntudir, |
174 | 127 | sources=self.PLUGIN_STAGE_SOURCES) | ||
175 | 119 | ubuntu.get(self.PLUGIN_STAGE_PACKAGES + part_stage_packages) | 128 | ubuntu.get(self.PLUGIN_STAGE_PACKAGES + part_stage_packages) |
176 | 120 | ubuntu.unpack(self.installdir) | 129 | ubuntu.unpack(self.installdir) |
177 | 121 | self._fixup(self.installdir) | 130 | self._fixup(self.installdir) |
178 | 122 | 131 | ||
179 | 123 | def _fixup(self, root): | 132 | def _fixup(self, root): |
180 | 124 | if os.path.isfile(os.path.join(root, 'usr', 'bin', 'xml2-config')): | 133 | if os.path.isfile(os.path.join(root, 'usr', 'bin', 'xml2-config')): |
182 | 125 | self.run(['sed', '-i', '-e', 's|prefix=/usr|prefix={}/usr|'.format(root), os.path.join(root, 'usr', 'bin', 'xml2-config')]) | 134 | self.run( |
183 | 135 | ['sed', '-i', '-e', 's|prefix=/usr|prefix={}/usr|'. | ||
184 | 136 | format(root), | ||
185 | 137 | os.path.join(root, 'usr', 'bin', 'xml2-config')]) | ||
186 | 126 | if os.path.isfile(os.path.join(root, 'usr', 'bin', 'xslt-config')): | 138 | if os.path.isfile(os.path.join(root, 'usr', 'bin', 'xslt-config')): |
188 | 127 | self.run(['sed', '-i', '-e', 's|prefix=/usr|prefix={}/usr|'.format(root), os.path.join(root, 'usr', 'bin', 'xslt-config')]) | 139 | self.run( |
189 | 140 | ['sed', '-i', '-e', 's|prefix=/usr|prefix={}/usr|'. | ||
190 | 141 | format(root), | ||
191 | 142 | os.path.join(root, 'usr', 'bin', 'xslt-config')]) | ||
192 | 128 | 143 | ||
193 | 129 | 144 | ||
194 | 130 | def _get_source_handler(source_type, source): | 145 | def _get_source_handler(source_type, source): |
195 | 131 | 146 | ||
196 | === modified file 'snapcraft/cmds.py' | |||
197 | --- snapcraft/cmds.py 2015-10-04 20:03:23 +0000 | |||
198 | +++ snapcraft/cmds.py 2015-10-05 19:37:43 +0000 | |||
199 | @@ -54,7 +54,8 @@ | |||
200 | 54 | if args.part: | 54 | if args.part: |
201 | 55 | yaml += 'parts:\n' | 55 | yaml += 'parts:\n' |
202 | 56 | for part_name in args.part: | 56 | for part_name in args.part: |
204 | 57 | part = snapcraft.plugin.load_plugin(part_name, part_name, load_code=False) | 57 | part = snapcraft.plugin.load_plugin(part_name, part_name, |
205 | 58 | load_code=False) | ||
206 | 58 | yaml += ' ' + part.names()[0] + ':\n' | 59 | yaml += ' ' + part.names()[0] + ':\n' |
207 | 59 | for opt in part.config.get('options', []): | 60 | for opt in part.config.get('options', []): |
208 | 60 | if part.config['options'][opt].get('required', False): | 61 | if part.config['options'][opt].get('required', False): |
209 | @@ -73,7 +74,10 @@ | |||
210 | 73 | common.env = config.stage_env() | 74 | common.env = config.stage_env() |
211 | 74 | userCommand = args.userCommand | 75 | userCommand = args.userCommand |
212 | 75 | if not userCommand: | 76 | if not userCommand: |
214 | 76 | userCommand = ['/usr/bin/env', 'PS1=\[\e[1;32m\]snapcraft:\w\$\[\e[0m\] ', '/bin/bash', '--norc'] | 77 | userCommand = ['/usr/bin/env', |
215 | 78 | 'PS1=\[\e[1;32m\]snapcraft:\w\$\[\e[0m\] ', | ||
216 | 79 | '/bin/bash', | ||
217 | 80 | '--norc'] | ||
218 | 77 | common.run(userCommand) | 81 | common.run(userCommand) |
219 | 78 | 82 | ||
220 | 79 | 83 | ||
221 | @@ -168,7 +172,8 @@ | |||
222 | 168 | qemu_img = os.path.join(qemudir, "15.04.img") | 172 | qemu_img = os.path.join(qemudir, "15.04.img") |
223 | 169 | if not os.path.exists(qemu_img): | 173 | if not os.path.exists(qemu_img): |
224 | 170 | os.makedirs(qemudir, exist_ok=True) | 174 | os.makedirs(qemudir, exist_ok=True) |
226 | 171 | logger.info('Setting up virtual snappy environment, root access required') | 175 | logger.info( |
227 | 176 | 'Setting up virtual snappy environment, root access required') | ||
228 | 172 | common.run([ | 177 | common.run([ |
229 | 173 | 'sudo', 'ubuntu-device-flash', 'core', '15.04', '--developer-mode', | 178 | 'sudo', 'ubuntu-device-flash', 'core', '15.04', '--developer-mode', |
230 | 174 | '--enable-ssh', '-o', os.path.relpath(qemu_img, qemudir)], | 179 | '--enable-ssh', '-o', os.path.relpath(qemu_img, qemudir)], |
231 | @@ -181,7 +186,8 @@ | |||
232 | 181 | # the snapcraft run workflow. | 186 | # the snapcraft run workflow. |
233 | 182 | # | 187 | # |
234 | 183 | # For example: | 188 | # For example: |
236 | 184 | # $ export SNAPCRAFT_RUN_QEMU_ARGS="-usb -device usb-host,hostbus=1,hostaddr=10" | 189 | # $ export SNAPCRAFT_RUN_QEMU_ARGS=\ |
237 | 190 | # "-usb -device usb-host,hostbus=1,hostaddr=10" | ||
238 | 185 | # $ snapcraft run | 191 | # $ snapcraft run |
239 | 186 | qemu_args = os.getenv("SNAPCRAFT_RUN_QEMU_ARGS") | 192 | qemu_args = os.getenv("SNAPCRAFT_RUN_QEMU_ARGS") |
240 | 187 | if qemu_args is not None: | 193 | if qemu_args is not None: |
241 | @@ -258,7 +264,9 @@ | |||
242 | 258 | for part in parts: | 264 | for part in parts: |
243 | 259 | # Gather our own files up | 265 | # Gather our own files up |
244 | 260 | fileset = getattr(part.code.options, 'stage', ['*']) or ['*'] | 266 | fileset = getattr(part.code.options, 'stage', ['*']) or ['*'] |
246 | 261 | part_files, _ = snapcraft.plugin.migratable_filesets(fileset, part.installdir) | 267 | part_files, _ = snapcraft.plugin.migratable_filesets( |
247 | 268 | fileset, | ||
248 | 269 | part.installdir) | ||
249 | 262 | 270 | ||
250 | 263 | # Scan previous parts for collisions | 271 | # Scan previous parts for collisions |
251 | 264 | for other_part_name in parts_files: | 272 | for other_part_name in parts_files: |
252 | @@ -266,19 +274,27 @@ | |||
253 | 266 | conflict_files = [] | 274 | conflict_files = [] |
254 | 267 | for f in common: | 275 | for f in common: |
255 | 268 | this = os.path.join(part.installdir, f) | 276 | this = os.path.join(part.installdir, f) |
257 | 269 | other = os.path.join(parts_files[other_part_name]['installdir'], f) | 277 | other = os.path.join( |
258 | 278 | parts_files[other_part_name]['installdir'], | ||
259 | 279 | f) | ||
260 | 270 | if os.path.islink(this) and os.path.islink(other): | 280 | if os.path.islink(this) and os.path.islink(other): |
261 | 271 | continue | 281 | continue |
262 | 272 | if not filecmp.cmp(this, other, shallow=False): | 282 | if not filecmp.cmp(this, other, shallow=False): |
263 | 273 | conflict_files.append(f) | 283 | conflict_files.append(f) |
264 | 274 | 284 | ||
265 | 275 | if conflict_files: | 285 | if conflict_files: |
267 | 276 | logger.error('Error: parts %s and %s have the following file paths in common which have different contents:\n %s', other_part_name, part.names()[0], '\n '.join(sorted(conflict_files))) | 286 | logger.error('Error: parts %s and %s have the following file ' |
268 | 287 | 'paths in common which have different ' | ||
269 | 288 | 'contents:\n %s', | ||
270 | 289 | other_part_name, | ||
271 | 290 | part.names()[0], | ||
272 | 291 | '\n '.join(sorted(conflict_files))) | ||
273 | 277 | 292 | ||
274 | 278 | return False | 293 | return False |
275 | 279 | 294 | ||
276 | 280 | # And add our files to the list | 295 | # And add our files to the list |
278 | 281 | parts_files[part.names()[0]] = {'files': part_files, 'installdir': part.installdir} | 296 | parts_files[part.names()[0]] = {'files': part_files, |
279 | 297 | 'installdir': part.installdir} | ||
280 | 282 | 298 | ||
281 | 283 | return True | 299 | return True |
282 | 284 | 300 | ||
283 | @@ -305,9 +321,9 @@ | |||
284 | 305 | # This ends up running multiple times, as each part gets to its | 321 | # This ends up running multiple times, as each part gets to its |
285 | 306 | # staging cmd. That's inefficient, but largely OK. | 322 | # staging cmd. That's inefficient, but largely OK. |
286 | 307 | # FIXME: fix the above by iterating over cmds before iterating | 323 | # FIXME: fix the above by iterating over cmds before iterating |
290 | 308 | # all_parts. But then we need to make sure we continue to handle | 324 | # all_parts. But then we need to make sure we continue to |
291 | 309 | # cases like go, where you want go built before trying to pull | 325 | # handle cases like go, where you want go built before trying |
292 | 310 | # a go project. | 326 | # to pull a go project. |
293 | 311 | if not _check_for_collisions(config.all_parts): | 327 | if not _check_for_collisions(config.all_parts): |
294 | 312 | sys.exit(1) | 328 | sys.exit(1) |
295 | 313 | 329 | ||
296 | @@ -337,7 +353,9 @@ | |||
297 | 337 | def _install_build_packages(packages): | 353 | def _install_build_packages(packages): |
298 | 338 | new_packages = [] | 354 | new_packages = [] |
299 | 339 | for check_pkg in packages: | 355 | for check_pkg in packages: |
301 | 340 | if subprocess.call(['dpkg-query', '-s', check_pkg], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) != 0: | 356 | if subprocess.call(['dpkg-query', '-s', check_pkg], |
302 | 357 | stdout=subprocess.DEVNULL, | ||
303 | 358 | stderr=subprocess.DEVNULL) != 0: | ||
304 | 341 | new_packages.append(check_pkg) | 359 | new_packages.append(check_pkg) |
305 | 342 | if new_packages: | 360 | if new_packages: |
306 | 343 | logger.info('Installing required packages on the host system') | 361 | logger.info('Installing required packages on the host system') |
307 | @@ -361,8 +379,9 @@ | |||
308 | 361 | return _config | 379 | return _config |
309 | 362 | except snapcraft.yaml.SnapcraftYamlFileError as e: | 380 | except snapcraft.yaml.SnapcraftYamlFileError as e: |
310 | 363 | logger.error( | 381 | logger.error( |
313 | 364 | 'Could not find {}. Are you sure you are in the right directory?\n' | 382 | 'Could not find {}. Are you sure you are in the right ' |
314 | 365 | 'To start a new project, use \'snapcraft init\''.format(e.file)) | 383 | 'directory?\nTo start a new project, use \'snapcraft ' |
315 | 384 | 'init\''.format(e.file)) | ||
316 | 366 | sys.exit(1) | 385 | sys.exit(1) |
317 | 367 | except snapcraft.yaml.SnapcraftSchemaError as e: | 386 | except snapcraft.yaml.SnapcraftSchemaError as e: |
318 | 368 | msg = "Issues while validating snapcraft.yaml: {}".format(e.message) | 387 | msg = "Issues while validating snapcraft.yaml: {}".format(e.message) |
319 | @@ -374,5 +393,6 @@ | |||
320 | 374 | 'missing for the "{}" part.'.format(e.part)) | 393 | 'missing for the "{}" part.'.format(e.part)) |
321 | 375 | sys.exit(1) | 394 | sys.exit(1) |
322 | 376 | except snapcraft.yaml.SnapcraftLogicError as e: | 395 | except snapcraft.yaml.SnapcraftLogicError as e: |
324 | 377 | logger.error('Issue detected while analyzing snapcraft.yaml: {}'.format(e.message)) | 396 | logger.error('Issue detected while analyzing ' |
325 | 397 | 'snapcraft.yaml: {}'.format(e.message)) | ||
326 | 378 | sys.exit(1) | 398 | sys.exit(1) |
327 | 379 | 399 | ||
328 | === modified file 'snapcraft/common.py' | |||
329 | --- snapcraft/common.py 2015-09-18 21:23:40 +0000 | |||
330 | +++ snapcraft/common.py 2015-10-05 19:37:43 +0000 | |||
331 | @@ -57,7 +57,8 @@ | |||
332 | 57 | f.write('\n') | 57 | f.write('\n') |
333 | 58 | f.write('exec $*') | 58 | f.write('exec $*') |
334 | 59 | f.flush() | 59 | f.flush() |
336 | 60 | return subprocess.check_output(['/bin/sh', f.name] + cmd, **kwargs).decode('utf8').strip() | 60 | return subprocess.check_output(['/bin/sh', f.name] + cmd, |
337 | 61 | **kwargs).decode('utf8').strip() | ||
338 | 61 | 62 | ||
339 | 62 | 63 | ||
340 | 63 | def fatal(): | 64 | def fatal(): |
341 | @@ -67,14 +68,17 @@ | |||
342 | 67 | def get_arch(): | 68 | def get_arch(): |
343 | 68 | global _arch | 69 | global _arch |
344 | 69 | if _arch is None: | 70 | if _arch is None: |
346 | 70 | _arch = subprocess.check_output(['dpkg-architecture', '-qDEB_BUILD_ARCH']).decode('utf8').strip() | 71 | _arch = subprocess.check_output( |
347 | 72 | ['dpkg-architecture', '-qDEB_BUILD_ARCH']).decode('utf8').strip() | ||
348 | 71 | return _arch | 73 | return _arch |
349 | 72 | 74 | ||
350 | 73 | 75 | ||
351 | 74 | def get_arch_triplet(): | 76 | def get_arch_triplet(): |
352 | 75 | global _arch_triplet | 77 | global _arch_triplet |
353 | 76 | if _arch_triplet is None: | 78 | if _arch_triplet is None: |
355 | 77 | _arch_triplet = subprocess.check_output(['dpkg-architecture', '-qDEB_BUILD_MULTIARCH']).decode('utf8').strip() | 79 | _arch_triplet = subprocess.check_output( |
356 | 80 | ['dpkg-architecture', '-qDEB_BUILD_MULTIARCH'] | ||
357 | 81 | ).decode('utf8').strip() | ||
358 | 78 | return _arch_triplet | 82 | return _arch_triplet |
359 | 79 | 83 | ||
360 | 80 | 84 | ||
361 | 81 | 85 | ||
362 | === modified file 'snapcraft/main.py' | |||
363 | --- snapcraft/main.py 2015-09-17 14:14:14 +0000 | |||
364 | +++ snapcraft/main.py 2015-10-05 19:37:43 +0000 | |||
365 | @@ -30,9 +30,11 @@ | |||
366 | 30 | # Parent parsers | 30 | # Parent parsers |
367 | 31 | 31 | ||
368 | 32 | force_parser = argparse.ArgumentParser(add_help=False) | 32 | force_parser = argparse.ArgumentParser(add_help=False) |
370 | 33 | force_parser.add_argument('--force', action='store_true', help='redo all steps for all parts') | 33 | force_parser.add_argument('--force', action='store_true', |
371 | 34 | help='redo all steps for all parts') | ||
372 | 34 | 35 | ||
374 | 35 | cmd_parser = argparse.ArgumentParser(add_help=False, parents=[force_parser]) | 36 | cmd_parser = argparse.ArgumentParser(add_help=False, |
375 | 37 | parents=[force_parser]) | ||
376 | 36 | cmd_parser.add_argument('part', nargs='*') | 38 | cmd_parser.add_argument('part', nargs='*') |
377 | 37 | 39 | ||
378 | 38 | # Command parsers | 40 | # Command parsers |
379 | @@ -42,28 +44,44 @@ | |||
380 | 42 | parser.set_defaults(func=snapcraft.cmds.init) | 44 | parser.set_defaults(func=snapcraft.cmds.init) |
381 | 43 | 45 | ||
382 | 44 | parser = subparsers.add_parser('shell', help='enter staging environment') | 46 | parser = subparsers.add_parser('shell', help='enter staging environment') |
384 | 45 | parser.add_argument('userCommand', nargs=argparse.REMAINDER, metavar='cmd', help='optional command to run inside staging environment') | 47 | parser.add_argument( |
385 | 48 | 'userCommand', nargs=argparse.REMAINDER, | ||
386 | 49 | metavar='cmd', | ||
387 | 50 | help='optional command to run inside staging environment') | ||
388 | 46 | parser.set_defaults(func=snapcraft.cmds.shell) | 51 | parser.set_defaults(func=snapcraft.cmds.shell) |
389 | 47 | 52 | ||
391 | 48 | parser = subparsers.add_parser('run', help='run snap in kvm', add_help=False) | 53 | parser = subparsers.add_parser('run', help='run snap in kvm', |
392 | 54 | add_help=False) | ||
393 | 49 | parser.set_defaults(func=snapcraft.cmds.run) | 55 | parser.set_defaults(func=snapcraft.cmds.run) |
394 | 50 | 56 | ||
396 | 51 | parser = subparsers.add_parser('clean', help='clean up the environment (to start from scratch)') | 57 | parser = subparsers.add_parser( |
397 | 58 | 'clean', | ||
398 | 59 | help='clean up the environment (to start from scratch)') | ||
399 | 52 | parser.set_defaults(func=snapcraft.cmds.clean) | 60 | parser.set_defaults(func=snapcraft.cmds.clean) |
400 | 53 | 61 | ||
411 | 54 | parser = subparsers.add_parser('pull', help='get sources', parents=[cmd_parser]) | 62 | parser = subparsers.add_parser('pull', help='get sources', |
412 | 55 | parser.set_defaults(func=snapcraft.cmds.cmd) | 63 | parents=[cmd_parser]) |
413 | 56 | 64 | parser.set_defaults(func=snapcraft.cmds.cmd) | |
414 | 57 | parser = subparsers.add_parser('build', help='build parts', parents=[cmd_parser]) | 65 | |
415 | 58 | parser.set_defaults(func=snapcraft.cmds.cmd) | 66 | parser = subparsers.add_parser('build', help='build parts', |
416 | 59 | 67 | parents=[cmd_parser]) | |
417 | 60 | parser = subparsers.add_parser('stage', help='put parts into staging area', parents=[cmd_parser]) | 68 | parser.set_defaults(func=snapcraft.cmds.cmd) |
418 | 61 | parser.set_defaults(func=snapcraft.cmds.cmd) | 69 | |
419 | 62 | 70 | parser = subparsers.add_parser( | |
420 | 63 | parser = subparsers.add_parser('snap', help='put parts into snap area', parents=[cmd_parser]) | 71 | 'stage', |
421 | 72 | help='put parts into staging area', parents=[cmd_parser]) | ||
422 | 73 | parser.set_defaults(func=snapcraft.cmds.cmd) | ||
423 | 74 | |||
424 | 75 | parser = subparsers.add_parser( | ||
425 | 76 | 'snap', | ||
426 | 77 | help='put parts into snap area', | ||
427 | 78 | parents=[cmd_parser]) | ||
428 | 64 | parser.set_defaults(func=snapcraft.cmds.snap) | 79 | parser.set_defaults(func=snapcraft.cmds.snap) |
429 | 65 | 80 | ||
431 | 66 | parser = subparsers.add_parser('assemble', help='make snap package', parents=[force_parser], aliases=['all']) | 81 | parser = subparsers.add_parser( |
432 | 82 | 'assemble', | ||
433 | 83 | help='make snap package', parents=[force_parser], | ||
434 | 84 | aliases=['all']) | ||
435 | 67 | parser.set_defaults(func=snapcraft.cmds.assemble) | 85 | parser.set_defaults(func=snapcraft.cmds.assemble) |
436 | 68 | 86 | ||
437 | 69 | # Now run parser | 87 | # Now run parser |
438 | 70 | 88 | ||
439 | === modified file 'snapcraft/meta.py' | |||
440 | --- snapcraft/meta.py 2015-09-30 09:19:00 +0000 | |||
441 | +++ snapcraft/meta.py 2015-10-05 19:37:43 +0000 | |||
442 | @@ -91,7 +91,8 @@ | |||
443 | 91 | args = execparts[1:] if len(execparts) > 1 else [] | 91 | args = execparts[1:] if len(execparts) > 1 else [] |
444 | 92 | 92 | ||
445 | 93 | config_hook_path = os.path.join(hooks_dir, 'config') | 93 | config_hook_path = os.path.join(hooks_dir, 'config') |
447 | 94 | _write_wrap_exe(execparts[0], config_hook_path, args=args, cwd='$SNAP_APP_PATH') | 94 | _write_wrap_exe(execparts[0], config_hook_path, args=args, |
448 | 95 | cwd='$SNAP_APP_PATH') | ||
449 | 95 | 96 | ||
450 | 96 | 97 | ||
451 | 97 | def _copy(meta_dir, relpath, new_relpath=None): | 98 | def _copy(meta_dir, relpath, new_relpath=None): |
452 | @@ -110,8 +111,10 @@ | |||
453 | 110 | for runnable in runnables: | 111 | for runnable in runnables: |
454 | 111 | for entry in ('security-policy', 'security-override'): | 112 | for entry in ('security-policy', 'security-override'): |
455 | 112 | if entry in runnable: | 113 | if entry in runnable: |
458 | 113 | runnable[entry]['apparmor'] = _copy(meta_dir, runnable[entry]['apparmor']) | 114 | runnable[entry]['apparmor'] = \ |
459 | 114 | runnable[entry]['seccomp'] = _copy(meta_dir, runnable[entry]['seccomp']) | 115 | _copy(meta_dir, runnable[entry]['apparmor']) |
460 | 116 | runnable[entry]['seccomp'] = \ | ||
461 | 117 | _copy(meta_dir, runnable[entry]['seccomp']) | ||
462 | 115 | 118 | ||
463 | 116 | return runnables | 119 | return runnables |
464 | 117 | 120 | ||
465 | @@ -140,12 +143,14 @@ | |||
466 | 140 | if 'binaries' in config_data: | 143 | if 'binaries' in config_data: |
467 | 141 | binaries = config_data['binaries'] | 144 | binaries = config_data['binaries'] |
468 | 142 | binaries = _wrap_binaries(binaries) | 145 | binaries = _wrap_binaries(binaries) |
470 | 143 | package_yaml['binaries'] = _copy_security_profiles(meta_dir, _repack_names(binaries)) | 146 | package_yaml['binaries'] = \ |
471 | 147 | _copy_security_profiles(meta_dir, _repack_names(binaries)) | ||
472 | 144 | 148 | ||
473 | 145 | if 'services' in config_data: | 149 | if 'services' in config_data: |
474 | 146 | services = config_data['services'] | 150 | services = config_data['services'] |
475 | 147 | services = _wrap_services(services) | 151 | services = _wrap_services(services) |
477 | 148 | package_yaml['services'] = _copy_security_profiles(meta_dir, _repack_names(services)) | 152 | package_yaml['services'] = \ |
478 | 153 | _copy_security_profiles(meta_dir, _repack_names(services)) | ||
479 | 149 | 154 | ||
480 | 150 | return package_yaml | 155 | return package_yaml |
481 | 151 | 156 | ||
482 | @@ -159,7 +164,8 @@ | |||
483 | 159 | 164 | ||
484 | 160 | 165 | ||
485 | 161 | def _compose_readme(config_data): | 166 | def _compose_readme(config_data): |
487 | 162 | return '{config[summary]}\n{config[description]}\n'.format(config=config_data) | 167 | s = '{config[summary]}\n{config[description]}\n' |
488 | 168 | return s.format(config=config_data) | ||
489 | 163 | 169 | ||
490 | 164 | 170 | ||
491 | 165 | def _replace_cmd(execparts, cmd): | 171 | def _replace_cmd(execparts, cmd): |
492 | @@ -199,7 +205,8 @@ | |||
493 | 199 | wrapexec = '$SNAP_APP_PATH/{}'.format(relexepath) | 205 | wrapexec = '$SNAP_APP_PATH/{}'.format(relexepath) |
494 | 200 | if not os.path.exists(exepath) and '/' not in relexepath: | 206 | if not os.path.exists(exepath) and '/' not in relexepath: |
495 | 201 | # If it doesn't exist it might be in the path | 207 | # If it doesn't exist it might be in the path |
497 | 202 | logger.debug('Checking to see if "{}" is in the $PATH'.format(relexepath)) | 208 | logger.debug('Checking to see if "{}" is in the $PATH'.format( |
498 | 209 | relexepath)) | ||
499 | 203 | with tempfile.NamedTemporaryFile('w+') as tempf: | 210 | with tempfile.NamedTemporaryFile('w+') as tempf: |
500 | 204 | script = ('#!/bin/sh\n' + | 211 | script = ('#!/bin/sh\n' + |
501 | 205 | '{}\n'.format(common.assemble_env()) + | 212 | '{}\n'.format(common.assemble_env()) + |
502 | @@ -209,7 +216,8 @@ | |||
503 | 209 | if common.run(['/bin/sh', tempf.name], cwd=snap_dir): | 216 | if common.run(['/bin/sh', tempf.name], cwd=snap_dir): |
504 | 210 | wrapexec = relexepath | 217 | wrapexec = relexepath |
505 | 211 | else: | 218 | else: |
507 | 212 | logger.warning('Warning: unable to find "{}" in the path'.format(relexepath)) | 219 | logger.warning('Warning: unable to find "{}" in the path'. |
508 | 220 | format(relexepath)) | ||
509 | 213 | 221 | ||
510 | 214 | _write_wrap_exe(wrapexec, wrappath) | 222 | _write_wrap_exe(wrapexec, wrappath) |
511 | 215 | 223 | ||
512 | 216 | 224 | ||
513 | === modified file 'snapcraft/plugin.py' | |||
514 | --- snapcraft/plugin.py 2015-09-22 10:39:06 +0000 | |||
515 | +++ snapcraft/plugin.py 2015-10-05 19:37:43 +0000 | |||
516 | @@ -49,7 +49,8 @@ | |||
517 | 49 | 49 | ||
518 | 50 | class PluginHandler: | 50 | class PluginHandler: |
519 | 51 | 51 | ||
521 | 52 | def __init__(self, name, part_name, properties, load_code=True, load_config=True): | 52 | def __init__(self, name, part_name, properties, load_code=True, |
522 | 53 | load_config=True): | ||
523 | 53 | self.valid = False | 54 | self.valid = False |
524 | 54 | self.code = None | 55 | self.code = None |
525 | 55 | self.config = {} | 56 | self.config = {} |
526 | @@ -107,7 +108,8 @@ | |||
527 | 107 | setattr(options, attrname, properties[opt]) | 108 | setattr(options, attrname, properties[opt]) |
528 | 108 | else: | 109 | else: |
529 | 109 | if opt_parameters.get('required', False): | 110 | if opt_parameters.get('required', False): |
531 | 110 | raise PluginError('Required field {} missing on part {}'.format(opt, name)) | 111 | raise PluginError('Required field {} missing on part {}'. |
532 | 112 | format(opt, name)) | ||
533 | 111 | setattr(options, attrname, None) | 113 | setattr(options, attrname, None) |
534 | 112 | 114 | ||
535 | 113 | return options | 115 | return options |
536 | @@ -117,7 +119,8 @@ | |||
537 | 117 | module_name = name.replace('-', '_') | 119 | module_name = name.replace('-', '_') |
538 | 118 | 120 | ||
539 | 119 | try: | 121 | try: |
541 | 120 | module = importlib.import_module('snapcraft.plugins.' + module_name) | 122 | module = importlib.import_module('snapcraft.plugins.' + |
542 | 123 | module_name) | ||
543 | 121 | except ImportError: | 124 | except ImportError: |
544 | 122 | module = None | 125 | module = None |
545 | 123 | 126 | ||
546 | @@ -160,7 +163,8 @@ | |||
547 | 160 | try: | 163 | try: |
548 | 161 | with open(self.statefile, 'r') as f: | 164 | with open(self.statefile, 'r') as f: |
549 | 162 | lastStep = f.read() | 165 | lastStep = f.read() |
551 | 163 | return common.COMMAND_ORDER.index(stage) > common.COMMAND_ORDER.index(lastStep) | 166 | return (common.COMMAND_ORDER.index(stage) > |
552 | 167 | common.COMMAND_ORDER.index(lastStep)) | ||
553 | 164 | except Exception: | 168 | except Exception: |
554 | 165 | return True | 169 | return True |
555 | 166 | 170 | ||
556 | @@ -179,7 +183,8 @@ | |||
557 | 179 | return True | 183 | return True |
558 | 180 | self.makedirs() | 184 | self.makedirs() |
559 | 181 | 185 | ||
561 | 182 | run_setup_stage_packages = self.code and hasattr(self.code, 'setup_stage_packages') | 186 | run_setup_stage_packages = self.code and \ |
562 | 187 | hasattr(self.code, 'setup_stage_packages') | ||
563 | 183 | run_pull = self.code and hasattr(self.code, 'pull') | 188 | run_pull = self.code and hasattr(self.code, 'pull') |
564 | 184 | 189 | ||
565 | 185 | if run_setup_stage_packages or run_pull: | 190 | if run_setup_stage_packages or run_pull: |
566 | @@ -248,7 +253,8 @@ | |||
567 | 248 | snap_files, snap_dirs = self._migratable_fileset_for('stage') | 253 | snap_files, snap_dirs = self._migratable_fileset_for('stage') |
568 | 249 | 254 | ||
569 | 250 | try: | 255 | try: |
571 | 251 | _migrate_files(snap_files, snap_dirs, self.installdir, self.stagedir) | 256 | _migrate_files(snap_files, snap_dirs, self.installdir, |
572 | 257 | self.stagedir) | ||
573 | 252 | except FileNotFoundError as e: | 258 | except FileNotFoundError as e: |
574 | 253 | logger.error('Could not find file %s defined in stage', | 259 | logger.error('Could not find file %s defined in stage', |
575 | 254 | os.path.relpath(e.filename, os.path.curdir)) | 260 | os.path.relpath(e.filename, os.path.curdir)) |
576 | @@ -284,7 +290,8 @@ | |||
577 | 284 | 290 | ||
578 | 285 | 291 | ||
579 | 286 | def load_plugin(part_name, plugin_name, properties={}, load_code=True): | 292 | def load_plugin(part_name, plugin_name, properties={}, load_code=True): |
581 | 287 | part = PluginHandler(plugin_name, part_name, properties, load_code=load_code) | 293 | part = PluginHandler(plugin_name, part_name, properties, |
582 | 294 | load_code=load_code) | ||
583 | 288 | if not part.is_valid(): | 295 | if not part.is_valid(): |
584 | 289 | logger.error('Could not load part %s', plugin_name) | 296 | logger.error('Could not load part %s', plugin_name) |
585 | 290 | sys.exit(1) | 297 | sys.exit(1) |
586 | @@ -300,10 +307,13 @@ | |||
587 | 300 | # And chop files, including whole trees if any dirs are mentioned | 307 | # And chop files, including whole trees if any dirs are mentioned |
588 | 301 | snap_files = include_files - exclude_files | 308 | snap_files = include_files - exclude_files |
589 | 302 | for exclude_dir in exclude_dirs: | 309 | for exclude_dir in exclude_dirs: |
591 | 303 | snap_files = set([x for x in snap_files if not x.startswith(exclude_dir + '/')]) | 310 | snap_files = set([x for x in snap_files |
592 | 311 | if not x.startswith(exclude_dir + '/')]) | ||
593 | 304 | 312 | ||
594 | 305 | # Separate dirs from files | 313 | # Separate dirs from files |
596 | 306 | snap_dirs = set([x for x in snap_files if os.path.isdir(os.path.join(srcdir, x)) and not os.path.islink(os.path.join(srcdir, x))]) | 314 | snap_dirs = set([x for x in snap_files |
597 | 315 | if os.path.isdir(os.path.join(srcdir, x)) and | ||
598 | 316 | not os.path.islink(os.path.join(srcdir, x))]) | ||
599 | 307 | snap_files = snap_files - snap_dirs | 317 | snap_files = snap_files - snap_dirs |
600 | 308 | 318 | ||
601 | 309 | return snap_files, snap_dirs | 319 | return snap_files, snap_dirs |
602 | @@ -356,8 +366,12 @@ | |||
603 | 356 | # files from an include like 'lib' | 366 | # files from an include like 'lib' |
604 | 357 | for include_dir in include_dirs: | 367 | for include_dir in include_dirs: |
605 | 358 | for root, dirs, files in os.walk(include_dir): | 368 | for root, dirs, files in os.walk(include_dir): |
608 | 359 | include_files |= set([os.path.relpath(os.path.join(root, d), directory) for d in dirs]) | 369 | include_files |= \ |
609 | 360 | include_files |= set([os.path.relpath(os.path.join(root, f), directory) for f in files]) | 370 | set([os.path.relpath(os.path.join(root, d), directory) |
610 | 371 | for d in dirs]) | ||
611 | 372 | include_files |= \ | ||
612 | 373 | set([os.path.relpath(os.path.join(root, f), directory) | ||
613 | 374 | for f in files]) | ||
614 | 361 | 375 | ||
615 | 362 | return include_files | 376 | return include_files |
616 | 363 | 377 | ||
617 | @@ -369,8 +383,10 @@ | |||
618 | 369 | matches = glob.glob(os.path.join(directory, exclude)) | 383 | matches = glob.glob(os.path.join(directory, exclude)) |
619 | 370 | exclude_files |= set(matches) | 384 | exclude_files |= set(matches) |
620 | 371 | 385 | ||
623 | 372 | exclude_dirs = [os.path.relpath(x, directory) for x in exclude_files if os.path.isdir(x)] | 386 | exclude_dirs = [os.path.relpath(x, directory) |
624 | 373 | exclude_files = set([os.path.relpath(x, directory) for x in exclude_files]) | 387 | for x in exclude_files if os.path.isdir(x)] |
625 | 388 | exclude_files = set([os.path.relpath(x, directory) | ||
626 | 389 | for x in exclude_files]) | ||
627 | 374 | 390 | ||
628 | 375 | return exclude_files, exclude_dirs | 391 | return exclude_files, exclude_dirs |
629 | 376 | 392 | ||
630 | 377 | 393 | ||
631 | === modified file 'snapcraft/plugins/ant.py' | |||
632 | --- snapcraft/plugins/ant.py 2015-10-01 08:54:15 +0000 | |||
633 | +++ snapcraft/plugins/ant.py 2015-10-05 19:37:43 +0000 | |||
634 | @@ -36,7 +36,8 @@ | |||
635 | 36 | return False | 36 | return False |
636 | 37 | files = glob.glob(os.path.join(self.builddir, 'target', '*.jar')) | 37 | files = glob.glob(os.path.join(self.builddir, 'target', '*.jar')) |
637 | 38 | if not files: | 38 | if not files: |
639 | 39 | logger.error('Could not find any built jar files for part %s', self.name) | 39 | logger.error('Could not find any built jar files for part %s', |
640 | 40 | self.name) | ||
641 | 40 | sys.exit(1) | 41 | sys.exit(1) |
642 | 41 | jardir = os.path.join(self.installdir, 'jar') | 42 | jardir = os.path.join(self.installdir, 'jar') |
643 | 42 | return self.run(['mkdir', '-p', jardir]) and \ | 43 | return self.run(['mkdir', '-p', jardir]) and \ |
644 | 43 | 44 | ||
645 | === modified file 'snapcraft/plugins/autotools.py' | |||
646 | --- snapcraft/plugins/autotools.py 2015-10-01 08:54:15 +0000 | |||
647 | +++ snapcraft/plugins/autotools.py 2015-10-05 19:37:43 +0000 | |||
648 | @@ -28,5 +28,5 @@ | |||
649 | 28 | if not os.path.exists(os.path.join(self.builddir, "configure")): | 28 | if not os.path.exists(os.path.join(self.builddir, "configure")): |
650 | 29 | if not self.run(['env', 'NOCONFIGURE=1', './autogen.sh']): | 29 | if not self.run(['env', 'NOCONFIGURE=1', './autogen.sh']): |
651 | 30 | return False | 30 | return False |
654 | 31 | return self.run(['./configure', '--prefix='] + self.options.configflags) and \ | 31 | return self.run(['./configure', '--prefix='] + |
655 | 32 | super().build() | 32 | self.options.configflags) and super().build() |
656 | 33 | 33 | ||
657 | === modified file 'snapcraft/plugins/cmake.py' | |||
658 | --- snapcraft/plugins/cmake.py 2015-10-01 08:54:15 +0000 | |||
659 | +++ snapcraft/plugins/cmake.py 2015-10-05 19:37:43 +0000 | |||
660 | @@ -24,5 +24,5 @@ | |||
661 | 24 | self.options.configflags = [] | 24 | self.options.configflags = [] |
662 | 25 | 25 | ||
663 | 26 | def build(self): | 26 | def build(self): |
666 | 27 | return self.run(['cmake', '.', '-DCMAKE_INSTALL_PREFIX='] + self.options.configflags) and \ | 27 | return self.run(['cmake', '.', '-DCMAKE_INSTALL_PREFIX='] + |
667 | 28 | super().build() | 28 | self.options.configflags) and super().build() |
668 | 29 | 29 | ||
669 | === modified file 'snapcraft/plugins/copy.py' | |||
670 | --- snapcraft/plugins/copy.py 2015-08-26 08:52:09 +0000 | |||
671 | +++ snapcraft/plugins/copy.py 2015-10-05 19:37:43 +0000 | |||
672 | @@ -37,5 +37,6 @@ | |||
673 | 37 | dst_dir = os.path.dirname(dst) | 37 | dst_dir = os.path.dirname(dst) |
674 | 38 | if not os.path.exists(dst_dir): | 38 | if not os.path.exists(dst_dir): |
675 | 39 | os.makedirs(dst_dir) | 39 | os.makedirs(dst_dir) |
677 | 40 | res &= self.run(["cp", "--preserve=all", "-R", src, dst], cwd=os.getcwd()) | 40 | res &= self.run(["cp", "--preserve=all", "-R", src, dst], |
678 | 41 | cwd=os.getcwd()) | ||
679 | 41 | return res | 42 | return res |
680 | 42 | 43 | ||
681 | === modified file 'snapcraft/plugins/go.py' | |||
682 | --- snapcraft/plugins/go.py 2015-10-01 08:54:15 +0000 | |||
683 | +++ snapcraft/plugins/go.py 2015-10-05 19:37:43 +0000 | |||
684 | @@ -43,7 +43,8 @@ | |||
685 | 43 | return False | 43 | return False |
686 | 44 | if not self.run(['go', 'install', self.fullname]): | 44 | if not self.run(['go', 'install', self.fullname]): |
687 | 45 | return False | 45 | return False |
689 | 46 | return self.run(['cp', '-a', os.path.join(self.builddir, 'bin'), self.installdir]) | 46 | return self.run(['cp', '-a', os.path.join(self.builddir, 'bin'), |
690 | 47 | self.installdir]) | ||
691 | 47 | 48 | ||
692 | 48 | def run(self, cmd, **kwargs): | 49 | def run(self, cmd, **kwargs): |
693 | 49 | cmd = ['env', 'GOPATH=' + self.builddir] + cmd | 50 | cmd = ['env', 'GOPATH=' + self.builddir] + cmd |
694 | 50 | 51 | ||
695 | === modified file 'snapcraft/plugins/maven.py' | |||
696 | --- snapcraft/plugins/maven.py 2015-10-01 08:54:15 +0000 | |||
697 | +++ snapcraft/plugins/maven.py 2015-10-05 19:37:43 +0000 | |||
698 | @@ -36,7 +36,8 @@ | |||
699 | 36 | jarfiles = glob.glob(os.path.join(self.builddir, 'target', '*.jar')) | 36 | jarfiles = glob.glob(os.path.join(self.builddir, 'target', '*.jar')) |
700 | 37 | warfiles = glob.glob(os.path.join(self.builddir, 'target', '*.war')) | 37 | warfiles = glob.glob(os.path.join(self.builddir, 'target', '*.war')) |
701 | 38 | if not (jarfiles or warfiles): | 38 | if not (jarfiles or warfiles): |
703 | 39 | logger.error('Could not find any built jar or war files for part %s', self.name) | 39 | logger.error('Could not find any built jar or war files for ' |
704 | 40 | 'part %s', self.name) | ||
705 | 40 | snapcraft.common.fatal() | 41 | snapcraft.common.fatal() |
706 | 41 | if jarfiles: | 42 | if jarfiles: |
707 | 42 | jardir = os.path.join(self.installdir, 'jar') | 43 | jardir = os.path.join(self.installdir, 'jar') |
708 | 43 | 44 | ||
709 | === modified file 'snapcraft/plugins/python2.py' | |||
710 | --- snapcraft/plugins/python2.py 2015-10-01 08:54:15 +0000 | |||
711 | +++ snapcraft/plugins/python2.py 2015-10-05 19:37:43 +0000 | |||
712 | @@ -62,7 +62,8 @@ | |||
713 | 62 | 62 | ||
714 | 63 | if not os.path.exists(site_packages_dir): | 63 | if not os.path.exists(site_packages_dir): |
715 | 64 | os.symlink( | 64 | os.symlink( |
717 | 65 | os.path.join(prefix, 'lib', self.python_version, 'dist-packages'), | 65 | os.path.join(prefix, 'lib', self.python_version, |
718 | 66 | 'dist-packages'), | ||
719 | 66 | site_packages_dir) | 67 | site_packages_dir) |
720 | 67 | 68 | ||
721 | 68 | if not self.run(['python2', easy_install, '--prefix', prefix, 'pip']): | 69 | if not self.run(['python2', easy_install, '--prefix', prefix, 'pip']): |
722 | @@ -99,7 +100,8 @@ | |||
723 | 99 | @property | 100 | @property |
724 | 100 | def dist_packages_dir(self): | 101 | def dist_packages_dir(self): |
725 | 101 | return os.path.join( | 102 | return os.path.join( |
727 | 102 | self.installdir, 'usr', 'lib', self.python_version, 'dist-packages') | 103 | self.installdir, 'usr', 'lib', self.python_version, |
728 | 104 | 'dist-packages') | ||
729 | 103 | 105 | ||
730 | 104 | @property | 106 | @property |
731 | 105 | def python_version(self): | 107 | def python_version(self): |
732 | 106 | 108 | ||
733 | === modified file 'snapcraft/plugins/python3.py' | |||
734 | --- snapcraft/plugins/python3.py 2015-10-02 16:45:13 +0000 | |||
735 | +++ snapcraft/plugins/python3.py 2015-10-05 19:37:43 +0000 | |||
736 | @@ -99,7 +99,8 @@ | |||
737 | 99 | @property | 99 | @property |
738 | 100 | def dist_packages_dir(self): | 100 | def dist_packages_dir(self): |
739 | 101 | return os.path.join( | 101 | return os.path.join( |
741 | 102 | self.installdir, 'usr', 'lib', self.python_version, 'dist-packages') | 102 | self.installdir, 'usr', 'lib', self.python_version, |
742 | 103 | 'dist-packages') | ||
743 | 103 | 104 | ||
744 | 104 | @property | 105 | @property |
745 | 105 | def python_version(self): | 106 | def python_version(self): |
746 | 106 | 107 | ||
747 | === modified file 'snapcraft/plugins/qml.py' | |||
748 | --- snapcraft/plugins/qml.py 2015-09-08 21:21:07 +0000 | |||
749 | +++ snapcraft/plugins/qml.py 2015-10-05 19:37:43 +0000 | |||
750 | @@ -81,7 +81,8 @@ | |||
751 | 81 | "LD_LIBRARY_PATH=%s/usr/lib/%s:$LD_LIBRARY_PATH" % (root, arch), | 81 | "LD_LIBRARY_PATH=%s/usr/lib/%s:$LD_LIBRARY_PATH" % (root, arch), |
752 | 82 | # Mir config | 82 | # Mir config |
753 | 83 | "MIR_SOCKET=/run/mir_socket", | 83 | "MIR_SOCKET=/run/mir_socket", |
755 | 84 | "MIR_CLIENT_PLATFORM_PATH=%s/usr/lib/%s/mir/client-platform" % (root, arch), | 84 | "MIR_CLIENT_PLATFORM_PATH={}/usr/lib/{}/mir/client-platform" |
756 | 85 | .format(root, arch), | ||
757 | 85 | # XKB config | 86 | # XKB config |
758 | 86 | "XKB_CONFIG_ROOT=%s/usr/share/X11/xkb" % root, | 87 | "XKB_CONFIG_ROOT=%s/usr/share/X11/xkb" % root, |
759 | 87 | # Qt Platform to Mir | 88 | # Qt Platform to Mir |
760 | @@ -89,14 +90,18 @@ | |||
761 | 89 | "QTCHOOSER_NO_GLOBAL_DIR=1", | 90 | "QTCHOOSER_NO_GLOBAL_DIR=1", |
762 | 90 | "QT_SELECT=snappy-qt5", | 91 | "QT_SELECT=snappy-qt5", |
763 | 91 | # Qt Libs | 92 | # Qt Libs |
766 | 92 | "LD_LIBRARY_PATH=%s/usr/lib/%s/qt5/libs:$LD_LIBRARY_PATH" % (root, arch), | 93 | "LD_LIBRARY_PATH={}/usr/lib/{}/qt5/libs:$LD_LIBRARY_PATH" |
767 | 93 | "LD_LIBRARY_PATH=%s/usr/lib/%s/pulseaudio:$LD_LIBRARY_PATH" % (root, arch), | 94 | .format(root, arch), |
768 | 95 | "LD_LIBRARY_PATH={}/usr/lib/{}/pulseaudio:$LD_LIBRARY_PATH" | ||
769 | 96 | .format(root, arch), | ||
770 | 94 | # Qt Modules | 97 | # Qt Modules |
771 | 95 | "QT_PLUGIN_PATH=%s/usr/lib/%s/qt5/plugins" % (root, arch), | 98 | "QT_PLUGIN_PATH=%s/usr/lib/%s/qt5/plugins" % (root, arch), |
772 | 96 | "QML2_IMPORT_PATH=%s/usr/lib/%s/qt5/qml" % (root, arch), | 99 | "QML2_IMPORT_PATH=%s/usr/lib/%s/qt5/qml" % (root, arch), |
773 | 97 | # Mesa Libs | 100 | # Mesa Libs |
776 | 98 | "LD_LIBRARY_PATH=%s/usr/lib/%s/mesa:$LD_LIBRARY_PATH" % (root, arch), | 101 | "LD_LIBRARY_PATH={}/usr/lib/{}/mesa:$LD_LIBRARY_PATH" |
777 | 99 | "LD_LIBRARY_PATH=%s/usr/lib/%s/mesa-egl:$LD_LIBRARY_PATH" % (root, arch), | 102 | .format(root, arch), |
778 | 103 | "LD_LIBRARY_PATH={}/usr/lib/{}/mesa-egl:$LD_LIBRARY_PATH" | ||
779 | 104 | .format(root, arch), | ||
780 | 100 | # XDG Config | 105 | # XDG Config |
781 | 101 | "XDG_CONFIG_DIRS=%s/etc/xdg:$XDG_CONFIG_DIRS" % root, | 106 | "XDG_CONFIG_DIRS=%s/etc/xdg:$XDG_CONFIG_DIRS" % root, |
782 | 102 | "XDG_CONFIG_DIRS=%s/usr/xdg:$XDG_CONFIG_DIRS" % root, | 107 | "XDG_CONFIG_DIRS=%s/usr/xdg:$XDG_CONFIG_DIRS" % root, |
783 | 103 | 108 | ||
784 | === modified file 'snapcraft/repo.py' | |||
785 | --- snapcraft/repo.py 2015-09-30 17:23:17 +0000 | |||
786 | +++ snapcraft/repo.py 2015-10-05 19:37:43 +0000 | |||
787 | @@ -28,7 +28,8 @@ | |||
788 | 28 | 28 | ||
789 | 29 | import snapcraft.common | 29 | import snapcraft.common |
790 | 30 | 30 | ||
792 | 31 | _DEFAULT_SOURCES = '''deb http://${prefix}.ubuntu.com/${suffix}/ ${release} main restricted | 31 | _DEFAULT_SOURCES = \ |
793 | 32 | '''deb http://${prefix}.ubuntu.com/${suffix}/ ${release} main restricted | ||
794 | 32 | deb http://${prefix}.ubuntu.com/${suffix}/ ${release}-updates main restricted | 33 | deb http://${prefix}.ubuntu.com/${suffix}/ ${release}-updates main restricted |
795 | 33 | deb http://${prefix}.ubuntu.com/${suffix}/ ${release} universe | 34 | deb http://${prefix}.ubuntu.com/${suffix}/ ${release} universe |
796 | 34 | deb http://${prefix}.ubuntu.com/${suffix}/ ${release}-updates universe | 35 | deb http://${prefix}.ubuntu.com/${suffix}/ ${release}-updates universe |
797 | @@ -103,7 +104,8 @@ | |||
798 | 103 | skipped_essential.append(pkg.name) | 104 | skipped_essential.append(pkg.name) |
799 | 104 | pkg.mark_keep() | 105 | pkg.mark_keep() |
800 | 105 | continue | 106 | continue |
802 | 106 | if (pkg.name in manifest_dep_names and pkg.name not in package_names): | 107 | if (pkg.name in manifest_dep_names and |
803 | 108 | pkg.name not in package_names): | ||
804 | 107 | skipped_blacklisted.append(pkg.name) | 109 | skipped_blacklisted.append(pkg.name) |
805 | 108 | pkg.mark_keep() | 110 | pkg.mark_keep() |
806 | 109 | continue | 111 | continue |
807 | @@ -111,7 +113,8 @@ | |||
808 | 111 | if skipped_essential: | 113 | if skipped_essential: |
809 | 112 | print('Skipping priority essential packages:', skipped_essential) | 114 | print('Skipping priority essential packages:', skipped_essential) |
810 | 113 | if skipped_blacklisted: | 115 | if skipped_blacklisted: |
812 | 114 | print('Skipping blacklisted from manifest packages:', skipped_blacklisted) | 116 | print('Skipping blacklisted from manifest packages:', |
813 | 117 | skipped_blacklisted) | ||
814 | 115 | 118 | ||
815 | 116 | # download the remaining ones with proper progress | 119 | # download the remaining ones with proper progress |
816 | 117 | apt.apt_pkg.config.set("Dir::Cache::Archives", self.downloaddir) | 120 | apt.apt_pkg.config.set("Dir::Cache::Archives", self.downloaddir) |
817 | @@ -131,7 +134,8 @@ | |||
818 | 131 | def _manifest_dep_names(self): | 134 | def _manifest_dep_names(self): |
819 | 132 | manifest_dep_names = set() | 135 | manifest_dep_names = set() |
820 | 133 | 136 | ||
822 | 134 | with open(os.path.abspath(os.path.join(__file__, '..', 'manifest.txt'))) as f: | 137 | with open(os.path.abspath(os.path.join(__file__, '..', |
823 | 138 | 'manifest.txt'))) as f: | ||
824 | 135 | for line in f: | 139 | for line in f: |
825 | 136 | pkg = line.strip() | 140 | pkg = line.strip() |
826 | 137 | if pkg in self.apt_cache: | 141 | if pkg in self.apt_cache: |
827 | 138 | 142 | ||
828 | === modified file 'snapcraft/sources.py' | |||
829 | --- snapcraft/sources.py 2015-09-29 08:11:32 +0000 | |||
830 | +++ snapcraft/sources.py 2015-10-05 19:37:43 +0000 | |||
831 | @@ -35,7 +35,8 @@ | |||
832 | 35 | 35 | ||
833 | 36 | class Base: | 36 | class Base: |
834 | 37 | 37 | ||
836 | 38 | def __init__(self, source, source_dir, source_tag=None, source_branch=None): | 38 | def __init__(self, source, source_dir, source_tag=None, |
837 | 39 | source_branch=None): | ||
838 | 39 | self.source = source | 40 | self.source = source |
839 | 40 | self.source_dir = source_dir | 41 | self.source_dir = source_dir |
840 | 41 | self.source_tag = source_tag | 42 | self.source_tag = source_tag |
841 | @@ -45,35 +46,43 @@ | |||
842 | 45 | raise NotImplementedError('this is just a base class') | 46 | raise NotImplementedError('this is just a base class') |
843 | 46 | 47 | ||
844 | 47 | def provision(self, dst): | 48 | def provision(self, dst): |
846 | 48 | return snapcraft.common.run(['cp', '-Trfa', self.source_dir, dst], cwd=os.getcwd()) | 49 | return snapcraft.common.run(['cp', '-Trfa', self.source_dir, dst], |
847 | 50 | cwd=os.getcwd()) | ||
848 | 49 | 51 | ||
849 | 50 | 52 | ||
850 | 51 | class Bazaar(Base): | 53 | class Bazaar(Base): |
851 | 52 | 54 | ||
853 | 53 | def __init__(self, source, source_dir, source_tag=None, source_branch=None): | 55 | def __init__(self, source, source_dir, source_tag=None, |
854 | 56 | source_branch=None): | ||
855 | 54 | super().__init__(source, source_dir, source_tag, source_branch) | 57 | super().__init__(source, source_dir, source_tag, source_branch) |
856 | 55 | if source_branch: | 58 | if source_branch: |
858 | 56 | raise IncompatibleOptionsError('can\'t specify a source-branch for a bzr source') | 59 | raise IncompatibleOptionsError( |
859 | 60 | 'can\'t specify a source-branch for a bzr source') | ||
860 | 57 | 61 | ||
861 | 58 | def pull(self): | 62 | def pull(self): |
862 | 59 | tag_opts = [] | 63 | tag_opts = [] |
863 | 60 | if self.source_tag: | 64 | if self.source_tag: |
864 | 61 | tag_opts = ['-r', 'tag:' + self.source_tag] | 65 | tag_opts = ['-r', 'tag:' + self.source_tag] |
865 | 62 | if os.path.exists(os.path.join(self.source_dir, ".bzr")): | 66 | if os.path.exists(os.path.join(self.source_dir, ".bzr")): |
867 | 63 | cmd = ['bzr', 'pull'] + tag_opts + [self.source, '-d', self.source_dir] | 67 | cmd = ['bzr', 'pull'] + tag_opts + \ |
868 | 68 | [self.source, '-d', self.source_dir] | ||
869 | 64 | else: | 69 | else: |
870 | 65 | os.rmdir(self.source_dir) | 70 | os.rmdir(self.source_dir) |
872 | 66 | cmd = ['bzr', 'branch'] + tag_opts + [self.source, self.source_dir] | 71 | cmd = ['bzr', 'branch'] + tag_opts + \ |
873 | 72 | [self.source, self.source_dir] | ||
874 | 67 | 73 | ||
875 | 68 | return snapcraft.common.run(cmd, cwd=os.getcwd()) | 74 | return snapcraft.common.run(cmd, cwd=os.getcwd()) |
876 | 69 | 75 | ||
877 | 70 | 76 | ||
878 | 71 | class Git(Base): | 77 | class Git(Base): |
879 | 72 | 78 | ||
881 | 73 | def __init__(self, source, source_dir, source_tag=None, source_branch=None): | 79 | def __init__(self, source, source_dir, source_tag=None, |
882 | 80 | source_branch=None): | ||
883 | 74 | super().__init__(source, source_dir, source_tag, source_branch) | 81 | super().__init__(source, source_dir, source_tag, source_branch) |
884 | 75 | if source_tag and source_branch: | 82 | if source_tag and source_branch: |
886 | 76 | raise IncompatibleOptionsError('can\'t specify both source-tag and source-branch for a git source') | 83 | raise IncompatibleOptionsError( |
887 | 84 | 'can\'t specify both source-tag and source-branch for ' | ||
888 | 85 | 'a git source') | ||
889 | 77 | 86 | ||
890 | 78 | def pull(self): | 87 | def pull(self): |
891 | 79 | if os.path.exists(os.path.join(self.source_dir, ".git")): | 88 | if os.path.exists(os.path.join(self.source_dir, ".git")): |
892 | @@ -86,18 +95,23 @@ | |||
893 | 86 | else: | 95 | else: |
894 | 87 | branch_opts = [] | 96 | branch_opts = [] |
895 | 88 | if self.source_tag or self.source_branch: | 97 | if self.source_tag or self.source_branch: |
898 | 89 | branch_opts = ['--branch', self.source_tag or self.source_branch] | 98 | branch_opts = ['--branch', |
899 | 90 | cmd = ['git', 'clone'] + branch_opts + [self.source, self.source_dir] | 99 | self.source_tag or self.source_branch] |
900 | 100 | cmd = ['git', 'clone'] + branch_opts + \ | ||
901 | 101 | [self.source, self.source_dir] | ||
902 | 91 | 102 | ||
903 | 92 | return snapcraft.common.run(cmd, cwd=os.getcwd()) | 103 | return snapcraft.common.run(cmd, cwd=os.getcwd()) |
904 | 93 | 104 | ||
905 | 94 | 105 | ||
906 | 95 | class Mercurial(Base): | 106 | class Mercurial(Base): |
907 | 96 | 107 | ||
909 | 97 | def __init__(self, source, source_dir, source_tag=None, source_branch=None): | 108 | def __init__(self, source, source_dir, source_tag=None, |
910 | 109 | source_branch=None): | ||
911 | 98 | super().__init__(source, source_dir, source_tag, source_branch) | 110 | super().__init__(source, source_dir, source_tag, source_branch) |
912 | 99 | if source_tag and source_branch: | 111 | if source_tag and source_branch: |
914 | 100 | raise IncompatibleOptionsError('can\'t specify both source-tag and source-branch for a mercurial source') | 112 | raise IncompatibleOptionsError( |
915 | 113 | 'can\'t specify both source-tag and source-branch for a ' | ||
916 | 114 | 'mercurial source') | ||
917 | 101 | 115 | ||
918 | 102 | def pull(self): | 116 | def pull(self): |
919 | 103 | if os.path.exists(os.path.join(self.source_dir, ".hg")): | 117 | if os.path.exists(os.path.join(self.source_dir, ".hg")): |
920 | @@ -118,23 +132,29 @@ | |||
921 | 118 | 132 | ||
922 | 119 | class Tar(Base): | 133 | class Tar(Base): |
923 | 120 | 134 | ||
925 | 121 | def __init__(self, source, source_dir, source_tag=None, source_branch=None): | 135 | def __init__(self, source, source_dir, source_tag=None, |
926 | 136 | source_branch=None): | ||
927 | 122 | super().__init__(source, source_dir, source_tag, source_branch) | 137 | super().__init__(source, source_dir, source_tag, source_branch) |
928 | 123 | if source_tag: | 138 | if source_tag: |
930 | 124 | raise IncompatibleOptionsError('can\'t specify a source-tag for a tar source') | 139 | raise IncompatibleOptionsError( |
931 | 140 | 'can\'t specify a source-tag for a tar source') | ||
932 | 125 | elif source_branch: | 141 | elif source_branch: |
934 | 126 | raise IncompatibleOptionsError('can\'t specify a source-branch for a tar source') | 142 | raise IncompatibleOptionsError( |
935 | 143 | 'can\'t specify a source-branch for a tar source') | ||
936 | 127 | 144 | ||
937 | 128 | def pull(self): | 145 | def pull(self): |
938 | 129 | if snapcraft.common.isurl(self.source): | 146 | if snapcraft.common.isurl(self.source): |
940 | 130 | return snapcraft.common.run(['wget', '-q', '-c', self.source], cwd=self.source_dir) | 147 | return snapcraft.common.run(['wget', '-q', '-c', self.source], |
941 | 148 | cwd=self.source_dir) | ||
942 | 131 | else: | 149 | else: |
943 | 132 | return True | 150 | return True |
944 | 133 | 151 | ||
945 | 134 | def provision(self, dst, clean_target=True): | 152 | def provision(self, dst, clean_target=True): |
946 | 135 | # TODO add unit tests. | 153 | # TODO add unit tests. |
947 | 136 | if snapcraft.common.isurl(self.source): | 154 | if snapcraft.common.isurl(self.source): |
949 | 137 | tarball = os.path.join(self.source_dir, os.path.basename(self.source)) | 155 | tarball = os.path.join( |
950 | 156 | self.source_dir, | ||
951 | 157 | os.path.basename(self.source)) | ||
952 | 138 | else: | 158 | else: |
953 | 139 | tarball = os.path.abspath(self.source) | 159 | tarball = os.path.abspath(self.source) |
954 | 140 | 160 | ||
955 | 141 | 161 | ||
956 | === modified file 'snapcraft/tests/test_base_plugin.py' | |||
957 | --- snapcraft/tests/test_base_plugin.py 2015-09-29 08:37:47 +0000 | |||
958 | +++ snapcraft/tests/test_base_plugin.py 2015-10-05 19:37:43 +0000 | |||
959 | @@ -137,5 +137,6 @@ | |||
960 | 137 | self.assertEqual(raised.exception.code, 1, 'Wrong exit code returned.') | 137 | self.assertEqual(raised.exception.code, 1, 'Wrong exit code returned.') |
961 | 138 | expected = ( | 138 | expected = ( |
962 | 139 | 'Issues while setting up sources for part \'test_plugin\': can\'t ' | 139 | 'Issues while setting up sources for part \'test_plugin\': can\'t ' |
964 | 140 | 'specify a {} for a {} source.\n'.format(self.error, self.source_type)) | 140 | 'specify a {} for a {} source.\n' |
965 | 141 | .format(self.error, self.source_type)) | ||
966 | 141 | self.assertEqual(expected, fake_logger.output) | 142 | self.assertEqual(expected, fake_logger.output) |
967 | 142 | 143 | ||
968 | === modified file 'snapcraft/tests/test_cmds.py' | |||
969 | --- snapcraft/tests/test_cmds.py 2015-09-18 16:52:06 +0000 | |||
970 | +++ snapcraft/tests/test_cmds.py 2015-10-05 19:37:43 +0000 | |||
971 | @@ -73,7 +73,8 @@ | |||
972 | 73 | 73 | ||
973 | 74 | self.assertFalse(cmds._check_for_collisions([part1, part2, part3])) | 74 | self.assertFalse(cmds._check_for_collisions([part1, part2, part3])) |
974 | 75 | self.assertEqual( | 75 | self.assertEqual( |
976 | 76 | 'Error: parts part2 and part3 have the following file paths in common which have different contents:\n' | 76 | 'Error: parts part2 and part3 have the following file paths in ' |
977 | 77 | 'common which have different contents:\n' | ||
978 | 77 | ' 1\n' | 78 | ' 1\n' |
979 | 78 | ' a/2\n', | 79 | ' a/2\n', |
980 | 79 | fake_logger.output) | 80 | fake_logger.output) |
981 | 80 | 81 | ||
982 | === modified file 'snapcraft/tests/test_copy_plugin.py' | |||
983 | --- snapcraft/tests/test_copy_plugin.py 2015-07-23 14:23:29 +0000 | |||
984 | +++ snapcraft/tests/test_copy_plugin.py 2015-10-05 19:37:43 +0000 | |||
985 | @@ -73,4 +73,5 @@ | |||
986 | 73 | 73 | ||
987 | 74 | c = CopyPlugin("copy", self.mock_options) | 74 | c = CopyPlugin("copy", self.mock_options) |
988 | 75 | self.assertTrue(c.build()) | 75 | self.assertTrue(c.build()) |
990 | 76 | self.assertTrue(os.path.exists(os.path.join(self.dst_prefix, "dir/dst"))) | 76 | self.assertTrue(os.path.exists(os.path.join(self.dst_prefix, |
991 | 77 | "dir/dst"))) | ||
992 | 77 | 78 | ||
993 | === modified file 'snapcraft/tests/test_meta.py' | |||
994 | --- snapcraft/tests/test_meta.py 2015-09-21 05:04:31 +0000 | |||
995 | +++ snapcraft/tests/test_meta.py 2015-10-05 19:37:43 +0000 | |||
996 | @@ -44,7 +44,8 @@ | |||
997 | 44 | } | 44 | } |
998 | 45 | 45 | ||
999 | 46 | def test_plain_no_binaries_or_services(self): | 46 | def test_plain_no_binaries_or_services(self): |
1001 | 47 | y = meta._compose_package_yaml('meta', self.config_data, ['armhf', 'amd64']) | 47 | y = meta._compose_package_yaml('meta', self.config_data, |
1002 | 48 | ['armhf', 'amd64']) | ||
1003 | 48 | 49 | ||
1004 | 49 | expected = { | 50 | expected = { |
1005 | 50 | 'name': 'my-package', | 51 | 'name': 'my-package', |
1006 | @@ -74,7 +75,8 @@ | |||
1007 | 74 | 'binary2': {'exec': 'binary2.sh'}, | 75 | 'binary2': {'exec': 'binary2.sh'}, |
1008 | 75 | } | 76 | } |
1009 | 76 | 77 | ||
1011 | 77 | y = meta._compose_package_yaml('meta', self.config_data, ['armhf', 'amd64']) | 78 | y = meta._compose_package_yaml('meta', self.config_data, |
1012 | 79 | ['armhf', 'amd64']) | ||
1013 | 78 | 80 | ||
1014 | 79 | self.assertEqual(len(y['binaries']), 2) | 81 | self.assertEqual(len(y['binaries']), 2) |
1015 | 80 | for b in y['binaries']: | 82 | for b in y['binaries']: |
1016 | @@ -92,7 +94,8 @@ | |||
1017 | 92 | }, | 94 | }, |
1018 | 93 | } | 95 | } |
1019 | 94 | 96 | ||
1021 | 95 | y = meta._compose_package_yaml('meta', self.config_data, ['armhf', 'amd64']) | 97 | y = meta._compose_package_yaml('meta', self.config_data, |
1022 | 98 | ['armhf', 'amd64']) | ||
1023 | 96 | 99 | ||
1024 | 97 | self.assertEqual(len(y['services']), 2) | 100 | self.assertEqual(len(y['services']), 2) |
1025 | 98 | for b in y['services']: | 101 | for b in y['services']: |
1026 | @@ -105,7 +108,8 @@ | |||
1027 | 105 | def test_plain_no_binaries_or_services_with_optionals(self): | 108 | def test_plain_no_binaries_or_services_with_optionals(self): |
1028 | 106 | self.config_data['frameworks'] = ['mir', ] | 109 | self.config_data['frameworks'] = ['mir', ] |
1029 | 107 | 110 | ||
1031 | 108 | y = meta._compose_package_yaml('meta', self.config_data, ['armhf', 'amd64']) | 111 | y = meta._compose_package_yaml('meta', self.config_data, |
1032 | 112 | ['armhf', 'amd64']) | ||
1033 | 109 | 113 | ||
1034 | 110 | expected = { | 114 | expected = { |
1035 | 111 | 'name': 'my-package', | 115 | 'name': 'my-package', |
1036 | @@ -120,7 +124,8 @@ | |||
1037 | 120 | 124 | ||
1038 | 121 | def test_compose_readme(self): | 125 | def test_compose_readme(self): |
1039 | 122 | self.config_data['summary'] = 'one line summary' | 126 | self.config_data['summary'] = 'one line summary' |
1041 | 123 | self.config_data['description'] = 'the description\nwhich can be longer' | 127 | self.config_data['description'] = \ |
1042 | 128 | 'the description\nwhich can be longer' | ||
1043 | 124 | 129 | ||
1044 | 125 | readme_text = '''one line summary | 130 | readme_text = '''one line summary |
1045 | 126 | the description | 131 | the description |
1046 | @@ -170,7 +175,8 @@ | |||
1047 | 170 | } | 175 | } |
1048 | 171 | } | 176 | } |
1049 | 172 | 177 | ||
1051 | 173 | self.meta_dir = os.path.join(os.path.abspath(os.curdir), 'snap', 'meta') | 178 | self.meta_dir = os.path.join(os.path.abspath(os.curdir), |
1052 | 179 | 'snap', 'meta') | ||
1053 | 174 | self.hooks_dir = os.path.join(self.meta_dir, 'hooks') | 180 | self.hooks_dir = os.path.join(self.meta_dir, 'hooks') |
1054 | 175 | 181 | ||
1055 | 176 | self.expected_open_calls = [ | 182 | self.expected_open_calls = [ |
1056 | @@ -263,7 +269,8 @@ | |||
1057 | 263 | mock_wrap_exe.assert_has_calls([ | 269 | mock_wrap_exe.assert_has_calls([ |
1058 | 264 | call( | 270 | call( |
1059 | 265 | '$SNAP_APP_PATH/bin/bash', | 271 | '$SNAP_APP_PATH/bin/bash', |
1061 | 266 | os.path.join(os.path.abspath(os.curdir), 'snap/bin/bash.wrapper'), | 272 | os.path.join(os.path.abspath(os.curdir), |
1062 | 273 | 'snap/bin/bash.wrapper'), | ||
1063 | 267 | ), | 274 | ), |
1064 | 268 | call( | 275 | call( |
1065 | 269 | 'bin/config', | 276 | 'bin/config', |
1066 | @@ -273,14 +280,18 @@ | |||
1067 | 273 | ), | 280 | ), |
1068 | 274 | ]) | 281 | ]) |
1069 | 275 | self.mock_copyfile.assert_has_calls([ | 282 | self.mock_copyfile.assert_has_calls([ |
1073 | 276 | call('my-icon.png', os.path.join(self.meta_dir, 'my-icon.png')), | 283 | call('my-icon.png', os.path.join(self.meta_dir, |
1074 | 277 | call('file.apparmor', os.path.join(self.meta_dir, 'file.apparmor')), | 284 | 'my-icon.png')), |
1075 | 278 | call('file.seccomp', os.path.join(self.meta_dir, 'file.seccomp')), | 285 | call('file.apparmor', os.path.join(self.meta_dir, |
1076 | 286 | 'file.apparmor')), | ||
1077 | 287 | call('file.seccomp', os.path.join(self.meta_dir, | ||
1078 | 288 | 'file.seccomp')), | ||
1079 | 279 | ]) | 289 | ]) |
1080 | 280 | 290 | ||
1081 | 281 | @patch('snapcraft.meta._write_wrap_exe') | 291 | @patch('snapcraft.meta._write_wrap_exe') |
1082 | 282 | @patch('snapcraft.meta.open', create=True) | 292 | @patch('snapcraft.meta.open', create=True) |
1084 | 283 | def test_create_meta_with_vararg_config(self, mock_the_open, mock_wrap_exe): | 293 | def test_create_meta_with_vararg_config(self, mock_the_open, |
1085 | 294 | mock_wrap_exe): | ||
1086 | 284 | self.config_data['config'] = 'python3 my.py --config' | 295 | self.config_data['config'] = 'python3 my.py --config' |
1087 | 285 | 296 | ||
1088 | 286 | meta.create(self.config_data, ['amd64']) | 297 | meta.create(self.config_data, ['amd64']) |
1089 | @@ -294,7 +305,8 @@ | |||
1090 | 294 | mock_wrap_exe.assert_has_calls([ | 305 | mock_wrap_exe.assert_has_calls([ |
1091 | 295 | call( | 306 | call( |
1092 | 296 | '$SNAP_APP_PATH/bin/bash', | 307 | '$SNAP_APP_PATH/bin/bash', |
1094 | 297 | os.path.join(os.path.abspath(os.curdir), 'snap/bin/bash.wrapper'), | 308 | os.path.join(os.path.abspath(os.curdir), |
1095 | 309 | 'snap/bin/bash.wrapper'), | ||
1096 | 298 | ), | 310 | ), |
1097 | 299 | call( | 311 | call( |
1098 | 300 | 'python3', | 312 | 'python3', |
1099 | @@ -311,7 +323,8 @@ | |||
1100 | 311 | 323 | ||
1101 | 312 | meta.create(self.config_data, ['amd64']) | 324 | meta.create(self.config_data, ['amd64']) |
1102 | 313 | 325 | ||
1104 | 314 | self.mock_makedirs.assert_called_once_with(self.meta_dir, exist_ok=True) | 326 | self.mock_makedirs.assert_called_once_with(self.meta_dir, |
1105 | 327 | exist_ok=True) | ||
1106 | 315 | mock_the_open.assert_has_calls(self.expected_open_calls) | 328 | mock_the_open.assert_has_calls(self.expected_open_calls) |
1107 | 316 | 329 | ||
1108 | 317 | 330 | ||
1109 | 318 | 331 | ||
1110 | === modified file 'snapcraft/tests/test_plugin.py' | |||
1111 | --- snapcraft/tests/test_plugin.py 2015-09-22 03:51:37 +0000 | |||
1112 | +++ snapcraft/tests/test_plugin.py 2015-10-05 19:37:43 +0000 | |||
1113 | @@ -76,7 +76,8 @@ | |||
1114 | 76 | 76 | ||
1115 | 77 | include, exclude = plugin._get_file_list(stage_set) | 77 | include, exclude = plugin._get_file_list(stage_set) |
1116 | 78 | 78 | ||
1118 | 79 | self.assertEqual(include, ['opt/something', 'usr/bin', '-everything', r'\a']) | 79 | self.assertEqual(include, ['opt/something', 'usr/bin', |
1119 | 80 | '-everything', r'\a']) | ||
1120 | 80 | self.assertEqual(exclude, ['etc', 'usr/lib/*.a']) | 81 | self.assertEqual(exclude, ['etc', 'usr/lib/*.a']) |
1121 | 81 | 82 | ||
1122 | 82 | def test_fileset_only_includes(self): | 83 | def test_fileset_only_includes(self): |
1123 | @@ -182,7 +183,8 @@ | |||
1124 | 182 | dstdir = tmpdir + '/stage' | 183 | dstdir = tmpdir + '/stage' |
1125 | 183 | os.makedirs(dstdir) | 184 | os.makedirs(dstdir) |
1126 | 184 | 185 | ||
1128 | 185 | snap_files, snap_dirs = plugin.migratable_filesets(filesets[key]['fileset'], srcdir) | 186 | snap_files, snap_dirs = plugin.migratable_filesets( |
1129 | 187 | filesets[key]['fileset'], srcdir) | ||
1130 | 186 | plugin._migrate_files(snap_files, snap_dirs, srcdir, dstdir) | 188 | plugin._migrate_files(snap_files, snap_dirs, srcdir, dstdir) |
1131 | 187 | 189 | ||
1132 | 188 | expected = [] | 190 | expected = [] |
1133 | 189 | 191 | ||
1134 | === modified file 'snapcraft/tests/test_repo.py' | |||
1135 | --- snapcraft/tests/test_repo.py 2015-09-23 14:24:04 +0000 | |||
1136 | +++ snapcraft/tests/test_repo.py 2015-10-05 19:37:43 +0000 | |||
1137 | @@ -31,7 +31,8 @@ | |||
1138 | 31 | sources_list = repo._format_sources_list( | 31 | sources_list = repo._format_sources_list( |
1139 | 32 | repo._DEFAULT_SOURCES, 'amd64', 'vivid') | 32 | repo._DEFAULT_SOURCES, 'amd64', 'vivid') |
1140 | 33 | 33 | ||
1142 | 34 | expected_sources_list = '''deb http://ar.archive.ubuntu.com/ubuntu/ vivid main restricted | 34 | expected_sources_list = \ |
1143 | 35 | '''deb http://ar.archive.ubuntu.com/ubuntu/ vivid main restricted | ||
1144 | 35 | deb http://ar.archive.ubuntu.com/ubuntu/ vivid-updates main restricted | 36 | deb http://ar.archive.ubuntu.com/ubuntu/ vivid-updates main restricted |
1145 | 36 | deb http://ar.archive.ubuntu.com/ubuntu/ vivid universe | 37 | deb http://ar.archive.ubuntu.com/ubuntu/ vivid universe |
1146 | 37 | deb http://ar.archive.ubuntu.com/ubuntu/ vivid-updates universe | 38 | deb http://ar.archive.ubuntu.com/ubuntu/ vivid-updates universe |
1147 | @@ -48,7 +49,8 @@ | |||
1148 | 48 | sources_list = repo._format_sources_list( | 49 | sources_list = repo._format_sources_list( |
1149 | 49 | repo._DEFAULT_SOURCES, 'armhf', 'trusty') | 50 | repo._DEFAULT_SOURCES, 'armhf', 'trusty') |
1150 | 50 | 51 | ||
1152 | 51 | expected_sources_list = '''deb http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted | 52 | expected_sources_list = \ |
1153 | 53 | '''deb http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted | ||
1154 | 52 | deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates main restricted | 54 | deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates main restricted |
1155 | 53 | deb http://ports.ubuntu.com/ubuntu-ports/ trusty universe | 55 | deb http://ports.ubuntu.com/ubuntu-ports/ trusty universe |
1156 | 54 | deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates universe | 56 | deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates universe |
1157 | 55 | 57 | ||
1158 | === modified file 'snapcraft/tests/test_sources.py' | |||
1159 | --- snapcraft/tests/test_sources.py 2015-09-01 09:58:55 +0000 | |||
1160 | +++ snapcraft/tests/test_sources.py 2015-10-05 19:37:43 +0000 | |||
1161 | @@ -98,7 +98,8 @@ | |||
1162 | 98 | bzr.pull() | 98 | bzr.pull() |
1163 | 99 | 99 | ||
1164 | 100 | self.mock_run.assert_called_once_with( | 100 | self.mock_run.assert_called_once_with( |
1166 | 101 | ['bzr', 'branch', '-r', 'tag:tag', 'lp:my-source', 'source_dir'], cwd=os.getcwd()) | 101 | ['bzr', 'branch', '-r', 'tag:tag', 'lp:my-source', |
1167 | 102 | 'source_dir'], cwd=os.getcwd()) | ||
1168 | 102 | 103 | ||
1169 | 103 | def test_pull_existing_with_tag(self): | 104 | def test_pull_existing_with_tag(self): |
1170 | 104 | self.mock_path_exists.return_value = True | 105 | self.mock_path_exists.return_value = True |
1171 | @@ -107,7 +108,8 @@ | |||
1172 | 107 | bzr.pull() | 108 | bzr.pull() |
1173 | 108 | 109 | ||
1174 | 109 | self.mock_run.assert_called_once_with( | 110 | self.mock_run.assert_called_once_with( |
1176 | 110 | ['bzr', 'pull', '-r', 'tag:tag', 'lp:my-source', '-d', 'source_dir'], cwd=os.getcwd()) | 111 | ['bzr', 'pull', '-r', 'tag:tag', 'lp:my-source', '-d', |
1177 | 112 | 'source_dir'], cwd=os.getcwd()) | ||
1178 | 111 | 113 | ||
1179 | 112 | def test_provision(self): | 114 | def test_provision(self): |
1180 | 113 | bzr = sources.Bazaar('lp:my-source', 'source_dir') | 115 | bzr = sources.Bazaar('lp:my-source', 'source_dir') |
1181 | @@ -135,18 +137,21 @@ | |||
1182 | 135 | ['git', 'clone', 'git://my-source', 'source_dir'], cwd=os.getcwd()) | 137 | ['git', 'clone', 'git://my-source', 'source_dir'], cwd=os.getcwd()) |
1183 | 136 | 138 | ||
1184 | 137 | def test_pull_branch(self): | 139 | def test_pull_branch(self): |
1186 | 138 | git = sources.Git('git://my-source', 'source_dir', source_branch='my-branch') | 140 | git = sources.Git('git://my-source', 'source_dir', |
1187 | 141 | source_branch='my-branch') | ||
1188 | 139 | git.pull() | 142 | git.pull() |
1189 | 140 | 143 | ||
1190 | 141 | self.mock_run.assert_called_once_with( | 144 | self.mock_run.assert_called_once_with( |
1192 | 142 | ['git', 'clone', '--branch', 'my-branch', 'git://my-source', 'source_dir'], cwd=os.getcwd()) | 145 | ['git', 'clone', '--branch', 'my-branch', 'git://my-source', |
1193 | 146 | 'source_dir'], cwd=os.getcwd()) | ||
1194 | 143 | 147 | ||
1195 | 144 | def test_pull_tag(self): | 148 | def test_pull_tag(self): |
1196 | 145 | git = sources.Git('git://my-source', 'source_dir', source_tag='tag') | 149 | git = sources.Git('git://my-source', 'source_dir', source_tag='tag') |
1197 | 146 | git.pull() | 150 | git.pull() |
1198 | 147 | 151 | ||
1199 | 148 | self.mock_run.assert_called_once_with( | 152 | self.mock_run.assert_called_once_with( |
1201 | 149 | ['git', 'clone', '--branch', 'tag', 'git://my-source', 'source_dir'], cwd=os.getcwd()) | 153 | ['git', 'clone', '--branch', 'tag', 'git://my-source', |
1202 | 154 | 'source_dir'], cwd=os.getcwd()) | ||
1203 | 150 | 155 | ||
1204 | 151 | def test_pull_existing(self): | 156 | def test_pull_existing(self): |
1205 | 152 | self.mock_path_exists.return_value = True | 157 | self.mock_path_exists.return_value = True |
1206 | @@ -155,7 +160,8 @@ | |||
1207 | 155 | git.pull() | 160 | git.pull() |
1208 | 156 | 161 | ||
1209 | 157 | self.mock_run.assert_called_once_with( | 162 | self.mock_run.assert_called_once_with( |
1211 | 158 | ['git', '-C', 'source_dir', 'pull', 'git://my-source', 'HEAD'], cwd=os.getcwd()) | 163 | ['git', '-C', 'source_dir', 'pull', 'git://my-source', |
1212 | 164 | 'HEAD'], cwd=os.getcwd()) | ||
1213 | 159 | 165 | ||
1214 | 160 | def test_pull_existing_with_tag(self): | 166 | def test_pull_existing_with_tag(self): |
1215 | 161 | self.mock_path_exists.return_value = True | 167 | self.mock_path_exists.return_value = True |
1216 | @@ -164,16 +170,19 @@ | |||
1217 | 164 | git.pull() | 170 | git.pull() |
1218 | 165 | 171 | ||
1219 | 166 | self.mock_run.assert_called_once_with( | 172 | self.mock_run.assert_called_once_with( |
1221 | 167 | ['git', '-C', 'source_dir', 'pull', 'git://my-source', 'refs/tags/tag'], cwd=os.getcwd()) | 173 | ['git', '-C', 'source_dir', 'pull', 'git://my-source', |
1222 | 174 | 'refs/tags/tag'], cwd=os.getcwd()) | ||
1223 | 168 | 175 | ||
1224 | 169 | def test_pull_existing_with_branch(self): | 176 | def test_pull_existing_with_branch(self): |
1225 | 170 | self.mock_path_exists.return_value = True | 177 | self.mock_path_exists.return_value = True |
1226 | 171 | 178 | ||
1228 | 172 | git = sources.Git('git://my-source', 'source_dir', source_branch='my-branch') | 179 | git = sources.Git('git://my-source', 'source_dir', |
1229 | 180 | source_branch='my-branch') | ||
1230 | 173 | git.pull() | 181 | git.pull() |
1231 | 174 | 182 | ||
1232 | 175 | self.mock_run.assert_called_once_with( | 183 | self.mock_run.assert_called_once_with( |
1234 | 176 | ['git', '-C', 'source_dir', 'pull', 'git://my-source', 'refs/heads/my-branch'], cwd=os.getcwd()) | 184 | ['git', '-C', 'source_dir', 'pull', 'git://my-source', |
1235 | 185 | 'refs/heads/my-branch'], cwd=os.getcwd()) | ||
1236 | 177 | 186 | ||
1237 | 178 | def test_provision(self): | 187 | def test_provision(self): |
1238 | 179 | bzr = sources.Git('git://my-source', 'source_dir') | 188 | bzr = sources.Git('git://my-source', 'source_dir') |
1239 | @@ -184,9 +193,11 @@ | |||
1240 | 184 | 193 | ||
1241 | 185 | def test_init_with_source_branch_and_tag_raises_exception(self): | 194 | def test_init_with_source_branch_and_tag_raises_exception(self): |
1242 | 186 | with self.assertRaises(sources.IncompatibleOptionsError) as raised: | 195 | with self.assertRaises(sources.IncompatibleOptionsError) as raised: |
1244 | 187 | sources.Git('git://mysource', 'source_dir', source_tag='tag', source_branch='branch') | 196 | sources.Git('git://mysource', 'source_dir', source_tag='tag', |
1245 | 197 | source_branch='branch') | ||
1246 | 188 | 198 | ||
1248 | 189 | expected_message = 'can\'t specify both source-tag and source-branch for a git source' | 199 | expected_message = \ |
1249 | 200 | 'can\'t specify both source-tag and source-branch for a git source' | ||
1250 | 190 | self.assertEqual(raised.exception.message, expected_message) | 201 | self.assertEqual(raised.exception.message, expected_message) |
1251 | 191 | 202 | ||
1252 | 192 | 203 | ||
1253 | @@ -200,18 +211,22 @@ | |||
1254 | 200 | ['hg', 'clone', 'hg://my-source', 'source_dir'], cwd=os.getcwd()) | 211 | ['hg', 'clone', 'hg://my-source', 'source_dir'], cwd=os.getcwd()) |
1255 | 201 | 212 | ||
1256 | 202 | def test_pull_branch(self): | 213 | def test_pull_branch(self): |
1258 | 203 | hg = sources.Mercurial('hg://my-source', 'source_dir', source_branch='my-branch') | 214 | hg = sources.Mercurial('hg://my-source', 'source_dir', |
1259 | 215 | source_branch='my-branch') | ||
1260 | 204 | hg.pull() | 216 | hg.pull() |
1261 | 205 | 217 | ||
1262 | 206 | self.mock_run.assert_called_once_with( | 218 | self.mock_run.assert_called_once_with( |
1264 | 207 | ['hg', 'clone', '-u', 'my-branch', 'hg://my-source', 'source_dir'], cwd=os.getcwd()) | 219 | ['hg', 'clone', '-u', 'my-branch', 'hg://my-source', |
1265 | 220 | 'source_dir'], cwd=os.getcwd()) | ||
1266 | 208 | 221 | ||
1267 | 209 | def test_pull_tag(self): | 222 | def test_pull_tag(self): |
1269 | 210 | hg = sources.Mercurial('hg://my-source', 'source_dir', source_tag='tag') | 223 | hg = sources.Mercurial('hg://my-source', 'source_dir', |
1270 | 224 | source_tag='tag') | ||
1271 | 211 | hg.pull() | 225 | hg.pull() |
1272 | 212 | 226 | ||
1273 | 213 | self.mock_run.assert_called_once_with( | 227 | self.mock_run.assert_called_once_with( |
1275 | 214 | ['hg', 'clone', '-u', 'tag', 'hg://my-source', 'source_dir'], cwd=os.getcwd()) | 228 | ['hg', 'clone', '-u', 'tag', 'hg://my-source', |
1276 | 229 | 'source_dir'], cwd=os.getcwd()) | ||
1277 | 215 | 230 | ||
1278 | 216 | def test_pull_existing(self): | 231 | def test_pull_existing(self): |
1279 | 217 | self.mock_path_exists.return_value = True | 232 | self.mock_path_exists.return_value = True |
1280 | @@ -225,7 +240,8 @@ | |||
1281 | 225 | def test_pull_existing_with_tag(self): | 240 | def test_pull_existing_with_tag(self): |
1282 | 226 | self.mock_path_exists.return_value = True | 241 | self.mock_path_exists.return_value = True |
1283 | 227 | 242 | ||
1285 | 228 | hg = sources.Mercurial('hg://my-source', 'source_dir', source_tag='tag') | 243 | hg = sources.Mercurial('hg://my-source', 'source_dir', |
1286 | 244 | source_tag='tag') | ||
1287 | 229 | hg.pull() | 245 | hg.pull() |
1288 | 230 | 246 | ||
1289 | 231 | self.mock_run.assert_called_once_with( | 247 | self.mock_run.assert_called_once_with( |
1290 | @@ -234,11 +250,13 @@ | |||
1291 | 234 | def test_pull_existing_with_branch(self): | 250 | def test_pull_existing_with_branch(self): |
1292 | 235 | self.mock_path_exists.return_value = True | 251 | self.mock_path_exists.return_value = True |
1293 | 236 | 252 | ||
1295 | 237 | hg = sources.Mercurial('hg://my-source', 'source_dir', source_branch='my-branch') | 253 | hg = sources.Mercurial('hg://my-source', 'source_dir', |
1296 | 254 | source_branch='my-branch') | ||
1297 | 238 | hg.pull() | 255 | hg.pull() |
1298 | 239 | 256 | ||
1299 | 240 | self.mock_run.assert_called_once_with( | 257 | self.mock_run.assert_called_once_with( |
1301 | 241 | ['hg', 'pull', '-b', 'my-branch', 'hg://my-source'], cwd=os.getcwd()) | 258 | ['hg', 'pull', '-b', 'my-branch', 'hg://my-source'], |
1302 | 259 | cwd=os.getcwd()) | ||
1303 | 242 | 260 | ||
1304 | 243 | def test_provision(self): | 261 | def test_provision(self): |
1305 | 244 | bzr = sources.Mercurial('hg://my-source', 'source_dir') | 262 | bzr = sources.Mercurial('hg://my-source', 'source_dir') |
1306 | @@ -249,9 +267,12 @@ | |||
1307 | 249 | 267 | ||
1308 | 250 | def test_init_with_source_branch_and_tag_raises_exception(self): | 268 | def test_init_with_source_branch_and_tag_raises_exception(self): |
1309 | 251 | with self.assertRaises(sources.IncompatibleOptionsError) as raised: | 269 | with self.assertRaises(sources.IncompatibleOptionsError) as raised: |
1311 | 252 | sources.Mercurial('hg://mysource', 'source_dir', source_tag='tag', source_branch='branch') | 270 | sources.Mercurial('hg://mysource', 'source_dir', source_tag='tag', |
1312 | 271 | source_branch='branch') | ||
1313 | 253 | 272 | ||
1315 | 254 | expected_message = 'can\'t specify both source-tag and source-branch for a mercurial source' | 273 | expected_message = ( |
1316 | 274 | 'can\'t specify both source-tag and source-branch for a mercurial ' | ||
1317 | 275 | 'source') | ||
1318 | 255 | self.assertEqual(raised.exception.message, expected_message) | 276 | self.assertEqual(raised.exception.message, expected_message) |
1319 | 256 | 277 | ||
1320 | 257 | 278 | ||
1321 | @@ -288,7 +309,8 @@ | |||
1322 | 288 | local.provision('dst') | 309 | local.provision('dst') |
1323 | 289 | 310 | ||
1324 | 290 | self.mock_rmdir.assert_called_once_with('dst') | 311 | self.mock_rmdir.assert_called_once_with('dst') |
1326 | 291 | self.mock_symlink.assert_called_once_with('/home/ubuntu/sources/snap/source', 'dst') | 312 | self.mock_symlink.assert_called_once_with( |
1327 | 313 | '/home/ubuntu/sources/snap/source', 'dst') | ||
1328 | 292 | 314 | ||
1329 | 293 | def test_provision_when_target_is_file(self): | 315 | def test_provision_when_target_is_file(self): |
1330 | 294 | self.mock_isdir.return_value = False | 316 | self.mock_isdir.return_value = False |
1331 | @@ -297,4 +319,5 @@ | |||
1332 | 297 | local.provision('dst') | 319 | local.provision('dst') |
1333 | 298 | 320 | ||
1334 | 299 | self.mock_remove.assert_called_once_with('dst') | 321 | self.mock_remove.assert_called_once_with('dst') |
1336 | 300 | self.mock_symlink.assert_called_once_with('/home/ubuntu/sources/snap/source', 'dst') | 322 | self.mock_symlink.assert_called_once_with( |
1337 | 323 | '/home/ubuntu/sources/snap/source', 'dst') | ||
1338 | 301 | 324 | ||
1339 | === modified file 'snapcraft/tests/test_yaml.py' | |||
1340 | --- snapcraft/tests/test_yaml.py 2015-10-01 08:54:15 +0000 | |||
1341 | +++ snapcraft/tests/test_yaml.py 2015-10-05 19:37:43 +0000 | |||
1342 | @@ -101,7 +101,8 @@ | |||
1343 | 101 | self.useFixture(fake_logger) | 101 | self.useFixture(fake_logger) |
1344 | 102 | 102 | ||
1345 | 103 | # no snapcraft.yaml | 103 | # no snapcraft.yaml |
1347 | 104 | with self.assertRaises(snapcraft.yaml.SnapcraftYamlFileError) as raised: | 104 | with self.assertRaises( |
1348 | 105 | snapcraft.yaml.SnapcraftYamlFileError) as raised: | ||
1349 | 105 | snapcraft.yaml.Config() | 106 | snapcraft.yaml.Config() |
1350 | 106 | 107 | ||
1351 | 107 | self.assertEqual(raised.exception.file, 'snapcraft.yaml') | 108 | self.assertEqual(raised.exception.file, 'snapcraft.yaml') |
1352 | @@ -130,7 +131,9 @@ | |||
1353 | 130 | with self.assertRaises(snapcraft.yaml.SnapcraftLogicError) as raised: | 131 | with self.assertRaises(snapcraft.yaml.SnapcraftLogicError) as raised: |
1354 | 131 | snapcraft.yaml.Config() | 132 | snapcraft.yaml.Config() |
1355 | 132 | 133 | ||
1357 | 133 | self.assertEqual(raised.exception.message, 'circular dependency chain found in parts definition') | 134 | self.assertEqual( |
1358 | 135 | raised.exception.message, | ||
1359 | 136 | 'circular dependency chain found in parts definition') | ||
1360 | 134 | self.assertFalse(self.mock_wiki.get_part.called) | 137 | self.assertFalse(self.mock_wiki.get_part.called) |
1361 | 135 | 138 | ||
1362 | 136 | @unittest.mock.patch('snapcraft.yaml.Config.load_plugin') | 139 | @unittest.mock.patch('snapcraft.yaml.Config.load_plugin') |
1363 | @@ -153,7 +156,8 @@ | |||
1364 | 153 | with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised: | 156 | with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised: |
1365 | 154 | snapcraft.yaml.Config() | 157 | snapcraft.yaml.Config() |
1366 | 155 | 158 | ||
1368 | 156 | self.assertEqual(raised.exception.message, '\'name\' is a required property') | 159 | self.assertEqual(raised.exception.message, |
1369 | 160 | '\'name\' is a required property') | ||
1370 | 157 | 161 | ||
1371 | 158 | @unittest.mock.patch('snapcraft.yaml.Config.load_plugin') | 162 | @unittest.mock.patch('snapcraft.yaml.Config.load_plugin') |
1372 | 159 | def test_invalid_yaml_invalid_name_as_number(self, mock_loadPlugin): | 163 | def test_invalid_yaml_invalid_name_as_number(self, mock_loadPlugin): |
1373 | @@ -175,7 +179,8 @@ | |||
1374 | 175 | with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised: | 179 | with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised: |
1375 | 176 | snapcraft.yaml.Config() | 180 | snapcraft.yaml.Config() |
1376 | 177 | 181 | ||
1378 | 178 | self.assertEqual(raised.exception.message, '1 is not of type \'string\'') | 182 | self.assertEqual(raised.exception.message, |
1379 | 183 | '1 is not of type \'string\'') | ||
1380 | 179 | 184 | ||
1381 | 180 | @unittest.mock.patch('snapcraft.yaml.Config.load_plugin') | 185 | @unittest.mock.patch('snapcraft.yaml.Config.load_plugin') |
1382 | 181 | def test_invalid_yaml_invalid_name_chars(self, mock_loadPlugin): | 186 | def test_invalid_yaml_invalid_name_chars(self, mock_loadPlugin): |
1383 | @@ -197,7 +202,9 @@ | |||
1384 | 197 | with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised: | 202 | with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised: |
1385 | 198 | snapcraft.yaml.Config() | 203 | snapcraft.yaml.Config() |
1386 | 199 | 204 | ||
1388 | 200 | self.assertEqual(raised.exception.message, '\'myapp@me_1.0\' does not match \'^[a-z0-9][a-z0-9+-]*$\'') | 205 | self.assertEqual( |
1389 | 206 | raised.exception.message, | ||
1390 | 207 | '\'myapp@me_1.0\' does not match \'^[a-z0-9][a-z0-9+-]*$\'') | ||
1391 | 201 | 208 | ||
1392 | 202 | @unittest.mock.patch('snapcraft.yaml.Config.load_plugin') | 209 | @unittest.mock.patch('snapcraft.yaml.Config.load_plugin') |
1393 | 203 | def test_deprecation_for_type(self, mock_loadPlugin): | 210 | def test_deprecation_for_type(self, mock_loadPlugin): |
1394 | @@ -240,7 +247,9 @@ | |||
1395 | 240 | with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised: | 247 | with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised: |
1396 | 241 | snapcraft.yaml.Config() | 248 | snapcraft.yaml.Config() |
1397 | 242 | 249 | ||
1399 | 243 | self.assertEqual(raised.exception.message, '\'description\' is a required property') | 250 | self.assertEqual( |
1400 | 251 | raised.exception.message, | ||
1401 | 252 | '\'description\' is a required property') | ||
1402 | 244 | 253 | ||
1403 | 245 | @unittest.mock.patch('snapcraft.yaml.Config.load_plugin') | 254 | @unittest.mock.patch('snapcraft.yaml.Config.load_plugin') |
1404 | 246 | def test_tab_in_yaml(self, mock_loadPlugin): | 255 | def test_tab_in_yaml(self, mock_loadPlugin): |
1405 | @@ -296,7 +305,8 @@ | |||
1406 | 296 | snapcraft.yaml.Config() | 305 | snapcraft.yaml.Config() |
1407 | 297 | 306 | ||
1408 | 298 | mock_loadPlugin.assert_called_with('part1', 'go', { | 307 | mock_loadPlugin.assert_called_with('part1', 'go', { |
1410 | 299 | 'snap': ['/usr/lib/wget.so', '/usr/bin/wget', '/usr/share/my-icon.png'], | 308 | 'snap': ['/usr/lib/wget.so', '/usr/bin/wget', |
1411 | 309 | '/usr/share/my-icon.png'], | ||
1412 | 300 | 'stage-packages': ['fswebcam'], | 310 | 'stage-packages': ['fswebcam'], |
1413 | 301 | 'stage': ['/usr/lib/wget.so', '/usr/bin/wget', '/usr/lib/wget.a'], | 311 | 'stage': ['/usr/lib/wget.so', '/usr/bin/wget', '/usr/lib/wget.a'], |
1414 | 302 | }) | 312 | }) |
1415 | @@ -333,11 +343,13 @@ | |||
1416 | 333 | with self.subTest(key=key): | 343 | with self.subTest(key=key): |
1417 | 334 | del data[key] | 344 | del data[key] |
1418 | 335 | 345 | ||
1420 | 336 | with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised: | 346 | with self.assertRaises( |
1421 | 347 | snapcraft.yaml.SnapcraftSchemaError) as raised: | ||
1422 | 337 | snapcraft.yaml._validate_snapcraft_yaml(data) | 348 | snapcraft.yaml._validate_snapcraft_yaml(data) |
1423 | 338 | 349 | ||
1424 | 339 | expected_message = '\'{}\' is a required property'.format(key) | 350 | expected_message = '\'{}\' is a required property'.format(key) |
1426 | 340 | self.assertEqual(raised.exception.message, expected_message, msg=data) | 351 | self.assertEqual(raised.exception.message, expected_message, |
1427 | 352 | msg=data) | ||
1428 | 341 | 353 | ||
1429 | 342 | def test_invalid_names(self): | 354 | def test_invalid_names(self): |
1430 | 343 | invalid_names = [ | 355 | invalid_names = [ |
1431 | @@ -351,11 +363,15 @@ | |||
1432 | 351 | with self.subTest(key=name): | 363 | with self.subTest(key=name): |
1433 | 352 | data['name'] = name | 364 | data['name'] = name |
1434 | 353 | 365 | ||
1436 | 354 | with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised: | 366 | with self.assertRaises( |
1437 | 367 | snapcraft.yaml.SnapcraftSchemaError) as raised: | ||
1438 | 355 | snapcraft.yaml._validate_snapcraft_yaml(data) | 368 | snapcraft.yaml._validate_snapcraft_yaml(data) |
1439 | 356 | 369 | ||
1442 | 357 | expected_message = '\'{}\' does not match \'^[a-z0-9][a-z0-9+-]*$\''.format(name) | 370 | expected_message = ( |
1443 | 358 | self.assertEqual(raised.exception.message, expected_message, msg=data) | 371 | '\'{}\' does not match \'^[a-z0-9][a-z0-9+-]*$\'').format( |
1444 | 372 | name) | ||
1445 | 373 | self.assertEqual(raised.exception.message, expected_message, | ||
1446 | 374 | msg=data) | ||
1447 | 359 | 375 | ||
1448 | 360 | def test_summary_too_long(self): | 376 | def test_summary_too_long(self): |
1449 | 361 | self.data['summary'] = 'a' * 80 | 377 | self.data['summary'] = 'a' * 80 |
1450 | @@ -363,7 +379,8 @@ | |||
1451 | 363 | snapcraft.yaml._validate_snapcraft_yaml(self.data) | 379 | snapcraft.yaml._validate_snapcraft_yaml(self.data) |
1452 | 364 | 380 | ||
1453 | 365 | expected_message = '\'{}\' is too long'.format(self.data['summary']) | 381 | expected_message = '\'{}\' is too long'.format(self.data['summary']) |
1455 | 366 | self.assertEqual(raised.exception.message, expected_message, msg=self.data) | 382 | self.assertEqual(raised.exception.message, expected_message, |
1456 | 383 | msg=self.data) | ||
1457 | 367 | 384 | ||
1458 | 368 | def test_valid_types(self): | 385 | def test_valid_types(self): |
1459 | 369 | self.data['type'] = 'app' | 386 | self.data['type'] = 'app' |
1460 | @@ -386,11 +403,14 @@ | |||
1461 | 386 | with self.subTest(key=t): | 403 | with self.subTest(key=t): |
1462 | 387 | data['type'] = t | 404 | data['type'] = t |
1463 | 388 | 405 | ||
1465 | 389 | with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised: | 406 | with self.assertRaises( |
1466 | 407 | snapcraft.yaml.SnapcraftSchemaError) as raised: | ||
1467 | 390 | snapcraft.yaml._validate_snapcraft_yaml(data) | 408 | snapcraft.yaml._validate_snapcraft_yaml(data) |
1468 | 391 | 409 | ||
1471 | 392 | expected_message = '\'{}\' is not one of [\'app\', \'framework\']'.format(t) | 410 | expected_message = ('\'{}\' is not one of ' + |
1472 | 393 | self.assertEqual(raised.exception.message, expected_message, msg=data) | 411 | '[\'app\', \'framework\']').format(t) |
1473 | 412 | self.assertEqual(raised.exception.message, expected_message, | ||
1474 | 413 | msg=data) | ||
1475 | 394 | 414 | ||
1476 | 395 | def test_valid_services(self): | 415 | def test_valid_services(self): |
1477 | 396 | self.data['services'] = { | 416 | self.data['services'] = { |
1478 | @@ -416,11 +436,14 @@ | |||
1479 | 416 | with self.subTest(key=t): | 436 | with self.subTest(key=t): |
1480 | 417 | data['binaries'] = {t: invalid_names[t]} | 437 | data['binaries'] = {t: invalid_names[t]} |
1481 | 418 | 438 | ||
1483 | 419 | with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised: | 439 | with self.assertRaises( |
1484 | 440 | snapcraft.yaml.SnapcraftSchemaError) as raised: | ||
1485 | 420 | snapcraft.yaml._validate_snapcraft_yaml(data) | 441 | snapcraft.yaml._validate_snapcraft_yaml(data) |
1486 | 421 | 442 | ||
1489 | 422 | expected_message = 'Additional properties are not allowed (\'{}\' was unexpected)'.format(t) | 443 | expected_message = ('Additional properties are not allowed ' |
1490 | 423 | self.assertEqual(raised.exception.message, expected_message, msg=data) | 444 | '(\'{}\' was unexpected)').format(t) |
1491 | 445 | self.assertEqual(raised.exception.message, expected_message, | ||
1492 | 446 | msg=data) | ||
1493 | 424 | 447 | ||
1494 | 425 | def test_invalid_service_names(self): | 448 | def test_invalid_service_names(self): |
1495 | 426 | invalid_names = { | 449 | invalid_names = { |
1496 | @@ -435,11 +458,14 @@ | |||
1497 | 435 | with self.subTest(key=t): | 458 | with self.subTest(key=t): |
1498 | 436 | data['services'] = {t: invalid_names[t]} | 459 | data['services'] = {t: invalid_names[t]} |
1499 | 437 | 460 | ||
1501 | 438 | with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised: | 461 | with self.assertRaises( |
1502 | 462 | snapcraft.yaml.SnapcraftSchemaError) as raised: | ||
1503 | 439 | snapcraft.yaml._validate_snapcraft_yaml(data) | 463 | snapcraft.yaml._validate_snapcraft_yaml(data) |
1504 | 440 | 464 | ||
1507 | 441 | expected_message = 'Additional properties are not allowed (\'{}\' was unexpected)'.format(t) | 465 | expected_message = ('Additional properties are not allowed ' |
1508 | 442 | self.assertEqual(raised.exception.message, expected_message, msg=data) | 466 | '(\'{}\' was unexpected)').format(t) |
1509 | 467 | self.assertEqual(raised.exception.message, expected_message, | ||
1510 | 468 | msg=data) | ||
1511 | 443 | 469 | ||
1512 | 444 | def test_services_required_properties(self): | 470 | def test_services_required_properties(self): |
1513 | 445 | self.data['services'] = {'service1': {}} | 471 | self.data['services'] = {'service1': {}} |
1514 | @@ -448,19 +474,24 @@ | |||
1515 | 448 | snapcraft.yaml._validate_snapcraft_yaml(self.data) | 474 | snapcraft.yaml._validate_snapcraft_yaml(self.data) |
1516 | 449 | 475 | ||
1517 | 450 | expected_message = '\'start\' is a required property' | 476 | expected_message = '\'start\' is a required property' |
1519 | 451 | self.assertEqual(raised.exception.message, expected_message, msg=self.data) | 477 | self.assertEqual(raised.exception.message, expected_message, |
1520 | 478 | msg=self.data) | ||
1521 | 452 | 479 | ||
1522 | 453 | def test_schema_file_not_found(self): | 480 | def test_schema_file_not_found(self): |
1523 | 454 | mock_the_open = unittest.mock.mock_open() | 481 | mock_the_open = unittest.mock.mock_open() |
1524 | 455 | mock_the_open.side_effect = FileNotFoundError() | 482 | mock_the_open.side_effect = FileNotFoundError() |
1525 | 456 | 483 | ||
1528 | 457 | with unittest.mock.patch('snapcraft.yaml.open', mock_the_open, create=True): | 484 | with unittest.mock.patch('snapcraft.yaml.open', mock_the_open, |
1529 | 458 | with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised: | 485 | create=True): |
1530 | 486 | with self.assertRaises( | ||
1531 | 487 | snapcraft.yaml.SnapcraftSchemaError) as raised: | ||
1532 | 459 | snapcraft.yaml._validate_snapcraft_yaml(self.data) | 488 | snapcraft.yaml._validate_snapcraft_yaml(self.data) |
1533 | 460 | 489 | ||
1535 | 461 | expected_path = os.path.join(snapcraft.common.get_schemadir(), 'snapcraft.yaml') | 490 | expected_path = os.path.join(snapcraft.common.get_schemadir(), |
1536 | 491 | 'snapcraft.yaml') | ||
1537 | 462 | mock_the_open.assert_called_once_with(expected_path) | 492 | mock_the_open.assert_called_once_with(expected_path) |
1539 | 463 | expected_message = 'snapcraft validation file is missing from installation path' | 493 | expected_message = ('snapcraft validation file is missing from ' |
1540 | 494 | 'installation path') | ||
1541 | 464 | self.assertEqual(raised.exception.message, expected_message) | 495 | self.assertEqual(raised.exception.message, expected_message) |
1542 | 465 | 496 | ||
1543 | 466 | def test_icon_missing(self): | 497 | def test_icon_missing(self): |
1544 | @@ -470,7 +501,8 @@ | |||
1545 | 470 | snapcraft.yaml._validate_snapcraft_yaml(self.data) | 501 | snapcraft.yaml._validate_snapcraft_yaml(self.data) |
1546 | 471 | 502 | ||
1547 | 472 | expected_message = '\'my-icon.png\' is not a \'icon-path\'' | 503 | expected_message = '\'my-icon.png\' is not a \'icon-path\'' |
1549 | 473 | self.assertEqual(raised.exception.message, expected_message, msg=self.data) | 504 | self.assertEqual(raised.exception.message, expected_message, |
1550 | 505 | msg=self.data) | ||
1551 | 474 | 506 | ||
1552 | 475 | 507 | ||
1553 | 476 | class TestFilesets(TestCase): | 508 | class TestFilesets(TestCase): |
1554 | 477 | 509 | ||
1555 | === modified file 'snapcraft/yaml.py' | |||
1556 | --- snapcraft/yaml.py 2015-10-02 18:25:33 +0000 | |||
1557 | +++ snapcraft/yaml.py 2015-10-05 19:37:43 +0000 | |||
1558 | @@ -145,14 +145,16 @@ | |||
1559 | 145 | present = True | 145 | present = True |
1560 | 146 | break | 146 | break |
1561 | 147 | if not present: | 147 | if not present: |
1563 | 148 | new_parts.append(self.load_plugin(required_part, required_part, {})) | 148 | new_parts.append(self.load_plugin(required_part, |
1564 | 149 | required_part, {})) | ||
1565 | 149 | 150 | ||
1566 | 150 | def _compute_part_dependencies(self, after_requests): | 151 | def _compute_part_dependencies(self, after_requests): |
1567 | 151 | '''Gather the lists of dependencies and adds to all_parts.''' | 152 | '''Gather the lists of dependencies and adds to all_parts.''' |
1568 | 152 | w = snapcraft.wiki.Wiki() | 153 | w = snapcraft.wiki.Wiki() |
1569 | 153 | 154 | ||
1570 | 154 | for part in self.all_parts: | 155 | for part in self.all_parts: |
1572 | 155 | dep_names = part.config.get('requires', []) + after_requests.get(part.names()[0], []) | 156 | dep_names = part.config.get('requires', []) + \ |
1573 | 157 | after_requests.get(part.names()[0], []) | ||
1574 | 156 | for dep in dep_names: | 158 | for dep in dep_names: |
1575 | 157 | found = False | 159 | found = False |
1576 | 158 | for i in range(len(self.all_parts)): | 160 | for i in range(len(self.all_parts)): |
1577 | @@ -164,9 +166,11 @@ | |||
1578 | 164 | wiki_part = w.get_part(dep) | 166 | wiki_part = w.get_part(dep) |
1579 | 165 | found = True if wiki_part else False | 167 | found = True if wiki_part else False |
1580 | 166 | if found: | 168 | if found: |
1582 | 167 | part.deps.append(self.load_plugin(dep, wiki_part['plugin'], wiki_part)) | 169 | part.deps.append(self.load_plugin( |
1583 | 170 | dep, wiki_part['plugin'], wiki_part)) | ||
1584 | 168 | if not found: | 171 | if not found: |
1586 | 169 | raise SnapcraftLogicError('part name missing {}'.format(dep)) | 172 | raise SnapcraftLogicError( |
1587 | 173 | 'part name missing {}'.format(dep)) | ||
1588 | 170 | 174 | ||
1589 | 171 | def _sort_parts(self): | 175 | def _sort_parts(self): |
1590 | 172 | '''Performs an inneficient but easy to follow sorting of parts.''' | 176 | '''Performs an inneficient but easy to follow sorting of parts.''' |
1591 | @@ -184,14 +188,16 @@ | |||
1592 | 184 | top_part = part | 188 | top_part = part |
1593 | 185 | break | 189 | break |
1594 | 186 | if not top_part: | 190 | if not top_part: |
1596 | 187 | raise SnapcraftLogicError('circular dependency chain found in parts definition') | 191 | raise SnapcraftLogicError( |
1597 | 192 | 'circular dependency chain found in parts definition') | ||
1598 | 188 | sorted_parts = [top_part] + sorted_parts | 193 | sorted_parts = [top_part] + sorted_parts |
1599 | 189 | self.all_parts.remove(top_part) | 194 | self.all_parts.remove(top_part) |
1600 | 190 | 195 | ||
1601 | 191 | return sorted_parts | 196 | return sorted_parts |
1602 | 192 | 197 | ||
1603 | 193 | def load_plugin(self, part_name, plugin_name, properties, load_code=True): | 198 | def load_plugin(self, part_name, plugin_name, properties, load_code=True): |
1605 | 194 | part = snapcraft.plugin.load_plugin(part_name, plugin_name, properties, load_code=load_code) | 199 | part = snapcraft.plugin.load_plugin(part_name, plugin_name, |
1606 | 200 | properties, load_code=load_code) | ||
1607 | 195 | 201 | ||
1608 | 196 | self.build_tools += part.config.get('build-packages', []) | 202 | self.build_tools += part.config.get('build-packages', []) |
1609 | 197 | self.all_parts.append(part) | 203 | self.all_parts.append(part) |
1610 | @@ -280,15 +286,18 @@ | |||
1611 | 280 | 286 | ||
1612 | 281 | 287 | ||
1613 | 282 | def _validate_snapcraft_yaml(snapcraft_yaml): | 288 | def _validate_snapcraft_yaml(snapcraft_yaml): |
1615 | 283 | schema_file = os.path.abspath(os.path.join(common.get_schemadir(), 'snapcraft.yaml')) | 289 | schema_file = os.path.abspath(os.path.join(common.get_schemadir(), |
1616 | 290 | 'snapcraft.yaml')) | ||
1617 | 284 | 291 | ||
1618 | 285 | try: | 292 | try: |
1619 | 286 | with open(schema_file) as fp: | 293 | with open(schema_file) as fp: |
1620 | 287 | schema = yaml.load(fp) | 294 | schema = yaml.load(fp) |
1621 | 288 | format_check = jsonschema.FormatChecker() | 295 | format_check = jsonschema.FormatChecker() |
1623 | 289 | jsonschema.validate(snapcraft_yaml, schema, format_checker=format_check) | 296 | jsonschema.validate(snapcraft_yaml, schema, |
1624 | 297 | format_checker=format_check) | ||
1625 | 290 | except FileNotFoundError: | 298 | except FileNotFoundError: |
1627 | 291 | raise SnapcraftSchemaError('snapcraft validation file is missing from installation path') | 299 | raise SnapcraftSchemaError( |
1628 | 300 | 'snapcraft validation file is missing from installation path') | ||
1629 | 292 | except jsonschema.ValidationError as e: | 301 | except jsonschema.ValidationError as e: |
1630 | 293 | raise SnapcraftSchemaError(e.message) | 302 | raise SnapcraftSchemaError(e.message) |
1631 | 294 | 303 |
If we are going to do this, maybe also remove the pep8 exception