Merge lp:~elopio/snapcraft/fix-pep8-and-doc-indentation into lp:~snappy-dev/snapcraft/core

Proposed by Leo Arias
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
Reviewer Review Type Date Requested Status
Leo Arias (community) Approve
Daniel Holbach Pending
Sergio Schvezov Pending
John Lenton Pending
Review via email: mp+273446@code.launchpad.net

This proposal supersedes a proposal from 2015-10-02.

Commit message

Fix markdown indentation, make pep8 and pyflakes3 happy.

To post a comment you must log in.
Revision history for this message
Sergio Schvezov (sergiusens) wrote : Posted in a previous version of this proposal

If we are going to do this, maybe also remove the pep8 exception

review: Needs Fixing
Revision history for this message
Daniel Holbach (dholbach) wrote : Posted in a previous version of this proposal

Done.

Revision history for this message
John Lenton (chipaca) wrote : Posted in a previous version of this proposal

LGTM :)

review: Approve
Revision history for this message
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

Revision history for this message
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/meta.py:115:49: E126 continuation line over-indented for hanging indent
snapcraft/meta.py:116:49: E126 continuation line over-indented for hanging indent
snapcraft/meta.py:118:49: E126 continuation line over-indented for hanging indent
snapcraft/meta.py:119:49: E126 continuation line over-indented for hanging indent
snapcraft/meta.py:149:37: E126 continuation line over-indented for hanging indent
snapcraft/meta.py:150:37: E126 continuation line over-indented for hanging indent
snapcraft/meta.py:156:37: E126 continuation line over-indented for hanging indent
snapcraft/meta.py:157:37: E126 continuation line over-indented for hanging indent
snapcraft/meta.py:172:17: E126 continuation line over-indented for hanging indent
snapcraft/plugin.py:187:17: E126 continuation line over-indented for hanging indent
snapcraft/repo.py:31:80: E501 line too long (91 > 79 characters)
snapcraft/sources.py:68:21: E126 continuation line over-indented for hanging indent
snapcraft/yaml.py:157:25: E126 continuation line over-indented for hanging indent
snapcraft/tests/test_repo.py:34:80: E501 line too long (97 > 79 characters)
snapcraft/tests/test_repo.py:51:80: E501 line too long (99 > 79 characters)
snapcraft/tests/test_repo.py:34:80: E501 line too long (97 > 79 characters)
snapcraft/tests/test_repo.py:51:80: E501 line too long (99 > 79 characters)

Revision history for this message
Daniel Holbach (dholbach) wrote : Posted in a previous version of this proposal

Could this be tarmac is using an old pep8?

review: Needs Information
Revision history for this message
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://code.launchpad.net/~dholbach/snapcraft/fix-pep8-and-doc-indentation/+merge/273195)
<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.

Revision history for this message
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/common.py:81: undefined name 'decode'

Revision history for this message
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.

review: Approve
Revision history for this message
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/common.py:81:17: E126 continuation line over-indented for hanging indent

Revision history for this message
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/common.py:81:17: E126 continuation line over-indented for hanging indent

Revision history for this message
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/common.py:81:17: E126 continuation line over-indented for hanging indent

Revision history for this message
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/common.py:81:17: E126 continuation line over-indented for hanging indent

Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :
Download full text (4.1 KiB)

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/tmpu9u848ie/parts/copy/install/zzz
cp --preserve=all -R src /tmp/tmp79huuwcn/parts/copy/install/dst
cp --preserve=all -R src /tmp/tmps1vpx7b4/parts/copy/install/dir/dst

...................................Warning: unable to find "test_relexepath" in the path
.................................F.................................
======================================================================
FAIL: test_init_with_source_branch_and_tag_raises_exception (snapcraft.tests.test_sources.TestMercurial)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/tarmac/branch.DenRbR/snapcraft/tests/test_sources.py", line 275, in test_init_with_source_branch_and_tag_raises_exception
    self.assertEqual(raised.exception.message, expected_message)
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.tests.test_yaml.TestValidation) (key='package@awesome')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/tarmac/branch.DenRbR/snapcraft/tests/test_yaml.py", line 373, in test_invalid_names
    msg=data)
AssertionError: "'package@awesome' does not match '^[a-z0-9][a-z0-9+-]*$'" != "'{}' does not match "
- 'package@awesome' does not match '^[a-z0-9][a-z0-9+-]*$'
+ '{}' does not match
 : {'description': 'description which can be pretty long', 'version': '1.0-snapcraft1~ppa1', 'icon': 'my-icon.png', 'vendor': 'Me <email address hidden>', 'summary': 'my summary less that 79 chars', 'name': 'package@awesome', 'parts': {'part1': {'plugin': 'project'}}}

======================================================================
FAIL: test_invalid_names (snapcraft.tests.test_yaml.TestValidation) (key='something.another')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/tarmac/branch.DenRbR/snapcraft/tests/test_yaml.py", line 373, in test_invalid_names
    msg=data)
AssertionError: "'something.another' does not match '^[a-z0-9][a-z0-9+-]*$'" != "'{}' does not match "
- 'something.another' does not match '^[a-z0-9][a-z0-9+-]*$'
+ '{}' does not match
 : {'description': 'description which can be pretty long', 'version': '1.0-snapcraft1~ppa1', 'icon': 'my-icon.png', 'vendor': 'Me <email address hidden>', 'summary': 'my summary less that 79 chars', 'name': 'so...

Read more...

Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

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

oh come on!

Revision history for this message
Leo Arias (elopio) :
review: Approve
Revision history for this message
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/tests/test_yaml.py:372:25: E126 continuation line over-indented for hanging indent
snapcraft/tests/test_yaml.py:372:25: E126 continuation line over-indented for hanging indent

Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

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

spam spam spam spam.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'docs/snapcraft-advanced-features.md'
--- docs/snapcraft-advanced-features.md 2015-10-01 08:54:15 +0000
+++ docs/snapcraft-advanced-features.md 2015-10-05 19:37:43 +0000
@@ -74,11 +74,11 @@
74assemble and build the snap:74assemble and build the snap:
7575
76 parts:76 parts:
77 spongeshaker:77 spongeshaker:
78 plugin: python278 plugin: python2
79 source: git://github.com/markokr/spongeshaker.git79 source: git://github.com/markokr/spongeshaker.git
80 make-project:80 make-project:
81 plugin: make81 plugin: make
82 source: .82 source: .
8383
84The example above mixes and matches parts of different origin. Locally it84The example above mixes and matches parts of different origin. Locally it
8585
=== modified file 'examples/py2-project/sha3sum.py'
--- examples/py2-project/sha3sum.py 2015-07-17 14:44:45 +0000
+++ examples/py2-project/sha3sum.py 2015-10-05 19:37:43 +0000
@@ -12,4 +12,3 @@
12 data = fp.read()12 data = fp.read()
13 h.update(data)13 h.update(data)
14 print(h.hexdigest())14 print(h.hexdigest())
15
1615
=== modified file 'examples/py3-project/sha3sum.py'
--- examples/py3-project/sha3sum.py 2015-07-15 09:55:27 +0000
+++ examples/py3-project/sha3sum.py 2015-10-05 19:37:43 +0000
@@ -12,4 +12,3 @@
12 data = fp.read()12 data = fp.read()
13 h.update(data)13 h.update(data)
14 print(h.hexdigest())14 print(h.hexdigest())
15
1615
=== modified file 'examples/webcam-webui/config.py'
--- examples/webcam-webui/config.py 2015-09-15 20:53:36 +0000
+++ examples/webcam-webui/config.py 2015-10-05 19:37:43 +0000
@@ -17,7 +17,8 @@
17 if config_yaml:17 if config_yaml:
18 set_config(config_file, config_yaml)18 set_config(config_file, config_yaml)
1919
20 yaml.dump(get_config(config_file), stream=sys.stdout, default_flow_style=False)20 yaml.dump(get_config(config_file), stream=sys.stdout,
21 default_flow_style=False)
2122
2223
23def set_config(config_file, config_yaml={}):24def set_config(config_file, config_yaml={}):
@@ -37,9 +38,11 @@
3738
38def _config(config_yaml={}):39def _config(config_yaml={}):
39 try:40 try:
40 interval_value = config_yaml['config'][os.environ['SNAP_NAME']]['interval']41 interval_value = config_yaml['config'][
42 os.environ['SNAP_NAME']]['interval']
41 if not isinstance(interval_value, int):43 if not isinstance(interval_value, int):
42 config_yaml['config'][os.environ['SNAP_NAME']]['interval'] = _DEFAULT_INTERVAL44 config_yaml['config'][
45 os.environ['SNAP_NAME']]['interval'] = _DEFAULT_INTERVAL
43 except KeyError:46 except KeyError:
44 interval = {47 interval = {
45 'config': {48 'config': {
4649
=== modified file 'integration-tests/data/pypi-config/config.py'
--- integration-tests/data/pypi-config/config.py 2015-09-17 19:05:20 +0000
+++ integration-tests/data/pypi-config/config.py 2015-10-05 19:37:43 +0000
@@ -17,7 +17,9 @@
17 if config_yaml:17 if config_yaml:
18 set_config(config_file, config_yaml)18 set_config(config_file, config_yaml)
1919
20 yaml.dump(get_config(config_file), stream=sys.stdout, default_flow_style=False)20 yaml.dump(get_config(config_file),
21 stream=sys.stdout,
22 default_flow_style=False)
2123
2224
23def set_config(config_file, config_yaml={}):25def set_config(config_file, config_yaml={}):
@@ -37,9 +39,11 @@
3739
38def _config(config_yaml={}):40def _config(config_yaml={}):
39 try:41 try:
40 interval_value = config_yaml['config'][os.environ['SNAP_NAME']]['interval']42 interval_value = config_yaml['config'][
43 os.environ['SNAP_NAME']]['interval']
41 if not isinstance(interval_value, int):44 if not isinstance(interval_value, int):
42 config_yaml['config'][os.environ['SNAP_NAME']]['interval'] = _DEFAULT_INTERVAL45 config_yaml['config'][
46 os.environ['SNAP_NAME']]['interval'] = _DEFAULT_INTERVAL
43 except KeyError:47 except KeyError:
44 interval = {48 interval = {
45 'config': {49 'config': {
4650
=== modified file 'runtests.sh'
--- runtests.sh 2015-10-02 02:24:13 +0000
+++ runtests.sh 2015-10-05 19:37:43 +0000
@@ -48,7 +48,7 @@
48 # These three checks could easily be done with flake8 in one shot if48 # These three checks could easily be done with flake8 in one shot if
49 # we had python3-flake8 provide flake849 # we had python3-flake8 provide flake8
50 # Ignore 501 (line-too-long)50 # Ignore 501 (line-too-long)
51 pep8 $SRC_PATHS --ignore=E50151 pep8 $SRC_PATHS
5252
53 pyflakes3 $SRC_PATHS53 pyflakes3 $SRC_PATHS
5454
5555
=== modified file 'setup.py'
--- setup.py 2015-09-02 15:10:58 +0000
+++ setup.py 2015-10-05 19:37:43 +0000
@@ -37,8 +37,10 @@
37 package_data={'snapcraft': ['manifest.txt']},37 package_data={'snapcraft': ['manifest.txt']},
38 scripts=['bin/snapcraft'],38 scripts=['bin/snapcraft'],
39 data_files=[39 data_files=[
40 ('share/snapcraft/plugins', ['plugins/' + x for x in os.listdir('plugins')]),40 ('share/snapcraft/plugins',
41 ('share/snapcraft/schema', ['schema/' + x for x in os.listdir('schema')]),41 ['plugins/' + x for x in os.listdir('plugins')]),
42 ('share/snapcraft/schema',
43 ['schema/' + x for x in os.listdir('schema')]),
42 ],44 ],
43 cmdclass={'test': TestCommand},45 cmdclass={'test': TestCommand},
44 )46 )
4547
=== modified file 'snapcraft/__init__.py'
--- snapcraft/__init__.py 2015-09-29 08:37:47 +0000
+++ snapcraft/__init__.py 2015-10-05 19:37:43 +0000
@@ -42,8 +42,10 @@
42 self.partdir = os.path.join(os.getcwd(), "parts", self.name)42 self.partdir = os.path.join(os.getcwd(), "parts", self.name)
43 self.sourcedir = os.path.join(os.getcwd(), "parts", self.name, "src")43 self.sourcedir = os.path.join(os.getcwd(), "parts", self.name, "src")
44 self.builddir = os.path.join(os.getcwd(), "parts", self.name, "build")44 self.builddir = os.path.join(os.getcwd(), "parts", self.name, "build")
45 self.ubuntudir = os.path.join(os.getcwd(), "parts", self.name, 'ubuntu')45 self.ubuntudir = os.path.join(os.getcwd(), "parts", self.name,
46 self.installdir = os.path.join(os.getcwd(), "parts", self.name, "install")46 'ubuntu')
47 self.installdir = os.path.join(os.getcwd(), "parts", self.name,
48 "install")
47 self.stagedir = os.path.join(os.getcwd(), "stage")49 self.stagedir = os.path.join(os.getcwd(), "stage")
48 self.snapdir = os.path.join(os.getcwd(), "snap")50 self.snapdir = os.path.join(os.getcwd(), "snap")
4951
@@ -84,17 +86,23 @@
84 def isurl(self, url):86 def isurl(self, url):
85 return snapcraft.common.isurl(url)87 return snapcraft.common.isurl(url)
8688
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,
90 source_branch=None):
88 try:91 try:
89 handler_class = _get_source_handler(source_type, source)92 handler_class = _get_source_handler(source_type, source)
90 except ValueError:93 except ValueError:
91 logger.error("Unrecognized source '%s' for part '%s'.", source, self.name)94 logger.error("Unrecognized source '%s' for part '%s'.", source,
95 self.name)
92 snapcraft.common.fatal()96 snapcraft.common.fatal()
9397
94 try:98 try:
95 handler = handler_class(source, self.sourcedir, source_tag, source_branch)99 handler = handler_class(source, self.sourcedir, source_tag,
100 source_branch)
96 except snapcraft.sources.IncompatibleOptionsError as e:101 except snapcraft.sources.IncompatibleOptionsError as e:
97 logger.error('Issues while setting up sources for part \'%s\': %s.', self.name, e.message)102 logger.error(
103 'Issues while setting up sources for part \'%s\': %s.',
104 self.name,
105 e.message)
98 snapcraft.common.fatal()106 snapcraft.common.fatal()
99 if not handler.pull():107 if not handler.pull():
100 return False108 return False
@@ -115,16 +123,23 @@
115 def setup_stage_packages(self):123 def setup_stage_packages(self):
116 part_stage_packages = getattr(self.options, 'stage_packages', []) or []124 part_stage_packages = getattr(self.options, 'stage_packages', []) or []
117 if self.PLUGIN_STAGE_PACKAGES or part_stage_packages:125 if self.PLUGIN_STAGE_PACKAGES or part_stage_packages:
118 ubuntu = snapcraft.repo.Ubuntu(self.ubuntudir, sources=self.PLUGIN_STAGE_SOURCES)126 ubuntu = snapcraft.repo.Ubuntu(self.ubuntudir,
127 sources=self.PLUGIN_STAGE_SOURCES)
119 ubuntu.get(self.PLUGIN_STAGE_PACKAGES + part_stage_packages)128 ubuntu.get(self.PLUGIN_STAGE_PACKAGES + part_stage_packages)
120 ubuntu.unpack(self.installdir)129 ubuntu.unpack(self.installdir)
121 self._fixup(self.installdir)130 self._fixup(self.installdir)
122131
123 def _fixup(self, root):132 def _fixup(self, root):
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')):
125 self.run(['sed', '-i', '-e', 's|prefix=/usr|prefix={}/usr|'.format(root), os.path.join(root, 'usr', 'bin', 'xml2-config')])134 self.run(
135 ['sed', '-i', '-e', 's|prefix=/usr|prefix={}/usr|'.
136 format(root),
137 os.path.join(root, 'usr', 'bin', 'xml2-config')])
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')):
127 self.run(['sed', '-i', '-e', 's|prefix=/usr|prefix={}/usr|'.format(root), os.path.join(root, 'usr', 'bin', 'xslt-config')])139 self.run(
140 ['sed', '-i', '-e', 's|prefix=/usr|prefix={}/usr|'.
141 format(root),
142 os.path.join(root, 'usr', 'bin', 'xslt-config')])
128143
129144
130def _get_source_handler(source_type, source):145def _get_source_handler(source_type, source):
131146
=== modified file 'snapcraft/cmds.py'
--- snapcraft/cmds.py 2015-10-04 20:03:23 +0000
+++ snapcraft/cmds.py 2015-10-05 19:37:43 +0000
@@ -54,7 +54,8 @@
54 if args.part:54 if args.part:
55 yaml += 'parts:\n'55 yaml += 'parts:\n'
56 for part_name in args.part:56 for part_name in args.part:
57 part = snapcraft.plugin.load_plugin(part_name, part_name, load_code=False)57 part = snapcraft.plugin.load_plugin(part_name, part_name,
58 load_code=False)
58 yaml += ' ' + part.names()[0] + ':\n'59 yaml += ' ' + part.names()[0] + ':\n'
59 for opt in part.config.get('options', []):60 for opt in part.config.get('options', []):
60 if part.config['options'][opt].get('required', False):61 if part.config['options'][opt].get('required', False):
@@ -73,7 +74,10 @@
73 common.env = config.stage_env()74 common.env = config.stage_env()
74 userCommand = args.userCommand75 userCommand = args.userCommand
75 if not userCommand:76 if not userCommand:
76 userCommand = ['/usr/bin/env', 'PS1=\[\e[1;32m\]snapcraft:\w\$\[\e[0m\] ', '/bin/bash', '--norc']77 userCommand = ['/usr/bin/env',
78 'PS1=\[\e[1;32m\]snapcraft:\w\$\[\e[0m\] ',
79 '/bin/bash',
80 '--norc']
77 common.run(userCommand)81 common.run(userCommand)
7882
7983
@@ -168,7 +172,8 @@
168 qemu_img = os.path.join(qemudir, "15.04.img")172 qemu_img = os.path.join(qemudir, "15.04.img")
169 if not os.path.exists(qemu_img):173 if not os.path.exists(qemu_img):
170 os.makedirs(qemudir, exist_ok=True)174 os.makedirs(qemudir, exist_ok=True)
171 logger.info('Setting up virtual snappy environment, root access required')175 logger.info(
176 'Setting up virtual snappy environment, root access required')
172 common.run([177 common.run([
173 'sudo', 'ubuntu-device-flash', 'core', '15.04', '--developer-mode',178 'sudo', 'ubuntu-device-flash', 'core', '15.04', '--developer-mode',
174 '--enable-ssh', '-o', os.path.relpath(qemu_img, qemudir)],179 '--enable-ssh', '-o', os.path.relpath(qemu_img, qemudir)],
@@ -181,7 +186,8 @@
181 # the snapcraft run workflow.186 # the snapcraft run workflow.
182 #187 #
183 # For example:188 # For example:
184 # $ export SNAPCRAFT_RUN_QEMU_ARGS="-usb -device usb-host,hostbus=1,hostaddr=10"189 # $ export SNAPCRAFT_RUN_QEMU_ARGS=\
190 # "-usb -device usb-host,hostbus=1,hostaddr=10"
185 # $ snapcraft run191 # $ snapcraft run
186 qemu_args = os.getenv("SNAPCRAFT_RUN_QEMU_ARGS")192 qemu_args = os.getenv("SNAPCRAFT_RUN_QEMU_ARGS")
187 if qemu_args is not None:193 if qemu_args is not None:
@@ -258,7 +264,9 @@
258 for part in parts:264 for part in parts:
259 # Gather our own files up265 # Gather our own files up
260 fileset = getattr(part.code.options, 'stage', ['*']) or ['*']266 fileset = getattr(part.code.options, 'stage', ['*']) or ['*']
261 part_files, _ = snapcraft.plugin.migratable_filesets(fileset, part.installdir)267 part_files, _ = snapcraft.plugin.migratable_filesets(
268 fileset,
269 part.installdir)
262270
263 # Scan previous parts for collisions271 # Scan previous parts for collisions
264 for other_part_name in parts_files:272 for other_part_name in parts_files:
@@ -266,19 +274,27 @@
266 conflict_files = []274 conflict_files = []
267 for f in common:275 for f in common:
268 this = os.path.join(part.installdir, f)276 this = os.path.join(part.installdir, f)
269 other = os.path.join(parts_files[other_part_name]['installdir'], f)277 other = os.path.join(
278 parts_files[other_part_name]['installdir'],
279 f)
270 if os.path.islink(this) and os.path.islink(other):280 if os.path.islink(this) and os.path.islink(other):
271 continue281 continue
272 if not filecmp.cmp(this, other, shallow=False):282 if not filecmp.cmp(this, other, shallow=False):
273 conflict_files.append(f)283 conflict_files.append(f)
274284
275 if conflict_files:285 if conflict_files:
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 '
287 'paths in common which have different '
288 'contents:\n %s',
289 other_part_name,
290 part.names()[0],
291 '\n '.join(sorted(conflict_files)))
277292
278 return False293 return False
279294
280 # And add our files to the list295 # And add our files to the list
281 parts_files[part.names()[0]] = {'files': part_files, 'installdir': part.installdir}296 parts_files[part.names()[0]] = {'files': part_files,
297 'installdir': part.installdir}
282298
283 return True299 return True
284300
@@ -305,9 +321,9 @@
305 # This ends up running multiple times, as each part gets to its321 # This ends up running multiple times, as each part gets to its
306 # staging cmd. That's inefficient, but largely OK.322 # staging cmd. That's inefficient, but largely OK.
307 # FIXME: fix the above by iterating over cmds before iterating323 # FIXME: fix the above by iterating over cmds before iterating
308 # all_parts. But then we need to make sure we continue to handle324 # all_parts. But then we need to make sure we continue to
309 # cases like go, where you want go built before trying to pull325 # handle cases like go, where you want go built before trying
310 # a go project.326 # to pull a go project.
311 if not _check_for_collisions(config.all_parts):327 if not _check_for_collisions(config.all_parts):
312 sys.exit(1)328 sys.exit(1)
313329
@@ -337,7 +353,9 @@
337def _install_build_packages(packages):353def _install_build_packages(packages):
338 new_packages = []354 new_packages = []
339 for check_pkg in packages:355 for check_pkg in packages:
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],
357 stdout=subprocess.DEVNULL,
358 stderr=subprocess.DEVNULL) != 0:
341 new_packages.append(check_pkg)359 new_packages.append(check_pkg)
342 if new_packages:360 if new_packages:
343 logger.info('Installing required packages on the host system')361 logger.info('Installing required packages on the host system')
@@ -361,8 +379,9 @@
361 return _config379 return _config
362 except snapcraft.yaml.SnapcraftYamlFileError as e:380 except snapcraft.yaml.SnapcraftYamlFileError as e:
363 logger.error(381 logger.error(
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 '
365 'To start a new project, use \'snapcraft init\''.format(e.file))383 'directory?\nTo start a new project, use \'snapcraft '
384 'init\''.format(e.file))
366 sys.exit(1)385 sys.exit(1)
367 except snapcraft.yaml.SnapcraftSchemaError as e:386 except snapcraft.yaml.SnapcraftSchemaError as e:
368 msg = "Issues while validating snapcraft.yaml: {}".format(e.message)387 msg = "Issues while validating snapcraft.yaml: {}".format(e.message)
@@ -374,5 +393,6 @@
374 'missing for the "{}" part.'.format(e.part))393 'missing for the "{}" part.'.format(e.part))
375 sys.exit(1)394 sys.exit(1)
376 except snapcraft.yaml.SnapcraftLogicError as e:395 except snapcraft.yaml.SnapcraftLogicError as e:
377 logger.error('Issue detected while analyzing snapcraft.yaml: {}'.format(e.message))396 logger.error('Issue detected while analyzing '
397 'snapcraft.yaml: {}'.format(e.message))
378 sys.exit(1)398 sys.exit(1)
379399
=== modified file 'snapcraft/common.py'
--- snapcraft/common.py 2015-09-18 21:23:40 +0000
+++ snapcraft/common.py 2015-10-05 19:37:43 +0000
@@ -57,7 +57,8 @@
57 f.write('\n')57 f.write('\n')
58 f.write('exec $*')58 f.write('exec $*')
59 f.flush()59 f.flush()
60 return subprocess.check_output(['/bin/sh', f.name] + cmd, **kwargs).decode('utf8').strip()60 return subprocess.check_output(['/bin/sh', f.name] + cmd,
61 **kwargs).decode('utf8').strip()
6162
6263
63def fatal():64def fatal():
@@ -67,14 +68,17 @@
67def get_arch():68def get_arch():
68 global _arch69 global _arch
69 if _arch is None:70 if _arch is None:
70 _arch = subprocess.check_output(['dpkg-architecture', '-qDEB_BUILD_ARCH']).decode('utf8').strip()71 _arch = subprocess.check_output(
72 ['dpkg-architecture', '-qDEB_BUILD_ARCH']).decode('utf8').strip()
71 return _arch73 return _arch
7274
7375
74def get_arch_triplet():76def get_arch_triplet():
75 global _arch_triplet77 global _arch_triplet
76 if _arch_triplet is None:78 if _arch_triplet is None:
77 _arch_triplet = subprocess.check_output(['dpkg-architecture', '-qDEB_BUILD_MULTIARCH']).decode('utf8').strip()79 _arch_triplet = subprocess.check_output(
80 ['dpkg-architecture', '-qDEB_BUILD_MULTIARCH']
81 ).decode('utf8').strip()
78 return _arch_triplet82 return _arch_triplet
7983
8084
8185
=== modified file 'snapcraft/main.py'
--- snapcraft/main.py 2015-09-17 14:14:14 +0000
+++ snapcraft/main.py 2015-10-05 19:37:43 +0000
@@ -30,9 +30,11 @@
30 # Parent parsers30 # Parent parsers
3131
32 force_parser = argparse.ArgumentParser(add_help=False)32 force_parser = argparse.ArgumentParser(add_help=False)
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',
34 help='redo all steps for all parts')
3435
35 cmd_parser = argparse.ArgumentParser(add_help=False, parents=[force_parser])36 cmd_parser = argparse.ArgumentParser(add_help=False,
37 parents=[force_parser])
36 cmd_parser.add_argument('part', nargs='*')38 cmd_parser.add_argument('part', nargs='*')
3739
38 # Command parsers40 # Command parsers
@@ -42,28 +44,44 @@
42 parser.set_defaults(func=snapcraft.cmds.init)44 parser.set_defaults(func=snapcraft.cmds.init)
4345
44 parser = subparsers.add_parser('shell', help='enter staging environment')46 parser = subparsers.add_parser('shell', help='enter staging environment')
45 parser.add_argument('userCommand', nargs=argparse.REMAINDER, metavar='cmd', help='optional command to run inside staging environment')47 parser.add_argument(
48 'userCommand', nargs=argparse.REMAINDER,
49 metavar='cmd',
50 help='optional command to run inside staging environment')
46 parser.set_defaults(func=snapcraft.cmds.shell)51 parser.set_defaults(func=snapcraft.cmds.shell)
4752
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',
54 add_help=False)
49 parser.set_defaults(func=snapcraft.cmds.run)55 parser.set_defaults(func=snapcraft.cmds.run)
5056
51 parser = subparsers.add_parser('clean', help='clean up the environment (to start from scratch)')57 parser = subparsers.add_parser(
58 'clean',
59 help='clean up the environment (to start from scratch)')
52 parser.set_defaults(func=snapcraft.cmds.clean)60 parser.set_defaults(func=snapcraft.cmds.clean)
5361
54 parser = subparsers.add_parser('pull', help='get sources', parents=[cmd_parser])62 parser = subparsers.add_parser('pull', help='get sources',
55 parser.set_defaults(func=snapcraft.cmds.cmd)63 parents=[cmd_parser])
5664 parser.set_defaults(func=snapcraft.cmds.cmd)
57 parser = subparsers.add_parser('build', help='build parts', parents=[cmd_parser])65
58 parser.set_defaults(func=snapcraft.cmds.cmd)66 parser = subparsers.add_parser('build', help='build parts',
5967 parents=[cmd_parser])
60 parser = subparsers.add_parser('stage', help='put parts into staging area', parents=[cmd_parser])68 parser.set_defaults(func=snapcraft.cmds.cmd)
61 parser.set_defaults(func=snapcraft.cmds.cmd)69
6270 parser = subparsers.add_parser(
63 parser = subparsers.add_parser('snap', help='put parts into snap area', parents=[cmd_parser])71 'stage',
72 help='put parts into staging area', parents=[cmd_parser])
73 parser.set_defaults(func=snapcraft.cmds.cmd)
74
75 parser = subparsers.add_parser(
76 'snap',
77 help='put parts into snap area',
78 parents=[cmd_parser])
64 parser.set_defaults(func=snapcraft.cmds.snap)79 parser.set_defaults(func=snapcraft.cmds.snap)
6580
66 parser = subparsers.add_parser('assemble', help='make snap package', parents=[force_parser], aliases=['all'])81 parser = subparsers.add_parser(
82 'assemble',
83 help='make snap package', parents=[force_parser],
84 aliases=['all'])
67 parser.set_defaults(func=snapcraft.cmds.assemble)85 parser.set_defaults(func=snapcraft.cmds.assemble)
6886
69 # Now run parser87 # Now run parser
7088
=== modified file 'snapcraft/meta.py'
--- snapcraft/meta.py 2015-09-30 09:19:00 +0000
+++ snapcraft/meta.py 2015-10-05 19:37:43 +0000
@@ -91,7 +91,8 @@
91 args = execparts[1:] if len(execparts) > 1 else []91 args = execparts[1:] if len(execparts) > 1 else []
9292
93 config_hook_path = os.path.join(hooks_dir, 'config')93 config_hook_path = os.path.join(hooks_dir, 'config')
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,
95 cwd='$SNAP_APP_PATH')
9596
9697
97def _copy(meta_dir, relpath, new_relpath=None):98def _copy(meta_dir, relpath, new_relpath=None):
@@ -110,8 +111,10 @@
110 for runnable in runnables:111 for runnable in runnables:
111 for entry in ('security-policy', 'security-override'):112 for entry in ('security-policy', 'security-override'):
112 if entry in runnable:113 if entry in runnable:
113 runnable[entry]['apparmor'] = _copy(meta_dir, runnable[entry]['apparmor'])114 runnable[entry]['apparmor'] = \
114 runnable[entry]['seccomp'] = _copy(meta_dir, runnable[entry]['seccomp'])115 _copy(meta_dir, runnable[entry]['apparmor'])
116 runnable[entry]['seccomp'] = \
117 _copy(meta_dir, runnable[entry]['seccomp'])
115118
116 return runnables119 return runnables
117120
@@ -140,12 +143,14 @@
140 if 'binaries' in config_data:143 if 'binaries' in config_data:
141 binaries = config_data['binaries']144 binaries = config_data['binaries']
142 binaries = _wrap_binaries(binaries)145 binaries = _wrap_binaries(binaries)
143 package_yaml['binaries'] = _copy_security_profiles(meta_dir, _repack_names(binaries))146 package_yaml['binaries'] = \
147 _copy_security_profiles(meta_dir, _repack_names(binaries))
144148
145 if 'services' in config_data:149 if 'services' in config_data:
146 services = config_data['services']150 services = config_data['services']
147 services = _wrap_services(services)151 services = _wrap_services(services)
148 package_yaml['services'] = _copy_security_profiles(meta_dir, _repack_names(services))152 package_yaml['services'] = \
153 _copy_security_profiles(meta_dir, _repack_names(services))
149154
150 return package_yaml155 return package_yaml
151156
@@ -159,7 +164,8 @@
159164
160165
161def _compose_readme(config_data):166def _compose_readme(config_data):
162 return '{config[summary]}\n{config[description]}\n'.format(config=config_data)167 s = '{config[summary]}\n{config[description]}\n'
168 return s.format(config=config_data)
163169
164170
165def _replace_cmd(execparts, cmd):171def _replace_cmd(execparts, cmd):
@@ -199,7 +205,8 @@
199 wrapexec = '$SNAP_APP_PATH/{}'.format(relexepath)205 wrapexec = '$SNAP_APP_PATH/{}'.format(relexepath)
200 if not os.path.exists(exepath) and '/' not in relexepath:206 if not os.path.exists(exepath) and '/' not in relexepath:
201 # If it doesn't exist it might be in the path207 # If it doesn't exist it might be in the path
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(
209 relexepath))
203 with tempfile.NamedTemporaryFile('w+') as tempf:210 with tempfile.NamedTemporaryFile('w+') as tempf:
204 script = ('#!/bin/sh\n' +211 script = ('#!/bin/sh\n' +
205 '{}\n'.format(common.assemble_env()) +212 '{}\n'.format(common.assemble_env()) +
@@ -209,7 +216,8 @@
209 if common.run(['/bin/sh', tempf.name], cwd=snap_dir):216 if common.run(['/bin/sh', tempf.name], cwd=snap_dir):
210 wrapexec = relexepath217 wrapexec = relexepath
211 else:218 else:
212 logger.warning('Warning: unable to find "{}" in the path'.format(relexepath))219 logger.warning('Warning: unable to find "{}" in the path'.
220 format(relexepath))
213221
214 _write_wrap_exe(wrapexec, wrappath)222 _write_wrap_exe(wrapexec, wrappath)
215223
216224
=== modified file 'snapcraft/plugin.py'
--- snapcraft/plugin.py 2015-09-22 10:39:06 +0000
+++ snapcraft/plugin.py 2015-10-05 19:37:43 +0000
@@ -49,7 +49,8 @@
4949
50class PluginHandler:50class PluginHandler:
5151
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,
53 load_config=True):
53 self.valid = False54 self.valid = False
54 self.code = None55 self.code = None
55 self.config = {}56 self.config = {}
@@ -107,7 +108,8 @@
107 setattr(options, attrname, properties[opt])108 setattr(options, attrname, properties[opt])
108 else:109 else:
109 if opt_parameters.get('required', False):110 if opt_parameters.get('required', False):
110 raise PluginError('Required field {} missing on part {}'.format(opt, name))111 raise PluginError('Required field {} missing on part {}'.
112 format(opt, name))
111 setattr(options, attrname, None)113 setattr(options, attrname, None)
112114
113 return options115 return options
@@ -117,7 +119,8 @@
117 module_name = name.replace('-', '_')119 module_name = name.replace('-', '_')
118120
119 try:121 try:
120 module = importlib.import_module('snapcraft.plugins.' + module_name)122 module = importlib.import_module('snapcraft.plugins.' +
123 module_name)
121 except ImportError:124 except ImportError:
122 module = None125 module = None
123126
@@ -160,7 +163,8 @@
160 try:163 try:
161 with open(self.statefile, 'r') as f:164 with open(self.statefile, 'r') as f:
162 lastStep = f.read()165 lastStep = f.read()
163 return common.COMMAND_ORDER.index(stage) > common.COMMAND_ORDER.index(lastStep)166 return (common.COMMAND_ORDER.index(stage) >
167 common.COMMAND_ORDER.index(lastStep))
164 except Exception:168 except Exception:
165 return True169 return True
166170
@@ -179,7 +183,8 @@
179 return True183 return True
180 self.makedirs()184 self.makedirs()
181185
182 run_setup_stage_packages = self.code and hasattr(self.code, 'setup_stage_packages')186 run_setup_stage_packages = self.code and \
187 hasattr(self.code, 'setup_stage_packages')
183 run_pull = self.code and hasattr(self.code, 'pull')188 run_pull = self.code and hasattr(self.code, 'pull')
184189
185 if run_setup_stage_packages or run_pull:190 if run_setup_stage_packages or run_pull:
@@ -248,7 +253,8 @@
248 snap_files, snap_dirs = self._migratable_fileset_for('stage')253 snap_files, snap_dirs = self._migratable_fileset_for('stage')
249254
250 try:255 try:
251 _migrate_files(snap_files, snap_dirs, self.installdir, self.stagedir)256 _migrate_files(snap_files, snap_dirs, self.installdir,
257 self.stagedir)
252 except FileNotFoundError as e:258 except FileNotFoundError as e:
253 logger.error('Could not find file %s defined in stage',259 logger.error('Could not find file %s defined in stage',
254 os.path.relpath(e.filename, os.path.curdir))260 os.path.relpath(e.filename, os.path.curdir))
@@ -284,7 +290,8 @@
284290
285291
286def load_plugin(part_name, plugin_name, properties={}, load_code=True):292def load_plugin(part_name, plugin_name, properties={}, load_code=True):
287 part = PluginHandler(plugin_name, part_name, properties, load_code=load_code)293 part = PluginHandler(plugin_name, part_name, properties,
294 load_code=load_code)
288 if not part.is_valid():295 if not part.is_valid():
289 logger.error('Could not load part %s', plugin_name)296 logger.error('Could not load part %s', plugin_name)
290 sys.exit(1)297 sys.exit(1)
@@ -300,10 +307,13 @@
300 # And chop files, including whole trees if any dirs are mentioned307 # And chop files, including whole trees if any dirs are mentioned
301 snap_files = include_files - exclude_files308 snap_files = include_files - exclude_files
302 for exclude_dir in exclude_dirs:309 for exclude_dir in exclude_dirs:
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
311 if not x.startswith(exclude_dir + '/')])
304312
305 # Separate dirs from files313 # Separate dirs from files
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
315 if os.path.isdir(os.path.join(srcdir, x)) and
316 not os.path.islink(os.path.join(srcdir, x))])
307 snap_files = snap_files - snap_dirs317 snap_files = snap_files - snap_dirs
308318
309 return snap_files, snap_dirs319 return snap_files, snap_dirs
@@ -356,8 +366,12 @@
356 # files from an include like 'lib'366 # files from an include like 'lib'
357 for include_dir in include_dirs:367 for include_dir in include_dirs:
358 for root, dirs, files in os.walk(include_dir):368 for root, dirs, files in os.walk(include_dir):
359 include_files |= set([os.path.relpath(os.path.join(root, d), directory) for d in dirs])369 include_files |= \
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)
371 for d in dirs])
372 include_files |= \
373 set([os.path.relpath(os.path.join(root, f), directory)
374 for f in files])
361375
362 return include_files376 return include_files
363377
@@ -369,8 +383,10 @@
369 matches = glob.glob(os.path.join(directory, exclude))383 matches = glob.glob(os.path.join(directory, exclude))
370 exclude_files |= set(matches)384 exclude_files |= set(matches)
371385
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)
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)]
388 exclude_files = set([os.path.relpath(x, directory)
389 for x in exclude_files])
374390
375 return exclude_files, exclude_dirs391 return exclude_files, exclude_dirs
376392
377393
=== modified file 'snapcraft/plugins/ant.py'
--- snapcraft/plugins/ant.py 2015-10-01 08:54:15 +0000
+++ snapcraft/plugins/ant.py 2015-10-05 19:37:43 +0000
@@ -36,7 +36,8 @@
36 return False36 return False
37 files = glob.glob(os.path.join(self.builddir, 'target', '*.jar'))37 files = glob.glob(os.path.join(self.builddir, 'target', '*.jar'))
38 if not files:38 if not files:
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',
40 self.name)
40 sys.exit(1)41 sys.exit(1)
41 jardir = os.path.join(self.installdir, 'jar')42 jardir = os.path.join(self.installdir, 'jar')
42 return self.run(['mkdir', '-p', jardir]) and \43 return self.run(['mkdir', '-p', jardir]) and \
4344
=== modified file 'snapcraft/plugins/autotools.py'
--- snapcraft/plugins/autotools.py 2015-10-01 08:54:15 +0000
+++ snapcraft/plugins/autotools.py 2015-10-05 19:37:43 +0000
@@ -28,5 +28,5 @@
28 if not os.path.exists(os.path.join(self.builddir, "configure")):28 if not os.path.exists(os.path.join(self.builddir, "configure")):
29 if not self.run(['env', 'NOCONFIGURE=1', './autogen.sh']):29 if not self.run(['env', 'NOCONFIGURE=1', './autogen.sh']):
30 return False30 return False
31 return self.run(['./configure', '--prefix='] + self.options.configflags) and \31 return self.run(['./configure', '--prefix='] +
32 super().build()32 self.options.configflags) and super().build()
3333
=== modified file 'snapcraft/plugins/cmake.py'
--- snapcraft/plugins/cmake.py 2015-10-01 08:54:15 +0000
+++ snapcraft/plugins/cmake.py 2015-10-05 19:37:43 +0000
@@ -24,5 +24,5 @@
24 self.options.configflags = []24 self.options.configflags = []
2525
26 def build(self):26 def build(self):
27 return self.run(['cmake', '.', '-DCMAKE_INSTALL_PREFIX='] + self.options.configflags) and \27 return self.run(['cmake', '.', '-DCMAKE_INSTALL_PREFIX='] +
28 super().build()28 self.options.configflags) and super().build()
2929
=== modified file 'snapcraft/plugins/copy.py'
--- snapcraft/plugins/copy.py 2015-08-26 08:52:09 +0000
+++ snapcraft/plugins/copy.py 2015-10-05 19:37:43 +0000
@@ -37,5 +37,6 @@
37 dst_dir = os.path.dirname(dst)37 dst_dir = os.path.dirname(dst)
38 if not os.path.exists(dst_dir):38 if not os.path.exists(dst_dir):
39 os.makedirs(dst_dir)39 os.makedirs(dst_dir)
40 res &= self.run(["cp", "--preserve=all", "-R", src, dst], cwd=os.getcwd())40 res &= self.run(["cp", "--preserve=all", "-R", src, dst],
41 cwd=os.getcwd())
41 return res42 return res
4243
=== modified file 'snapcraft/plugins/go.py'
--- snapcraft/plugins/go.py 2015-10-01 08:54:15 +0000
+++ snapcraft/plugins/go.py 2015-10-05 19:37:43 +0000
@@ -43,7 +43,8 @@
43 return False43 return False
44 if not self.run(['go', 'install', self.fullname]):44 if not self.run(['go', 'install', self.fullname]):
45 return False45 return False
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'),
47 self.installdir])
4748
48 def run(self, cmd, **kwargs):49 def run(self, cmd, **kwargs):
49 cmd = ['env', 'GOPATH=' + self.builddir] + cmd50 cmd = ['env', 'GOPATH=' + self.builddir] + cmd
5051
=== modified file 'snapcraft/plugins/maven.py'
--- snapcraft/plugins/maven.py 2015-10-01 08:54:15 +0000
+++ snapcraft/plugins/maven.py 2015-10-05 19:37:43 +0000
@@ -36,7 +36,8 @@
36 jarfiles = glob.glob(os.path.join(self.builddir, 'target', '*.jar'))36 jarfiles = glob.glob(os.path.join(self.builddir, 'target', '*.jar'))
37 warfiles = glob.glob(os.path.join(self.builddir, 'target', '*.war'))37 warfiles = glob.glob(os.path.join(self.builddir, 'target', '*.war'))
38 if not (jarfiles or warfiles):38 if not (jarfiles or warfiles):
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 '
40 'part %s', self.name)
40 snapcraft.common.fatal()41 snapcraft.common.fatal()
41 if jarfiles:42 if jarfiles:
42 jardir = os.path.join(self.installdir, 'jar')43 jardir = os.path.join(self.installdir, 'jar')
4344
=== modified file 'snapcraft/plugins/python2.py'
--- snapcraft/plugins/python2.py 2015-10-01 08:54:15 +0000
+++ snapcraft/plugins/python2.py 2015-10-05 19:37:43 +0000
@@ -62,7 +62,8 @@
6262
63 if not os.path.exists(site_packages_dir):63 if not os.path.exists(site_packages_dir):
64 os.symlink(64 os.symlink(
65 os.path.join(prefix, 'lib', self.python_version, 'dist-packages'),65 os.path.join(prefix, 'lib', self.python_version,
66 'dist-packages'),
66 site_packages_dir)67 site_packages_dir)
6768
68 if not self.run(['python2', easy_install, '--prefix', prefix, 'pip']):69 if not self.run(['python2', easy_install, '--prefix', prefix, 'pip']):
@@ -99,7 +100,8 @@
99 @property100 @property
100 def dist_packages_dir(self):101 def dist_packages_dir(self):
101 return os.path.join(102 return os.path.join(
102 self.installdir, 'usr', 'lib', self.python_version, 'dist-packages')103 self.installdir, 'usr', 'lib', self.python_version,
104 'dist-packages')
103105
104 @property106 @property
105 def python_version(self):107 def python_version(self):
106108
=== modified file 'snapcraft/plugins/python3.py'
--- snapcraft/plugins/python3.py 2015-10-02 16:45:13 +0000
+++ snapcraft/plugins/python3.py 2015-10-05 19:37:43 +0000
@@ -99,7 +99,8 @@
99 @property99 @property
100 def dist_packages_dir(self):100 def dist_packages_dir(self):
101 return os.path.join(101 return os.path.join(
102 self.installdir, 'usr', 'lib', self.python_version, 'dist-packages')102 self.installdir, 'usr', 'lib', self.python_version,
103 'dist-packages')
103104
104 @property105 @property
105 def python_version(self):106 def python_version(self):
106107
=== modified file 'snapcraft/plugins/qml.py'
--- snapcraft/plugins/qml.py 2015-09-08 21:21:07 +0000
+++ snapcraft/plugins/qml.py 2015-10-05 19:37:43 +0000
@@ -81,7 +81,8 @@
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),
82 # Mir config82 # Mir config
83 "MIR_SOCKET=/run/mir_socket",83 "MIR_SOCKET=/run/mir_socket",
84 "MIR_CLIENT_PLATFORM_PATH=%s/usr/lib/%s/mir/client-platform" % (root, arch),84 "MIR_CLIENT_PLATFORM_PATH={}/usr/lib/{}/mir/client-platform"
85 .format(root, arch),
85 # XKB config86 # XKB config
86 "XKB_CONFIG_ROOT=%s/usr/share/X11/xkb" % root,87 "XKB_CONFIG_ROOT=%s/usr/share/X11/xkb" % root,
87 # Qt Platform to Mir88 # Qt Platform to Mir
@@ -89,14 +90,18 @@
89 "QTCHOOSER_NO_GLOBAL_DIR=1",90 "QTCHOOSER_NO_GLOBAL_DIR=1",
90 "QT_SELECT=snappy-qt5",91 "QT_SELECT=snappy-qt5",
91 # Qt Libs92 # Qt Libs
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"
93 "LD_LIBRARY_PATH=%s/usr/lib/%s/pulseaudio:$LD_LIBRARY_PATH" % (root, arch),94 .format(root, arch),
95 "LD_LIBRARY_PATH={}/usr/lib/{}/pulseaudio:$LD_LIBRARY_PATH"
96 .format(root, arch),
94 # Qt Modules97 # Qt Modules
95 "QT_PLUGIN_PATH=%s/usr/lib/%s/qt5/plugins" % (root, arch),98 "QT_PLUGIN_PATH=%s/usr/lib/%s/qt5/plugins" % (root, arch),
96 "QML2_IMPORT_PATH=%s/usr/lib/%s/qt5/qml" % (root, arch),99 "QML2_IMPORT_PATH=%s/usr/lib/%s/qt5/qml" % (root, arch),
97 # Mesa Libs100 # Mesa Libs
98 "LD_LIBRARY_PATH=%s/usr/lib/%s/mesa:$LD_LIBRARY_PATH" % (root, arch),101 "LD_LIBRARY_PATH={}/usr/lib/{}/mesa:$LD_LIBRARY_PATH"
99 "LD_LIBRARY_PATH=%s/usr/lib/%s/mesa-egl:$LD_LIBRARY_PATH" % (root, arch),102 .format(root, arch),
103 "LD_LIBRARY_PATH={}/usr/lib/{}/mesa-egl:$LD_LIBRARY_PATH"
104 .format(root, arch),
100 # XDG Config105 # XDG Config
101 "XDG_CONFIG_DIRS=%s/etc/xdg:$XDG_CONFIG_DIRS" % root,106 "XDG_CONFIG_DIRS=%s/etc/xdg:$XDG_CONFIG_DIRS" % root,
102 "XDG_CONFIG_DIRS=%s/usr/xdg:$XDG_CONFIG_DIRS" % root,107 "XDG_CONFIG_DIRS=%s/usr/xdg:$XDG_CONFIG_DIRS" % root,
103108
=== modified file 'snapcraft/repo.py'
--- snapcraft/repo.py 2015-09-30 17:23:17 +0000
+++ snapcraft/repo.py 2015-10-05 19:37:43 +0000
@@ -28,7 +28,8 @@
2828
29import snapcraft.common29import snapcraft.common
3030
31_DEFAULT_SOURCES = '''deb http://${prefix}.ubuntu.com/${suffix}/ ${release} main restricted31_DEFAULT_SOURCES = \
32 '''deb http://${prefix}.ubuntu.com/${suffix}/ ${release} main restricted
32deb http://${prefix}.ubuntu.com/${suffix}/ ${release}-updates main restricted33deb http://${prefix}.ubuntu.com/${suffix}/ ${release}-updates main restricted
33deb http://${prefix}.ubuntu.com/${suffix}/ ${release} universe34deb http://${prefix}.ubuntu.com/${suffix}/ ${release} universe
34deb http://${prefix}.ubuntu.com/${suffix}/ ${release}-updates universe35deb http://${prefix}.ubuntu.com/${suffix}/ ${release}-updates universe
@@ -103,7 +104,8 @@
103 skipped_essential.append(pkg.name)104 skipped_essential.append(pkg.name)
104 pkg.mark_keep()105 pkg.mark_keep()
105 continue106 continue
106 if (pkg.name in manifest_dep_names and pkg.name not in package_names):107 if (pkg.name in manifest_dep_names and
108 pkg.name not in package_names):
107 skipped_blacklisted.append(pkg.name)109 skipped_blacklisted.append(pkg.name)
108 pkg.mark_keep()110 pkg.mark_keep()
109 continue111 continue
@@ -111,7 +113,8 @@
111 if skipped_essential:113 if skipped_essential:
112 print('Skipping priority essential packages:', skipped_essential)114 print('Skipping priority essential packages:', skipped_essential)
113 if skipped_blacklisted:115 if skipped_blacklisted:
114 print('Skipping blacklisted from manifest packages:', skipped_blacklisted)116 print('Skipping blacklisted from manifest packages:',
117 skipped_blacklisted)
115118
116 # download the remaining ones with proper progress119 # download the remaining ones with proper progress
117 apt.apt_pkg.config.set("Dir::Cache::Archives", self.downloaddir)120 apt.apt_pkg.config.set("Dir::Cache::Archives", self.downloaddir)
@@ -131,7 +134,8 @@
131 def _manifest_dep_names(self):134 def _manifest_dep_names(self):
132 manifest_dep_names = set()135 manifest_dep_names = set()
133136
134 with open(os.path.abspath(os.path.join(__file__, '..', 'manifest.txt'))) as f:137 with open(os.path.abspath(os.path.join(__file__, '..',
138 'manifest.txt'))) as f:
135 for line in f:139 for line in f:
136 pkg = line.strip()140 pkg = line.strip()
137 if pkg in self.apt_cache:141 if pkg in self.apt_cache:
138142
=== modified file 'snapcraft/sources.py'
--- snapcraft/sources.py 2015-09-29 08:11:32 +0000
+++ snapcraft/sources.py 2015-10-05 19:37:43 +0000
@@ -35,7 +35,8 @@
3535
36class Base:36class Base:
3737
38 def __init__(self, source, source_dir, source_tag=None, source_branch=None):38 def __init__(self, source, source_dir, source_tag=None,
39 source_branch=None):
39 self.source = source40 self.source = source
40 self.source_dir = source_dir41 self.source_dir = source_dir
41 self.source_tag = source_tag42 self.source_tag = source_tag
@@ -45,35 +46,43 @@
45 raise NotImplementedError('this is just a base class')46 raise NotImplementedError('this is just a base class')
4647
47 def provision(self, dst):48 def provision(self, dst):
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],
50 cwd=os.getcwd())
4951
5052
51class Bazaar(Base):53class Bazaar(Base):
5254
53 def __init__(self, source, source_dir, source_tag=None, source_branch=None):55 def __init__(self, source, source_dir, source_tag=None,
56 source_branch=None):
54 super().__init__(source, source_dir, source_tag, source_branch)57 super().__init__(source, source_dir, source_tag, source_branch)
55 if source_branch:58 if source_branch:
56 raise IncompatibleOptionsError('can\'t specify a source-branch for a bzr source')59 raise IncompatibleOptionsError(
60 'can\'t specify a source-branch for a bzr source')
5761
58 def pull(self):62 def pull(self):
59 tag_opts = []63 tag_opts = []
60 if self.source_tag:64 if self.source_tag:
61 tag_opts = ['-r', 'tag:' + self.source_tag]65 tag_opts = ['-r', 'tag:' + self.source_tag]
62 if os.path.exists(os.path.join(self.source_dir, ".bzr")):66 if os.path.exists(os.path.join(self.source_dir, ".bzr")):
63 cmd = ['bzr', 'pull'] + tag_opts + [self.source, '-d', self.source_dir]67 cmd = ['bzr', 'pull'] + tag_opts + \
68 [self.source, '-d', self.source_dir]
64 else:69 else:
65 os.rmdir(self.source_dir)70 os.rmdir(self.source_dir)
66 cmd = ['bzr', 'branch'] + tag_opts + [self.source, self.source_dir]71 cmd = ['bzr', 'branch'] + tag_opts + \
72 [self.source, self.source_dir]
6773
68 return snapcraft.common.run(cmd, cwd=os.getcwd())74 return snapcraft.common.run(cmd, cwd=os.getcwd())
6975
7076
71class Git(Base):77class Git(Base):
7278
73 def __init__(self, source, source_dir, source_tag=None, source_branch=None):79 def __init__(self, source, source_dir, source_tag=None,
80 source_branch=None):
74 super().__init__(source, source_dir, source_tag, source_branch)81 super().__init__(source, source_dir, source_tag, source_branch)
75 if source_tag and source_branch:82 if source_tag and source_branch:
76 raise IncompatibleOptionsError('can\'t specify both source-tag and source-branch for a git source')83 raise IncompatibleOptionsError(
84 'can\'t specify both source-tag and source-branch for '
85 'a git source')
7786
78 def pull(self):87 def pull(self):
79 if os.path.exists(os.path.join(self.source_dir, ".git")):88 if os.path.exists(os.path.join(self.source_dir, ".git")):
@@ -86,18 +95,23 @@
86 else:95 else:
87 branch_opts = []96 branch_opts = []
88 if self.source_tag or self.source_branch:97 if self.source_tag or self.source_branch:
89 branch_opts = ['--branch', self.source_tag or self.source_branch]98 branch_opts = ['--branch',
90 cmd = ['git', 'clone'] + branch_opts + [self.source, self.source_dir]99 self.source_tag or self.source_branch]
100 cmd = ['git', 'clone'] + branch_opts + \
101 [self.source, self.source_dir]
91102
92 return snapcraft.common.run(cmd, cwd=os.getcwd())103 return snapcraft.common.run(cmd, cwd=os.getcwd())
93104
94105
95class Mercurial(Base):106class Mercurial(Base):
96107
97 def __init__(self, source, source_dir, source_tag=None, source_branch=None):108 def __init__(self, source, source_dir, source_tag=None,
109 source_branch=None):
98 super().__init__(source, source_dir, source_tag, source_branch)110 super().__init__(source, source_dir, source_tag, source_branch)
99 if source_tag and source_branch:111 if source_tag and source_branch:
100 raise IncompatibleOptionsError('can\'t specify both source-tag and source-branch for a mercurial source')112 raise IncompatibleOptionsError(
113 'can\'t specify both source-tag and source-branch for a '
114 'mercurial source')
101115
102 def pull(self):116 def pull(self):
103 if os.path.exists(os.path.join(self.source_dir, ".hg")):117 if os.path.exists(os.path.join(self.source_dir, ".hg")):
@@ -118,23 +132,29 @@
118132
119class Tar(Base):133class Tar(Base):
120134
121 def __init__(self, source, source_dir, source_tag=None, source_branch=None):135 def __init__(self, source, source_dir, source_tag=None,
136 source_branch=None):
122 super().__init__(source, source_dir, source_tag, source_branch)137 super().__init__(source, source_dir, source_tag, source_branch)
123 if source_tag:138 if source_tag:
124 raise IncompatibleOptionsError('can\'t specify a source-tag for a tar source')139 raise IncompatibleOptionsError(
140 'can\'t specify a source-tag for a tar source')
125 elif source_branch:141 elif source_branch:
126 raise IncompatibleOptionsError('can\'t specify a source-branch for a tar source')142 raise IncompatibleOptionsError(
143 'can\'t specify a source-branch for a tar source')
127144
128 def pull(self):145 def pull(self):
129 if snapcraft.common.isurl(self.source):146 if snapcraft.common.isurl(self.source):
130 return snapcraft.common.run(['wget', '-q', '-c', self.source], cwd=self.source_dir)147 return snapcraft.common.run(['wget', '-q', '-c', self.source],
148 cwd=self.source_dir)
131 else:149 else:
132 return True150 return True
133151
134 def provision(self, dst, clean_target=True):152 def provision(self, dst, clean_target=True):
135 # TODO add unit tests.153 # TODO add unit tests.
136 if snapcraft.common.isurl(self.source):154 if snapcraft.common.isurl(self.source):
137 tarball = os.path.join(self.source_dir, os.path.basename(self.source))155 tarball = os.path.join(
156 self.source_dir,
157 os.path.basename(self.source))
138 else:158 else:
139 tarball = os.path.abspath(self.source)159 tarball = os.path.abspath(self.source)
140160
141161
=== modified file 'snapcraft/tests/test_base_plugin.py'
--- snapcraft/tests/test_base_plugin.py 2015-09-29 08:37:47 +0000
+++ snapcraft/tests/test_base_plugin.py 2015-10-05 19:37:43 +0000
@@ -137,5 +137,6 @@
137 self.assertEqual(raised.exception.code, 1, 'Wrong exit code returned.')137 self.assertEqual(raised.exception.code, 1, 'Wrong exit code returned.')
138 expected = (138 expected = (
139 'Issues while setting up sources for part \'test_plugin\': can\'t '139 'Issues while setting up sources for part \'test_plugin\': can\'t '
140 'specify a {} for a {} source.\n'.format(self.error, self.source_type))140 'specify a {} for a {} source.\n'
141 .format(self.error, self.source_type))
141 self.assertEqual(expected, fake_logger.output)142 self.assertEqual(expected, fake_logger.output)
142143
=== modified file 'snapcraft/tests/test_cmds.py'
--- snapcraft/tests/test_cmds.py 2015-09-18 16:52:06 +0000
+++ snapcraft/tests/test_cmds.py 2015-10-05 19:37:43 +0000
@@ -73,7 +73,8 @@
7373
74 self.assertFalse(cmds._check_for_collisions([part1, part2, part3]))74 self.assertFalse(cmds._check_for_collisions([part1, part2, part3]))
75 self.assertEqual(75 self.assertEqual(
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 '
77 'common which have different contents:\n'
77 ' 1\n'78 ' 1\n'
78 ' a/2\n',79 ' a/2\n',
79 fake_logger.output)80 fake_logger.output)
8081
=== modified file 'snapcraft/tests/test_copy_plugin.py'
--- snapcraft/tests/test_copy_plugin.py 2015-07-23 14:23:29 +0000
+++ snapcraft/tests/test_copy_plugin.py 2015-10-05 19:37:43 +0000
@@ -73,4 +73,5 @@
7373
74 c = CopyPlugin("copy", self.mock_options)74 c = CopyPlugin("copy", self.mock_options)
75 self.assertTrue(c.build())75 self.assertTrue(c.build())
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,
77 "dir/dst")))
7778
=== modified file 'snapcraft/tests/test_meta.py'
--- snapcraft/tests/test_meta.py 2015-09-21 05:04:31 +0000
+++ snapcraft/tests/test_meta.py 2015-10-05 19:37:43 +0000
@@ -44,7 +44,8 @@
44 }44 }
4545
46 def test_plain_no_binaries_or_services(self):46 def test_plain_no_binaries_or_services(self):
47 y = meta._compose_package_yaml('meta', self.config_data, ['armhf', 'amd64'])47 y = meta._compose_package_yaml('meta', self.config_data,
48 ['armhf', 'amd64'])
4849
49 expected = {50 expected = {
50 'name': 'my-package',51 'name': 'my-package',
@@ -74,7 +75,8 @@
74 'binary2': {'exec': 'binary2.sh'},75 'binary2': {'exec': 'binary2.sh'},
75 }76 }
7677
77 y = meta._compose_package_yaml('meta', self.config_data, ['armhf', 'amd64'])78 y = meta._compose_package_yaml('meta', self.config_data,
79 ['armhf', 'amd64'])
7880
79 self.assertEqual(len(y['binaries']), 2)81 self.assertEqual(len(y['binaries']), 2)
80 for b in y['binaries']:82 for b in y['binaries']:
@@ -92,7 +94,8 @@
92 },94 },
93 }95 }
9496
95 y = meta._compose_package_yaml('meta', self.config_data, ['armhf', 'amd64'])97 y = meta._compose_package_yaml('meta', self.config_data,
98 ['armhf', 'amd64'])
9699
97 self.assertEqual(len(y['services']), 2)100 self.assertEqual(len(y['services']), 2)
98 for b in y['services']:101 for b in y['services']:
@@ -105,7 +108,8 @@
105 def test_plain_no_binaries_or_services_with_optionals(self):108 def test_plain_no_binaries_or_services_with_optionals(self):
106 self.config_data['frameworks'] = ['mir', ]109 self.config_data['frameworks'] = ['mir', ]
107110
108 y = meta._compose_package_yaml('meta', self.config_data, ['armhf', 'amd64'])111 y = meta._compose_package_yaml('meta', self.config_data,
112 ['armhf', 'amd64'])
109113
110 expected = {114 expected = {
111 'name': 'my-package',115 'name': 'my-package',
@@ -120,7 +124,8 @@
120124
121 def test_compose_readme(self):125 def test_compose_readme(self):
122 self.config_data['summary'] = 'one line summary'126 self.config_data['summary'] = 'one line summary'
123 self.config_data['description'] = 'the description\nwhich can be longer'127 self.config_data['description'] = \
128 'the description\nwhich can be longer'
124129
125 readme_text = '''one line summary130 readme_text = '''one line summary
126the description131the description
@@ -170,7 +175,8 @@
170 }175 }
171 }176 }
172177
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),
179 'snap', 'meta')
174 self.hooks_dir = os.path.join(self.meta_dir, 'hooks')180 self.hooks_dir = os.path.join(self.meta_dir, 'hooks')
175181
176 self.expected_open_calls = [182 self.expected_open_calls = [
@@ -263,7 +269,8 @@
263 mock_wrap_exe.assert_has_calls([269 mock_wrap_exe.assert_has_calls([
264 call(270 call(
265 '$SNAP_APP_PATH/bin/bash',271 '$SNAP_APP_PATH/bin/bash',
266 os.path.join(os.path.abspath(os.curdir), 'snap/bin/bash.wrapper'),272 os.path.join(os.path.abspath(os.curdir),
273 'snap/bin/bash.wrapper'),
267 ),274 ),
268 call(275 call(
269 'bin/config',276 'bin/config',
@@ -273,14 +280,18 @@
273 ),280 ),
274 ])281 ])
275 self.mock_copyfile.assert_has_calls([282 self.mock_copyfile.assert_has_calls([
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,
277 call('file.apparmor', os.path.join(self.meta_dir, 'file.apparmor')),284 'my-icon.png')),
278 call('file.seccomp', os.path.join(self.meta_dir, 'file.seccomp')),285 call('file.apparmor', os.path.join(self.meta_dir,
286 'file.apparmor')),
287 call('file.seccomp', os.path.join(self.meta_dir,
288 'file.seccomp')),
279 ])289 ])
280290
281 @patch('snapcraft.meta._write_wrap_exe')291 @patch('snapcraft.meta._write_wrap_exe')
282 @patch('snapcraft.meta.open', create=True)292 @patch('snapcraft.meta.open', create=True)
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,
294 mock_wrap_exe):
284 self.config_data['config'] = 'python3 my.py --config'295 self.config_data['config'] = 'python3 my.py --config'
285296
286 meta.create(self.config_data, ['amd64'])297 meta.create(self.config_data, ['amd64'])
@@ -294,7 +305,8 @@
294 mock_wrap_exe.assert_has_calls([305 mock_wrap_exe.assert_has_calls([
295 call(306 call(
296 '$SNAP_APP_PATH/bin/bash',307 '$SNAP_APP_PATH/bin/bash',
297 os.path.join(os.path.abspath(os.curdir), 'snap/bin/bash.wrapper'),308 os.path.join(os.path.abspath(os.curdir),
309 'snap/bin/bash.wrapper'),
298 ),310 ),
299 call(311 call(
300 'python3',312 'python3',
@@ -311,7 +323,8 @@
311323
312 meta.create(self.config_data, ['amd64'])324 meta.create(self.config_data, ['amd64'])
313325
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,
327 exist_ok=True)
315 mock_the_open.assert_has_calls(self.expected_open_calls)328 mock_the_open.assert_has_calls(self.expected_open_calls)
316329
317330
318331
=== modified file 'snapcraft/tests/test_plugin.py'
--- snapcraft/tests/test_plugin.py 2015-09-22 03:51:37 +0000
+++ snapcraft/tests/test_plugin.py 2015-10-05 19:37:43 +0000
@@ -76,7 +76,8 @@
7676
77 include, exclude = plugin._get_file_list(stage_set)77 include, exclude = plugin._get_file_list(stage_set)
7878
79 self.assertEqual(include, ['opt/something', 'usr/bin', '-everything', r'\a'])79 self.assertEqual(include, ['opt/something', 'usr/bin',
80 '-everything', r'\a'])
80 self.assertEqual(exclude, ['etc', 'usr/lib/*.a'])81 self.assertEqual(exclude, ['etc', 'usr/lib/*.a'])
8182
82 def test_fileset_only_includes(self):83 def test_fileset_only_includes(self):
@@ -182,7 +183,8 @@
182 dstdir = tmpdir + '/stage'183 dstdir = tmpdir + '/stage'
183 os.makedirs(dstdir)184 os.makedirs(dstdir)
184185
185 snap_files, snap_dirs = plugin.migratable_filesets(filesets[key]['fileset'], srcdir)186 snap_files, snap_dirs = plugin.migratable_filesets(
187 filesets[key]['fileset'], srcdir)
186 plugin._migrate_files(snap_files, snap_dirs, srcdir, dstdir)188 plugin._migrate_files(snap_files, snap_dirs, srcdir, dstdir)
187189
188 expected = []190 expected = []
189191
=== modified file 'snapcraft/tests/test_repo.py'
--- snapcraft/tests/test_repo.py 2015-09-23 14:24:04 +0000
+++ snapcraft/tests/test_repo.py 2015-10-05 19:37:43 +0000
@@ -31,7 +31,8 @@
31 sources_list = repo._format_sources_list(31 sources_list = repo._format_sources_list(
32 repo._DEFAULT_SOURCES, 'amd64', 'vivid')32 repo._DEFAULT_SOURCES, 'amd64', 'vivid')
3333
34 expected_sources_list = '''deb http://ar.archive.ubuntu.com/ubuntu/ vivid main restricted34 expected_sources_list = \
35 '''deb http://ar.archive.ubuntu.com/ubuntu/ vivid main restricted
35deb http://ar.archive.ubuntu.com/ubuntu/ vivid-updates main restricted36deb http://ar.archive.ubuntu.com/ubuntu/ vivid-updates main restricted
36deb http://ar.archive.ubuntu.com/ubuntu/ vivid universe37deb http://ar.archive.ubuntu.com/ubuntu/ vivid universe
37deb http://ar.archive.ubuntu.com/ubuntu/ vivid-updates universe38deb http://ar.archive.ubuntu.com/ubuntu/ vivid-updates universe
@@ -48,7 +49,8 @@
48 sources_list = repo._format_sources_list(49 sources_list = repo._format_sources_list(
49 repo._DEFAULT_SOURCES, 'armhf', 'trusty')50 repo._DEFAULT_SOURCES, 'armhf', 'trusty')
5051
51 expected_sources_list = '''deb http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted52 expected_sources_list = \
53 '''deb http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted
52deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates main restricted54deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates main restricted
53deb http://ports.ubuntu.com/ubuntu-ports/ trusty universe55deb http://ports.ubuntu.com/ubuntu-ports/ trusty universe
54deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates universe56deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates universe
5557
=== modified file 'snapcraft/tests/test_sources.py'
--- snapcraft/tests/test_sources.py 2015-09-01 09:58:55 +0000
+++ snapcraft/tests/test_sources.py 2015-10-05 19:37:43 +0000
@@ -98,7 +98,8 @@
98 bzr.pull()98 bzr.pull()
9999
100 self.mock_run.assert_called_once_with(100 self.mock_run.assert_called_once_with(
101 ['bzr', 'branch', '-r', 'tag:tag', 'lp:my-source', 'source_dir'], cwd=os.getcwd())101 ['bzr', 'branch', '-r', 'tag:tag', 'lp:my-source',
102 'source_dir'], cwd=os.getcwd())
102103
103 def test_pull_existing_with_tag(self):104 def test_pull_existing_with_tag(self):
104 self.mock_path_exists.return_value = True105 self.mock_path_exists.return_value = True
@@ -107,7 +108,8 @@
107 bzr.pull()108 bzr.pull()
108109
109 self.mock_run.assert_called_once_with(110 self.mock_run.assert_called_once_with(
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',
112 'source_dir'], cwd=os.getcwd())
111113
112 def test_provision(self):114 def test_provision(self):
113 bzr = sources.Bazaar('lp:my-source', 'source_dir')115 bzr = sources.Bazaar('lp:my-source', 'source_dir')
@@ -135,18 +137,21 @@
135 ['git', 'clone', 'git://my-source', 'source_dir'], cwd=os.getcwd())137 ['git', 'clone', 'git://my-source', 'source_dir'], cwd=os.getcwd())
136138
137 def test_pull_branch(self):139 def test_pull_branch(self):
138 git = sources.Git('git://my-source', 'source_dir', source_branch='my-branch')140 git = sources.Git('git://my-source', 'source_dir',
141 source_branch='my-branch')
139 git.pull()142 git.pull()
140143
141 self.mock_run.assert_called_once_with(144 self.mock_run.assert_called_once_with(
142 ['git', 'clone', '--branch', 'my-branch', 'git://my-source', 'source_dir'], cwd=os.getcwd())145 ['git', 'clone', '--branch', 'my-branch', 'git://my-source',
146 'source_dir'], cwd=os.getcwd())
143147
144 def test_pull_tag(self):148 def test_pull_tag(self):
145 git = sources.Git('git://my-source', 'source_dir', source_tag='tag')149 git = sources.Git('git://my-source', 'source_dir', source_tag='tag')
146 git.pull()150 git.pull()
147151
148 self.mock_run.assert_called_once_with(152 self.mock_run.assert_called_once_with(
149 ['git', 'clone', '--branch', 'tag', 'git://my-source', 'source_dir'], cwd=os.getcwd())153 ['git', 'clone', '--branch', 'tag', 'git://my-source',
154 'source_dir'], cwd=os.getcwd())
150155
151 def test_pull_existing(self):156 def test_pull_existing(self):
152 self.mock_path_exists.return_value = True157 self.mock_path_exists.return_value = True
@@ -155,7 +160,8 @@
155 git.pull()160 git.pull()
156161
157 self.mock_run.assert_called_once_with(162 self.mock_run.assert_called_once_with(
158 ['git', '-C', 'source_dir', 'pull', 'git://my-source', 'HEAD'], cwd=os.getcwd())163 ['git', '-C', 'source_dir', 'pull', 'git://my-source',
164 'HEAD'], cwd=os.getcwd())
159165
160 def test_pull_existing_with_tag(self):166 def test_pull_existing_with_tag(self):
161 self.mock_path_exists.return_value = True167 self.mock_path_exists.return_value = True
@@ -164,16 +170,19 @@
164 git.pull()170 git.pull()
165171
166 self.mock_run.assert_called_once_with(172 self.mock_run.assert_called_once_with(
167 ['git', '-C', 'source_dir', 'pull', 'git://my-source', 'refs/tags/tag'], cwd=os.getcwd())173 ['git', '-C', 'source_dir', 'pull', 'git://my-source',
174 'refs/tags/tag'], cwd=os.getcwd())
168175
169 def test_pull_existing_with_branch(self):176 def test_pull_existing_with_branch(self):
170 self.mock_path_exists.return_value = True177 self.mock_path_exists.return_value = True
171178
172 git = sources.Git('git://my-source', 'source_dir', source_branch='my-branch')179 git = sources.Git('git://my-source', 'source_dir',
180 source_branch='my-branch')
173 git.pull()181 git.pull()
174182
175 self.mock_run.assert_called_once_with(183 self.mock_run.assert_called_once_with(
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',
185 'refs/heads/my-branch'], cwd=os.getcwd())
177186
178 def test_provision(self):187 def test_provision(self):
179 bzr = sources.Git('git://my-source', 'source_dir')188 bzr = sources.Git('git://my-source', 'source_dir')
@@ -184,9 +193,11 @@
184193
185 def test_init_with_source_branch_and_tag_raises_exception(self):194 def test_init_with_source_branch_and_tag_raises_exception(self):
186 with self.assertRaises(sources.IncompatibleOptionsError) as raised:195 with self.assertRaises(sources.IncompatibleOptionsError) as raised:
187 sources.Git('git://mysource', 'source_dir', source_tag='tag', source_branch='branch')196 sources.Git('git://mysource', 'source_dir', source_tag='tag',
197 source_branch='branch')
188198
189 expected_message = 'can\'t specify both source-tag and source-branch for a git source'199 expected_message = \
200 'can\'t specify both source-tag and source-branch for a git source'
190 self.assertEqual(raised.exception.message, expected_message)201 self.assertEqual(raised.exception.message, expected_message)
191202
192203
@@ -200,18 +211,22 @@
200 ['hg', 'clone', 'hg://my-source', 'source_dir'], cwd=os.getcwd())211 ['hg', 'clone', 'hg://my-source', 'source_dir'], cwd=os.getcwd())
201212
202 def test_pull_branch(self):213 def test_pull_branch(self):
203 hg = sources.Mercurial('hg://my-source', 'source_dir', source_branch='my-branch')214 hg = sources.Mercurial('hg://my-source', 'source_dir',
215 source_branch='my-branch')
204 hg.pull()216 hg.pull()
205217
206 self.mock_run.assert_called_once_with(218 self.mock_run.assert_called_once_with(
207 ['hg', 'clone', '-u', 'my-branch', 'hg://my-source', 'source_dir'], cwd=os.getcwd())219 ['hg', 'clone', '-u', 'my-branch', 'hg://my-source',
220 'source_dir'], cwd=os.getcwd())
208221
209 def test_pull_tag(self):222 def test_pull_tag(self):
210 hg = sources.Mercurial('hg://my-source', 'source_dir', source_tag='tag')223 hg = sources.Mercurial('hg://my-source', 'source_dir',
224 source_tag='tag')
211 hg.pull()225 hg.pull()
212226
213 self.mock_run.assert_called_once_with(227 self.mock_run.assert_called_once_with(
214 ['hg', 'clone', '-u', 'tag', 'hg://my-source', 'source_dir'], cwd=os.getcwd())228 ['hg', 'clone', '-u', 'tag', 'hg://my-source',
229 'source_dir'], cwd=os.getcwd())
215230
216 def test_pull_existing(self):231 def test_pull_existing(self):
217 self.mock_path_exists.return_value = True232 self.mock_path_exists.return_value = True
@@ -225,7 +240,8 @@
225 def test_pull_existing_with_tag(self):240 def test_pull_existing_with_tag(self):
226 self.mock_path_exists.return_value = True241 self.mock_path_exists.return_value = True
227242
228 hg = sources.Mercurial('hg://my-source', 'source_dir', source_tag='tag')243 hg = sources.Mercurial('hg://my-source', 'source_dir',
244 source_tag='tag')
229 hg.pull()245 hg.pull()
230246
231 self.mock_run.assert_called_once_with(247 self.mock_run.assert_called_once_with(
@@ -234,11 +250,13 @@
234 def test_pull_existing_with_branch(self):250 def test_pull_existing_with_branch(self):
235 self.mock_path_exists.return_value = True251 self.mock_path_exists.return_value = True
236252
237 hg = sources.Mercurial('hg://my-source', 'source_dir', source_branch='my-branch')253 hg = sources.Mercurial('hg://my-source', 'source_dir',
254 source_branch='my-branch')
238 hg.pull()255 hg.pull()
239256
240 self.mock_run.assert_called_once_with(257 self.mock_run.assert_called_once_with(
241 ['hg', 'pull', '-b', 'my-branch', 'hg://my-source'], cwd=os.getcwd())258 ['hg', 'pull', '-b', 'my-branch', 'hg://my-source'],
259 cwd=os.getcwd())
242260
243 def test_provision(self):261 def test_provision(self):
244 bzr = sources.Mercurial('hg://my-source', 'source_dir')262 bzr = sources.Mercurial('hg://my-source', 'source_dir')
@@ -249,9 +267,12 @@
249267
250 def test_init_with_source_branch_and_tag_raises_exception(self):268 def test_init_with_source_branch_and_tag_raises_exception(self):
251 with self.assertRaises(sources.IncompatibleOptionsError) as raised:269 with self.assertRaises(sources.IncompatibleOptionsError) as raised:
252 sources.Mercurial('hg://mysource', 'source_dir', source_tag='tag', source_branch='branch')270 sources.Mercurial('hg://mysource', 'source_dir', source_tag='tag',
271 source_branch='branch')
253272
254 expected_message = 'can\'t specify both source-tag and source-branch for a mercurial source'273 expected_message = (
274 'can\'t specify both source-tag and source-branch for a mercurial '
275 'source')
255 self.assertEqual(raised.exception.message, expected_message)276 self.assertEqual(raised.exception.message, expected_message)
256277
257278
@@ -288,7 +309,8 @@
288 local.provision('dst')309 local.provision('dst')
289310
290 self.mock_rmdir.assert_called_once_with('dst')311 self.mock_rmdir.assert_called_once_with('dst')
291 self.mock_symlink.assert_called_once_with('/home/ubuntu/sources/snap/source', 'dst')312 self.mock_symlink.assert_called_once_with(
313 '/home/ubuntu/sources/snap/source', 'dst')
292314
293 def test_provision_when_target_is_file(self):315 def test_provision_when_target_is_file(self):
294 self.mock_isdir.return_value = False316 self.mock_isdir.return_value = False
@@ -297,4 +319,5 @@
297 local.provision('dst')319 local.provision('dst')
298320
299 self.mock_remove.assert_called_once_with('dst')321 self.mock_remove.assert_called_once_with('dst')
300 self.mock_symlink.assert_called_once_with('/home/ubuntu/sources/snap/source', 'dst')322 self.mock_symlink.assert_called_once_with(
323 '/home/ubuntu/sources/snap/source', 'dst')
301324
=== modified file 'snapcraft/tests/test_yaml.py'
--- snapcraft/tests/test_yaml.py 2015-10-01 08:54:15 +0000
+++ snapcraft/tests/test_yaml.py 2015-10-05 19:37:43 +0000
@@ -101,7 +101,8 @@
101 self.useFixture(fake_logger)101 self.useFixture(fake_logger)
102102
103 # no snapcraft.yaml103 # no snapcraft.yaml
104 with self.assertRaises(snapcraft.yaml.SnapcraftYamlFileError) as raised:104 with self.assertRaises(
105 snapcraft.yaml.SnapcraftYamlFileError) as raised:
105 snapcraft.yaml.Config()106 snapcraft.yaml.Config()
106107
107 self.assertEqual(raised.exception.file, 'snapcraft.yaml')108 self.assertEqual(raised.exception.file, 'snapcraft.yaml')
@@ -130,7 +131,9 @@
130 with self.assertRaises(snapcraft.yaml.SnapcraftLogicError) as raised:131 with self.assertRaises(snapcraft.yaml.SnapcraftLogicError) as raised:
131 snapcraft.yaml.Config()132 snapcraft.yaml.Config()
132133
133 self.assertEqual(raised.exception.message, 'circular dependency chain found in parts definition')134 self.assertEqual(
135 raised.exception.message,
136 'circular dependency chain found in parts definition')
134 self.assertFalse(self.mock_wiki.get_part.called)137 self.assertFalse(self.mock_wiki.get_part.called)
135138
136 @unittest.mock.patch('snapcraft.yaml.Config.load_plugin')139 @unittest.mock.patch('snapcraft.yaml.Config.load_plugin')
@@ -153,7 +156,8 @@
153 with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised:156 with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised:
154 snapcraft.yaml.Config()157 snapcraft.yaml.Config()
155158
156 self.assertEqual(raised.exception.message, '\'name\' is a required property')159 self.assertEqual(raised.exception.message,
160 '\'name\' is a required property')
157161
158 @unittest.mock.patch('snapcraft.yaml.Config.load_plugin')162 @unittest.mock.patch('snapcraft.yaml.Config.load_plugin')
159 def test_invalid_yaml_invalid_name_as_number(self, mock_loadPlugin):163 def test_invalid_yaml_invalid_name_as_number(self, mock_loadPlugin):
@@ -175,7 +179,8 @@
175 with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised:179 with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised:
176 snapcraft.yaml.Config()180 snapcraft.yaml.Config()
177181
178 self.assertEqual(raised.exception.message, '1 is not of type \'string\'')182 self.assertEqual(raised.exception.message,
183 '1 is not of type \'string\'')
179184
180 @unittest.mock.patch('snapcraft.yaml.Config.load_plugin')185 @unittest.mock.patch('snapcraft.yaml.Config.load_plugin')
181 def test_invalid_yaml_invalid_name_chars(self, mock_loadPlugin):186 def test_invalid_yaml_invalid_name_chars(self, mock_loadPlugin):
@@ -197,7 +202,9 @@
197 with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised:202 with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised:
198 snapcraft.yaml.Config()203 snapcraft.yaml.Config()
199204
200 self.assertEqual(raised.exception.message, '\'myapp@me_1.0\' does not match \'^[a-z0-9][a-z0-9+-]*$\'')205 self.assertEqual(
206 raised.exception.message,
207 '\'myapp@me_1.0\' does not match \'^[a-z0-9][a-z0-9+-]*$\'')
201208
202 @unittest.mock.patch('snapcraft.yaml.Config.load_plugin')209 @unittest.mock.patch('snapcraft.yaml.Config.load_plugin')
203 def test_deprecation_for_type(self, mock_loadPlugin):210 def test_deprecation_for_type(self, mock_loadPlugin):
@@ -240,7 +247,9 @@
240 with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised:247 with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised:
241 snapcraft.yaml.Config()248 snapcraft.yaml.Config()
242249
243 self.assertEqual(raised.exception.message, '\'description\' is a required property')250 self.assertEqual(
251 raised.exception.message,
252 '\'description\' is a required property')
244253
245 @unittest.mock.patch('snapcraft.yaml.Config.load_plugin')254 @unittest.mock.patch('snapcraft.yaml.Config.load_plugin')
246 def test_tab_in_yaml(self, mock_loadPlugin):255 def test_tab_in_yaml(self, mock_loadPlugin):
@@ -296,7 +305,8 @@
296 snapcraft.yaml.Config()305 snapcraft.yaml.Config()
297306
298 mock_loadPlugin.assert_called_with('part1', 'go', {307 mock_loadPlugin.assert_called_with('part1', 'go', {
299 'snap': ['/usr/lib/wget.so', '/usr/bin/wget', '/usr/share/my-icon.png'],308 'snap': ['/usr/lib/wget.so', '/usr/bin/wget',
309 '/usr/share/my-icon.png'],
300 'stage-packages': ['fswebcam'],310 'stage-packages': ['fswebcam'],
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'],
302 })312 })
@@ -333,11 +343,13 @@
333 with self.subTest(key=key):343 with self.subTest(key=key):
334 del data[key]344 del data[key]
335345
336 with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised:346 with self.assertRaises(
347 snapcraft.yaml.SnapcraftSchemaError) as raised:
337 snapcraft.yaml._validate_snapcraft_yaml(data)348 snapcraft.yaml._validate_snapcraft_yaml(data)
338349
339 expected_message = '\'{}\' is a required property'.format(key)350 expected_message = '\'{}\' is a required property'.format(key)
340 self.assertEqual(raised.exception.message, expected_message, msg=data)351 self.assertEqual(raised.exception.message, expected_message,
352 msg=data)
341353
342 def test_invalid_names(self):354 def test_invalid_names(self):
343 invalid_names = [355 invalid_names = [
@@ -351,11 +363,15 @@
351 with self.subTest(key=name):363 with self.subTest(key=name):
352 data['name'] = name364 data['name'] = name
353365
354 with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised:366 with self.assertRaises(
367 snapcraft.yaml.SnapcraftSchemaError) as raised:
355 snapcraft.yaml._validate_snapcraft_yaml(data)368 snapcraft.yaml._validate_snapcraft_yaml(data)
356369
357 expected_message = '\'{}\' does not match \'^[a-z0-9][a-z0-9+-]*$\''.format(name)370 expected_message = (
358 self.assertEqual(raised.exception.message, expected_message, msg=data)371 '\'{}\' does not match \'^[a-z0-9][a-z0-9+-]*$\'').format(
372 name)
373 self.assertEqual(raised.exception.message, expected_message,
374 msg=data)
359375
360 def test_summary_too_long(self):376 def test_summary_too_long(self):
361 self.data['summary'] = 'a' * 80377 self.data['summary'] = 'a' * 80
@@ -363,7 +379,8 @@
363 snapcraft.yaml._validate_snapcraft_yaml(self.data)379 snapcraft.yaml._validate_snapcraft_yaml(self.data)
364380
365 expected_message = '\'{}\' is too long'.format(self.data['summary'])381 expected_message = '\'{}\' is too long'.format(self.data['summary'])
366 self.assertEqual(raised.exception.message, expected_message, msg=self.data)382 self.assertEqual(raised.exception.message, expected_message,
383 msg=self.data)
367384
368 def test_valid_types(self):385 def test_valid_types(self):
369 self.data['type'] = 'app'386 self.data['type'] = 'app'
@@ -386,11 +403,14 @@
386 with self.subTest(key=t):403 with self.subTest(key=t):
387 data['type'] = t404 data['type'] = t
388405
389 with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised:406 with self.assertRaises(
407 snapcraft.yaml.SnapcraftSchemaError) as raised:
390 snapcraft.yaml._validate_snapcraft_yaml(data)408 snapcraft.yaml._validate_snapcraft_yaml(data)
391409
392 expected_message = '\'{}\' is not one of [\'app\', \'framework\']'.format(t)410 expected_message = ('\'{}\' is not one of ' +
393 self.assertEqual(raised.exception.message, expected_message, msg=data)411 '[\'app\', \'framework\']').format(t)
412 self.assertEqual(raised.exception.message, expected_message,
413 msg=data)
394414
395 def test_valid_services(self):415 def test_valid_services(self):
396 self.data['services'] = {416 self.data['services'] = {
@@ -416,11 +436,14 @@
416 with self.subTest(key=t):436 with self.subTest(key=t):
417 data['binaries'] = {t: invalid_names[t]}437 data['binaries'] = {t: invalid_names[t]}
418438
419 with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised:439 with self.assertRaises(
440 snapcraft.yaml.SnapcraftSchemaError) as raised:
420 snapcraft.yaml._validate_snapcraft_yaml(data)441 snapcraft.yaml._validate_snapcraft_yaml(data)
421442
422 expected_message = 'Additional properties are not allowed (\'{}\' was unexpected)'.format(t)443 expected_message = ('Additional properties are not allowed '
423 self.assertEqual(raised.exception.message, expected_message, msg=data)444 '(\'{}\' was unexpected)').format(t)
445 self.assertEqual(raised.exception.message, expected_message,
446 msg=data)
424447
425 def test_invalid_service_names(self):448 def test_invalid_service_names(self):
426 invalid_names = {449 invalid_names = {
@@ -435,11 +458,14 @@
435 with self.subTest(key=t):458 with self.subTest(key=t):
436 data['services'] = {t: invalid_names[t]}459 data['services'] = {t: invalid_names[t]}
437460
438 with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised:461 with self.assertRaises(
462 snapcraft.yaml.SnapcraftSchemaError) as raised:
439 snapcraft.yaml._validate_snapcraft_yaml(data)463 snapcraft.yaml._validate_snapcraft_yaml(data)
440464
441 expected_message = 'Additional properties are not allowed (\'{}\' was unexpected)'.format(t)465 expected_message = ('Additional properties are not allowed '
442 self.assertEqual(raised.exception.message, expected_message, msg=data)466 '(\'{}\' was unexpected)').format(t)
467 self.assertEqual(raised.exception.message, expected_message,
468 msg=data)
443469
444 def test_services_required_properties(self):470 def test_services_required_properties(self):
445 self.data['services'] = {'service1': {}}471 self.data['services'] = {'service1': {}}
@@ -448,19 +474,24 @@
448 snapcraft.yaml._validate_snapcraft_yaml(self.data)474 snapcraft.yaml._validate_snapcraft_yaml(self.data)
449475
450 expected_message = '\'start\' is a required property'476 expected_message = '\'start\' is a required property'
451 self.assertEqual(raised.exception.message, expected_message, msg=self.data)477 self.assertEqual(raised.exception.message, expected_message,
478 msg=self.data)
452479
453 def test_schema_file_not_found(self):480 def test_schema_file_not_found(self):
454 mock_the_open = unittest.mock.mock_open()481 mock_the_open = unittest.mock.mock_open()
455 mock_the_open.side_effect = FileNotFoundError()482 mock_the_open.side_effect = FileNotFoundError()
456483
457 with unittest.mock.patch('snapcraft.yaml.open', mock_the_open, create=True):484 with unittest.mock.patch('snapcraft.yaml.open', mock_the_open,
458 with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised:485 create=True):
486 with self.assertRaises(
487 snapcraft.yaml.SnapcraftSchemaError) as raised:
459 snapcraft.yaml._validate_snapcraft_yaml(self.data)488 snapcraft.yaml._validate_snapcraft_yaml(self.data)
460489
461 expected_path = os.path.join(snapcraft.common.get_schemadir(), 'snapcraft.yaml')490 expected_path = os.path.join(snapcraft.common.get_schemadir(),
491 'snapcraft.yaml')
462 mock_the_open.assert_called_once_with(expected_path)492 mock_the_open.assert_called_once_with(expected_path)
463 expected_message = 'snapcraft validation file is missing from installation path'493 expected_message = ('snapcraft validation file is missing from '
494 'installation path')
464 self.assertEqual(raised.exception.message, expected_message)495 self.assertEqual(raised.exception.message, expected_message)
465496
466 def test_icon_missing(self):497 def test_icon_missing(self):
@@ -470,7 +501,8 @@
470 snapcraft.yaml._validate_snapcraft_yaml(self.data)501 snapcraft.yaml._validate_snapcraft_yaml(self.data)
471502
472 expected_message = '\'my-icon.png\' is not a \'icon-path\''503 expected_message = '\'my-icon.png\' is not a \'icon-path\''
473 self.assertEqual(raised.exception.message, expected_message, msg=self.data)504 self.assertEqual(raised.exception.message, expected_message,
505 msg=self.data)
474506
475507
476class TestFilesets(TestCase):508class TestFilesets(TestCase):
477509
=== modified file 'snapcraft/yaml.py'
--- snapcraft/yaml.py 2015-10-02 18:25:33 +0000
+++ snapcraft/yaml.py 2015-10-05 19:37:43 +0000
@@ -145,14 +145,16 @@
145 present = True145 present = True
146 break146 break
147 if not present:147 if not present:
148 new_parts.append(self.load_plugin(required_part, required_part, {}))148 new_parts.append(self.load_plugin(required_part,
149 required_part, {}))
149150
150 def _compute_part_dependencies(self, after_requests):151 def _compute_part_dependencies(self, after_requests):
151 '''Gather the lists of dependencies and adds to all_parts.'''152 '''Gather the lists of dependencies and adds to all_parts.'''
152 w = snapcraft.wiki.Wiki()153 w = snapcraft.wiki.Wiki()
153154
154 for part in self.all_parts:155 for part in self.all_parts:
155 dep_names = part.config.get('requires', []) + after_requests.get(part.names()[0], [])156 dep_names = part.config.get('requires', []) + \
157 after_requests.get(part.names()[0], [])
156 for dep in dep_names:158 for dep in dep_names:
157 found = False159 found = False
158 for i in range(len(self.all_parts)):160 for i in range(len(self.all_parts)):
@@ -164,9 +166,11 @@
164 wiki_part = w.get_part(dep)166 wiki_part = w.get_part(dep)
165 found = True if wiki_part else False167 found = True if wiki_part else False
166 if found:168 if found:
167 part.deps.append(self.load_plugin(dep, wiki_part['plugin'], wiki_part))169 part.deps.append(self.load_plugin(
170 dep, wiki_part['plugin'], wiki_part))
168 if not found:171 if not found:
169 raise SnapcraftLogicError('part name missing {}'.format(dep))172 raise SnapcraftLogicError(
173 'part name missing {}'.format(dep))
170174
171 def _sort_parts(self):175 def _sort_parts(self):
172 '''Performs an inneficient but easy to follow sorting of parts.'''176 '''Performs an inneficient but easy to follow sorting of parts.'''
@@ -184,14 +188,16 @@
184 top_part = part188 top_part = part
185 break189 break
186 if not top_part:190 if not top_part:
187 raise SnapcraftLogicError('circular dependency chain found in parts definition')191 raise SnapcraftLogicError(
192 'circular dependency chain found in parts definition')
188 sorted_parts = [top_part] + sorted_parts193 sorted_parts = [top_part] + sorted_parts
189 self.all_parts.remove(top_part)194 self.all_parts.remove(top_part)
190195
191 return sorted_parts196 return sorted_parts
192197
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):
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,
200 properties, load_code=load_code)
195201
196 self.build_tools += part.config.get('build-packages', [])202 self.build_tools += part.config.get('build-packages', [])
197 self.all_parts.append(part)203 self.all_parts.append(part)
@@ -280,15 +286,18 @@
280286
281287
282def _validate_snapcraft_yaml(snapcraft_yaml):288def _validate_snapcraft_yaml(snapcraft_yaml):
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(),
290 'snapcraft.yaml'))
284291
285 try:292 try:
286 with open(schema_file) as fp:293 with open(schema_file) as fp:
287 schema = yaml.load(fp)294 schema = yaml.load(fp)
288 format_check = jsonschema.FormatChecker()295 format_check = jsonschema.FormatChecker()
289 jsonschema.validate(snapcraft_yaml, schema, format_checker=format_check)296 jsonschema.validate(snapcraft_yaml, schema,
297 format_checker=format_check)
290 except FileNotFoundError:298 except FileNotFoundError:
291 raise SnapcraftSchemaError('snapcraft validation file is missing from installation path')299 raise SnapcraftSchemaError(
300 'snapcraft validation file is missing from installation path')
292 except jsonschema.ValidationError as e:301 except jsonschema.ValidationError as e:
293 raise SnapcraftSchemaError(e.message)302 raise SnapcraftSchemaError(e.message)
294303

Subscribers

People subscribed via source and target branches

to all changes: