summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2020-10-08 17:16:06 +0200
committerHelmut Grohne <helmut@subdivi.de>2020-10-08 17:16:06 +0200
commitaaae5693485ae850bfe2c9506f2586a9542641bf (patch)
tree40058cc72f43afedcf952aab96d1e00705939048
parentbab219106d1b6761b4869ba60743e0c32ab7bf8c (diff)
downloadcrossqa-aaae5693485ae850bfe2c9506f2586a9542641bf.tar.gz
add build architecture to schema of depstate table
-rwxr-xr-xbuild.py19
-rwxr-xr-xdepcheck.py31
-rw-r--r--schema.sql5
-rw-r--r--webapp.py3
4 files changed, 35 insertions, 23 deletions
diff --git a/build.py b/build.py
index 5e2ee85..9bfa52c 100755
--- a/build.py
+++ b/build.py
@@ -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()
diff --git a/schema.sql b/schema.sql
index 1c2a2ec..7c591c9 100644
--- a/schema.sql
+++ b/schema.sql
@@ -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,
diff --git a/webapp.py b/webapp.py
index 794af29..03d37b3 100644
--- a/webapp.py
+++ b/webapp.py
@@ -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: