repo: allow for architecture-specific stage-packages #876

Merged
merged 3 commits into from Nov 9, 2016
Jump to file or symbol
Failed to load files and symbols.
+22 −2
Split
@@ -79,9 +79,11 @@ contain.
be staged before the dependent part starts its lifecycle.*
* `stage-packages` (list of strings)
A list of Ubuntu packages to use that would support the part creation.
+ To restrict to a specific architecture, use `pkg:arch`.
* `build-packages` (list of strings)
A list of Ubuntu packages to be installed on the host to aid in building
the part. These packages will not go into the final snap.
+ To restrict to a specific architecture, use `pkg:arch`.
* `filesets` (yaml subsection)
A dictionary with filesets, the key being a recognizable user defined
string and its value a list of strings of files to be included or
@@ -245,8 +245,18 @@ def get(self, package_names):
def _get(self, apt_cache, package_names):
manifest_dep_names = self._manifest_dep_names(apt_cache)
+ deb_arch = snapcraft.ProjectOptions().deb_arch
for name in package_names:
+ fields = name.split(":", 2)
+ name = fields[0]
+
+ # Skip if the architecture doesn't match deb_arch
+ if len(fields) == 2 and fields[1] != deb_arch:
+ logger.debug('Skipping {!r} based on architecture filter'
+ .format(name))
+ continue
+
try:
logger.debug('Marking {!r} as to install'.format(name))
apt_cache[name].mark_install()
@@ -41,7 +41,8 @@ def test_get_package(self, mock_apt):
project_options = snapcraft.ProjectOptions(
use_geoip=False)
ubuntu = repo.Ubuntu(self.tempdir, project_options=project_options)
- ubuntu.get(['fake-package'])
+ ubuntu.get(['fake-package', 'fake-package-arch1:test',
+ 'fake-package-arch2:%s' % project_options.deb_arch])
mock_apt.assert_has_calls([
call.apt_pkg.config.set('Dir::Cache::Archives',
@@ -64,7 +65,14 @@ def test_get_package(self, mock_apt):
# __getitem__ is tricky
self.assertIn(
- call('fake-package'), mock_apt.Cache().__getitem__.call_args_list)
+ call('fake-package'),
+ mock_apt.Cache().__getitem__.call_args_list)
+ self.assertNotIn(
+ call('fake-package-arch1'),
+ mock_apt.Cache().__getitem__.call_args_list)
+ self.assertIn(
+ call('fake-package-arch2'),
+ mock_apt.Cache().__getitem__.call_args_list)
@patch('snapcraft.repo._get_geoip_country_code_prefix')
def test_sources_is_none_uses_default(self, mock_cc):