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
=== modified file 'debian/changelog'
--- debian/changelog 2018-06-12 23:24:28 +0000
+++ debian/changelog 2018-07-30 10:10:39 +0000
@@ -1,3 +1,9 @@
1launchpad-buildd (164) UNRELEASED; urgency=medium
2
3 * Configure snap proxy settings for Subversion (LP: #1668358).
4
5 -- Colin Watson <cjwatson@ubuntu.com> Mon, 30 Jul 2018 11:07:53 +0100
6
1launchpad-buildd (163) xenial; urgency=medium7launchpad-buildd (163) xenial; urgency=medium
28
3 * Revert change to tolerate chroot tarballs with a top-level directory9 * Revert change to tolerate chroot tarballs with a top-level directory
410
=== modified file 'lpbuildd/target/build_snap.py'
--- lpbuildd/target/build_snap.py 2018-06-12 06:25:33 +0000
+++ lpbuildd/target/build_snap.py 2018-07-30 10:10:39 +0000
@@ -10,6 +10,12 @@
10import logging10import logging
11import os.path11import os.path
12import sys12import sys
13import tempfile
14from textwrap import dedent
15try:
16 from urllib.parse import urlparse
17except ImportError:
18 from urlparse import urlparse
1319
14from lpbuildd.target.operation import Operation20from lpbuildd.target.operation import Operation
15from lpbuildd.target.vcs import VCSOperationMixin21from lpbuildd.target.vcs import VCSOperationMixin
@@ -79,6 +85,28 @@
79 json.dump(status, status_file)85 json.dump(status, status_file)
80 os.rename("%s.tmp" % status_path, status_path)86 os.rename("%s.tmp" % status_path, status_path)
8187
88 def install_svn_servers(self):
89 proxy = urlparse(self.args.proxy_url)
90 svn_servers = dedent("""\
91 [global]
92 http-proxy-host = {host}
93 http-proxy-port = {port}
94 """.format(host=proxy.hostname, port=proxy.port))
95 # We should never end up with an authenticated proxy here since
96 # lpbuildd.snap deals with it, but it's almost as easy to just
97 # handle it as to assert that we don't need to.
98 if proxy.username:
99 svn_servers += "http-proxy-username = {}\n".format(proxy.username)
100 if proxy.password:
101 svn_servers += "http-proxy-password = {}\n".format(proxy.password)
102 with tempfile.NamedTemporaryFile(mode="w+") as svn_servers_file:
103 svn_servers_file.write(svn_servers)
104 svn_servers_file.flush()
105 os.fchmod(svn_servers_file.fileno(), 0o644)
106 self.backend.run(["mkdir", "-p", "/root/.subversion"])
107 self.backend.copy_in(
108 svn_servers_file.name, "/root/.subversion/servers")
109
82 def install(self):110 def install(self):
83 logger.info("Running install phase...")111 logger.info("Running install phase...")
84 deps = []112 deps = []
@@ -110,6 +138,7 @@
110 self.backend.copy_in(138 self.backend.copy_in(
111 os.path.join(self.slavebin, "snap-git-proxy"),139 os.path.join(self.slavebin, "snap-git-proxy"),
112 "/usr/local/bin/snap-git-proxy")140 "/usr/local/bin/snap-git-proxy")
141 self.install_svn_servers()
113142
114 def repo(self):143 def repo(self):
115 """Collect git or bzr branch."""144 """Collect git or bzr branch."""
116145
=== modified file 'lpbuildd/target/tests/test_build_snap.py'
--- lpbuildd/target/tests/test_build_snap.py 2018-06-12 06:25:33 +0000
+++ lpbuildd/target/tests/test_build_snap.py 2018-07-30 10:10:39 +0000
@@ -150,10 +150,17 @@
150 build_snap.install()150 build_snap.install()
151 self.assertThat(build_snap.backend.run.calls, MatchesListwise([151 self.assertThat(build_snap.backend.run.calls, MatchesListwise([
152 RanAptGet("install", "git", "python3", "socat", "snapcraft"),152 RanAptGet("install", "git", "python3", "socat", "snapcraft"),
153 RanCommand(["mkdir", "-p", "/root/.subversion"]),
153 ]))154 ]))
154 self.assertEqual(155 self.assertEqual(
155 (b"proxy script\n", stat.S_IFREG | 0o755),156 (b"proxy script\n", stat.S_IFREG | 0o755),
156 build_snap.backend.backend_fs["/usr/local/bin/snap-git-proxy"])157 build_snap.backend.backend_fs["/usr/local/bin/snap-git-proxy"])
158 self.assertEqual(
159 (b"[global]\n"
160 b"http-proxy-host = proxy.example\n"
161 b"http-proxy-port = 3128\n",
162 stat.S_IFREG | 0o644),
163 build_snap.backend.backend_fs["/root/.subversion/servers"])
157164
158 def test_install_channels(self):165 def test_install_channels(self):
159 args = [166 args = [

Subscribers

People subscribed via source and target branches

to all changes: