~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/canonical/buildd/debian.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-03-17 20:41:13 UTC
  • mfrom: (3277.1.4 launchpad-foobar2)
  • Revision ID: pqm@pqm.ubuntu.com-20060317204113-9841a4470db3611b
[r=jamesh] Mainline soyuz

Show diffs side-by-side

added added

removed removed

Lines of Context:
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>
3
4
 
4
5
# Buildd Slave sbuild manager implementation
5
6
 
6
7
__metaclass__ = type
7
8
 
8
9
import os
 
10
import re
9
11
 
10
12
from canonical.buildd.slave import (
11
13
    BuildManager, RunCapture
29
31
    """SBUILD process result codes."""
30
32
    OK = 0
31
33
    DEPFAIL = 1
32
 
    BUILDERFAIL = 2
 
34
    GIVENBACK = 2
 
35
    PACKAGEFAIL = 3
 
36
    BUILDERFAIL = 4
 
37
 
 
38
 
 
39
class BuildLogRegexes:
 
40
    """Build log regexes for performing actions based on regexes, and extracting dependencies for auto dep-waits"""
 
41
    GIVENBACK=[
 
42
      (" terminated by signal 4"),
 
43
      ("^E: There are problems and -y was used without --force-yes"),
 
44
      ("^make.* Illegal instruction"),
 
45
    ]
 
46
    DEPFAIL=[
 
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>"),
 
51
    ]
33
52
 
34
53
 
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
47
67
        slave.emptyLog()
48
68
        self.alreadyfailed = False
66
86
            self.arch_indep = extra_args['arch_indep']
67
87
        else:
68
88
            self.arch_indep = False
69
 
 
 
89
        
70
90
        BuildManager.initiate(self, files, chroot, extra_args)
71
91
 
72
92
    def doOgreModel(self):
85
105
        args.extend(self._sbuildargs)
86
106
        if self.arch_indep:
87
107
            args.extend(["-A"])
 
108
        args.extend(["--comp=" + self.ogre])
88
109
        args.extend([self._dscfile])
89
110
        self.runSubProcess( self._sbuildpath, args )
90
111
 
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()
 
229
            tmpLogHandle.close()
 
230
            if success == SBuildExitCodes.DEPFAIL or success == SBuildExitCodes.PACKAGEFAIL:
 
231
                for rx in BuildLogRegexes.GIVENBACK:
 
232
                    mo=re.search(rx, tmpLog, re.M)
 
233
                    if mo:
 
234
                        success = SBuildExitCodes.GIVENBACK
 
235
 
206
236
            if success == SBuildExitCodes.DEPFAIL:
207
 
                self._slave.depFail()
208
 
            elif success == SBuildExitCodes.BUILDERFAIL:
209
 
                self._slave.builderFail()
210
 
            else:
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)
 
239
                    if mo:
 
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
 
245
                            break
 
246
                    else:
 
247
                        success = SBuildExitCodes.PACKAGEFAIL
 
248
 
 
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()
217
265
        else:
 
266
            print("Returning build status: OK")
218
267
            self.gatherResults()
219
268
            self._state = DebianBuildState.REAP
220
269
            self.doReapProcesses()