Merge lp:~cjwatson/launchpad-buildd/svn-proxy into lp:launchpad-buildd

Proposed by Colin Watson
Status: Merged
Merged at revision: 346
Proposed branch: lp:~cjwatson/launchpad-buildd/svn-proxy
Merge into: lp:launchpad-buildd
Diff against target: 89 lines (+42/-0)
3 files modified
debian/changelog (+6/-0)
lpbuildd/target/build_snap.py (+29/-0)
lpbuildd/target/tests/test_build_snap.py (+7/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad-buildd/svn-proxy
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+351753@code.launchpad.net

Commit message

Configure snap proxy settings for Subversion.

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

Yuck.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2018-06-12 23:24:28 +0000
3+++ debian/changelog 2018-07-30 10:10:39 +0000
4@@ -1,3 +1,9 @@
5+launchpad-buildd (164) UNRELEASED; urgency=medium
6+
7+ * Configure snap proxy settings for Subversion (LP: #1668358).
8+
9+ -- Colin Watson <cjwatson@ubuntu.com> Mon, 30 Jul 2018 11:07:53 +0100
10+
11 launchpad-buildd (163) xenial; urgency=medium
12
13 * Revert change to tolerate chroot tarballs with a top-level directory
14
15=== modified file 'lpbuildd/target/build_snap.py'
16--- lpbuildd/target/build_snap.py 2018-06-12 06:25:33 +0000
17+++ lpbuildd/target/build_snap.py 2018-07-30 10:10:39 +0000
18@@ -10,6 +10,12 @@
19 import logging
20 import os.path
21 import sys
22+import tempfile
23+from textwrap import dedent
24+try:
25+ from urllib.parse import urlparse
26+except ImportError:
27+ from urlparse import urlparse
28
29 from lpbuildd.target.operation import Operation
30 from lpbuildd.target.vcs import VCSOperationMixin
31@@ -79,6 +85,28 @@
32 json.dump(status, status_file)
33 os.rename("%s.tmp" % status_path, status_path)
34
35+ def install_svn_servers(self):
36+ proxy = urlparse(self.args.proxy_url)
37+ svn_servers = dedent("""\
38+ [global]
39+ http-proxy-host = {host}
40+ http-proxy-port = {port}
41+ """.format(host=proxy.hostname, port=proxy.port))
42+ # We should never end up with an authenticated proxy here since
43+ # lpbuildd.snap deals with it, but it's almost as easy to just
44+ # handle it as to assert that we don't need to.
45+ if proxy.username:
46+ svn_servers += "http-proxy-username = {}\n".format(proxy.username)
47+ if proxy.password:
48+ svn_servers += "http-proxy-password = {}\n".format(proxy.password)
49+ with tempfile.NamedTemporaryFile(mode="w+") as svn_servers_file:
50+ svn_servers_file.write(svn_servers)
51+ svn_servers_file.flush()
52+ os.fchmod(svn_servers_file.fileno(), 0o644)
53+ self.backend.run(["mkdir", "-p", "/root/.subversion"])
54+ self.backend.copy_in(
55+ svn_servers_file.name, "/root/.subversion/servers")
56+
57 def install(self):
58 logger.info("Running install phase...")
59 deps = []
60@@ -110,6 +138,7 @@
61 self.backend.copy_in(
62 os.path.join(self.slavebin, "snap-git-proxy"),
63 "/usr/local/bin/snap-git-proxy")
64+ self.install_svn_servers()
65
66 def repo(self):
67 """Collect git or bzr branch."""
68
69=== modified file 'lpbuildd/target/tests/test_build_snap.py'
70--- lpbuildd/target/tests/test_build_snap.py 2018-06-12 06:25:33 +0000
71+++ lpbuildd/target/tests/test_build_snap.py 2018-07-30 10:10:39 +0000
72@@ -150,10 +150,17 @@
73 build_snap.install()
74 self.assertThat(build_snap.backend.run.calls, MatchesListwise([
75 RanAptGet("install", "git", "python3", "socat", "snapcraft"),
76+ RanCommand(["mkdir", "-p", "/root/.subversion"]),
77 ]))
78 self.assertEqual(
79 (b"proxy script\n", stat.S_IFREG | 0o755),
80 build_snap.backend.backend_fs["/usr/local/bin/snap-git-proxy"])
81+ self.assertEqual(
82+ (b"[global]\n"
83+ b"http-proxy-host = proxy.example\n"
84+ b"http-proxy-port = 3128\n",
85+ stat.S_IFREG | 0o644),
86+ build_snap.backend.backend_fs["/root/.subversion/servers"])
87
88 def test_install_channels(self):
89 args = [

Subscribers

People subscribed via source and target branches

to all changes: