diff options
author | Mattia Rizzolo <mattia@mapreri.org> | 2015-01-30 12:50:43 +0100 |
---|---|---|
committer | Holger Levsen <holger@layer-acht.org> | 2015-01-30 12:52:36 +0100 |
commit | 4282dfda3f8c9110bd9af567daddec8deb40a1c8 (patch) | |
tree | 1806e8686ca49778dff38379f32f8f43b591cdbf | |
parent | 8fc0af71ad23d3b1e1b0a44f97a21b3a69f1f024 (diff) | |
download | jenkins.debian.net-4282dfda3f8c9110bd9af567daddec8deb40a1c8.tar.xz |
reproducible: rewrite the reproducible_json.sh in python, and replace it
-rwxr-xr-x | bin/reproducible_json.py | 33 | ||||
-rwxr-xr-x | bin/reproducible_json.sh | 43 | ||||
-rw-r--r-- | job-cfg/reproducible.yaml | 2 |
3 files changed, 34 insertions, 44 deletions
diff --git a/bin/reproducible_json.py b/bin/reproducible_json.py new file mode 100755 index 00000000..7080b9ea --- /dev/null +++ b/bin/reproducible_json.py @@ -0,0 +1,33 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- +# +# Copyright © 2015 Mattia Rizzolo <mattia@mapreri.org> +# Licensed under GPL-2+ +# +# Depends: python3 +# +# Build the reproducible.json file, to provide a nice datasource + +from reproducible_common import * + +import json + +result = sorted(query_db('SELECT name, version, status FROM source_packages' + + ' WHERE status != ""')) +count = int(query_db('SELECT COUNT(name) FROM source_packages ' + + 'WHERE status != ""')[0][0]) + +log.info('processing ' + str(count) + ' package to create .json output') + +all_pkgs = [] +keys = ['package', 'version', 'status'] +for row in result: + pkg = dict(zip(keys, row)) + pkg['suite'] = 'sid' + all_pkgs.append(pkg) + +with open(REPRODUCIBLE_JSON, 'w') as fd: + json.dump(all_pkgs, fd, indent=4, sort_keys=True) + +log.info(REPRODUCIBLE_URL + '/reproducible.json has been updated.') + diff --git a/bin/reproducible_json.sh b/bin/reproducible_json.sh deleted file mode 100755 index 9c877e45..00000000 --- a/bin/reproducible_json.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -# Copyright 2014-2015 Holger Levsen <holger@layer-acht.org> -# released under the GPLv=2 - -DEBUG=false -. /srv/jenkins/bin/common-functions.sh -common_init "$@" - -# common code defining db access -. /srv/jenkins/bin/reproducible_common.sh - -set +x - -write_json() { - echo "$1" >> $JSON -} - -JSON=$(mktemp) -RESULT=$(sqlite3 -init $INIT $PACKAGES_DB "SELECT name,version,status FROM source_packages WHERE status != \"\"") -COUNT_TOTAL=$(sqlite3 -init $INIT $PACKAGES_DB "SELECT COUNT(name) FROM source_packages WHERE status != \"\"") -echo "$(date) - processing $COUNT_TOTAL packages to create .json output... this will take a while." - -sep="" -write_json "[" -while read LINE ; do - PKG=$(echo "$LINE" | cut -d "|" -f1) - VERSION=$(echo "$LINE" | cut -d "|" -f2) - STATUS=$(echo "$LINE" | cut -d "|" -f3) - write_json "${sep}{" - write_json "\"package\": \"$PKG\"," - write_json "\"version\": \"$VERSION\"," - write_json "\"status\": \"$STATUS\"," - write_json "\"suite\": \"sid\"" - write_json "}" - sep=", " -done < <(echo "$RESULT") -write_json "]" - -echo -echo "$(date) - $REPRODUCIBLE_URL/reproducible.json has been updated." -mv $JSON /var/lib/jenkins/userContent/reproducible.json -chmod 755 /var/lib/jenkins/userContent/reproducible.json diff --git a/job-cfg/reproducible.yaml b/job-cfg/reproducible.yaml index c5ff65bc..39668ae5 100644 --- a/job-cfg/reproducible.yaml +++ b/job-cfg/reproducible.yaml @@ -234,7 +234,7 @@ - '{name}_json': my_description: 'Generate https://reproducible.debian.net/userContent/reproducible.json for consumption by tracker.debian.org.' my_timed: '1 0 * * *' - my_shell: '/srv/jenkins/bin/reproducible_json.sh' + my_shell: '/srv/jenkins/bin/reproducible_json.py' my_recipients: 'holger@layer-acht.org' - '{name}_create_meta_pkg_sets': my_description: 'Create meta package sets for later consumption when generating HTML stats.' |