summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Berg2020-02-21 15:27:29 +0000
committerChristoph Berg2020-02-21 15:27:29 +0000
commit5d5346f1e776c19c25d77246043ed7e9ab657a05 (patch)
treef914fc23052bc445a00e2e42b722037b2267eaac
parentd9f446a9d768d0a3626467448f16401a6d07ff26 (diff)
Track source files
-rw-r--r--pgapt-db/sql/pgdg_apt.sql13
-rwxr-xr-xrepo/bin/import-sourcesfile19
2 files changed, 25 insertions, 7 deletions
diff --git a/pgapt-db/sql/pgdg_apt.sql b/pgapt-db/sql/pgdg_apt.sql
index c6123ca..1ff48d3 100644
--- a/pgapt-db/sql/pgdg_apt.sql
+++ b/pgapt-db/sql/pgdg_apt.sql
@@ -64,6 +64,18 @@ CREATE TABLE source (
PRIMARY KEY (source, srcversion)
);
+CREATE TABLE sourcefile (
+ source text NOT NULL,
+ srcversion debversion NOT NULL,
+ directory text NOT NULL,
+ filename text NOT NULL,
+ upload boolean, -- null = to do, t = done, f = error
+
+ PRIMARY KEY (filename),
+ FOREIGN KEY (source, srcversion) REFERENCES source (source, srcversion)
+);
+
+
CREATE TABLE package (
package text NOT NULL,
version debversion NOT NULL,
@@ -74,6 +86,7 @@ CREATE TABLE package (
source text NOT NULL,
srcversion debversion NOT NULL,
time timestamptz(0) NOT NULL,
+ upload boolean, -- null = to do, t = done, f = error
PRIMARY KEY (package, version, arch)
);
diff --git a/repo/bin/import-sourcesfile b/repo/bin/import-sourcesfile
index dd9cec4..15ccf7a 100755
--- a/repo/bin/import-sourcesfile
+++ b/repo/bin/import-sourcesfile
@@ -63,6 +63,11 @@ def parseSourceFile(distribution, component, packagesfile, ctime):
cur.execute("""INSERT INTO source (source, srcversion, control, c, time)
VALUES (%s, %s, %s, control2jsonb(%s), %s)""",
[package, version, control, control, ctime])
+ cur.execute("""INSERT INTO sourcefile (source, srcversion, directory, filename)
+ SELECT %s, %s, c->>'directory', regexp_replace(f, '.* ', '')
+ FROM control2jsonb(%s) c, jsonb_array_elements_text(c->'files') f
+ ON CONFLICT DO NOTHING""",
+ [package, version, control])
# finally, add the package to the suite's package list
cur.execute("""INSERT INTO sourcelist
@@ -71,14 +76,14 @@ def parseSourceFile(distribution, component, packagesfile, ctime):
[distribution, component, package, version])
# record info in suite history table
- cur.execute("""INSERT INTO packagehist
- (distribution, component, package, version, time)
- SELECT distribution, component, package, version, %s
- FROM packagelist l
+ cur.execute("""INSERT INTO sourcehist
+ (distribution, component, source, srcversion, time)
+ SELECT distribution, component, source, srcversion, %s
+ FROM sourcelist l
WHERE (distribution, component) = (%s, %s) AND NOT EXISTS
- (SELECT * FROM packagehist h WHERE
- (l.distribution, l.component, l.package, l.version) =
- (h.distribution, h.component, h.package, h.version))""",
+ (SELECT * FROM sourcehist h WHERE
+ (l.distribution, l.component, l.source, l.srcversion) =
+ (h.distribution, h.component, h.source, h.srcversion))""",
[ctime, distribution, component])
(packagesfile, distribution, component) = (sys.argv[1], sys.argv[2], sys.argv[3])