1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
# Copyright 2009, 2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
import re
from canonical.buildd.debian import DebianBuildManager, DebianBuildState
class SBuildExitCodes:
"""SBUILD process result codes."""
OK = 0
DEPFAIL = 1
GIVENBACK = 2
PACKAGEFAIL = 3
BUILDERFAIL = 4
class BuildLogRegexes:
"""Build log regexes for performing actions based on regexes, and extracting dependencies for auto dep-waits"""
GIVENBACK = [
("^E: There are problems and -y was used without --force-yes"),
]
DEPFAIL = [
("(?P<pk>[\-+.\w]+)\(inst [^ ]+ ! >> wanted (?P<v>[\-.+\w:~]+)\)","\g<pk> (>> \g<v>)"),
("(?P<pk>[\-+.\w]+)\(inst [^ ]+ ! >?= wanted (?P<v>[\-.+\w:~]+)\)","\g<pk> (>= \g<v>)"),
("(?s)^E: Couldn't find package (?P<pk>[\-+.\w]+)(?!.*^E: Couldn't find package)","\g<pk>"),
("(?s)^E: Package '?(?P<pk>[\-+.\w]+)'? has no installation candidate(?!.*^E: Package)","\g<pk>"),
("(?s)^E: Unable to locate package (?P<pk>[\-+.\w]+)(?!.*^E: Unable to locate package)", "\g<pk>"),
]
class BinaryPackageBuildState(DebianBuildState):
SBUILD = "SBUILD"
class BinaryPackageBuildManager(DebianBuildManager):
"""Handle buildd building for a debian style binary package build"""
initial_build_state = BinaryPackageBuildState.SBUILD
def __init__(self, slave, buildid):
DebianBuildManager.__init__(self, slave, buildid)
self._sbuildpath = slave._config.get("binarypackagemanager", "sbuildpath")
self._sbuildargs = slave._config.get("binarypackagemanager",
"sbuildargs").split(" ")
def initiate(self, files, chroot, extra_args):
"""Initiate a build with a given set of files and chroot."""
self._dscfile = None
for f in files:
if f.endswith(".dsc"):
self._dscfile = f
if self._dscfile is None:
raise ValueError, files
self.archive_purpose = extra_args.get('archive_purpose')
self.suite = extra_args.get('suite')
self.component = extra_args['ogrecomponent']
self.arch_indep = extra_args.get('arch_indep', False)
self.build_debug_symbols = extra_args.get('build_debug_symbols', False)
super(BinaryPackageBuildManager, self).initiate(
files, chroot, extra_args)
def doRunBuild(self):
"""Run the sbuild process to build the package."""
args = ["sbuild-package", self._buildid, self.arch_tag]
if self.suite:
args.extend([self.suite])
args.extend(self._sbuildargs)
args.extend(["--dist=" + self.suite])
else:
args.extend(['autobuild'])
args.extend(self._sbuildargs)
args.extend(["--dist=autobuild"])
if self.arch_indep:
args.extend(["-A"])
if self.archive_purpose:
args.extend(["--purpose=" + self.archive_purpose])
if self.build_debug_symbols:
args.extend(["--build-debug-symbols"])
args.extend(["--architecture=" + self.arch_tag])
args.extend(["--comp=" + self.component])
args.extend([self._dscfile])
self.runSubProcess( self._sbuildpath, args )
def iterate_SBUILD(self, success):
"""Finished the sbuild run."""
tmpLog = self.getTmpLogContents()
if success != SBuildExitCodes.OK:
if (success == SBuildExitCodes.DEPFAIL or
success == SBuildExitCodes.PACKAGEFAIL):
for rx in BuildLogRegexes.GIVENBACK:
mo = re.search(rx, tmpLog, re.M)
if mo:
success = SBuildExitCodes.GIVENBACK
if success == SBuildExitCodes.DEPFAIL:
for rx, dep in BuildLogRegexes.DEPFAIL:
mo = re.search(rx, tmpLog, re.M)
if mo:
if not self.alreadyfailed:
print("Returning build status: DEPFAIL")
print("Dependencies: " + mo.expand(dep))
self._slave.depFail(mo.expand(dep))
success = SBuildExitCodes.DEPFAIL
break
else:
success = SBuildExitCodes.PACKAGEFAIL
if success == SBuildExitCodes.GIVENBACK:
if not self.alreadyfailed:
print("Returning build status: GIVENBACK")
self._slave.giveBack()
elif success == SBuildExitCodes.PACKAGEFAIL:
if not self.alreadyfailed:
print("Returning build status: PACKAGEFAIL")
self._slave.buildFail()
elif success >= SBuildExitCodes.BUILDERFAIL:
# anything else is assumed to be a buildd failure
if not self.alreadyfailed:
print("Returning build status: BUILDERFAIL")
self._slave.builderFail()
self.alreadyfailed = True
self._state = DebianBuildState.REAP
self.doReapProcesses()
else:
print("Returning build status: OK")
self.gatherResults()
self._state = DebianBuildState.REAP
self.doReapProcesses()
|