summaryrefslogtreecommitdiff
path: root/build.py
diff options
context:
space:
mode:
Diffstat (limited to 'build.py')
-rwxr-xr-xbuild.py28
1 files changed, 25 insertions, 3 deletions
diff --git a/build.py b/build.py
index 876e21b..8e1d763 100755
--- a/build.py
+++ b/build.py
@@ -45,20 +45,42 @@ def main():
args = argp.parse_args()
db = sqlite3.connect("db", detect_types=sqlite3.PARSE_DECLTYPES)
with contextlib.closing(db.cursor()) as cur:
- cur.execute("SELECT source, version, depstate.architecture FROM depstate JOIN depcheck ON depstate.architecture = depcheck.architecture WHERE satisfiable = 1 AND giveback = 0 ORDER BY random() LIMIT 1;")
+ cur.execute("""
+ SELECT d.source, d.version, d.architecture, r.rowid
+ FROM depstate AS d
+ JOIN buildrequests AS r
+ ON d.architecture = ifnull(r.architecture, d.architecture)
+ AND d.source = r.source
+ JOIN depcheck
+ ON d.architecture = depcheck.architecture
+ WHERE d.satisfiable = 1 AND depcheck.giveback = 0
+ ORDER BY r.priority DESC, random() LIMIT 1;""")
row = cur.fetchone()
+ if not row:
+ cur.execute("""
+ SELECT source, version, depstate.architecture, NULL
+ FROM depstate JOIN depcheck
+ ON depstate.architecture = depcheck.architecture
+ WHERE satisfiable = 1 AND giveback = 0
+ ORDER BY random() LIMIT 1;""")
+ row = cur.fetchone()
if not row:
print("no package satisfiable")
time.sleep(60)
return
- source, version, architecture = row
- print("building %s_%s for %s" % (source, version, architecture))
+ source, version, architecture, requestid = row
+ print("building %s_%s for %s%s" %
+ (source, version, architecture,
+ "" if requestid is None else " (request %d)" % requestid))
timestamp, success, filename, giveback = \
do_build(source, version, architecture, args.server)
with contextlib.closing(db.cursor()) as cur:
cur.execute("INSERT INTO builds (source, version, architecture, success, starttime, filename) VALUES (?, ?, ?, ?, ?, ?);",
(source, version, architecture, success, timestamp,
filename))
+ if requestid is not None:
+ cur.execute("DELETE FROM buildrequests WHERE rowid = ?;",
+ (requestid,))
if giveback:
cur.execute("UPDATE depcheck SET giveback = 1 WHERE architecture = ?;",
(architecture,))