[pkg-go] [PATCH] dakweb: add /golang/import_paths query

Michael Stapelberg stapelberg at debian.org
Tue Oct 24 06:31:48 UTC 2017


Updated patch attached (as per Ganneff’s review).

On Sun, Oct 22, 2017 at 6:41 PM, Michael Stapelberg
<stapelberg at 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
> +
> + at contact: https://pkg-go.alioth.debian.org/
> + at copyright: 2017 Michael Stapelberg <stapelberg at debian.org>
> + at license: GNU General Public License version 2 or later
> +"""
> +
> +import bottle
> +import json
> +
> +from daklib.dbconn import DBConn, MetadataKey
> +from dakweb.webregister import QueryRegister
> +
> +
> + at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-dakweb-add-binary-by_metadata-query.patch
Type: text/x-patch
Size: 2676 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-go-maintainers/attachments/20171024/84e7db5d/attachment-0001.bin>


More information about the Pkg-go-maintainers mailing list