add build architecture to schema of buildrequests table
authorHelmut Grohne <helmut@subdivi.de>
Thu, 8 Oct 2020 11:11:15 +0000 (13:11 +0200)
committerHelmut Grohne <helmut@subdivi.de>
Thu, 8 Oct 2020 11:11:15 +0000 (13:11 +0200)
build.py
schema.sql
webapp.py

index a642092..9fc3b8b 100755 (executable)
--- a/build.py
+++ b/build.py
@@ -56,7 +56,8 @@ def main():
             SELECT d.source, d.version, d.architecture, r.id
                 FROM depstate AS d
                     JOIN buildrequests AS r
-                        ON d.architecture = ifnull(r.architecture, d.architecture)
+                        ON 'amd64' = ifnull(r.buildarch, 'amd64')
+                            AND d.architecture = ifnull(r.hostarch, d.architecture)
                             AND d.source = r.source
                     JOIN depcheck
                         ON d.architecture = depcheck.architecture
index 872b7db..1c2a2ec 100644 (file)
@@ -35,7 +35,8 @@ CREATE INDEX builds_source_index ON builds(source);
 CREATE TABLE buildrequests (
        id INTEGER PRIMARY KEY,
        source TEXT NOT NULL,
-       architecture TEXT,
+       buildarch TEXT,
+       hostarch TEXT,
        requesttime TIMESTAMP NOT NULL,
         priority INTEGER NOT NULL DEFAULT 0);
 
index 3d3af0d..ee7cce6 100644 (file)
--- a/webapp.py
+++ b/webapp.py
@@ -424,7 +424,9 @@ def show_log(filename):
 def request_schedule():
     source = flask.request.form["source"]
     buildarch, hostarch = flask.request.form["archpair"].split("_")
-    if buildarch not in ("any", "amd64"):
+    if buildarch == "any":
+        buildarch = None
+    elif buildarch != "amd64":
         raise werkzeug.exceptions.BadRequest()
     with db.engine.connect() as conn:
         query = sqlalchemy.text("""
@@ -439,7 +441,9 @@ def request_schedule():
             if not conn.execute(query, hostarch=hostarch).first():
                 raise werkzeug.exceptions.BadRequest()
         query = sqlalchemy.text("""
-            INSERT INTO buildrequests (source, architecture, requesttime)
-                VALUES (:source, :hostarch, datetime('now'));""")
-        conn.execute(query, source=source, hostarch=hostarch)
+            INSERT INTO buildrequests (source, buildarch, hostarch,
+                                       requesttime)
+                VALUES (:source, :buildarch, :hostarch, datetime('now'));""")
+        conn.execute(query, source=source, buildarch=buildarch,
+                     hostarch=hostarch)
     return flask.render_template_string(schedule_template)