launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #21534
[Merge] lp:~cjwatson/launchpad-buildd/snap-git-proxy into lp:launchpad-buildd
Colin Watson has proposed merging lp:~cjwatson/launchpad-buildd/snap-git-proxy into lp:launchpad-buildd.
Commit message:
Configure a git:// proxy for snap builds (LP: #1663920).
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1663920 in launchpad-buildd: "enable git proxying"
https://bugs.launchpad.net/launchpad-buildd/+bug/1663920
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad-buildd/snap-git-proxy/+merge/323691
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad-buildd/snap-git-proxy into lp:launchpad-buildd.
=== modified file 'MANIFEST.in'
--- MANIFEST.in 2015-11-04 14:10:28 +0000
+++ MANIFEST.in 2017-05-05 18:11:15 +0000
@@ -14,6 +14,7 @@
include sbuildrc
include scan-for-processes
include slave-prep
+include snap-git-proxy
include sudo-wrapper
include template-buildd-slave.conf
include test_buildd_generatetranslationtemplates
=== modified file 'buildsnap'
--- buildsnap 2017-02-10 14:53:12 +0000
+++ buildsnap 2017-05-05 18:11:15 +0000
@@ -98,7 +98,16 @@
deps.append("bzr")
else:
deps.append("git")
+ if self.options.proxy_url:
+ deps.extend(["python3", "socat"])
self.chroot(["apt-get", "-y", "install"] + deps)
+ if self.options.proxy_url:
+ subprocess.check_call([
+ "sudo", "cp", "-a",
+ os.path.join(os.path.dirname(__file__), "snap-git-proxy"),
+ os.path.join(
+ self.chroot_path, "usr", "local", "bin", "snap-git-proxy"),
+ ])
def repo(self):
"""Collect git or bzr branch."""
@@ -107,6 +116,7 @@
if self.options.proxy_url:
env["http_proxy"] = self.options.proxy_url
env["https_proxy"] = self.options.proxy_url
+ env["GIT_PROXY_COMMAND"] = "/usr/local/bin/snap-git-proxy"
if self.options.branch is not None:
self.run_build_command(['ls', '/build'])
cmd = ["bzr", "branch", self.options.branch, self.name]
@@ -133,6 +143,7 @@
if self.options.proxy_url:
env["http_proxy"] = self.options.proxy_url
env["https_proxy"] = self.options.proxy_url
+ env["GIT_PROXY_COMMAND"] = "/usr/local/bin/snap-git-proxy"
self.run_build_command(
["snapcraft", "pull"],
path=os.path.join("/build", self.name),
@@ -145,6 +156,7 @@
if self.options.proxy_url:
env["http_proxy"] = self.options.proxy_url
env["https_proxy"] = self.options.proxy_url
+ env["GIT_PROXY_COMMAND"] = "/usr/local/bin/snap-git-proxy"
self.run_build_command(
["snapcraft"], path=os.path.join("/build", self.name), env=env)
=== modified file 'debian/changelog'
--- debian/changelog 2017-02-10 14:55:42 +0000
+++ debian/changelog 2017-05-05 18:11:15 +0000
@@ -1,3 +1,9 @@
+launchpad-buildd (143) UNRELEASED; urgency=medium
+
+ * Configure a git:// proxy for snap builds (LP: #1663920).
+
+ -- Colin Watson <cjwatson@xxxxxxxxxx> Fri, 05 May 2017 17:12:37 +0100
+
launchpad-buildd (142) trusty; urgency=medium
* lpbuildd.binarypackage: Pass DEB_BUILD_OPTIONS=noautodbgsym if we have
=== modified file 'debian/launchpad-buildd.install'
--- debian/launchpad-buildd.install 2015-08-25 09:23:24 +0000
+++ debian/launchpad-buildd.install 2017-05-05 18:11:15 +0000
@@ -13,6 +13,7 @@
sbuild-package usr/share/launchpad-buildd/slavebin
scan-for-processes usr/share/launchpad-buildd/slavebin
slave-prep usr/share/launchpad-buildd/slavebin
+snap-git-proxy usr/share/launchpad-buildd/slavebin
sudo-wrapper usr/share/launchpad-buildd/slavebin
umount-chroot usr/share/launchpad-buildd/slavebin
unpack-chroot usr/share/launchpad-buildd/slavebin
=== added file 'snap-git-proxy'
--- snap-git-proxy 1970-01-01 00:00:00 +0000
+++ snap-git-proxy 2017-05-05 18:11:15 +0000
@@ -0,0 +1,28 @@
+#! /usr/bin/python3
+# Copyright 2017 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Proxy the git protocol via http_proxy.
+
+Note that this is copied into the build chroot and run there.
+"""
+
+import os
+import sys
+from urllib.parse import urlparse
+
+
+def main():
+ proxy_url = urlparse(os.environ["http_proxy"])
+ proxy_arg = "PROXY:%s:%s:%s" % (
+ proxy_url.hostname, sys.argv[1], sys.argv[2])
+ if proxy_url.port:
+ proxy_arg += ",proxyport=%s" % proxy_url.port
+ if proxy_url.username:
+ proxy_arg += ",proxyauth=%s:%s" % (
+ proxy_url.username, proxy_url.password)
+ os.execvp("socat", ["socat", "STDIO", proxy_arg])
+
+
+if __name__ == "__main__":
+ main()