Merge ~cjwatson/launchpad-buildd:flake8 into launchpad-buildd:master
- Git
- lp:~cjwatson/launchpad-buildd
- flake8
- Merge into master
Proposed by
Colin Watson
Status: | Merged |
---|---|
Approved by: | Colin Watson |
Approved revision: | 2faae1482f1a26e354f9658ba8e554b4e272d765 |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~cjwatson/launchpad-buildd:flake8 |
Merge into: | launchpad-buildd:master |
Diff against target: |
907 lines (+211/-168) 27 files modified
.pre-commit-config.yaml (+13/-0) bin/buildrecipe (+21/-19) bin/test_buildd_generatetranslationtemplates (+0/-5) bin/test_buildd_recipe (+5/-6) buildd-genconfig (+36/-31) debian/changelog (+6/-0) debian/upgrade-config (+28/-10) lpbuildd/binarypackage.py (+17/-13) lpbuildd/builder.py (+4/-4) lpbuildd/check_implicit_pointer_functions.py (+7/-7) lpbuildd/oci.py (+1/-2) lpbuildd/proxy.py (+5/-5) lpbuildd/sourcepackagerecipe.py (+2/-3) lpbuildd/target/build_charm.py (+0/-1) lpbuildd/target/lxd.py (+2/-2) lpbuildd/target/operation.py (+0/-2) lpbuildd/target/tests/test_lxd.py (+3/-2) lpbuildd/target/vcs.py (+2/-1) lpbuildd/tests/fakebuilder.py (+4/-4) lpbuildd/tests/oci_tarball.py (+4/-6) lpbuildd/tests/test_binarypackage.py (+15/-15) lpbuildd/tests/test_buildrecipe.py (+29/-25) lpbuildd/tests/test_charm.py (+2/-1) lpbuildd/tests/test_harness.py (+1/-1) lpbuildd/tests/test_sourcepackagerecipe.py (+1/-1) lpbuildd/tests/test_util.py (+2/-1) setup.py (+1/-1) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jürgen Gmach | Approve | ||
Review via email: mp+412903@code.launchpad.net |
Commit message
Add basic pre-commit configuration and apply flake8
Description of the change
To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote : | # |
As mentioned at standup I have no particular objection to the occasional noqa comment, but in this case I found some alternative approaches that avoid line length issues while (IMO) not compromising readability.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml | |||
2 | 0 | new file mode 100644 | 0 | new file mode 100644 |
3 | index 0000000..8970c21 | |||
4 | --- /dev/null | |||
5 | +++ b/.pre-commit-config.yaml | |||
6 | @@ -0,0 +1,13 @@ | |||
7 | 1 | repos: | ||
8 | 2 | - repo: https://github.com/pre-commit/pre-commit-hooks | ||
9 | 3 | rev: v4.0.1 | ||
10 | 4 | hooks: | ||
11 | 5 | - id: check-added-large-files | ||
12 | 6 | - id: check-merge-conflict | ||
13 | 7 | - id: check-xml | ||
14 | 8 | - id: check-yaml | ||
15 | 9 | - id: debug-statements | ||
16 | 10 | - repo: https://github.com/PyCQA/flake8 | ||
17 | 11 | rev: 4.0.1 | ||
18 | 12 | hooks: | ||
19 | 13 | - id: flake8 | ||
20 | diff --git a/bin/buildrecipe b/bin/buildrecipe | |||
21 | index 4d04c4f..5dcab4a 100755 | |||
22 | --- a/bin/buildrecipe | |||
23 | +++ b/bin/buildrecipe | |||
24 | @@ -114,8 +114,8 @@ class RecipeBuilder: | |||
25 | 114 | # using buildd@<hostname>. | 114 | # using buildd@<hostname>. |
26 | 115 | hostname = socket.gethostname() | 115 | hostname = socket.gethostname() |
27 | 116 | email = 'buildd@%s' % hostname | 116 | email = 'buildd@%s' % hostname |
30 | 117 | lsb_release = subprocess.Popen(['sudo', | 117 | lsb_release = subprocess.Popen([ |
31 | 118 | '/usr/sbin/chroot', self.chroot_path, 'lsb_release', | 118 | 'sudo', '/usr/sbin/chroot', self.chroot_path, 'lsb_release', |
32 | 119 | '-r', '-s'], stdout=subprocess.PIPE, universal_newlines=True) | 119 | '-r', '-s'], stdout=subprocess.PIPE, universal_newlines=True) |
33 | 120 | distroseries_version = lsb_release.communicate()[0].rstrip() | 120 | distroseries_version = lsb_release.communicate()[0].rstrip() |
34 | 121 | assert lsb_release.returncode == 0 | 121 | assert lsb_release.returncode == 0 |
35 | @@ -190,12 +190,13 @@ class RecipeBuilder: | |||
36 | 190 | control = self.getSourceControl() | 190 | control = self.getSourceControl() |
37 | 191 | with open(os.path.join( | 191 | with open(os.path.join( |
38 | 192 | self.apt_dir, "%s.dsc" % package), "w") as dummy_dsc: | 192 | self.apt_dir, "%s.dsc" % package), "w") as dummy_dsc: |
45 | 193 | print(dedent("""\ | 193 | print( |
46 | 194 | Format: 1.0 | 194 | dedent("""\ |
47 | 195 | Source: %(package)s | 195 | Format: 1.0 |
48 | 196 | Architecture: any | 196 | Source: %(package)s |
49 | 197 | Version: 99:0 | 197 | Architecture: any |
50 | 198 | Maintainer: invalid@example.org""") % {"package": package}, | 198 | Version: 99:0 |
51 | 199 | Maintainer: invalid@example.org""") % {"package": package}, | ||
52 | 199 | file=dummy_dsc) | 200 | file=dummy_dsc) |
53 | 200 | for field in ( | 201 | for field in ( |
54 | 201 | "Build-Depends", "Build-Depends-Indep", | 202 | "Build-Depends", "Build-Depends-Indep", |
55 | @@ -208,17 +209,18 @@ class RecipeBuilder: | |||
56 | 208 | def runAptFtparchive(self): | 209 | def runAptFtparchive(self): |
57 | 209 | conf_path = os.path.join(self.apt_dir, "ftparchive.conf") | 210 | conf_path = os.path.join(self.apt_dir, "ftparchive.conf") |
58 | 210 | with open(conf_path, "w") as conf: | 211 | with open(conf_path, "w") as conf: |
70 | 211 | print(dedent("""\ | 212 | print( |
71 | 212 | Dir::ArchiveDir "%(apt_dir)s"; | 213 | dedent("""\ |
72 | 213 | Default::Sources::Compress ". bzip2"; | 214 | Dir::ArchiveDir "%(apt_dir)s"; |
73 | 214 | BinDirectory "%(apt_dir)s" { Sources "Sources"; }; | 215 | Default::Sources::Compress ". bzip2"; |
74 | 215 | APT::FTPArchive::Release { | 216 | BinDirectory "%(apt_dir)s" { Sources "Sources"; }; |
75 | 216 | Origin "buildrecipe-archive"; | 217 | APT::FTPArchive::Release { |
76 | 217 | Label "buildrecipe-archive"; | 218 | Origin "buildrecipe-archive"; |
77 | 218 | Suite "invalid"; | 219 | Label "buildrecipe-archive"; |
78 | 219 | Codename "invalid"; | 220 | Suite "invalid"; |
79 | 220 | Description "buildrecipe temporary archive"; | 221 | Codename "invalid"; |
80 | 221 | };""") % {"apt_dir": self.apt_dir}, | 222 | Description "buildrecipe temporary archive"; |
81 | 223 | };""") % {"apt_dir": self.apt_dir}, | ||
82 | 222 | file=conf) | 224 | file=conf) |
83 | 223 | ftparchive_env = dict(os.environ) | 225 | ftparchive_env = dict(os.environ) |
84 | 224 | ftparchive_env.pop("APT_CONFIG", None) | 226 | ftparchive_env.pop("APT_CONFIG", None) |
85 | diff --git a/bin/test_buildd_generatetranslationtemplates b/bin/test_buildd_generatetranslationtemplates | |||
86 | index 85ddc2e..2282f1d 100755 | |||
87 | --- a/bin/test_buildd_generatetranslationtemplates | |||
88 | +++ b/bin/test_buildd_generatetranslationtemplates | |||
89 | @@ -28,8 +28,3 @@ build_type = 'translation-templates' | |||
90 | 28 | filemap = {} | 28 | filemap = {} |
91 | 29 | args = {'branch_url': 'no-branch-here-sorry'} | 29 | args = {'branch_url': 'no-branch-here-sorry'} |
92 | 30 | print(proxy.build(buildid, build_type, chroot_sha1, filemap, args)) | 30 | print(proxy.build(buildid, build_type, chroot_sha1, filemap, args)) |
93 | 31 | #status = proxy.status() | ||
94 | 32 | #for filename, sha1 in status[3].iteritems(): | ||
95 | 33 | # print(filename) | ||
96 | 34 | #proxy.clean() | ||
97 | 35 | |||
98 | diff --git a/bin/test_buildd_recipe b/bin/test_buildd_recipe | |||
99 | index 849b28b..d4f5ed6 100755 | |||
100 | --- a/bin/test_buildd_recipe | |||
101 | +++ b/bin/test_buildd_recipe | |||
102 | @@ -17,12 +17,14 @@ distroseries_name = 'maverick' | |||
103 | 17 | recipe_text = """# bzr-builder format 0.2 deb-version {debupstream}-0~{revno} | 17 | recipe_text = """# bzr-builder format 0.2 deb-version {debupstream}-0~{revno} |
104 | 18 | http://bazaar.launchpad.dev/~ppa-user/+junk/wakeonlan""" | 18 | http://bazaar.launchpad.dev/~ppa-user/+junk/wakeonlan""" |
105 | 19 | 19 | ||
106 | 20 | |||
107 | 20 | def deb_line(host, suites): | 21 | def deb_line(host, suites): |
108 | 21 | prefix = 'deb http://' | 22 | prefix = 'deb http://' |
110 | 22 | if apt_cacher_ng_host != None: | 23 | if apt_cacher_ng_host is not None: |
111 | 23 | prefix += '%s:3142/' % apt_cacher_ng_host | 24 | prefix += '%s:3142/' % apt_cacher_ng_host |
112 | 24 | return '%s%s %s %s' % (prefix, host, distroseries_name, suites) | 25 | return '%s%s %s %s' % (prefix, host, distroseries_name, suites) |
113 | 25 | 26 | ||
114 | 27 | |||
115 | 26 | proxy = ServerProxy('http://localhost:8221/rpc') | 28 | proxy = ServerProxy('http://localhost:8221/rpc') |
116 | 27 | print(proxy.echo('Hello World')) | 29 | print(proxy.echo('Hello World')) |
117 | 28 | print(proxy.info()) | 30 | print(proxy.info()) |
118 | @@ -44,8 +46,5 @@ print(proxy.build( | |||
119 | 44 | deb_line('%s.archive.ubuntu.com/ubuntu' % country_code, | 46 | deb_line('%s.archive.ubuntu.com/ubuntu' % country_code, |
120 | 45 | 'main universe'), | 47 | 'main universe'), |
121 | 46 | deb_line('ppa.launchpad.net/launchpad/bzr-builder-dev/ubuntu', | 48 | deb_line('ppa.launchpad.net/launchpad/bzr-builder-dev/ubuntu', |
127 | 47 | 'main'),]})) | 49 | 'main'), |
128 | 48 | #status = proxy.status() | 50 | ]})) |
124 | 49 | #for filename, sha1 in status[3].iteritems(): | ||
125 | 50 | # print(filename) | ||
126 | 51 | #proxy.clean() | ||
129 | diff --git a/buildd-genconfig b/buildd-genconfig | |||
130 | index 2615b88..8195ef7 100755 | |||
131 | --- a/buildd-genconfig | |||
132 | +++ b/buildd-genconfig | |||
133 | @@ -5,42 +5,47 @@ | |||
134 | 5 | 5 | ||
135 | 6 | from __future__ import print_function | 6 | from __future__ import print_function |
136 | 7 | 7 | ||
137 | 8 | from optparse import OptionParser | ||
138 | 8 | import os | 9 | import os |
139 | 9 | 10 | ||
140 | 10 | archtag = os.popen("dpkg --print-architecture").read().strip() | 11 | archtag = os.popen("dpkg --print-architecture").read().strip() |
141 | 11 | 12 | ||
142 | 12 | from optparse import OptionParser | ||
143 | 13 | |||
144 | 14 | parser = OptionParser() | 13 | parser = OptionParser() |
174 | 15 | parser.add_option("-n", "--name", dest="NAME", | 14 | parser.add_option( |
175 | 16 | help="the name for this buildd", | 15 | "-n", "--name", dest="NAME", |
176 | 17 | metavar="NAME", | 16 | help="the name for this buildd", |
177 | 18 | default="default") | 17 | metavar="NAME", |
178 | 19 | 18 | default="default") | |
179 | 20 | parser.add_option("-H", "--host", dest="BINDHOST", | 19 | |
180 | 21 | help="the IP/host this buildd binds to", | 20 | parser.add_option( |
181 | 22 | metavar="HOSTNAME", | 21 | "-H", "--host", dest="BINDHOST", |
182 | 23 | default="localhost") | 22 | help="the IP/host this buildd binds to", |
183 | 24 | 23 | metavar="HOSTNAME", | |
184 | 25 | parser.add_option("-p", "--port", dest="BINDPORT", | 24 | default="localhost") |
185 | 26 | help="the port this buildd binds to", | 25 | |
186 | 27 | metavar="PORT", | 26 | parser.add_option( |
187 | 28 | default="8221") | 27 | "-p", "--port", dest="BINDPORT", |
188 | 29 | 28 | help="the port this buildd binds to", | |
189 | 30 | parser.add_option("-a", "--arch", dest="ARCHTAG", | 29 | metavar="PORT", |
190 | 31 | help="the arch tag this buildd claims", | 30 | default="8221") |
191 | 32 | metavar="ARCHTAG", | 31 | |
192 | 33 | default=archtag) | 32 | parser.add_option( |
193 | 34 | 33 | "-a", "--arch", dest="ARCHTAG", | |
194 | 35 | parser.add_option("-t", "--template", dest="TEMPLATE", | 34 | help="the arch tag this buildd claims", |
195 | 36 | help="the template file to use", | 35 | metavar="ARCHTAG", |
196 | 37 | metavar="FILE", | 36 | default=archtag) |
197 | 38 | default="/usr/share/launchpad-buildd/template-buildd-slave.conf") | 37 | |
198 | 39 | 38 | parser.add_option( | |
199 | 40 | parser.add_option("--proxy-port", dest="PROXYPORT", | 39 | "-t", "--template", dest="TEMPLATE", |
200 | 41 | help="the port the local builder proxy binds to", | 40 | help="the template file to use", |
201 | 42 | metavar="PORT", | 41 | metavar="FILE", |
202 | 43 | default="8222") | 42 | default="/usr/share/launchpad-buildd/template-buildd-slave.conf") |
203 | 43 | |||
204 | 44 | parser.add_option( | ||
205 | 45 | "--proxy-port", dest="PROXYPORT", | ||
206 | 46 | help="the port the local builder proxy binds to", | ||
207 | 47 | metavar="PORT", | ||
208 | 48 | default="8222") | ||
209 | 44 | 49 | ||
210 | 45 | (options, args) = parser.parse_args() | 50 | (options, args) = parser.parse_args() |
211 | 46 | 51 | ||
212 | diff --git a/debian/changelog b/debian/changelog | |||
213 | index 92cb241..a10074a 100644 | |||
214 | --- a/debian/changelog | |||
215 | +++ b/debian/changelog | |||
216 | @@ -1,3 +1,9 @@ | |||
217 | 1 | launchpad-buildd (206) UNRELEASED; urgency=medium | ||
218 | 2 | |||
219 | 3 | * Fix flake8 violations. | ||
220 | 4 | |||
221 | 5 | -- Colin Watson <cjwatson@ubuntu.com> Wed, 08 Dec 2021 15:42:26 +0000 | ||
222 | 6 | |||
223 | 1 | launchpad-buildd (205) bionic; urgency=medium | 7 | launchpad-buildd (205) bionic; urgency=medium |
224 | 2 | 8 | ||
225 | 3 | * Ignore NotAutomatic flag for -proposed and -backports (LP: #1016776). | 9 | * Ignore NotAutomatic flag for -proposed and -backports (LP: #1016776). |
226 | diff --git a/debian/upgrade-config b/debian/upgrade-config | |||
227 | index 3145a89..db10239 100755 | |||
228 | --- a/debian/upgrade-config | |||
229 | +++ b/debian/upgrade-config | |||
230 | @@ -31,6 +31,9 @@ apt_pkg.init() | |||
231 | 31 | 31 | ||
232 | 32 | (old_version, conf_file) = sys.argv[1:] | 32 | (old_version, conf_file) = sys.argv[1:] |
233 | 33 | 33 | ||
234 | 34 | bin_path = "/usr/share/launchpad-buildd/slavebin" | ||
235 | 35 | |||
236 | 36 | |||
237 | 34 | def upgrade_to_12(): | 37 | def upgrade_to_12(): |
238 | 35 | print("Upgrading %s to version 12" % conf_file) | 38 | print("Upgrading %s to version 12" % conf_file) |
239 | 36 | subprocess.call(["mv", conf_file, conf_file+"-prev12~"]) | 39 | subprocess.call(["mv", conf_file, conf_file+"-prev12~"]) |
240 | @@ -38,13 +41,14 @@ def upgrade_to_12(): | |||
241 | 38 | out_file = open(conf_file, "w") | 41 | out_file = open(conf_file, "w") |
242 | 39 | for line in in_file: | 42 | for line in in_file: |
243 | 40 | if line.startswith("[debianmanager]"): | 43 | if line.startswith("[debianmanager]"): |
245 | 41 | line += "ogrepath = /usr/share/launchpad-buildd/slavebin/apply-ogre-model\n" | 44 | line += "ogrepath = %s/apply-ogre-model\n" % bin_path |
246 | 42 | if line.startswith("sbuildargs"): | 45 | if line.startswith("sbuildargs"): |
247 | 43 | line = line.replace("-A", "") | 46 | line = line.replace("-A", "") |
248 | 44 | out_file.write(line) | 47 | out_file.write(line) |
249 | 45 | in_file.close() | 48 | in_file.close() |
250 | 46 | out_file.close() | 49 | out_file.close() |
251 | 47 | 50 | ||
252 | 51 | |||
253 | 48 | def upgrade_to_34(): | 52 | def upgrade_to_34(): |
254 | 49 | print("Upgrading %s to version 34" % conf_file) | 53 | print("Upgrading %s to version 34" % conf_file) |
255 | 50 | subprocess.call(["mv", conf_file, conf_file+"-prev34~"]) | 54 | subprocess.call(["mv", conf_file, conf_file+"-prev34~"]) |
256 | @@ -52,11 +56,12 @@ def upgrade_to_34(): | |||
257 | 52 | out_file = open(conf_file, "w") | 56 | out_file = open(conf_file, "w") |
258 | 53 | for line in in_file: | 57 | for line in in_file: |
259 | 54 | if line.startswith("[debianmanager]"): | 58 | if line.startswith("[debianmanager]"): |
261 | 55 | line += "sourcespath = /usr/share/launchpad-buildd/slavebin/override-sources-list\n" | 59 | line += "sourcespath = %s/override-sources-list\n" % bin_path |
262 | 56 | out_file.write(line) | 60 | out_file.write(line) |
263 | 57 | in_file.close() | 61 | in_file.close() |
264 | 58 | out_file.close() | 62 | out_file.close() |
265 | 59 | 63 | ||
266 | 64 | |||
267 | 60 | def upgrade_to_39(): | 65 | def upgrade_to_39(): |
268 | 61 | print("Upgrading %s to version 39" % conf_file) | 66 | print("Upgrading %s to version 39" % conf_file) |
269 | 62 | subprocess.call(["mv", conf_file, conf_file+"-prev39~"]) | 67 | subprocess.call(["mv", conf_file, conf_file+"-prev39~"]) |
270 | @@ -64,13 +69,14 @@ def upgrade_to_39(): | |||
271 | 64 | out_file = open(conf_file, "w") | 69 | out_file = open(conf_file, "w") |
272 | 65 | for line in in_file: | 70 | for line in in_file: |
273 | 66 | if line.startswith("sbuildargs"): | 71 | if line.startswith("sbuildargs"): |
275 | 67 | line = line.replace("-dautobuild ","") | 72 | line = line.replace("-dautobuild ", "") |
276 | 68 | if line.startswith("[slave]"): | 73 | if line.startswith("[slave]"): |
277 | 69 | line += "ntphost = ntp.buildd\n" | 74 | line += "ntphost = ntp.buildd\n" |
278 | 70 | out_file.write(line) | 75 | out_file.write(line) |
279 | 71 | in_file.close() | 76 | in_file.close() |
280 | 72 | out_file.close() | 77 | out_file.close() |
281 | 73 | 78 | ||
282 | 79 | |||
283 | 74 | def upgrade_to_57(): | 80 | def upgrade_to_57(): |
284 | 75 | print("Upgrading %s to version 57" % conf_file) | 81 | print("Upgrading %s to version 57" % conf_file) |
285 | 76 | subprocess.call(["mv", conf_file, conf_file+"-prev57~"]) | 82 | subprocess.call(["mv", conf_file, conf_file+"-prev57~"]) |
286 | @@ -90,6 +96,7 @@ def upgrade_to_57(): | |||
287 | 90 | in_file.close() | 96 | in_file.close() |
288 | 91 | out_file.close() | 97 | out_file.close() |
289 | 92 | 98 | ||
290 | 99 | |||
291 | 93 | def upgrade_to_58(): | 100 | def upgrade_to_58(): |
292 | 94 | print("Upgrading %s to version 58" % conf_file) | 101 | print("Upgrading %s to version 58" % conf_file) |
293 | 95 | subprocess.call(["mv", conf_file, conf_file+"-prev58~"]) | 102 | subprocess.call(["mv", conf_file, conf_file+"-prev58~"]) |
294 | @@ -98,8 +105,8 @@ def upgrade_to_58(): | |||
295 | 98 | out_file.write(in_file.read()) | 105 | out_file.write(in_file.read()) |
296 | 99 | out_file.write( | 106 | out_file.write( |
297 | 100 | '\n[sourcepackagerecipemanager]\n' | 107 | '\n[sourcepackagerecipemanager]\n' |
300 | 101 | 'buildrecipepath = /usr/share/launchpad-buildd' | 108 | 'buildrecipepath = %s/buildrecipe\n' % bin_path) |
301 | 102 | '/slavebin/buildrecipe\n') | 109 | |
302 | 103 | 110 | ||
303 | 104 | def upgrade_to_59(): | 111 | def upgrade_to_59(): |
304 | 105 | print("Upgrading %s to version 59" % conf_file) | 112 | print("Upgrading %s to version 59" % conf_file) |
305 | @@ -109,8 +116,9 @@ def upgrade_to_59(): | |||
306 | 109 | out_file.write(in_file.read()) | 116 | out_file.write(in_file.read()) |
307 | 110 | out_file.write( | 117 | out_file.write( |
308 | 111 | '\n[translationtemplatesmanager]\n' | 118 | '\n[translationtemplatesmanager]\n' |
311 | 112 | 'generatepath = /usr/share/launchpad-buildd/slavebin/generate-translation-templates\n' | 119 | 'generatepath = %s/generate-translation-templates\n' |
312 | 113 | 'resultarchive = translation-templates.tar.gz\n') | 120 | 'resultarchive = translation-templates.tar.gz\n' % bin_path) |
313 | 121 | |||
314 | 114 | 122 | ||
315 | 115 | def upgrade_to_63(): | 123 | def upgrade_to_63(): |
316 | 116 | print("Upgrading %s to version 63" % conf_file) | 124 | print("Upgrading %s to version 63" % conf_file) |
317 | @@ -121,6 +129,7 @@ def upgrade_to_63(): | |||
318 | 121 | if not line.startswith('ogrepath'): | 129 | if not line.startswith('ogrepath'): |
319 | 122 | out_file.write(line) | 130 | out_file.write(line) |
320 | 123 | 131 | ||
321 | 132 | |||
322 | 124 | def upgrade_to_110(): | 133 | def upgrade_to_110(): |
323 | 125 | print("Upgrading %s to version 110" % conf_file) | 134 | print("Upgrading %s to version 110" % conf_file) |
324 | 126 | subprocess.call(["mv", conf_file, conf_file+"-prev110~"]) | 135 | subprocess.call(["mv", conf_file, conf_file+"-prev110~"]) |
325 | @@ -128,11 +137,12 @@ def upgrade_to_110(): | |||
326 | 128 | out_file = open(conf_file, "w") | 137 | out_file = open(conf_file, "w") |
327 | 129 | for line in in_file: | 138 | for line in in_file: |
328 | 130 | if line.startswith("[allmanagers]"): | 139 | if line.startswith("[allmanagers]"): |
330 | 131 | line += "preppath = /usr/share/launchpad-buildd/slavebin/slave-prep\n" | 140 | line += "preppath = %s/slave-prep\n" % bin_path |
331 | 132 | out_file.write(line) | 141 | out_file.write(line) |
332 | 133 | in_file.close() | 142 | in_file.close() |
333 | 134 | out_file.close() | 143 | out_file.close() |
334 | 135 | 144 | ||
335 | 145 | |||
336 | 136 | def upgrade_to_115(): | 146 | def upgrade_to_115(): |
337 | 137 | print("Upgrading %s to version 115" % conf_file) | 147 | print("Upgrading %s to version 115" % conf_file) |
338 | 138 | subprocess.call(["mv", conf_file, conf_file+"-prev115~"]) | 148 | subprocess.call(["mv", conf_file, conf_file+"-prev115~"]) |
339 | @@ -143,13 +153,15 @@ def upgrade_to_115(): | |||
340 | 143 | if line.startswith("[allmanagers]"): | 153 | if line.startswith("[allmanagers]"): |
341 | 144 | in_allmanagers = True | 154 | in_allmanagers = True |
342 | 145 | elif in_allmanagers and (line.startswith("[") or not line.strip()): | 155 | elif in_allmanagers and (line.startswith("[") or not line.strip()): |
344 | 146 | out_file.write("processscanpath = /usr/share/launchpad-buildd/slavebin/scan-for-processes\n") | 156 | out_file.write( |
345 | 157 | "processscanpath = %s/scan-for-processes\n" % bin_path) | ||
346 | 147 | in_allmanagers = False | 158 | in_allmanagers = False |
347 | 148 | if not line.startswith("processscanpath = "): | 159 | if not line.startswith("processscanpath = "): |
348 | 149 | out_file.write(line) | 160 | out_file.write(line) |
349 | 150 | in_file.close() | 161 | in_file.close() |
350 | 151 | out_file.close() | 162 | out_file.close() |
351 | 152 | 163 | ||
352 | 164 | |||
353 | 153 | def upgrade_to_120(): | 165 | def upgrade_to_120(): |
354 | 154 | print("Upgrading %s to version 120" % conf_file) | 166 | print("Upgrading %s to version 120" % conf_file) |
355 | 155 | subprocess.call(["mv", conf_file, conf_file+"-prev120~"]) | 167 | subprocess.call(["mv", conf_file, conf_file+"-prev120~"]) |
356 | @@ -158,10 +170,11 @@ def upgrade_to_120(): | |||
357 | 158 | out_file.write(in_file.read()) | 170 | out_file.write(in_file.read()) |
358 | 159 | out_file.write( | 171 | out_file.write( |
359 | 160 | "\n[livefilesystemmanager]\n" | 172 | "\n[livefilesystemmanager]\n" |
361 | 161 | "buildlivefspath = /usr/share/launchpad-buildd/slavebin/buildlivefs\n") | 173 | "buildlivefspath = %s/buildlivefs\n" % bin_path) |
362 | 162 | in_file.close() | 174 | in_file.close() |
363 | 163 | out_file.close() | 175 | out_file.close() |
364 | 164 | 176 | ||
365 | 177 | |||
366 | 165 | def upgrade_to_126(): | 178 | def upgrade_to_126(): |
367 | 166 | print("Upgrading %s to version 126" % conf_file) | 179 | print("Upgrading %s to version 126" % conf_file) |
368 | 167 | subprocess.call(["mv", conf_file, conf_file+"-prev126~"]) | 180 | subprocess.call(["mv", conf_file, conf_file+"-prev126~"]) |
369 | @@ -176,6 +189,7 @@ def upgrade_to_126(): | |||
370 | 176 | in_file.close() | 189 | in_file.close() |
371 | 177 | out_file.close() | 190 | out_file.close() |
372 | 178 | 191 | ||
373 | 192 | |||
374 | 179 | def upgrade_to_127(): | 193 | def upgrade_to_127(): |
375 | 180 | print("Upgrading %s to version 127" % conf_file) | 194 | print("Upgrading %s to version 127" % conf_file) |
376 | 181 | os.rename(conf_file, conf_file + "-prev127~") | 195 | os.rename(conf_file, conf_file + "-prev127~") |
377 | @@ -209,6 +223,7 @@ def upgrade_to_127(): | |||
378 | 209 | in_file.close() | 223 | in_file.close() |
379 | 210 | out_file.close() | 224 | out_file.close() |
380 | 211 | 225 | ||
381 | 226 | |||
382 | 212 | def upgrade_to_162(): | 227 | def upgrade_to_162(): |
383 | 213 | print("Upgrading %s to version 162" % conf_file) | 228 | print("Upgrading %s to version 162" % conf_file) |
384 | 214 | os.rename(conf_file, conf_file + "-prev162~") | 229 | os.rename(conf_file, conf_file + "-prev162~") |
385 | @@ -220,6 +235,7 @@ def upgrade_to_162(): | |||
386 | 220 | "\n[snapmanager]\n" | 235 | "\n[snapmanager]\n" |
387 | 221 | "proxyport = 8222\n") | 236 | "proxyport = 8222\n") |
388 | 222 | 237 | ||
389 | 238 | |||
390 | 223 | def upgrade_to_190(): | 239 | def upgrade_to_190(): |
391 | 224 | print("Upgrading %s to version 190" % conf_file) | 240 | print("Upgrading %s to version 190" % conf_file) |
392 | 225 | os.rename(conf_file, conf_file + "-prev190~") | 241 | os.rename(conf_file, conf_file + "-prev190~") |
393 | @@ -231,6 +247,7 @@ def upgrade_to_190(): | |||
394 | 231 | line = "[builder]\n" | 247 | line = "[builder]\n" |
395 | 232 | out_file.write(line) | 248 | out_file.write(line) |
396 | 233 | 249 | ||
397 | 250 | |||
398 | 234 | def upgrade_to_200(): | 251 | def upgrade_to_200(): |
399 | 235 | print("Upgrading %s to version 200" % conf_file) | 252 | print("Upgrading %s to version 200" % conf_file) |
400 | 236 | 253 | ||
401 | @@ -273,6 +290,7 @@ def upgrade_to_200(): | |||
402 | 273 | (line.startswith("[") or not line.strip())): | 290 | (line.startswith("[") or not line.strip())): |
403 | 274 | in_snapmanager = False | 291 | in_snapmanager = False |
404 | 275 | 292 | ||
405 | 293 | |||
406 | 276 | if __name__ == "__main__": | 294 | if __name__ == "__main__": |
407 | 277 | old_version = re.sub(r'[~-].*', '', old_version) | 295 | old_version = re.sub(r'[~-].*', '', old_version) |
408 | 278 | if apt_pkg.version_compare(old_version, "12") < 0: | 296 | if apt_pkg.version_compare(old_version, "12") < 0: |
409 | diff --git a/lpbuildd/binarypackage.py b/lpbuildd/binarypackage.py | |||
410 | index 7312473..1bbf831 100644 | |||
411 | --- a/lpbuildd/binarypackage.py | |||
412 | +++ b/lpbuildd/binarypackage.py | |||
413 | @@ -48,7 +48,11 @@ APT_DUBIOUS_DEP_PATTERNS = [ | |||
414 | 48 | 48 | ||
415 | 49 | 49 | ||
416 | 50 | class BuildLogRegexes: | 50 | class BuildLogRegexes: |
418 | 51 | """Build log regexes for performing actions based on regexes, and extracting dependencies for auto dep-waits""" | 51 | """Various build log regexes. |
419 | 52 | |||
420 | 53 | These allow performing actions based on regexes, and extracting | ||
421 | 54 | dependencies for auto dep-waits. | ||
422 | 55 | """ | ||
423 | 52 | GIVENBACK = [ | 56 | GIVENBACK = [ |
424 | 53 | (r"^E: There are problems and -y was used without --force-yes"), | 57 | (r"^E: There are problems and -y was used without --force-yes"), |
425 | 54 | ] | 58 | ] |
426 | @@ -131,15 +135,16 @@ class BinaryPackageBuildManager(DebianBuildManager): | |||
427 | 131 | # Use the "plain" chroot type because we do the necessary setup | 135 | # Use the "plain" chroot type because we do the necessary setup |
428 | 132 | # and teardown ourselves: it's easier to do this the same way | 136 | # and teardown ourselves: it's easier to do this the same way |
429 | 133 | # for all build types. | 137 | # for all build types. |
439 | 134 | print(dedent('''\ | 138 | print( |
440 | 135 | [build-{buildid}] | 139 | dedent('''\ |
441 | 136 | description=build-{buildid} | 140 | [build-{buildid}] |
442 | 137 | groups=sbuild,root | 141 | description=build-{buildid} |
443 | 138 | root-groups=sbuild,root | 142 | groups=sbuild,root |
444 | 139 | type=plain | 143 | root-groups=sbuild,root |
445 | 140 | directory={chroot_path} | 144 | type=plain |
446 | 141 | ''').format( | 145 | directory={chroot_path} |
447 | 142 | buildid=self._buildid, chroot_path=self.chroot_path), | 146 | ''').format( |
448 | 147 | buildid=self._buildid, chroot_path=self.chroot_path), | ||
449 | 143 | file=schroot_file, end='') | 148 | file=schroot_file, end='') |
450 | 144 | schroot_file.flush() | 149 | schroot_file.flush() |
451 | 145 | subprocess.check_call( | 150 | subprocess.check_call( |
452 | @@ -285,9 +290,8 @@ class BinaryPackageBuildManager(DebianBuildManager): | |||
453 | 285 | return True | 290 | return True |
454 | 286 | dep_restrictions = dep.get("restrictions") | 291 | dep_restrictions = dep.get("restrictions") |
455 | 287 | if dep_restrictions is not None: | 292 | if dep_restrictions is not None: |
459 | 288 | if all( | 293 | if all(any(restriction.enabled for restriction in restrlist) |
460 | 289 | any(restriction.enabled for restriction in restrlist) | 294 | for restrlist in dep_restrictions): |
458 | 290 | for restrlist in dep_restrictions): | ||
461 | 291 | # This dependency "matches" in the sense that it's ignored | 295 | # This dependency "matches" in the sense that it's ignored |
462 | 292 | # when no build profiles are enabled. | 296 | # when no build profiles are enabled. |
463 | 293 | return True | 297 | return True |
464 | diff --git a/lpbuildd/builder.py b/lpbuildd/builder.py | |||
465 | index b8362d3..ad08639 100644 | |||
466 | --- a/lpbuildd/builder.py | |||
467 | +++ b/lpbuildd/builder.py | |||
468 | @@ -193,7 +193,8 @@ class BuildManager(object): | |||
469 | 193 | if notify: | 193 | if notify: |
470 | 194 | iterate = partial(self.iterateReap, state) | 194 | iterate = partial(self.iterateReap, state) |
471 | 195 | else: | 195 | else: |
473 | 196 | iterate = lambda success: None | 196 | def iterate(success): |
474 | 197 | pass | ||
475 | 197 | self.runTargetSubProcess("scan-for-processes", iterate=iterate) | 198 | self.runTargetSubProcess("scan-for-processes", iterate=iterate) |
476 | 198 | 199 | ||
477 | 199 | def doCleanup(self): | 200 | def doCleanup(self): |
478 | @@ -232,9 +233,8 @@ class BuildManager(object): | |||
479 | 232 | 233 | ||
480 | 233 | os.mkdir("%s/build-%s" % (self.home, self._buildid)) | 234 | os.mkdir("%s/build-%s" % (self.home, self._buildid)) |
481 | 234 | for f in files: | 235 | for f in files: |
485 | 235 | os.symlink( self._builder.cachePath(files[f]), | 236 | os.symlink(self._builder.cachePath(files[f]), |
486 | 236 | "%s/build-%s/%s" % (self.home, | 237 | "%s/build-%s/%s" % (self.home, self._buildid, f)) |
484 | 237 | self._buildid, f)) | ||
487 | 238 | self._chroottarfile = self._builder.cachePath(chroot) | 238 | self._chroottarfile = self._builder.cachePath(chroot) |
488 | 239 | 239 | ||
489 | 240 | self.image_type = extra_args.get('image_type', 'chroot') | 240 | self.image_type = extra_args.get('image_type', 'chroot') |
490 | diff --git a/lpbuildd/check_implicit_pointer_functions.py b/lpbuildd/check_implicit_pointer_functions.py | |||
491 | index 7f28338..78df89f 100755 | |||
492 | --- a/lpbuildd/check_implicit_pointer_functions.py | |||
493 | +++ b/lpbuildd/check_implicit_pointer_functions.py | |||
494 | @@ -42,12 +42,12 @@ implicit_pattern = re.compile( | |||
495 | 42 | pointer_pattern = re.compile( | 42 | pointer_pattern = re.compile( |
496 | 43 | br"([^:]*):(\d+):(\d+:)? warning: " | 43 | br"([^:]*):(\d+):(\d+:)? warning: " |
497 | 44 | br"(" | 44 | br"(" |
504 | 45 | br"(assignment" | 45 | br"(assignment" |
505 | 46 | br"|initialization" | 46 | br"|initialization" |
506 | 47 | br"|return" | 47 | br"|return" |
507 | 48 | br"|passing arg \d+ of `[^']*'" | 48 | br"|passing arg \d+ of `[^']*'" |
508 | 49 | br"|passing arg \d+ of pointer to function" | 49 | br"|passing arg \d+ of pointer to function" |
509 | 50 | br") makes pointer from integer without a cast" | 50 | br") makes pointer from integer without a cast" |
510 | 51 | br"|" | 51 | br"|" |
511 | 52 | br"cast to pointer from integer of different size)") | 52 | br"cast to pointer from integer of different size)") |
512 | 53 | 53 | ||
513 | @@ -77,7 +77,7 @@ def filter_log(in_file, out_file, in_line=False): | |||
514 | 77 | pointer_filename = m.group(1) | 77 | pointer_filename = m.group(1) |
515 | 78 | pointer_linenum = int(m.group(2)) | 78 | pointer_linenum = int(m.group(2)) |
516 | 79 | if (last_implicit_filename == pointer_filename | 79 | if (last_implicit_filename == pointer_filename |
518 | 80 | and last_implicit_linenum == pointer_linenum): | 80 | and last_implicit_linenum == pointer_linenum): |
519 | 81 | err = ( | 81 | err = ( |
520 | 82 | b"Function `%s' implicitly converted to pointer at " | 82 | b"Function `%s' implicitly converted to pointer at " |
521 | 83 | b"%s:%d" % ( | 83 | b"%s:%d" % ( |
522 | diff --git a/lpbuildd/oci.py b/lpbuildd/oci.py | |||
523 | index aa28a03..c6e103c 100644 | |||
524 | --- a/lpbuildd/oci.py | |||
525 | +++ b/lpbuildd/oci.py | |||
526 | @@ -242,7 +242,6 @@ class OCIBuildManager(BuildManagerProxyMixin, DebianBuildManager): | |||
527 | 242 | source_name, target_name)) | 242 | source_name, target_name)) |
528 | 243 | shutil.copy(source_name, target_name) | 243 | shutil.copy(source_name, target_name) |
529 | 244 | 244 | ||
530 | 245 | |||
531 | 246 | # We need these mapping files | 245 | # We need these mapping files |
532 | 247 | sha_directory = tempfile.mkdtemp() | 246 | sha_directory = tempfile.mkdtemp() |
533 | 248 | # This can change depending on the kernel options / docker package | 247 | # This can change depending on the kernel options / docker package |
534 | @@ -255,7 +254,7 @@ class OCIBuildManager(BuildManagerProxyMixin, DebianBuildManager): | |||
535 | 255 | # we will have no contents from it. | 254 | # we will have no contents from it. |
536 | 256 | if self.backend.path_exists(sha_path): | 255 | if self.backend.path_exists(sha_path): |
537 | 257 | sha_files = [x for x in self.backend.listdir(sha_path) | 256 | sha_files = [x for x in self.backend.listdir(sha_path) |
539 | 258 | if not x.startswith('.')] | 257 | if not x.startswith('.')] |
540 | 259 | for file in sha_files: | 258 | for file in sha_files: |
541 | 260 | self.backend.copy_out( | 259 | self.backend.copy_out( |
542 | 261 | os.path.join(sha_path, file), | 260 | os.path.join(sha_path, file), |
543 | diff --git a/lpbuildd/proxy.py b/lpbuildd/proxy.py | |||
544 | index 908770d..de6e3c7 100644 | |||
545 | --- a/lpbuildd/proxy.py | |||
546 | +++ b/lpbuildd/proxy.py | |||
547 | @@ -128,15 +128,15 @@ class BuilderProxyRequest(http.Request): | |||
548 | 128 | if self.startedWriting: | 128 | if self.startedWriting: |
549 | 129 | return | 129 | return |
550 | 130 | self.startedWriting = 1 | 130 | self.startedWriting = 1 |
553 | 131 | l = [] | 131 | lines = [] |
554 | 132 | l.append( | 132 | lines.append( |
555 | 133 | self.clientproto + b" " + intToBytes(self.code) + b" " + | 133 | self.clientproto + b" " + intToBytes(self.code) + b" " + |
556 | 134 | self.code_message + b"\r\n") | 134 | self.code_message + b"\r\n") |
557 | 135 | for name, values in self.responseHeaders.getAllRawHeaders(): | 135 | for name, values in self.responseHeaders.getAllRawHeaders(): |
558 | 136 | for value in values: | 136 | for value in values: |
562 | 137 | l.extend([name, b": ", value, b"\r\n"]) | 137 | lines.extend([name, b": ", value, b"\r\n"]) |
563 | 138 | l.append(b"\r\n") | 138 | lines.append(b"\r\n") |
564 | 139 | self.transport.writeSequence(l) | 139 | self.transport.writeSequence(lines) |
565 | 140 | 140 | ||
566 | 141 | def write(self, data): | 141 | def write(self, data): |
567 | 142 | if self.channel is not None: | 142 | if self.channel is not None: |
568 | diff --git a/lpbuildd/sourcepackagerecipe.py b/lpbuildd/sourcepackagerecipe.py | |||
569 | index b2f46cb..4e237a6 100644 | |||
570 | --- a/lpbuildd/sourcepackagerecipe.py | |||
571 | +++ b/lpbuildd/sourcepackagerecipe.py | |||
572 | @@ -117,9 +117,8 @@ class SourcePackageRecipeBuildManager(DebianBuildManager): | |||
573 | 117 | print("Returning build status: Build failed") | 117 | print("Returning build status: Build failed") |
574 | 118 | self._builder.buildFail() | 118 | self._builder.buildFail() |
575 | 119 | self.alreadyfailed = True | 119 | self.alreadyfailed = True |
579 | 120 | elif ( | 120 | elif (retcode >= RETCODE_FAILURE_INSTALL and |
580 | 121 | retcode >= RETCODE_FAILURE_INSTALL and | 121 | retcode <= RETCODE_FAILURE_BUILD_SOURCE_PACKAGE): |
578 | 122 | retcode <= RETCODE_FAILURE_BUILD_SOURCE_PACKAGE): | ||
581 | 123 | # XXX AaronBentley 2009-01-13: We should handle depwait separately | 122 | # XXX AaronBentley 2009-01-13: We should handle depwait separately |
582 | 124 | if not self.alreadyfailed: | 123 | if not self.alreadyfailed: |
583 | 125 | self._builder.buildFail() | 124 | self._builder.buildFail() |
584 | diff --git a/lpbuildd/target/build_charm.py b/lpbuildd/target/build_charm.py | |||
585 | index d5ade71..5d0b3ab 100644 | |||
586 | --- a/lpbuildd/target/build_charm.py | |||
587 | +++ b/lpbuildd/target/build_charm.py | |||
588 | @@ -136,4 +136,3 @@ class BuildCharm(BuilderProxyOperationMixin, VCSOperationMixin, | |||
589 | 136 | logger.exception('Build failed') | 136 | logger.exception('Build failed') |
590 | 137 | return RETCODE_FAILURE_BUILD | 137 | return RETCODE_FAILURE_BUILD |
591 | 138 | return 0 | 138 | return 0 |
592 | 139 | |||
593 | diff --git a/lpbuildd/target/lxd.py b/lpbuildd/target/lxd.py | |||
594 | index 6ddd1d0..163176d 100644 | |||
595 | --- a/lpbuildd/target/lxd.py | |||
596 | +++ b/lpbuildd/target/lxd.py | |||
597 | @@ -402,8 +402,8 @@ class LXD(Backend): | |||
598 | 402 | if os.path.islink(resolv_conf): | 402 | if os.path.islink(resolv_conf): |
599 | 403 | resolv_conf = os.path.realpath(resolv_conf) | 403 | resolv_conf = os.path.realpath(resolv_conf) |
600 | 404 | if (resolv_conf == "/run/systemd/resolve/stub-resolv.conf" and | 404 | if (resolv_conf == "/run/systemd/resolve/stub-resolv.conf" and |
603 | 405 | os.path.isfile("/run/systemd/resolve/resolv.conf")): | 405 | os.path.isfile("/run/systemd/resolve/resolv.conf")): |
604 | 406 | resolv_conf = "/run/systemd/resolve/resolv.conf" | 406 | resolv_conf = "/run/systemd/resolve/resolv.conf" |
605 | 407 | 407 | ||
606 | 408 | self.copy_in(resolv_conf, "/etc/resolv.conf") | 408 | self.copy_in(resolv_conf, "/etc/resolv.conf") |
607 | 409 | 409 | ||
608 | diff --git a/lpbuildd/target/operation.py b/lpbuildd/target/operation.py | |||
609 | index 7020786..2f9fe64 100644 | |||
610 | --- a/lpbuildd/target/operation.py | |||
611 | +++ b/lpbuildd/target/operation.py | |||
612 | @@ -5,8 +5,6 @@ from __future__ import print_function | |||
613 | 5 | 5 | ||
614 | 6 | __metaclass__ = type | 6 | __metaclass__ = type |
615 | 7 | 7 | ||
616 | 8 | import os | ||
617 | 9 | |||
618 | 10 | from lpbuildd.target.backend import make_backend | 8 | from lpbuildd.target.backend import make_backend |
619 | 11 | 9 | ||
620 | 12 | 10 | ||
621 | diff --git a/lpbuildd/target/tests/test_lxd.py b/lpbuildd/target/tests/test_lxd.py | |||
622 | index 38d3337..35be3bb 100644 | |||
623 | --- a/lpbuildd/target/tests/test_lxd.py | |||
624 | +++ b/lpbuildd/target/tests/test_lxd.py | |||
625 | @@ -312,8 +312,9 @@ class TestLXD(TestCase): | |||
626 | 312 | ("lxc.network.0.ipv4.gateway", "10.10.10.1"), | 312 | ("lxc.network.0.ipv4.gateway", "10.10.10.1"), |
627 | 313 | ]) | 313 | ]) |
628 | 314 | 314 | ||
631 | 315 | raw_lxc_config = "".join("{key}={val}\n".format(key=key, val=val) | 315 | raw_lxc_config = "".join( |
632 | 316 | for key, val in sorted(raw_lxc_config + extra_raw_lxc_config)) | 316 | "{key}={val}\n".format(key=key, val=val) |
633 | 317 | for key, val in sorted(raw_lxc_config + extra_raw_lxc_config)) | ||
634 | 317 | 318 | ||
635 | 318 | expected_config = { | 319 | expected_config = { |
636 | 319 | "security.privileged": "true", | 320 | "security.privileged": "true", |
637 | diff --git a/lpbuildd/target/vcs.py b/lpbuildd/target/vcs.py | |||
638 | index 4ddd9e5..f02e540 100644 | |||
639 | --- a/lpbuildd/target/vcs.py | |||
640 | +++ b/lpbuildd/target/vcs.py | |||
641 | @@ -57,7 +57,8 @@ class VCSOperationMixin: | |||
642 | 57 | else: | 57 | else: |
643 | 58 | return ["git"] | 58 | return ["git"] |
644 | 59 | 59 | ||
646 | 60 | def vcs_fetch(self, name, cwd, env=None, quiet=False, git_shallow_clone=False): | 60 | def vcs_fetch(self, name, cwd, env=None, quiet=False, |
647 | 61 | git_shallow_clone=False): | ||
648 | 61 | full_env = OrderedDict() | 62 | full_env = OrderedDict() |
649 | 62 | full_env["LANG"] = "C.UTF-8" | 63 | full_env["LANG"] = "C.UTF-8" |
650 | 63 | full_env["SHELL"] = "/bin/sh" | 64 | full_env["SHELL"] = "/bin/sh" |
651 | diff --git a/lpbuildd/tests/fakebuilder.py b/lpbuildd/tests/fakebuilder.py | |||
652 | index 7731ea2..ef20810 100644 | |||
653 | --- a/lpbuildd/tests/fakebuilder.py | |||
654 | +++ b/lpbuildd/tests/fakebuilder.py | |||
655 | @@ -108,10 +108,10 @@ class FakeBuilder: | |||
656 | 108 | self._config = FakeConfig() | 108 | self._config = FakeConfig() |
657 | 109 | self.waitingfiles = {} | 109 | self.waitingfiles = {} |
658 | 110 | for fake_method in ( | 110 | for fake_method in ( |
663 | 111 | "emptyLog", "log", | 111 | "emptyLog", "log", |
664 | 112 | "chrootFail", "buildFail", "builderFail", "depFail", "buildOK", | 112 | "chrootFail", "buildFail", "builderFail", "depFail", "buildOK", |
665 | 113 | "buildComplete", | 113 | "buildComplete", |
666 | 114 | ): | 114 | ): |
667 | 115 | setattr(self, fake_method, FakeMethod()) | 115 | setattr(self, fake_method, FakeMethod()) |
668 | 116 | 116 | ||
669 | 117 | def cachePath(self, file): | 117 | def cachePath(self, file): |
670 | diff --git a/lpbuildd/tests/oci_tarball.py b/lpbuildd/tests/oci_tarball.py | |||
671 | index 21ec013..35860ad 100644 | |||
672 | --- a/lpbuildd/tests/oci_tarball.py | |||
673 | +++ b/lpbuildd/tests/oci_tarball.py | |||
674 | @@ -17,8 +17,9 @@ class OCITarball: | |||
675 | 17 | @property | 17 | @property |
676 | 18 | def config(self): | 18 | def config(self): |
677 | 19 | return self._makeFile( | 19 | return self._makeFile( |
680 | 20 | {"rootfs": {"diff_ids": | 20 | {"rootfs": { |
681 | 21 | ["sha256:diff1", "sha256:diff2", "sha256:diff3"]}}, | 21 | "diff_ids": [ |
682 | 22 | "sha256:diff1", "sha256:diff2", "sha256:diff3"]}}, | ||
683 | 22 | 'config.json') | 23 | 'config.json') |
684 | 23 | 24 | ||
685 | 24 | @property | 25 | @property |
686 | @@ -57,10 +58,7 @@ class OCITarball: | |||
687 | 57 | source = os.path.join(source_layer_directory, "layer.tar") | 58 | source = os.path.join(source_layer_directory, "layer.tar") |
688 | 58 | 59 | ||
689 | 59 | os.mkdir(target_layer_directory) | 60 | os.mkdir(target_layer_directory) |
694 | 60 | os.symlink( | 61 | os.symlink(os.path.relpath(source, target_layer_directory), target) |
691 | 61 | os.path.relpath(source, target_layer_directory), | ||
692 | 62 | os.path.join(target_layer_directory, "layer.tar") | ||
693 | 63 | ) | ||
695 | 64 | return target_layer_directory | 62 | return target_layer_directory |
696 | 65 | 63 | ||
697 | 66 | def build_tar_file(self): | 64 | def build_tar_file(self): |
698 | diff --git a/lpbuildd/tests/test_binarypackage.py b/lpbuildd/tests/test_binarypackage.py | |||
699 | index c88bdb2..22c4b0a 100644 | |||
700 | --- a/lpbuildd/tests/test_binarypackage.py | |||
701 | +++ b/lpbuildd/tests/test_binarypackage.py | |||
702 | @@ -134,11 +134,11 @@ class TestBinaryPackageBuildManagerIteration(TestCase): | |||
703 | 134 | self.assertState( | 134 | self.assertState( |
704 | 135 | BinaryPackageBuildState.SBUILD, | 135 | BinaryPackageBuildState.SBUILD, |
705 | 136 | [ | 136 | [ |
711 | 137 | 'sharepath/bin/sbuild-package', 'sbuild-package', | 137 | 'sharepath/bin/sbuild-package', 'sbuild-package', |
712 | 138 | self.buildid, 'i386', 'warty', | 138 | self.buildid, 'i386', 'warty', |
713 | 139 | '-c', 'chroot:build-' + self.buildid, | 139 | '-c', 'chroot:build-' + self.buildid, |
714 | 140 | '--arch=i386', '--dist=warty', '--nolog', | 140 | '--arch=i386', '--dist=warty', '--nolog', |
715 | 141 | 'foo_1.dsc', | 141 | 'foo_1.dsc', |
716 | 142 | ], final=True) | 142 | ], final=True) |
717 | 143 | self.assertFalse(self.builder.wasCalled('chrootFail')) | 143 | self.assertFalse(self.builder.wasCalled('chrootFail')) |
718 | 144 | 144 | ||
719 | @@ -490,12 +490,12 @@ class TestBinaryPackageBuildManagerIteration(TestCase): | |||
720 | 490 | def test_relationMatches_versioned(self): | 490 | def test_relationMatches_versioned(self): |
721 | 491 | # relationMatches handles versioned dependencies correctly. | 491 | # relationMatches handles versioned dependencies correctly. |
722 | 492 | for version, expected in ( | 492 | for version, expected in ( |
729 | 493 | (("<<", "1"), False), (("<<", "1.1"), True), | 493 | (("<<", "1"), False), (("<<", "1.1"), True), |
730 | 494 | (("<=", "0.9"), False), (("<=", "1"), True), | 494 | (("<=", "0.9"), False), (("<=", "1"), True), |
731 | 495 | (("=", "1"), True), (("=", "2"), False), | 495 | (("=", "1"), True), (("=", "2"), False), |
732 | 496 | ((">=", "1"), True), ((">=", "1.1"), False), | 496 | ((">=", "1"), True), ((">=", "1.1"), False), |
733 | 497 | ((">>", "0.9"), True), ((">>", "1"), False), | 497 | ((">>", "0.9"), True), ((">>", "1"), False), |
734 | 498 | ): | 498 | ): |
735 | 499 | assert_method = self.assertTrue if expected else self.assertFalse | 499 | assert_method = self.assertTrue if expected else self.assertFalse |
736 | 500 | assert_method(self.buildmanager.relationMatches( | 500 | assert_method(self.buildmanager.relationMatches( |
737 | 501 | {"name": "foo", "version": version}, {"foo": set(["1"])}), | 501 | {"name": "foo", "version": version}, {"foo": set(["1"])}), |
738 | @@ -505,10 +505,10 @@ class TestBinaryPackageBuildManagerIteration(TestCase): | |||
739 | 505 | # If multiple versions of a package are present, relationMatches | 505 | # If multiple versions of a package are present, relationMatches |
740 | 506 | # returns True for dependencies that match any of them. | 506 | # returns True for dependencies that match any of them. |
741 | 507 | for version, expected in ( | 507 | for version, expected in ( |
746 | 508 | (("=", "1"), True), | 508 | (("=", "1"), True), |
747 | 509 | (("=", "1.1"), True), | 509 | (("=", "1.1"), True), |
748 | 510 | (("=", "2"), False), | 510 | (("=", "2"), False), |
749 | 511 | ): | 511 | ): |
750 | 512 | assert_method = self.assertTrue if expected else self.assertFalse | 512 | assert_method = self.assertTrue if expected else self.assertFalse |
751 | 513 | assert_method(self.buildmanager.relationMatches( | 513 | assert_method(self.buildmanager.relationMatches( |
752 | 514 | {"name": "foo", "version": version}, | 514 | {"name": "foo", "version": version}, |
753 | diff --git a/lpbuildd/tests/test_buildrecipe.py b/lpbuildd/tests/test_buildrecipe.py | |||
754 | index 2faa985..de7b50a 100644 | |||
755 | --- a/lpbuildd/tests/test_buildrecipe.py | |||
756 | +++ b/lpbuildd/tests/test_buildrecipe.py | |||
757 | @@ -277,12 +277,13 @@ class TestRecipeBuilder(TestCase): | |||
758 | 277 | os.makedirs(os.path.dirname(control_path)) | 277 | os.makedirs(os.path.dirname(control_path)) |
759 | 278 | os.makedirs(self.builder.apt_dir) | 278 | os.makedirs(self.builder.apt_dir) |
760 | 279 | with open(control_path, "w") as control: | 279 | with open(control_path, "w") as control: |
764 | 280 | print(dedent("""\ | 280 | print( |
765 | 281 | Source: foo | 281 | dedent("""\ |
766 | 282 | Build-Depends: debhelper (>= 9~), libfoo-dev | 282 | Source: foo |
767 | 283 | Build-Depends: debhelper (>= 9~), libfoo-dev | ||
768 | 283 | 284 | ||
771 | 284 | Package: foo | 285 | Package: foo |
772 | 285 | Depends: ${shlibs:Depends}"""), | 286 | Depends: ${shlibs:Depends}"""), |
773 | 286 | file=control) | 287 | file=control) |
774 | 287 | self.builder.makeDummyDsc("foo") | 288 | self.builder.makeDummyDsc("foo") |
775 | 288 | with open(os.path.join(self.builder.apt_dir, "foo.dsc")) as dsc: | 289 | with open(os.path.join(self.builder.apt_dir, "foo.dsc")) as dsc: |
776 | @@ -308,15 +309,16 @@ class TestRecipeBuilder(TestCase): | |||
777 | 308 | os.makedirs(os.path.dirname(control_path)) | 309 | os.makedirs(os.path.dirname(control_path)) |
778 | 309 | os.makedirs(self.builder.apt_dir) | 310 | os.makedirs(self.builder.apt_dir) |
779 | 310 | with open(control_path, "w") as control: | 311 | with open(control_path, "w") as control: |
786 | 311 | print(dedent("""\ | 312 | print( |
787 | 312 | Source: foo | 313 | dedent("""\ |
788 | 313 | Build-Depends: debhelper (>= 9~), | 314 | Source: foo |
789 | 314 | libfoo-dev, | 315 | Build-Depends: debhelper (>= 9~), |
790 | 315 | # comment line | 316 | libfoo-dev, |
791 | 316 | pkg-config | 317 | # comment line |
792 | 318 | pkg-config | ||
793 | 317 | 319 | ||
796 | 318 | Package: foo | 320 | Package: foo |
797 | 319 | Depends: ${shlibs:Depends}"""), | 321 | Depends: ${shlibs:Depends}"""), |
798 | 320 | file=control) | 322 | file=control) |
799 | 321 | self.builder.makeDummyDsc("foo") | 323 | self.builder.makeDummyDsc("foo") |
800 | 322 | with open(os.path.join(self.builder.apt_dir, "foo.dsc")) as dsc: | 324 | with open(os.path.join(self.builder.apt_dir, "foo.dsc")) as dsc: |
801 | @@ -337,13 +339,14 @@ class TestRecipeBuilder(TestCase): | |||
802 | 337 | def test_runAptFtparchive(self): | 339 | def test_runAptFtparchive(self): |
803 | 338 | os.makedirs(self.builder.apt_dir) | 340 | os.makedirs(self.builder.apt_dir) |
804 | 339 | with open(os.path.join(self.builder.apt_dir, "foo.dsc"), "w") as dsc: | 341 | with open(os.path.join(self.builder.apt_dir, "foo.dsc"), "w") as dsc: |
812 | 340 | print(dedent("""\ | 342 | print( |
813 | 341 | Format: 1.0 | 343 | dedent("""\ |
814 | 342 | Source: foo | 344 | Format: 1.0 |
815 | 343 | Architecture: any | 345 | Source: foo |
816 | 344 | Version: 99:0 | 346 | Architecture: any |
817 | 345 | Maintainer: invalid@example.org | 347 | Version: 99:0 |
818 | 346 | Build-Depends: debhelper (>= 9~), libfoo-dev"""), | 348 | Maintainer: invalid@example.org |
819 | 349 | Build-Depends: debhelper (>= 9~), libfoo-dev"""), | ||
820 | 347 | file=dsc) | 350 | file=dsc) |
821 | 348 | self.assertEqual(0, self.builder.runAptFtparchive()) | 351 | self.assertEqual(0, self.builder.runAptFtparchive()) |
822 | 349 | self.assertEqual( | 352 | self.assertEqual( |
823 | @@ -379,12 +382,13 @@ class TestRecipeBuilder(TestCase): | |||
824 | 379 | # Not a valid changelog, but only the first line matters here. | 382 | # Not a valid changelog, but only the first line matters here. |
825 | 380 | print("foo (1.0-1) bionic; urgency=medium", file=changelog) | 383 | print("foo (1.0-1) bionic; urgency=medium", file=changelog) |
826 | 381 | with open(control_path, "w") as control: | 384 | with open(control_path, "w") as control: |
830 | 382 | print(dedent("""\ | 385 | print( |
831 | 383 | Source: foo | 386 | dedent("""\ |
832 | 384 | Build-Depends: debhelper (>= 9~), libfoo-dev | 387 | Source: foo |
833 | 388 | Build-Depends: debhelper (>= 9~), libfoo-dev | ||
834 | 385 | 389 | ||
837 | 386 | Package: foo | 390 | Package: foo |
838 | 387 | Depends: ${shlibs:Depends}"""), | 391 | Depends: ${shlibs:Depends}"""), |
839 | 388 | file=control) | 392 | file=control) |
840 | 389 | self.assertEqual(0, self.builder.installBuildDeps()) | 393 | self.assertEqual(0, self.builder.installBuildDeps()) |
841 | 390 | self.assertThat( | 394 | self.assertThat( |
842 | diff --git a/lpbuildd/tests/test_charm.py b/lpbuildd/tests/test_charm.py | |||
843 | index 18e01a1..97b4a15 100644 | |||
844 | --- a/lpbuildd/tests/test_charm.py | |||
845 | +++ b/lpbuildd/tests/test_charm.py | |||
846 | @@ -101,7 +101,8 @@ class TestCharmBuildManagerIteration(TestCase): | |||
847 | 101 | "git_path": "master", | 101 | "git_path": "master", |
848 | 102 | } | 102 | } |
849 | 103 | expected_options = [ | 103 | expected_options = [ |
851 | 104 | "--git-repository", "https://git.launchpad.dev/~example/+git/charm", | 104 | "--git-repository", |
852 | 105 | "https://git.launchpad.dev/~example/+git/charm", | ||
853 | 105 | "--git-path", "master", | 106 | "--git-path", "master", |
854 | 106 | ] | 107 | ] |
855 | 107 | yield self.startBuild(args, expected_options) | 108 | yield self.startBuild(args, expected_options) |
856 | diff --git a/lpbuildd/tests/test_harness.py b/lpbuildd/tests/test_harness.py | |||
857 | index 049ecd1..0ea496b 100644 | |||
858 | --- a/lpbuildd/tests/test_harness.py | |||
859 | +++ b/lpbuildd/tests/test_harness.py | |||
860 | @@ -5,6 +5,6 @@ __metaclass__ = type | |||
861 | 5 | 5 | ||
862 | 6 | import doctest | 6 | import doctest |
863 | 7 | 7 | ||
864 | 8 | |||
865 | 8 | def test_suite(): | 9 | def test_suite(): |
866 | 9 | return doctest.DocTestSuite('lpbuildd.tests.harness') | 10 | return doctest.DocTestSuite('lpbuildd.tests.harness') |
867 | 10 | |||
868 | diff --git a/lpbuildd/tests/test_sourcepackagerecipe.py b/lpbuildd/tests/test_sourcepackagerecipe.py | |||
869 | index dda21d4..7a2cb48 100644 | |||
870 | --- a/lpbuildd/tests/test_sourcepackagerecipe.py | |||
871 | +++ b/lpbuildd/tests/test_sourcepackagerecipe.py | |||
872 | @@ -78,7 +78,7 @@ class TestSourcePackageRecipeBuildManagerIteration(TestCase): | |||
873 | 78 | 'archives': [ | 78 | 'archives': [ |
874 | 79 | 'deb http://archive.ubuntu.com/ubuntu maverick main universe', | 79 | 'deb http://archive.ubuntu.com/ubuntu maverick main universe', |
875 | 80 | 'deb http://ppa.launchpad.net/launchpad/bzr-builder-dev/' | 80 | 'deb http://ppa.launchpad.net/launchpad/bzr-builder-dev/' |
877 | 81 | 'ubuntu main', | 81 | 'ubuntu main', |
878 | 82 | ], | 82 | ], |
879 | 83 | } | 83 | } |
880 | 84 | if git: | 84 | if git: |
881 | diff --git a/lpbuildd/tests/test_util.py b/lpbuildd/tests/test_util.py | |||
882 | index 3eb92f9..8b04d44 100644 | |||
883 | --- a/lpbuildd/tests/test_util.py | |||
884 | +++ b/lpbuildd/tests/test_util.py | |||
885 | @@ -21,7 +21,8 @@ class TestShellEscape(TestCase): | |||
886 | 21 | self.assertEqual("' '", shell_escape(" ")) | 21 | self.assertEqual("' '", shell_escape(" ")) |
887 | 22 | 22 | ||
888 | 23 | def test_single_quotes(self): | 23 | def test_single_quotes(self): |
890 | 24 | self.assertEqual("'shell'\"'\"'s great'", shell_escape("shell's great")) | 24 | self.assertEqual( |
891 | 25 | "'shell'\"'\"'s great'", shell_escape("shell's great")) | ||
892 | 25 | 26 | ||
893 | 26 | def test_bytes(self): | 27 | def test_bytes(self): |
894 | 27 | self.assertEqual( | 28 | self.assertEqual( |
895 | diff --git a/setup.py b/setup.py | |||
896 | index 32e4498..aa05864 100755 | |||
897 | --- a/setup.py | |||
898 | +++ b/setup.py | |||
899 | @@ -57,7 +57,7 @@ setup( | |||
900 | 57 | # XXX cjwatson 2015-11-04: This does in fact require python-apt, but | 57 | # XXX cjwatson 2015-11-04: This does in fact require python-apt, but |
901 | 58 | # that's normally shipped as a system package and specifying it here | 58 | # that's normally shipped as a system package and specifying it here |
902 | 59 | # causes problems for Launchpad's build system. | 59 | # causes problems for Launchpad's build system. |
904 | 60 | #'python-apt', | 60 | # 'python-apt', |
905 | 61 | 'python-debian>=0.1.23', | 61 | 'python-debian>=0.1.23', |
906 | 62 | 'requests', | 62 | 'requests', |
907 | 63 | 'six', | 63 | 'six', |
LGTM
A couple of re-formats made the code less readable imho - let's have a quick discussion at standup whether the line length limit is set in stone or whether we could just # noqa this rare occasions.