diff options
author | Helmut Grohne <helmut@subdivi.de> | 2020-10-08 17:16:06 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2020-10-08 17:16:06 +0200 |
commit | aaae5693485ae850bfe2c9506f2586a9542641bf (patch) | |
tree | 40058cc72f43afedcf952aab96d1e00705939048 | |
parent | bab219106d1b6761b4869ba60743e0c32ab7bf8c (diff) | |
download | crossqa-aaae5693485ae850bfe2c9506f2586a9542641bf.tar.gz |
add build architecture to schema of depstate table
-rwxr-xr-x | build.py | 19 | ||||
-rwxr-xr-x | depcheck.py | 31 | ||||
-rw-r--r-- | schema.sql | 5 | ||||
-rw-r--r-- | webapp.py | 3 |
4 files changed, 35 insertions, 23 deletions
@@ -59,29 +59,30 @@ def main(): with contextlib.closing(db.cursor()) as cur: cur.execute("BEGIN IMMEDIATE;") cur.execute(""" - SELECT d.source, d.version, d.architecture, r.id + SELECT d.source, d.version, d.hostarch, r.id FROM depstate AS d JOIN buildrequests AS r - ON ? = ifnull(r.buildarch, 'amd64') - AND d.architecture = ifnull(r.hostarch, d.architecture) + ON ? = ifnull(r.buildarch, d.buildarch) + AND d.hostarch = ifnull(r.hostarch, d.hostarch) AND d.source = r.source JOIN depcheck - ON d.architecture = depcheck.architecture + ON d.hostarch = depcheck.architecture WHERE d.satisfiable = 1 AND depcheck.giveback = 0 AND NOT EXISTS (SELECT 1 FROM building WHERE d.source = building.source OR (? = building.buildarch AND - d.architecture = building.hostarch)) + d.hostarch = building.hostarch)) ORDER BY r.priority DESC, r.requesttime ASC, random() LIMIT 1;""", (buildarch, buildarch)) row = cur.fetchone() if not row: cur.execute(""" - SELECT source, version, depstate.architecture, NULL + SELECT source, version, depstate.hostarch, NULL FROM depstate JOIN depcheck - ON depstate.architecture = depcheck.architecture - WHERE satisfiable = 1 AND giveback = 0 - ORDER BY random() LIMIT 1;""") + ON depstate.hostarch = depcheck.architecture + WHERE depstate.buildarch = ? AND satisfiable = 1 + AND giveback = 0 + ORDER BY random() LIMIT 1;""", (buildarch,)) row = cur.fetchone() if not row: cur.execute("ROLLBACK;") diff --git a/depcheck.py b/depcheck.py index ad0a18d..b1f7458 100755 --- a/depcheck.py +++ b/depcheck.py @@ -415,24 +415,34 @@ def check_bdsat(mirror, buildarch, hostarch): return result -def update_depcheck(mirror, db, updatetime, architecture, state): +def update_depcheck(mirror, db, updatetime, buildarch, hostarch, state): with contextlib.closing(db.cursor()) as cur: cur.execute("BEGIN;") - cur.execute("SELECT source, version, satisfiable, reason FROM depstate WHERE architecture = ?;", - (architecture,)) + cur.execute(""" + SELECT source, version, satisfiable, reason FROM depstate + WHERE buildarch = ? AND hostarch = ?;""", + (buildarch, hostarch,)) for source, version, satisfiable, reason in list(cur.fetchall()): if satisfiable == (reason is None) and \ state.get(source) == (version, reason): del state[source] else: - cur.execute("DELETE FROM depstate WHERE source = ? AND version = ? AND architecture = ?;", - (source, version, architecture)) - cur.executemany("INSERT INTO depstate (source, architecture, version, satisfiable, reason) VALUES (?, ?, ?, ?, ?);", - ((source, architecture, version, reason is None, + cur.execute(""" + DELETE FROM depstate + WHERE source = ? AND version = ? AND buildarch = ? + AND hostarch = ?;""", + (source, version, buildarch, hostarch)) + cur.executemany(""" + INSERT INTO depstate (source, buildarch, hostarch, version, + satisfiable, reason) + VALUES (?, ?, ?, ?, ?, ?);""", + ((source, buildarch, hostarch, version, reason is None, reason) for source, (version, reason) in state.items())) - cur.execute("UPDATE depcheck SET releasetime = ?, updatetime = ?, giveback = 0 WHERE architecture = ?", - (mirror.releasetime, updatetime, architecture)) + cur.execute(""" + UPDATE depcheck SET releasetime = ?, updatetime = ?, giveback = 0 + WHERE architecture = ?""", + (mirror.releasetime, updatetime, hostarch)) db.commit() @@ -476,7 +486,8 @@ def main(): try: for architecture, state in pool.imap_unordered(docheck, archs): print("update %s" % architecture) - update_depcheck(mirror, db, now, architecture, state) + update_depcheck(mirror, db, now, BUILD_ARCH, architecture, + state) finally: pool.close() pool.join() @@ -3,10 +3,11 @@ CREATE TABLE depstate ( source TEXT NOT NULL, version TEXT NOT NULL, - architecture TEXT NOT NULL, + buildarch TEXT NOT NULL, + hostarch TEXT NOT NULL, satisfiable BOOLEAN NOT NULL CHECK (satisfiable in (0, 1)), reason TEXT, - UNIQUE (source, architecture, version)); + UNIQUE (source, buildarch, hostarch, version)); CREATE TABLE depcheck ( architecture TEXT NOT NULL UNIQUE, @@ -350,8 +350,7 @@ def collect_depstate(conn, source): version = None depstate = None query = sqlalchemy.text(""" - SELECT version, 'amd64' AS buildarch, architecture AS hostarch, - satisfiable, reason + SELECT version, buildarch, hostarch, satisfiable, reason FROM depstate WHERE source = :source;""") for row in conn.execute(query, source=source): if version is None or version_compare(version, row.version) > 0: |