Colin Watson has proposed merging lp:~cjwatson/launchpad-buildd/svn-proxy into lp:launchpad-buildd.
Commit message: Configure snap proxy settings for Subversion. Requested reviews: Launchpad code reviewers (launchpad-reviewers) Related bugs: Bug #1668358 in launchpad-buildd: "Snap Builds using SVN Unable to Access Internet" https://bugs.launchpad.net/launchpad-buildd/+bug/1668358 For more details, see: https://code.launchpad.net/~cjwatson/launchpad-buildd/svn-proxy/+merge/351753 -- Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad-buildd/svn-proxy into lp:launchpad-buildd.
=== 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 @@ +launchpad-buildd (164) UNRELEASED; urgency=medium + + * Configure snap proxy settings for Subversion (LP: #1668358). + + -- Colin Watson <[email protected]> Mon, 30 Jul 2018 11:07:53 +0100 + launchpad-buildd (163) xenial; urgency=medium * Revert change to tolerate chroot tarballs with a top-level directory === 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 @@ import logging import os.path import sys +import tempfile +from textwrap import dedent +try: + from urllib.parse import urlparse +except ImportError: + from urlparse import urlparse from lpbuildd.target.operation import Operation from lpbuildd.target.vcs import VCSOperationMixin @@ -79,6 +85,28 @@ json.dump(status, status_file) os.rename("%s.tmp" % status_path, status_path) + def install_svn_servers(self): + proxy = urlparse(self.args.proxy_url) + svn_servers = dedent("""\ + [global] + http-proxy-host = {host} + http-proxy-port = {port} + """.format(host=proxy.hostname, port=proxy.port)) + # We should never end up with an authenticated proxy here since + # lpbuildd.snap deals with it, but it's almost as easy to just + # handle it as to assert that we don't need to. + if proxy.username: + svn_servers += "http-proxy-username = {}\n".format(proxy.username) + if proxy.password: + svn_servers += "http-proxy-password = {}\n".format(proxy.password) + with tempfile.NamedTemporaryFile(mode="w+") as svn_servers_file: + svn_servers_file.write(svn_servers) + svn_servers_file.flush() + os.fchmod(svn_servers_file.fileno(), 0o644) + self.backend.run(["mkdir", "-p", "/root/.subversion"]) + self.backend.copy_in( + svn_servers_file.name, "/root/.subversion/servers") + def install(self): logger.info("Running install phase...") deps = [] @@ -110,6 +138,7 @@ self.backend.copy_in( os.path.join(self.slavebin, "snap-git-proxy"), "/usr/local/bin/snap-git-proxy") + self.install_svn_servers() def repo(self): """Collect git or bzr branch.""" === 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 @@ build_snap.install() self.assertThat(build_snap.backend.run.calls, MatchesListwise([ RanAptGet("install", "git", "python3", "socat", "snapcraft"), + RanCommand(["mkdir", "-p", "/root/.subversion"]), ])) self.assertEqual( (b"proxy script\n", stat.S_IFREG | 0o755), build_snap.backend.backend_fs["/usr/local/bin/snap-git-proxy"]) + self.assertEqual( + (b"[global]\n" + b"http-proxy-host = proxy.example\n" + b"http-proxy-port = 3128\n", + stat.S_IFREG | 0o644), + build_snap.backend.backend_fs["/root/.subversion/servers"]) def test_install_channels(self): args = [
_______________________________________________ Mailing list: https://launchpad.net/~launchpad-reviewers Post to : [email protected] Unsubscribe : https://launchpad.net/~launchpad-reviewers More help : https://help.launchpad.net/ListHelp

