diff options
-rwxr-xr-x | build.py | 20 | ||||
-rwxr-xr-x | depcheck.py | 27 | ||||
-rw-r--r-- | schema.sql | 23 | ||||
-rw-r--r-- | webapp.py | 12 |
4 files changed, 44 insertions, 38 deletions
@@ -62,24 +62,28 @@ def main(): SELECT d.source, d.version, d.hostarch, r.id FROM depstate AS d JOIN buildrequests AS r - ON ? = ifnull(r.buildarch, d.buildarch) + ON d.buildarch = ifnull(r.buildarch, d.buildarch) AND d.hostarch = ifnull(r.hostarch, d.hostarch) AND d.source = r.source JOIN depcheck - ON d.hostarch = depcheck.architecture - WHERE d.satisfiable = 1 AND depcheck.giveback = 0 + ON d.buildarch = depcheck.buildarch + AND d.hostarch = depcheck.hostarch + WHERE d.buildarch = ? + AND d.satisfiable = 1 + AND depcheck.giveback = 0 AND NOT EXISTS (SELECT 1 FROM building WHERE d.source = building.source - OR (? = building.buildarch AND + OR (d.buildarch = building.buildarch AND d.hostarch = building.hostarch)) ORDER BY r.priority DESC, r.requesttime ASC, random() - LIMIT 1;""", (buildarch, buildarch)) + LIMIT 1;""", (buildarch,)) row = cur.fetchone() if not row: cur.execute(""" SELECT source, version, depstate.hostarch, NULL FROM depstate JOIN depcheck - ON depstate.hostarch = depcheck.architecture + ON depstate.buildarch = depcheck.buildarch + AND depstate.hostarch = depcheck.hostarch WHERE depstate.buildarch = ? AND satisfiable = 1 AND giveback = 0 ORDER BY random() LIMIT 1;""", (buildarch,)) @@ -112,8 +116,8 @@ def main(): (requestid,)) if giveback: cur.execute("""UPDATE depcheck SET giveback = 1 - WHERE architecture = ?;""", - (hostarch,)) + WHERE buildarch = ? AND architecture = ?;""", + (buildarch, hostarch,)) finally: with contextlib.closing(db.cursor()) as cur: cur.execute("DELETE FROM building WHERE pid = ?;", (os.getpid(),)) diff --git a/depcheck.py b/depcheck.py index b1f7458..e3f3815 100755 --- a/depcheck.py +++ b/depcheck.py @@ -23,7 +23,6 @@ import requests from common import decompress_stream, yield_lines -BUILD_ARCH = "amd64" PROFILES = frozenset(("cross", "nocheck")) CPUEntry = collections.namedtuple('CPUEntry', @@ -441,13 +440,13 @@ def update_depcheck(mirror, db, updatetime, buildarch, hostarch, state): for source, (version, reason) in state.items())) cur.execute(""" UPDATE depcheck SET releasetime = ?, updatetime = ?, giveback = 0 - WHERE architecture = ?""", - (mirror.releasetime, updatetime, hostarch)) + WHERE buildarch = ? AND hostarch = ?""", + (mirror.releasetime, updatetime, buildarch, hostarch)) db.commit() -def main_docheck(mirror, architecture): - return (architecture, check_bdsat(mirror, BUILD_ARCH, architecture)) +def main_docheck(mirror, archpair): + return (*archpair, check_bdsat(mirror, *archpair)) class SequentialPool: @@ -474,20 +473,22 @@ def main(): mirror.update_release() db = sqlite3.connect("db") cur = db.cursor() - cur.execute("SELECT architecture FROM depcheck WHERE releasetime < ?;", + cur.execute(""" + SELECT buildarch, hostarch FROM depcheck WHERE releasetime < ?;""", (mirror.releasetime,)) - archs = set(row[0] for row in cur.fetchall()) - if not archs: + archpairs = set(cur.fetchall()) + if not archpairs: return - print("checking %s" % " ".join(sorted(archs))) + print("checking %s" % + ", ".join(sorted(map("%s -> %s".__mod__, archpairs)))) now = datetime.datetime.utcnow().replace(microsecond=0) with multiprocessing.Pool() if args.parallel else SequentialPool() as pool: docheck = functools.partial(main_docheck, mirror) try: - for architecture, state in pool.imap_unordered(docheck, archs): - print("update %s" % architecture) - update_depcheck(mirror, db, now, BUILD_ARCH, architecture, - state) + for buildarch, hostarch, state in pool.imap_unordered(docheck, + archpairs): + print("update %s -> %s" % (buildarch, hostarch)) + update_depcheck(mirror, db, now, buildarch, hostarch, state) finally: pool.close() pool.join() @@ -10,18 +10,21 @@ CREATE TABLE depstate ( UNIQUE (source, buildarch, hostarch, version)); CREATE TABLE depcheck ( - architecture TEXT NOT NULL UNIQUE, + buildarch TEXT NOT NULL, + hostarch TEXT NOT NULL, releasetime TIMESTAMP NOT NULL, updatetime TIMESTAMP NOT NULL, - giveback BOOLEAN NOT NULL CHECK (giveback in (0, 1))); -INSERT INTO depcheck (architecture, releasetime, updatetime, giveback) VALUES - ("arm64", "2000-01-01 00:00:00", "2000-01-01 00:00:00", 1), - ("armel", "2000-01-01 00:00:00", "2000-01-01 00:00:00", 1), - ("armhf", "2000-01-01 00:00:00", "2000-01-01 00:00:00", 1), - ("mips64el", "2000-01-01 00:00:00", "2000-01-01 00:00:00", 1), - ("mipsel", "2000-01-01 00:00:00", "2000-01-01 00:00:00", 1), - ("ppc64el", "2000-01-01 00:00:00", "2000-01-01 00:00:00", 1), - ("s390x", "2000-01-01 00:00:00", "2000-01-01 00:00:00", 1); + giveback BOOLEAN NOT NULL CHECK (giveback in (0, 1)), + UNIQUE (buildarch, hostarch)); +INSERT INTO depcheck (buildarch, hostarch, releasetime, updatetime, + giveback) VALUES + ('amd64', 'arm64', '2000-01-01 00:00:00', '2000-01-01 00:00:00', 1), + ('amd64', 'armel', '2000-01-01 00:00:00', '2000-01-01 00:00:00', 1), + ('amd64', 'armhf', '2000-01-01 00:00:00', '2000-01-01 00:00:00', 1), + ('amd64', 'mips64el', '2000-01-01 00:00:00', '2000-01-01 00:00:00', 1), + ('amd64', 'mipsel', '2000-01-01 00:00:00', '2000-01-01 00:00:00', 1), + ('amd64', 'ppc64el', '2000-01-01 00:00:00', '2000-01-01 00:00:00', 1), + ('amd64', 's390x', '2000-01-01 00:00:00', '2000-01-01 00:00:00', 1); CREATE TABLE builds ( source TEXT NOT NULL, @@ -383,9 +383,7 @@ def show_index(): def show_source(source): context = dict(sourcepackage=source) with db.engine.connect() as conn: - query = sqlalchemy.text("""SELECT 'amd64' AS buildarch, - architecture AS hostarch - FROM depcheck;""") + query = sqlalchemy.text("SELECT buildarch, hostarch FROM depcheck;") context["architectures"] = set(map(tuple, conn.execute(query))) context["version"], context["depresult"] = collect_depstate(conn, source) @@ -428,8 +426,6 @@ def request_schedule(): raise werkzeug.exceptions.BadRequest() if buildarch == "any": buildarch = None - elif buildarch != "amd64": - raise werkzeug.exceptions.BadRequest() with db.engine.connect() as conn: query = sqlalchemy.text(""" SELECT 1 FROM depstate WHERE source = :source;""") @@ -439,8 +435,10 @@ def request_schedule(): hostarch = None else: query = sqlalchemy.text(""" - SELECT 1 FROM depcheck WHERE architecture = :hostarch;""") - if not conn.execute(query, hostarch=hostarch).first(): + SELECT 1 FROM depcheck + WHERE buildarch = :buildarch AND hostarch = :hostarch;""") + if not conn.execute(query, buildarch=buildarch, + hostarch=hostarch).first(): raise werkzeug.exceptions.BadRequest() query = sqlalchemy.text(""" INSERT INTO buildrequests (source, buildarch, hostarch, |