2094
by Canonical.com Patch Queue Manager
[r=spiv,jamesh] Auto Buildd System implementation. |
1 |
#!/usr/bin/env python
|
2 |
# Copyright 2004 Canonical Ltd. All rights reserved.
|
|
3 |
# Author: Daniel Silverstone <daniel.silverstone@canonical.com>
|
|
4 |
# Celso Providelo <celso.providelo@canonical.com>
|
|
5 |
#
|
|
6 |
# Build Jobs initialization
|
|
7 |
#
|
|
8 |
__metaclass__ = type |
|
9 |
||
10 |
import sys |
|
11 |
import logging |
|
2755
by Canonical.com Patch Queue Manager
[r=stevea] Fixing bug # 2812, loading zcml info in builddmaster and consequently removing the database imports, fixing bug # 1305 by using standards in both buildd cronscripts. |
12 |
from optparse import OptionParser |
13 |
||
14 |
from zope.component import getUtility |
|
2094
by Canonical.com Patch Queue Manager
[r=spiv,jamesh] Auto Buildd System implementation. |
15 |
|
16 |
from canonical.lp import initZopeless |
|
2755
by Canonical.com Patch Queue Manager
[r=stevea] Fixing bug # 2812, loading zcml info in builddmaster and consequently removing the database imports, fixing bug # 1305 by using standards in both buildd cronscripts. |
17 |
from canonical.launchpad.interfaces import IDistroArchReleaseSet |
2094
by Canonical.com Patch Queue Manager
[r=spiv,jamesh] Auto Buildd System implementation. |
18 |
|
19 |
from canonical.launchpad.scripts.builddmaster import BuilddMaster |
|
20 |
from canonical.launchpad.scripts.lockfile import LockFile |
|
2755
by Canonical.com Patch Queue Manager
[r=stevea] Fixing bug # 2812, loading zcml info in builddmaster and consequently removing the database imports, fixing bug # 1305 by using standards in both buildd cronscripts. |
21 |
from canonical.launchpad.scripts import ( |
22 |
execute_zcml_for_scripts, logger_options, logger |
|
23 |
)
|
|
2094
by Canonical.com Patch Queue Manager
[r=spiv,jamesh] Auto Buildd System implementation. |
24 |
|
2555
by Canonical.com Patch Queue Manager
[trivial] Fix buildd scoring algorithm, remove queue_time parameter as described in specification, repair the tests, other minor fixes on failnotes writes and commiting data more frenquently. |
25 |
_default_lockfile = '/var/lock/buildd-master.lock' |
2755
by Canonical.com Patch Queue Manager
[r=stevea] Fixing bug # 2812, loading zcml info in builddmaster and consequently removing the database imports, fixing bug # 1305 by using standards in both buildd cronscripts. |
26 |
|
27 |
||
28 |
def rebuildQueue(log): |
|
2094
by Canonical.com Patch Queue Manager
[r=spiv,jamesh] Auto Buildd System implementation. |
29 |
"""Look for and initialise new build jobs."""
|
2755
by Canonical.com Patch Queue Manager
[r=stevea] Fixing bug # 2812, loading zcml info in builddmaster and consequently removing the database imports, fixing bug # 1305 by using standards in both buildd cronscripts. |
30 |
# XXX cprov 20051019
|
31 |
# retrive the user infromation from the config file
|
|
32 |
||
33 |
# setup a transaction manager
|
|
34 |
tm = initZopeless(dbuser='fiera') |
|
35 |
||
36 |
buildMaster = BuilddMaster(log, tm) |
|
2094
by Canonical.com Patch Queue Manager
[r=spiv,jamesh] Auto Buildd System implementation. |
37 |
|
38 |
# Simple container
|
|
39 |
distroreleases = set() |
|
40 |
||
41 |
# For every distroarchrelease we can find; put it into the build master
|
|
2755
by Canonical.com Patch Queue Manager
[r=stevea] Fixing bug # 2812, loading zcml info in builddmaster and consequently removing the database imports, fixing bug # 1305 by using standards in both buildd cronscripts. |
42 |
for archrelease in getUtility(IDistroArchReleaseSet): |
2094
by Canonical.com Patch Queue Manager
[r=spiv,jamesh] Auto Buildd System implementation. |
43 |
distroreleases.add(archrelease.distrorelease) |
44 |
buildMaster.addDistroArchRelease(archrelease) |
|
45 |
||
46 |
# For each distrorelease we care about; scan for sourcepackagereleases
|
|
47 |
# with no build associated with the distroarchreleases we're
|
|
48 |
# interested in
|
|
49 |
for distrorelease in distroreleases: |
|
50 |
buildMaster.createMissingBuilds(distrorelease) |
|
2663
by Canonical.com Patch Queue Manager
[r=stevea] Landing NominatedArchIndep changes. |
51 |
|
2094
by Canonical.com Patch Queue Manager
[r=spiv,jamesh] Auto Buildd System implementation. |
52 |
# For each build record in NEEDSBUILD, ensure it has a
|
53 |
#buildqueue entry
|
|
54 |
buildMaster.addMissingBuildQueueEntries() |
|
55 |
||
56 |
#Rescore the NEEDSBUILD properly
|
|
57 |
buildMaster.sanitiseAndScoreCandidates() |
|
2755
by Canonical.com Patch Queue Manager
[r=stevea] Fixing bug # 2812, loading zcml info in builddmaster and consequently removing the database imports, fixing bug # 1305 by using standards in both buildd cronscripts. |
58 |
|
2214
by Canonical.com Patch Queue Manager
[trivial] BuildFarm works again, bits repaired and ready for deep redesign. |
59 |
if __name__ == '__main__': |
2755
by Canonical.com Patch Queue Manager
[r=stevea] Fixing bug # 2812, loading zcml info in builddmaster and consequently removing the database imports, fixing bug # 1305 by using standards in both buildd cronscripts. |
60 |
parser = OptionParser() |
61 |
logger_options(parser) |
|
62 |
(options, arguments) = parser.parse_args() |
|
63 |
||
64 |
if arguments: |
|
65 |
parser.error("Unhandled arguments %r" % arguments) |
|
66 |
||
67 |
execute_zcml_for_scripts() |
|
68 |
||
69 |
log = logger(options, 'queuebuilder') |
|
70 |
||
71 |
log.info("Rebuilding Build Queue.") |
|
72 |
||
73 |
locker = LockFile(_default_lockfile, logger=log) |
|
2094
by Canonical.com Patch Queue Manager
[r=spiv,jamesh] Auto Buildd System implementation. |
74 |
try: |
75 |
locker.acquire() |
|
76 |
except OSError: |
|
2555
by Canonical.com Patch Queue Manager
[trivial] Fix buildd scoring algorithm, remove queue_time parameter as described in specification, repair the tests, other minor fixes on failnotes writes and commiting data more frenquently. |
77 |
logger.info("Cannot Acquire Lock.") |
2094
by Canonical.com Patch Queue Manager
[r=spiv,jamesh] Auto Buildd System implementation. |
78 |
sys.exit(1) |
79 |
||
80 |
try: |
|
2755
by Canonical.com Patch Queue Manager
[r=stevea] Fixing bug # 2812, loading zcml info in builddmaster and consequently removing the database imports, fixing bug # 1305 by using standards in both buildd cronscripts. |
81 |
rebuildQueue(log) |
2094
by Canonical.com Patch Queue Manager
[r=spiv,jamesh] Auto Buildd System implementation. |
82 |
finally: |
83 |
locker.release() |
|
2214
by Canonical.com Patch Queue Manager
[trivial] BuildFarm works again, bits repaired and ready for deep redesign. |
84 |
|
2755
by Canonical.com Patch Queue Manager
[r=stevea] Fixing bug # 2812, loading zcml info in builddmaster and consequently removing the database imports, fixing bug # 1305 by using standards in both buildd cronscripts. |
85 |
log.info("Buildd Queue Rebuilt.") |