Updated patch attached (as per Ganneff’s review). On Sun, Oct 22, 2017 at 6:41 PM, Michael Stapelberg <stapelb...@debian.org> wrote: > Please keep me CC'ed, I’m not subscribed to debian-dak. > > Please consider merging the following patch which you can find > attached to this email or at > https://github.com/stapelberg/dak/tree/golang. Thank you! > > This query will replace a heuristic in dh-make-golang(1) and help us resolve > Go build dependencies into Debian build dependencies accurately. > --- > dakweb/dakwebserver.py | 1 + > dakweb/queries/golang.py | 52 > ++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 53 insertions(+) > create mode 100644 dakweb/queries/golang.py > > diff --git a/dakweb/dakwebserver.py b/dakweb/dakwebserver.py > index 0ddc10cf..bd6b62ff 100755 > --- a/dakweb/dakwebserver.py > +++ b/dakweb/dakwebserver.py > @@ -45,6 +45,7 @@ from queries.archive import * > from queries.madison import * > from queries.source import * > from queries.suite import * > +from queries.golang import * > > # Set up our initial database connection > d = DBConn() > diff --git a/dakweb/queries/golang.py b/dakweb/queries/golang.py > new file mode 100644 > index 00000000..0c343424 > --- /dev/null > +++ b/dakweb/queries/golang.py > @@ -0,0 +1,52 @@ > +"""Golang related queries > + > +@contact: https://pkg-go.alioth.debian.org/ > +@copyright: 2017 Michael Stapelberg <stapelb...@debian.org> > +@license: GNU General Public License version 2 or later > +""" > + > +import bottle > +import json > + > +from daklib.dbconn import DBConn, MetadataKey > +from dakweb.webregister import QueryRegister > + > + > +@bottle.route('/golang/import_paths') > +def import_paths(): > + """ > + Returns a mapping of Go import path to Debian binary package name and > + corresponding Debian source package name. > + > + @rtype: dictionary > + @return: A list of dictionaries of > + - binary > + - source > + - importpath > + """ > + > + s = DBConn().session() > + conn = s.connection() > + res = conn.execute(""" > + SELECT > + binaries.package, > + source.source, > + source_metadata.value AS importpath > + FROM > + binaries LEFT JOIN > + source ON (binaries.source = source.id) LEFT JOIN > + source_metadata ON (source.id = source_metadata.src_id) LEFT JOIN > + metadata_keys ON (source_metadata.key_id = metadata_keys.key_id) > + WHERE > + metadata_keys.key = 'Go-Import-Path' > + GROUP BY > + binaries.package, > + source.source, > + source_metadata.value; > + """) > + out = [{'binary': res[0], 'source': res[1], 'importpath': res[2]} > for res in res] > + s.close() > + > + return json.dumps(out) > + > +QueryRegister().register_path('/golang/import_paths', import_paths) > -- > 2.14.2
-- Best regards, Michael
From 2a26e89d407d37ccb4a7d245fa32a732ecf83468 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg <stapelb...@debian.org> Date: Sun, 22 Oct 2017 18:32:04 +0200 Subject: [PATCH] dakweb: add /binary/by_metadata query This query will replace a heuristic in dh-make-golang(1) and help us resolve Go build dependencies into Debian build dependencies accurately. Signed-off-by: Michael Stapelberg <stapelb...@debian.org> --- dakweb/dakwebserver.py | 1 + dakweb/queries/binary.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 dakweb/queries/binary.py diff --git a/dakweb/dakwebserver.py b/dakweb/dakwebserver.py index 0ddc10cf..7b957344 100755 --- a/dakweb/dakwebserver.py +++ b/dakweb/dakwebserver.py @@ -45,6 +45,7 @@ from queries.archive import * from queries.madison import * from queries.source import * from queries.suite import * +from queries.binary import * # Set up our initial database connection d = DBConn() diff --git a/dakweb/queries/binary.py b/dakweb/queries/binary.py new file mode 100644 index 00000000..7a5692a2 --- /dev/null +++ b/dakweb/queries/binary.py @@ -0,0 +1,50 @@ +"""Debian binary package related queries. + +@copyright: 2017 Michael Stapelberg <stapelb...@debian.org> +@license: GNU General Public License version 2 or later +""" + +import bottle +import json + +from daklib.dbconn import DBConn, DBBinary, DBSource, SourceMetadata, MetadataKey +from dakweb.webregister import QueryRegister + + +@bottle.route('/binary/by_metadata/<key>') +def binary_by_metadata(key=None): + """ + + Finds all Debian binary packages which have the specified metadata set. + + E.g., to find out the Go import paths of all Debian Go packages, query + /binary/by_metadata/Go-Import-Path. + + @type key: string + @param key: Metadata key to search for. + + @rtype: dictionary + @return: A list of dictionaries of + - binary + - source + - metadata value + """ + + if not key: + return bottle.HTTPError(503, 'Metadata key not specified.') + + s = DBConn().session() + q = s.query(DBBinary.package, DBSource.source, SourceMetadata.value) + q = q.join(DBSource).join(SourceMetadata).join(MetadataKey) + q = q.filter(MetadataKey.key == key) + q = q.group_by(DBBinary.package, DBSource.source, SourceMetadata.value) + ret = [] + for p in q: + ret.append({'binary': p.package, + 'source': p.source, + 'metadata_value': p.value}) + s.close() + + return json.dumps(ret) + +QueryRegister().register_path('/binary/by_metadata', binary_by_metadata) -- 2.14.2
_______________________________________________ Pkg-go-maintainers mailing list Pkg-go-maintainers@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-go-maintainers