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
|
#!/usr/bin/env python
# Copyright 2004 Canonical Ltd. All rights reserved.
# Author: Daniel Silverstone <daniel.silverstone@canonical.com>
# Celso Providelo <celso.providelo@canonical.com>
#
# Build Jobs initialization
#
__metaclass__ = type
import sys
import logging
from canonical.lp import initZopeless
from canonical.launchpad.database import DistroArchRelease
from canonical.launchpad.scripts.builddmaster import BuilddMaster
from canonical.launchpad.scripts.lockfile import LockFile
_default_lockfile = '/var/lock/queuebuilder.lock'
_default_logfilename = '/var/tmp/queuebuilder.log'
def rebuildQueue(tm):
"""Look for and initialise new build jobs."""
buildMaster = BuilddMaster(logging.getLogger('queuebuilder'), tm)
# Simple container
distroreleases = set()
# For every distroarchrelease we can find; put it into the build master
for archrelease in DistroArchRelease.select():
distroreleases.add(archrelease.distrorelease)
buildMaster.addDistroArchRelease(archrelease)
# For each distrorelease we care about; scan for sourcepackagereleases
# with no build associated with the distroarchreleases we're
# interested in
for distrorelease in distroreleases:
buildMaster.createMissingBuilds(distrorelease)
# For each build record in NEEDSBUILD, ensure it has a
#buildqueue entry
buildMaster.addMissingBuildQueueEntries()
#Rescore the NEEDSBUILD properly
buildMaster.sanitiseAndScoreCandidates()
def main(tm):
# logging setup
#logging.basicConfig(filename=_default_logfilename)
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
logging.getLogger().debug("Initialising BuildQueue Builder")
locker = LockFile(_default_lockfile)
try:
locker.acquire()
except OSError:
logging.getLogger().info("Cannot Acquire Lock.")
sys.exit(1)
try:
rebuildQueue(tm)
finally:
locker.release()
if __name__ == '__main__':
# setup a transaction manager
tm = initZopeless(dbuser='fiera')
main(tm)
|