diff options
Diffstat (limited to 'build.py')
-rwxr-xr-x | build.py | 24 |
1 files changed, 15 insertions, 9 deletions
@@ -45,10 +45,16 @@ def do_build(source, version, architecture, server): print("status %s code %d" % (status, code)) return (now, code == 0, logtarget, status == "given-back") +def get_build_arch(): + return subprocess.check_output(["dpkg", "--print-architecture"], + encoding="ascii").strip() + def main(): argp = argparse.ArgumentParser() argp.add_argument("server", help="machine to build on") + argp.add_argument("--buildarch", help="build architecture of the server") args = argp.parse_args() + buildarch = args.buildarch or get_build_arch() db = sqlite3.connect("db", detect_types=sqlite3.PARSE_DECLTYPES) with contextlib.closing(db.cursor()) as cur: cur.execute("BEGIN IMMEDIATE;") @@ -56,7 +62,7 @@ def main(): SELECT d.source, d.version, d.architecture, r.id FROM depstate AS d JOIN buildrequests AS r - ON 'amd64' = ifnull(r.buildarch, 'amd64') + ON ? = ifnull(r.buildarch, 'amd64') AND d.architecture = ifnull(r.hostarch, d.architecture) AND d.source = r.source JOIN depcheck @@ -64,10 +70,10 @@ def main(): WHERE d.satisfiable = 1 AND depcheck.giveback = 0 AND NOT EXISTS (SELECT 1 FROM building WHERE d.source = building.source - OR ('amd64' = building.buildarch AND + OR (? = building.buildarch AND d.architecture = building.hostarch)) ORDER BY r.priority DESC, r.requesttime ASC, random() - LIMIT 1;""") + LIMIT 1;""", (buildarch, buildarch)) row = cur.fetchone() if not row: cur.execute(""" @@ -82,23 +88,23 @@ def main(): print("no package satisfiable") time.sleep(60) return - source, version, architecture, requestid = row + source, version, hostarch, requestid = row cur.execute("""INSERT INTO building (source, buildarch, hostarch, pid) VALUES (?, ?, ?, ?);""", - (source, 'amd64', architecture, os.getpid())) + (source, buildarch, hostarch, os.getpid())) cur.execute("COMMIT;") try: print("building %s_%s for %s%s" % - (source, version, architecture, + (source, version, hostarch, "" if requestid is None else " (request %d)" % requestid)) timestamp, success, filename, giveback = \ - do_build(source, version, architecture, args.server) + do_build(source, version, hostarch, args.server) with contextlib.closing(db.cursor()) as cur: cur.execute("""INSERT INTO builds (source, version, buildarch, hostarch, success, starttime, filename) VALUES (?, ?, ?, ?, ?, ?, ?);""", - (source, version, 'amd64', architecture, success, + (source, version, buildarch, hostarch, success, timestamp, filename)) if requestid is not None: cur.execute("DELETE FROM buildrequests WHERE id = ?;", @@ -106,7 +112,7 @@ def main(): if giveback: cur.execute("""UPDATE depcheck SET giveback = 1 WHERE architecture = ?;""", - (architecture,)) + (hostarch,)) finally: with contextlib.closing(db.cursor()) as cur: cur.execute("DELETE FROM building WHERE pid = ?;", (os.getpid(),)) |