summaryrefslogtreecommitdiffstats
path: root/bin/reproducible_html_packages.py
diff options
context:
space:
mode:
authorMattia Rizzolo <mattia@mapreri.org>2015-02-24 09:13:55 +0100
committerHolger Levsen <holger@layer-acht.org>2015-02-26 17:13:54 +0100
commitc81776ed4895b4323fae025dd6df6a5daf2eaec1 (patch)
tree42b68808b2a3bd186818beef942ddab41783a2a5 /bin/reproducible_html_packages.py
parenta2a14ff0595066884669928588482bc8cbeacbd3 (diff)
downloadjenkins.debian.net-c81776ed4895b4323fae025dd6df6a5daf2eaec1.tar.xz
reproducible: html_packages: update to a new database schema supporting multiple suites. yet, hardcode sid in purge_old_pages() and default to it in gen_packages_html()
Diffstat (limited to 'bin/reproducible_html_packages.py')
-rwxr-xr-xbin/reproducible_html_packages.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/bin/reproducible_html_packages.py b/bin/reproducible_html_packages.py
index 6b0306a3..d51180cd 100755
--- a/bin/reproducible_html_packages.py
+++ b/bin/reproducible_html_packages.py
@@ -56,15 +56,16 @@ def sizeof_fmt(num):
num /= 1024.0
return str(int(round(float("%f" % num), 0))) + "%s" % ('Yi')
-def check_package_status(package):
+def check_package_status(package, suite):
"""
This returns a tuple containing status, version and build_date of the last
version of the package built by jenkins CI
"""
try:
- query = 'SELECT status,version,build_date ' + \
- 'FROM source_packages ' + \
- 'WHERE name="%s"' % package
+ query = ('SELECT r.status, r.version, r.build_date ' +
+ 'FROM results AS r JOIN sources AS s ON r.package_id=s.id ' +
+ 'WHERE s.name="{pkg}" ' +
+ 'AND s.suite="{suite}"').format(pkg=package, suite=suite)
result = query_db(query)[0]
except IndexError:
print_critical_message('This query produces no results: ' + query +
@@ -131,7 +132,7 @@ def gen_bugs_links(package, bugs):
return html
-def gen_packages_html(packages, no_clean=False):
+def gen_packages_html(packages, suite='sid', no_clean=False):
"""
generate the /rb-pkg/package.html page
packages should be a list
@@ -142,7 +143,7 @@ def gen_packages_html(packages, no_clean=False):
log.info('Generating the pages of ' + str(total) + ' package(s)')
for pkg in sorted(packages):
pkg = str(pkg)
- status, version, build_date = check_package_status(pkg)
+ status, version, build_date = check_package_status(pkg, suite)
log.info('Generating the page of ' + pkg + ' ' + version +
' built at ' + build_date)
@@ -167,19 +168,23 @@ def gen_packages_html(packages, no_clean=False):
if not no_clean:
purge_old_pages() # housekeep is always good
-def gen_all_rb_pkg_pages(no_clean=False):
- query = 'SELECT name FROM source_packages WHERE status != ""'
+def gen_all_rb_pkg_pages(suite='sid', no_clean=False):
+ query = 'SELECT s.name ' + \
+ 'FROM results AS r JOIN sources AS s ON r.package_id=s.id ' + \
+ 'WHERE r.status !="" AND s.suite="%s"' % suite
rows = query_db(query)
pkgs = [str(i[0]) for i in rows]
log.info('Processing all the package pages, ' + str(len(pkgs)))
- gen_packages_html(pkgs, no_clean)
+ gen_packages_html(pkgs, suite, no_clean)
def purge_old_pages():
presents = sorted(os.listdir(RB_PKG_PATH))
for page in presents:
pkg = page.rsplit('.', 1)[0]
log.debug('Checking if ' + page + ' (from ' + pkg + ') is still needed')
- query = 'SELECT name FROM source_packages WHERE name="%s"' % pkg
+ query = 'SELECT s.name ' + \
+ 'FROM results AS r JOIN sources AS s ON r.package_id=s.id ' + \
+ 'WHERE s.name="%s" AND r.status != "" AND s.suite="sid"' % pkg
result = query_db(query)
if not result: # actually, the query produces no results
log.info('There is no package named ' + pkg + ' in the database.' +