Merge lp:~cjwatson/launchpad-buildd/snap-git-proxy into lp:launchpad-buildd
- snap-git-proxy
- Merge into trunk
Proposed by
Colin Watson
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 219 | ||||
Proposed branch: | lp:~cjwatson/launchpad-buildd/snap-git-proxy | ||||
Merge into: | lp:launchpad-buildd | ||||
Diff against target: |
224 lines (+64/-7) 11 files modified
MANIFEST.in (+1/-0) buildsnap (+12/-0) debian/changelog (+1/-0) debian/launchpad-buildd.install (+1/-0) lpbuildd/slave.py (+3/-0) lpbuildd/tests/buildlog (+1/-0) lpbuildd/tests/buildlog.long (+2/-0) lpbuildd/tests/test_1.diff (+8/-1) lpbuildd/tests/test_2.diff (+6/-5) lpbuildd/tests/test_buildd_slave.py (+1/-1) snap-git-proxy (+28/-0) |
||||
To merge this branch: | bzr merge lp:~cjwatson/launchpad-buildd/snap-git-proxy | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
William Grant | code | Approve | |
Review via email: mp+323691@code.launchpad.net |
Commit message
Configure a git:// proxy for snap builds (LP: #1663920).
Description of the change
To post a comment you must log in.
Revision history for this message
William Grant (wgrant) : | # |
review:
Approve
(code)
Revision history for this message
Colin Watson (cjwatson) : | # |
- 217. By Colin Watson
-
Sanitise snap proxy auth from logs.
Revision history for this message
Colin Watson (cjwatson) : | # |
- 218. By Colin Watson
-
Merge trunk.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'MANIFEST.in' | |||
2 | --- MANIFEST.in 2017-04-26 12:24:32 +0000 | |||
3 | +++ MANIFEST.in 2017-05-11 11:45:36 +0000 | |||
4 | @@ -15,6 +15,7 @@ | |||
5 | 15 | include sbuildrc | 15 | include sbuildrc |
6 | 16 | include scan-for-processes | 16 | include scan-for-processes |
7 | 17 | include slave-prep | 17 | include slave-prep |
8 | 18 | include snap-git-proxy | ||
9 | 18 | include sudo-wrapper | 19 | include sudo-wrapper |
10 | 19 | include template-buildd-slave.conf | 20 | include template-buildd-slave.conf |
11 | 20 | include test_buildd_generatetranslationtemplates | 21 | include test_buildd_generatetranslationtemplates |
12 | 21 | 22 | ||
13 | === modified file 'buildsnap' | |||
14 | --- buildsnap 2017-04-03 12:30:15 +0000 | |||
15 | +++ buildsnap 2017-05-11 11:45:36 +0000 | |||
16 | @@ -117,7 +117,16 @@ | |||
17 | 117 | deps.append("bzr") | 117 | deps.append("bzr") |
18 | 118 | else: | 118 | else: |
19 | 119 | deps.append("git") | 119 | deps.append("git") |
20 | 120 | if self.options.proxy_url: | ||
21 | 121 | deps.extend(["python3", "socat"]) | ||
22 | 120 | self.chroot(["apt-get", "-y", "install"] + deps) | 122 | self.chroot(["apt-get", "-y", "install"] + deps) |
23 | 123 | if self.options.proxy_url: | ||
24 | 124 | subprocess.check_call([ | ||
25 | 125 | "sudo", "cp", "-a", | ||
26 | 126 | os.path.join(os.path.dirname(__file__), "snap-git-proxy"), | ||
27 | 127 | os.path.join( | ||
28 | 128 | self.chroot_path, "usr", "local", "bin", "snap-git-proxy"), | ||
29 | 129 | ]) | ||
30 | 121 | 130 | ||
31 | 122 | def repo(self): | 131 | def repo(self): |
32 | 123 | """Collect git or bzr branch.""" | 132 | """Collect git or bzr branch.""" |
33 | @@ -126,6 +135,7 @@ | |||
34 | 126 | if self.options.proxy_url: | 135 | if self.options.proxy_url: |
35 | 127 | env["http_proxy"] = self.options.proxy_url | 136 | env["http_proxy"] = self.options.proxy_url |
36 | 128 | env["https_proxy"] = self.options.proxy_url | 137 | env["https_proxy"] = self.options.proxy_url |
37 | 138 | env["GIT_PROXY_COMMAND"] = "/usr/local/bin/snap-git-proxy" | ||
38 | 129 | if self.options.branch is not None: | 139 | if self.options.branch is not None: |
39 | 130 | self.run_build_command(['ls', '/build']) | 140 | self.run_build_command(['ls', '/build']) |
40 | 131 | cmd = ["bzr", "branch", self.options.branch, self.name] | 141 | cmd = ["bzr", "branch", self.options.branch, self.name] |
41 | @@ -161,6 +171,7 @@ | |||
42 | 161 | if self.options.proxy_url: | 171 | if self.options.proxy_url: |
43 | 162 | env["http_proxy"] = self.options.proxy_url | 172 | env["http_proxy"] = self.options.proxy_url |
44 | 163 | env["https_proxy"] = self.options.proxy_url | 173 | env["https_proxy"] = self.options.proxy_url |
45 | 174 | env["GIT_PROXY_COMMAND"] = "/usr/local/bin/snap-git-proxy" | ||
46 | 164 | self.run_build_command( | 175 | self.run_build_command( |
47 | 165 | ["snapcraft", "pull"], | 176 | ["snapcraft", "pull"], |
48 | 166 | path=os.path.join("/build", self.name), | 177 | path=os.path.join("/build", self.name), |
49 | @@ -173,6 +184,7 @@ | |||
50 | 173 | if self.options.proxy_url: | 184 | if self.options.proxy_url: |
51 | 174 | env["http_proxy"] = self.options.proxy_url | 185 | env["http_proxy"] = self.options.proxy_url |
52 | 175 | env["https_proxy"] = self.options.proxy_url | 186 | env["https_proxy"] = self.options.proxy_url |
53 | 187 | env["GIT_PROXY_COMMAND"] = "/usr/local/bin/snap-git-proxy" | ||
54 | 176 | self.run_build_command( | 188 | self.run_build_command( |
55 | 177 | ["snapcraft"], path=os.path.join("/build", self.name), env=env) | 189 | ["snapcraft"], path=os.path.join("/build", self.name), env=env) |
56 | 178 | 190 | ||
57 | 179 | 191 | ||
58 | === modified file 'debian/changelog' | |||
59 | --- debian/changelog 2017-05-11 08:52:10 +0000 | |||
60 | +++ debian/changelog 2017-05-11 11:45:36 +0000 | |||
61 | @@ -4,6 +4,7 @@ | |||
62 | 4 | other XML-RPC status information (LP: #1679157). | 4 | other XML-RPC status information (LP: #1679157). |
63 | 5 | * Write out trusted keys sent by buildd-manager (LP: #1626739). | 5 | * Write out trusted keys sent by buildd-manager (LP: #1626739). |
64 | 6 | * Add tests for lpbuildd.pottery, extracted from Launchpad. | 6 | * Add tests for lpbuildd.pottery, extracted from Launchpad. |
65 | 7 | * Configure a git:// proxy for snap builds (LP: #1663920). | ||
66 | 7 | 8 | ||
67 | 8 | -- Colin Watson <cjwatson@ubuntu.com> Fri, 31 Mar 2017 15:31:10 +0100 | 9 | -- Colin Watson <cjwatson@ubuntu.com> Fri, 31 Mar 2017 15:31:10 +0100 |
68 | 9 | 10 | ||
69 | 10 | 11 | ||
70 | === modified file 'debian/launchpad-buildd.install' | |||
71 | --- debian/launchpad-buildd.install 2017-04-26 12:24:32 +0000 | |||
72 | +++ debian/launchpad-buildd.install 2017-05-11 11:45:36 +0000 | |||
73 | @@ -14,6 +14,7 @@ | |||
74 | 14 | sbuild-package usr/share/launchpad-buildd/slavebin | 14 | sbuild-package usr/share/launchpad-buildd/slavebin |
75 | 15 | scan-for-processes usr/share/launchpad-buildd/slavebin | 15 | scan-for-processes usr/share/launchpad-buildd/slavebin |
76 | 16 | slave-prep usr/share/launchpad-buildd/slavebin | 16 | slave-prep usr/share/launchpad-buildd/slavebin |
77 | 17 | snap-git-proxy usr/share/launchpad-buildd/slavebin | ||
78 | 17 | sudo-wrapper usr/share/launchpad-buildd/slavebin | 18 | sudo-wrapper usr/share/launchpad-buildd/slavebin |
79 | 18 | umount-chroot usr/share/launchpad-buildd/slavebin | 19 | umount-chroot usr/share/launchpad-buildd/slavebin |
80 | 19 | unpack-chroot usr/share/launchpad-buildd/slavebin | 20 | unpack-chroot usr/share/launchpad-buildd/slavebin |
81 | 20 | 21 | ||
82 | === modified file 'lpbuildd/slave.py' | |||
83 | --- lpbuildd/slave.py 2017-05-11 08:42:49 +0000 | |||
84 | +++ lpbuildd/slave.py 2017-05-11 11:45:36 +0000 | |||
85 | @@ -37,9 +37,12 @@ | |||
86 | 37 | # This regular expression will be used to remove authentication | 37 | # This regular expression will be used to remove authentication |
87 | 38 | # credentials from URLs. | 38 | # credentials from URLs. |
88 | 39 | password_re = re.compile('://([^:]+:[^@]+@)(\S+)') | 39 | password_re = re.compile('://([^:]+:[^@]+@)(\S+)') |
89 | 40 | # Snap proxy passwords are UUIDs. | ||
90 | 41 | snap_proxy_auth_re = re.compile(',proxyauth=[^:]+:[A-Za-z0-9-]+') | ||
91 | 40 | 42 | ||
92 | 41 | for line in text_seq: | 43 | for line in text_seq: |
93 | 42 | sanitized_line = password_re.sub(r'://\2', line) | 44 | sanitized_line = password_re.sub(r'://\2', line) |
94 | 45 | sanitized_line = snap_proxy_auth_re.sub('', sanitized_line) | ||
95 | 43 | yield sanitized_line | 46 | yield sanitized_line |
96 | 44 | 47 | ||
97 | 45 | 48 | ||
98 | 46 | 49 | ||
99 | === modified file 'lpbuildd/tests/buildlog' | |||
100 | --- lpbuildd/tests/buildlog 2011-11-09 07:50:56 +0000 | |||
101 | +++ lpbuildd/tests/buildlog 2017-05-11 11:45:36 +0000 | |||
102 | @@ -21,3 +21,4 @@ | |||
103 | 21 | Need to get 0B/2832kB of archives. | 21 | Need to get 0B/2832kB of archives. |
104 | 22 | After unpacking 94.2kB of additional disk space will be used. | 22 | After unpacking 94.2kB of additional disk space will be used. |
105 | 23 | (Reading database ... 8942 files and directories currently installed.) | 23 | (Reading database ... 8942 files and directories currently installed.) |
106 | 24 | socat STDIO PROXY:snap-proxy.launchpad.dev:github.com:443,proxyport=3128,proxyauth=user:blah | ||
107 | 24 | 25 | ||
108 | === modified file 'lpbuildd/tests/buildlog.long' | |||
109 | --- lpbuildd/tests/buildlog.long 2011-11-09 07:50:56 +0000 | |||
110 | +++ lpbuildd/tests/buildlog.long 2017-05-11 11:45:36 +0000 | |||
111 | @@ -21,6 +21,7 @@ | |||
112 | 21 | Need to get 0B/2832kB of archives. | 21 | Need to get 0B/2832kB of archives. |
113 | 22 | After unpacking 94.2kB of additional disk space will be used. | 22 | After unpacking 94.2kB of additional disk space will be used. |
114 | 23 | (Reading database ... 8942 files and directories currently installed.) | 23 | (Reading database ... 8942 files and directories currently installed.) |
115 | 24 | socat STDIO PROXY:snap-proxy.launchpad.dev:github.com:443,proxyport=3128,proxyauth=user:blah | ||
116 | 24 | RUN: /usr/share/launchpad-buildd/slavebin/unpack-chroot ['unpack-chroot', '370614-896976', '/home/buildd/filecache-default/a40e3c410938399b35051833fe5244f9ac6f3774'] | 25 | RUN: /usr/share/launchpad-buildd/slavebin/unpack-chroot ['unpack-chroot', '370614-896976', '/home/buildd/filecache-default/a40e3c410938399b35051833fe5244f9ac6f3774'] |
117 | 25 | Unpacking chroot for build 370614-896976 | 26 | Unpacking chroot for build 370614-896976 |
118 | 26 | RUN: /usr/share/launchpad-buildd/slavebin/mount-chroot ['mount-chroot', '370614-896976'] | 27 | RUN: /usr/share/launchpad-buildd/slavebin/mount-chroot ['mount-chroot', '370614-896976'] |
119 | @@ -80,3 +81,4 @@ | |||
120 | 80 | Get:3 http://scrub:this@ftpmaster.internal gutsy/main Packages [1085kB] | 81 | Get:3 http://scrub:this@ftpmaster.internal gutsy/main Packages [1085kB] |
121 | 81 | Get:4 http://ftpmaster.internal gutsy/universe Packages [3991kB] | 82 | Get:4 http://ftpmaster.internal gutsy/universe Packages [3991kB] |
122 | 82 | Fetched 5142kB in 5s (1012kB/s) | 83 | Fetched 5142kB in 5s (1012kB/s) |
123 | 84 | socat STDIO PROXY:snap-proxy.launchpad.dev:github.com:443,proxyport=3128,proxyauth=user:blah | ||
124 | 83 | 85 | ||
125 | === modified file 'lpbuildd/tests/test_1.diff' | |||
126 | --- lpbuildd/tests/test_1.diff 2011-11-09 07:50:56 +0000 | |||
127 | +++ lpbuildd/tests/test_1.diff 2017-05-11 11:45:36 +0000 | |||
128 | @@ -14,4 +14,11 @@ | |||
129 | 14 | +Get:3 http://ftpmaster.internal gutsy/main Packages [1085kB] | 14 | +Get:3 http://ftpmaster.internal gutsy/main Packages [1085kB] |
130 | 15 | Get:4 http://ftpmaster.internal gutsy/universe Packages [3991kB] | 15 | Get:4 http://ftpmaster.internal gutsy/universe Packages [3991kB] |
131 | 16 | Fetched 5142kB in 5s (1012kB/s) | 16 | Fetched 5142kB in 5s (1012kB/s) |
132 | 17 | Reading package lists... | ||
133 | 18 | \ No newline at end of file | 17 | \ No newline at end of file |
134 | 18 | Reading package lists... | ||
135 | 19 | @@ -21,4 +21,4 @@ | ||
136 | 20 | |||
137 | 21 | Need to get 0B/2832kB of archives. | ||
138 | 22 | After unpacking 94.2kB of additional disk space will be used. | ||
139 | 23 | (Reading database ... 8942 files and directories currently installed.) | ||
140 | 24 | -socat STDIO PROXY:snap-proxy.launchpad.dev:github.com:443,proxyport=3128,proxyauth=user:blah | ||
141 | 25 | +socat STDIO PROXY:snap-proxy.launchpad.dev:github.com:443,proxyport=3128 | ||
142 | 19 | \ No newline at end of file | 26 | \ No newline at end of file |
143 | 20 | 27 | ||
144 | === modified file 'lpbuildd/tests/test_2.diff' | |||
145 | --- lpbuildd/tests/test_2.diff 2011-11-09 07:50:56 +0000 | |||
146 | +++ lpbuildd/tests/test_2.diff 2017-05-11 11:45:36 +0000 | |||
147 | @@ -2,10 +2,9 @@ | |||
148 | 2 | 2 | ||
149 | 3 | +++ | 3 | +++ |
150 | 4 | 4 | ||
152 | 5 | @@ -1,11 +1,10 @@ | 5 | @@ -1,10 +1,9 @@ |
153 | 6 | 6 | ||
156 | 7 | -ting chroot for build 370614-896976 | 7 | -l ['apply-ogre-model', '370614-896976', 'universe'] |
155 | 8 | RUN: /usr/share/launchpad-buildd/slavebin/apply-ogre-model ['apply-ogre-model', '370614-896976', 'universe'] | ||
157 | 9 | Attempting OGRE for universe in build-370614-896976 | 8 | Attempting OGRE for universe in build-370614-896976 |
158 | 10 | RUN: /usr/share/launchpad-buildd/slavebin/update-debian-chroot ['update-debian-chroot', '370614-896976'] | 9 | RUN: /usr/share/launchpad-buildd/slavebin/update-debian-chroot ['update-debian-chroot', '370614-896976'] |
159 | 11 | Updating debian chroot for build 370614-896976 | 10 | Updating debian chroot for build 370614-896976 |
160 | @@ -17,7 +16,7 @@ | |||
161 | 17 | Get:4 http://ftpmaster.internal gutsy/universe Packages [3991kB] | 16 | Get:4 http://ftpmaster.internal gutsy/universe Packages [3991kB] |
162 | 18 | Fetched 5142kB in 5s (1012kB/s) | 17 | Fetched 5142kB in 5s (1012kB/s) |
163 | 19 | Reading package lists... | 18 | Reading package lists... |
165 | 20 | @@ -26,8 +25,8 @@ | 19 | @@ -25,9 +24,9 @@ |
166 | 21 | 20 | ||
167 | 22 | Attempting OGRE for universe in build-370614-896976 | 21 | Attempting OGRE for universe in build-370614-896976 |
168 | 23 | RUN: /usr/share/launchpad-buildd/slavebin/update-debian-chroot ['update-debian-chroot', '370614-896976'] | 22 | RUN: /usr/share/launchpad-buildd/slavebin/update-debian-chroot ['update-debian-chroot', '370614-896976'] |
169 | @@ -29,4 +28,6 @@ | |||
170 | 29 | +Get:2 http://ftpmaster.internal gutsy Release [65.9kB] | 28 | +Get:2 http://ftpmaster.internal gutsy Release [65.9kB] |
171 | 30 | +Get:3 http://ftpmaster.internal gutsy/main Packages [1085kB] | 29 | +Get:3 http://ftpmaster.internal gutsy/main Packages [1085kB] |
172 | 31 | Get:4 http://ftpmaster.internal gutsy/universe Packages [3991kB] | 30 | Get:4 http://ftpmaster.internal gutsy/universe Packages [3991kB] |
173 | 32 | Fetched 5142kB in 5s (1012kB/s) | ||
174 | 33 | \ No newline at end of file | 31 | \ No newline at end of file |
175 | 32 | Fetched 5142kB in 5s (1012kB/s) | ||
176 | 33 | -socat STDIO PROXY:snap-proxy.launchpad.dev:github.com:443,proxyport=3128,proxyauth=user:blah | ||
177 | 34 | +socat STDIO PROXY:snap-proxy.launchpad.dev:github.com:443,proxyport=3128 | ||
178 | 34 | \ No newline at end of file | 35 | \ No newline at end of file |
179 | 35 | 36 | ||
180 | === modified file 'lpbuildd/tests/test_buildd_slave.py' | |||
181 | --- lpbuildd/tests/test_buildd_slave.py 2014-05-10 17:40:29 +0000 | |||
182 | +++ lpbuildd/tests/test_buildd_slave.py 2017-05-11 11:45:36 +0000 | |||
183 | @@ -3,7 +3,7 @@ | |||
184 | 3 | 3 | ||
185 | 4 | """Buildd Slave tests. | 4 | """Buildd Slave tests. |
186 | 5 | 5 | ||
188 | 6 | This file contains the follwoing tests: | 6 | This file contains the following tests: |
189 | 7 | 7 | ||
190 | 8 | * Basic authentication handling (used to download private sources); | 8 | * Basic authentication handling (used to download private sources); |
191 | 9 | * Build log sanitization (removal of passwords from private buildlog); | 9 | * Build log sanitization (removal of passwords from private buildlog); |
192 | 10 | 10 | ||
193 | === added file 'snap-git-proxy' | |||
194 | --- snap-git-proxy 1970-01-01 00:00:00 +0000 | |||
195 | +++ snap-git-proxy 2017-05-11 11:45:36 +0000 | |||
196 | @@ -0,0 +1,28 @@ | |||
197 | 1 | #! /usr/bin/python3 | ||
198 | 2 | # Copyright 2017 Canonical Ltd. This software is licensed under the | ||
199 | 3 | # GNU Affero General Public License version 3 (see the file LICENSE). | ||
200 | 4 | |||
201 | 5 | """Proxy the git protocol via http_proxy. | ||
202 | 6 | |||
203 | 7 | Note that this is copied into the build chroot and run there. | ||
204 | 8 | """ | ||
205 | 9 | |||
206 | 10 | import os | ||
207 | 11 | import sys | ||
208 | 12 | from urllib.parse import urlparse | ||
209 | 13 | |||
210 | 14 | |||
211 | 15 | def main(): | ||
212 | 16 | proxy_url = urlparse(os.environ["http_proxy"]) | ||
213 | 17 | proxy_arg = "PROXY:%s:%s:%s" % ( | ||
214 | 18 | proxy_url.hostname, sys.argv[1], sys.argv[2]) | ||
215 | 19 | if proxy_url.port: | ||
216 | 20 | proxy_arg += ",proxyport=%s" % proxy_url.port | ||
217 | 21 | if proxy_url.username: | ||
218 | 22 | proxy_arg += ",proxyauth=%s:%s" % ( | ||
219 | 23 | proxy_url.username, proxy_url.password) | ||
220 | 24 | os.execvp("socat", ["socat", "STDIO", proxy_arg]) | ||
221 | 25 | |||
222 | 26 | |||
223 | 27 | if __name__ == "__main__": | ||
224 | 28 | main() |