Merge lp:~cjwatson/launchpad/snap-no-tools-source-if-snapcraft-snap into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18972
Proposed branch: lp:~cjwatson/launchpad/snap-no-tools-source-if-snapcraft-snap
Merge into: lp:launchpad
Diff against target: 105 lines (+59/-10)
2 files modified
lib/lp/snappy/model/snapbuildbehaviour.py (+13/-9)
lib/lp/snappy/tests/test_snapbuildbehaviour.py (+46/-1)
To merge this branch: bzr merge lp:~cjwatson/launchpad/snap-no-tools-source-if-snapcraft-snap
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+367858@code.launchpad.net

Commit message

Only honour snappy.tools_source configuration when snapcraft is being installed from apt.

Description of the change

This configuration item is just so that we have a way to use a different version of snapcraft in an emergency to fix regressions, and if we're installing it as a snap then we have other mechanisms for that. Avoiding it in the snap case means that we don't have to put up with keyserver unreliability at build dispatch time when it doesn't really buy us anything.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/snappy/model/snapbuildbehaviour.py'
2--- lib/lp/snappy/model/snapbuildbehaviour.py 2019-05-22 16:54:09 +0000
3+++ lib/lp/snappy/model/snapbuildbehaviour.py 2019-05-23 18:38:58 +0000
4@@ -122,23 +122,27 @@
5 endpoint=config.snappy.builder_proxy_auth_api_endpoint,
6 token=token['username']))
7 args["name"] = build.snap.store_name or build.snap.name
8- # XXX cjwatson 2015-08-03: Allow tools_source to be overridden at
9- # some more fine-grained level.
10- args["archives"], args["trusted_keys"] = (
11- yield get_sources_list_for_building(
12- build, build.distro_arch_series, None,
13- tools_source=config.snappy.tools_source,
14- tools_fingerprint=config.snappy.tools_fingerprint,
15- logger=logger))
16 channels = build.channels or {}
17 if "snapcraft" not in channels:
18 channels["snapcraft"] = (
19 getFeatureFlag(SNAP_SNAPCRAFT_CHANNEL_FEATURE_FLAG) or "apt")
20- if channels.get("snapcraft") != "apt":
21+ if channels.get("snapcraft") == "apt":
22+ # XXX cjwatson 2015-08-03: Allow tools_source to be overridden
23+ # at some more fine-grained level.
24+ tools_source = config.snappy.tools_source
25+ tools_fingerprint = config.snappy.tools_fingerprint
26+ else:
27 # We have to remove the security proxy that Zope applies to this
28 # dict, since otherwise we'll be unable to serialise it to
29 # XML-RPC.
30 args["channels"] = removeSecurityProxy(channels)
31+ tools_source = None
32+ tools_fingerprint = None
33+ args["archives"], args["trusted_keys"] = (
34+ yield get_sources_list_for_building(
35+ build, build.distro_arch_series, None,
36+ tools_source=tools_source, tools_fingerprint=tools_fingerprint,
37+ logger=logger))
38 if build.snap.branch is not None:
39 args["branch"] = build.snap.branch.bzr_identity
40 elif build.snap.git_ref is not None:
41
42=== modified file 'lib/lp/snappy/tests/test_snapbuildbehaviour.py'
43--- lib/lp/snappy/tests/test_snapbuildbehaviour.py 2019-05-22 16:54:09 +0000
44+++ lib/lp/snappy/tests/test_snapbuildbehaviour.py 2019-05-23 18:38:58 +0000
45@@ -106,7 +106,10 @@
46 TestCaseWithFactory,
47 )
48 from lp.testing.dbuser import dbuser
49-from lp.testing.gpgkeys import gpgkeysdir
50+from lp.testing.gpgkeys import (
51+ gpgkeysdir,
52+ import_public_key,
53+ )
54 from lp.testing.keyserver import InProcessKeyServerFixture
55 from lp.testing.layers import LaunchpadZopelessLayer
56 from lp.xmlrpc.interfaces import IPrivateApplication
57@@ -660,6 +663,48 @@
58 ]))
59
60 @defer.inlineCallbacks
61+ def test_extraBuildArgs_tools_source_channels_apt(self):
62+ # If snapcraft is being installed from apt, extraBuildArgs sends an
63+ # extra archive to provide updates.
64+ yield self.useFixture(InProcessKeyServerFixture()).start()
65+ tools_source = (
66+ "deb http://ppa.launchpad.net/snappy-dev/snapcraft-daily/ubuntu "
67+ "%(series)s main")
68+ tools_fingerprint = "A419AE861E88BC9E04B9C26FBA2B9389DFD20543"
69+ self.pushConfig(
70+ "snappy",
71+ tools_source=tools_source, tools_fingerprint=tools_fingerprint)
72+ import_public_key("test@canonical.com")
73+ job = self.makeJob(channels={"snapcraft": "apt"})
74+ with dbuser(config.builddmaster.dbuser):
75+ args = yield job.extraBuildArgs()
76+ self.assertEqual(
77+ tools_source % {"series": job.build.distro_series.name},
78+ args["archives"][0])
79+ self.assertThat(args["trusted_keys"], MatchesListwise([
80+ Base64KeyMatches("A419AE861E88BC9E04B9C26FBA2B9389DFD20543"),
81+ ]))
82+
83+ @defer.inlineCallbacks
84+ def test_extraBuildArgs_tools_source_channels_snap(self):
85+ # If snapcraft is being installed from apt, extraBuildArgs ignores
86+ # tools_source.
87+ yield self.useFixture(InProcessKeyServerFixture()).start()
88+ tools_source = (
89+ "deb http://ppa.launchpad.net/snappy-dev/snapcraft-daily/ubuntu "
90+ "%(series)s main")
91+ tools_fingerprint = "A419AE861E88BC9E04B9C26FBA2B9389DFD20543"
92+ self.pushConfig(
93+ "snappy",
94+ tools_source=tools_source, tools_fingerprint=tools_fingerprint)
95+ import_public_key("test@canonical.com")
96+ job = self.makeJob(channels={"snapcraft": "stable"})
97+ with dbuser(config.builddmaster.dbuser):
98+ args = yield job.extraBuildArgs()
99+ self.assertNotIn(tools_source, args["archives"])
100+ self.assertEqual([], args["trusted_keys"])
101+
102+ @defer.inlineCallbacks
103 def test_extraBuildArgs_channels(self):
104 # If the build needs particular channels, extraBuildArgs sends them.
105 job = self.makeJob(channels={"snapcraft": "edge"})