Merge lp:~cjwatson/launchpad/external-dependencies-trusted into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18470
Proposed branch: lp:~cjwatson/launchpad/external-dependencies-trusted
Merge into: lp:launchpad
Diff against target: 39 lines (+12/-1)
2 files modified
lib/lp/soyuz/browser/tests/archive-views.txt (+9/-0)
lib/lp/soyuz/interfaces/archive.py (+3/-1)
To merge this branch: bzr merge lp:~cjwatson/launchpad/external-dependencies-trusted
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+331490@code.launchpad.net

Commit message

Accept and ignore options (e.g. "[trusted=yes]") in sources.list lines passed via external_dependencies.

Description of the change

We need this to tolerate builder chroots without allow-unauthenticated configuration: the external archive that we use for bootstrapping packages with circular dependencies is unsigned.

I considered more careful non-regex-based parsing, but I don't think it's worth the effort as this is just a preliminary scan for errors before handing it off to the builder.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)
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/soyuz/browser/tests/archive-views.txt'
2--- lib/lp/soyuz/browser/tests/archive-views.txt 2016-01-26 15:47:37 +0000
3+++ lib/lp/soyuz/browser/tests/archive-views.txt 2017-09-28 14:31:29 +0000
4@@ -1490,3 +1490,12 @@
5 ... "deb http://example.com/ karmic universe\n"
6 ... "deb example.com/ karmic main")
7 ['deb example.com/ karmic main: Invalid URL']
8+
9+Options are permitted:
10+
11+ >>> print validate_external_dependencies(
12+ ... "deb [trusted=yes] http://example.com/ karmic main")
13+ []
14+ >>> print validate_external_dependencies(
15+ ... "deb [trusted=yes] example.com/ karmic main")
16+ ['deb [trusted=yes] example.com/ karmic main: Invalid URL']
17
18=== modified file 'lib/lp/soyuz/interfaces/archive.py'
19--- lib/lp/soyuz/interfaces/archive.py 2017-06-26 09:54:51 +0000
20+++ lib/lp/soyuz/interfaces/archive.py 2017-09-28 14:31:29 +0000
21@@ -55,6 +55,7 @@
22 ]
23
24 import httplib
25+import re
26 from urlparse import urlparse
27
28 from lazr.restful.declarations import (
29@@ -2468,8 +2469,9 @@
30 # The field can consist of multiple entries separated by
31 # newlines, so process each in turn.
32 for dep in ext_deps.splitlines():
33+ dep_without_options = re.sub(r"^([^ ]*) \[[^]]*\] ", r"\1 ", dep)
34 try:
35- deb, url, suite, components = dep.split(" ", 3)
36+ deb, url, suite, components = dep_without_options.split(" ", 3)
37 except ValueError:
38 errors.append(
39 "'%s' is not a complete and valid sources.list entry"