1
1
# Copyright Canonical Limited
2
# Author: Daniel Silverstone <daniel.silverstone@canonical.com>
2
# Authors: Daniel Silverstone <daniel.silverstone@canonical.com>
3
# and Adam Conrad <adam.conrad@canonical.com>
4
5
# Buildd Slave sbuild manager implementation
10
12
from canonical.buildd.slave import (
11
13
BuildManager, RunCapture
29
31
"""SBUILD process result codes."""
39
class BuildLogRegexes:
40
"""Build log regexes for performing actions based on regexes, and extracting dependencies for auto dep-waits"""
42
(" terminated by signal 4"),
43
("^E: There are problems and -y was used without --force-yes"),
44
("^make.* Illegal instruction"),
47
("(?P<pk>[\-+.\w]+)\(inst [^ ]+ ! >> wanted (?P<v>[\-.+\w:]+)\)","\g<pk> (>> \g<v>)"),
48
("(?P<pk>[\-+.\w]+)\(inst [^ ]+ ! >?= wanted (?P<v>[\-.+\w:]+)\)","\g<pk> (>= \g<v>)"),
49
("(?s)^E: Couldn't find package (?P<pk>[\-+.\w]+)(?!.*^E: Couldn't find package)","\g<pk>"),
50
("(?s)^E: Package (?P<pk>[\-+.\w]+) has no installation candidate(?!.*^E: Package)","\g<pk>"),
35
54
class DebianBuildManager(BuildManager):
43
62
self._sbuildargs = slave._config.get("debianmanager",
44
63
"sbuildargs").split(" ")
45
64
self._ogrepath = slave._config.get("debianmanager", "ogrepath")
65
self._cachepath = slave._config.get("slave","filecache")
46
66
self._state = DebianBuildState.UNPACK
48
68
self.alreadyfailed = False
203
224
def iterate_SBUILD(self, success):
204
225
"""Finished the sbuild run."""
205
226
if success != SBuildExitCodes.OK:
227
tmpLogHandle = open(os.path.join(self._cachepath, "buildlog"))
228
tmpLog = tmpLogHandle.read()
230
if success == SBuildExitCodes.DEPFAIL or success == SBuildExitCodes.PACKAGEFAIL:
231
for rx in BuildLogRegexes.GIVENBACK:
232
mo=re.search(rx, tmpLog, re.M)
234
success = SBuildExitCodes.GIVENBACK
206
236
if success == SBuildExitCodes.DEPFAIL:
207
self._slave.depFail()
208
elif success == SBuildExitCodes.BUILDERFAIL:
209
self._slave.builderFail()
211
# anything else is a buildfail
212
if not self.alreadyfailed:
237
for rx, dep in BuildLogRegexes.DEPFAIL:
238
mo=re.search(rx, tmpLog, re.M)
240
if not self.alreadyfailed:
241
print("Returning build status: DEPFAIL")
242
print("Dependencies: " + mo.expand(dep))
243
self._slave.depFail(mo.expand(dep))
244
success = SBuildExitCodes.DEPFAIL
247
success = SBuildExitCodes.PACKAGEFAIL
249
if success == SBuildExitCodes.GIVENBACK:
250
if not self.alreadyfailed:
251
print("Returning build status: GIVENBACK")
252
self._slave.giveBack()
253
elif success == SBuildExitCodes.PACKAGEFAIL:
254
if not self.alreadyfailed:
255
print("Returning build status: PACKAGEFAIL")
213
256
self._slave.buildFail()
257
elif success >= SBuildExitCodes.BUILDERFAIL:
258
# anything else is assumed to be a buildd failure
259
if not self.alreadyfailed:
260
print("Returning build status: BUILDERFAIL")
261
self._slave.builderFail()
214
262
self.alreadyfailed = True
215
263
self._state = DebianBuildState.REAP
216
264
self.doReapProcesses()
266
print("Returning build status: OK")
218
267
self.gatherResults()
219
268
self._state = DebianBuildState.REAP
220
269
self.doReapProcesses()