summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattia Rizzolo <mattia@mapreri.org>2015-01-14 19:56:58 +0100
committerHolger Levsen <holger@layer-acht.org>2015-01-15 00:14:31 +0100
commitfa4ec80cbd367f3a9923dbd1a8b3387f21deb153 (patch)
treee48687d7eae8f13757a0fbe593738c4bfe0a6319
parent507c17c70c377331bc26f012da7e6734c1501ffd (diff)
downloadjenkins.debian.net-fa4ec80cbd367f3a9923dbd1a8b3387f21deb153.tar.xz
reproducible: add a pkg_has_buildinfo common function, to avoid code duplication
-rwxr-xr-xbin/reproducible_common.py21
-rwxr-xr-xbin/reproducible_html_packages.py2
2 files changed, 20 insertions, 3 deletions
diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py
index cc0c396a..887a2720 100755
--- a/bin/reproducible_common.py
+++ b/bin/reproducible_common.py
@@ -223,8 +223,11 @@ def join_status_icon(status, package=None, version=None):
'not_for_us': 'weather-few-clouds-night.png',
'blacklisted': 'error.png'}
if status == 'unreproducible':
- if os.access(BUILDINFO_PATH + '/' + str(package) + '_' + \
- strip_epoch(str(version)) + '_amd64.buildinfo', os.R_OK):
+ if not package:
+ log.error('Could not determinate the real state of package None. '
+ + 'Returning a generic "FTBR"')
+ status = 'FTBR'
+ elif pkg_has_buildinfo(package, version):
status = 'FTBR_with_buildinfo'
else:
status = 'FTBR'
@@ -252,6 +255,20 @@ def strip_epoch(version):
except IndexError:
return version
+def pkg_has_buildinfo(package, version=False):
+ """
+ if there is no version specified it will use the version listed in
+ reproducible.db
+ """
+ if not version:
+ query = 'SELECT version FROM source_packages WHERE name="%s"' % package
+ version = str(query_db(query)[0][0])
+ buildinfo = BUILDINFO_PATH + '/' + package + '_' + \
+ strip_epoch(version) + '_amd64.buildinfo'
+ if os.access(buildinfo, os.R_OK):
+ return True
+ else:
+ return False
# do the db querying
conn = init_conn()
diff --git a/bin/reproducible_html_packages.py b/bin/reproducible_html_packages.py
index f3f89244..49723944 100755
--- a/bin/reproducible_html_packages.py
+++ b/bin/reproducible_html_packages.py
@@ -92,7 +92,7 @@ def gen_extra_links(package, version):
default_view = url
else:
log.debug('debbindiff not detetected at ' + dbd)
- if os.access(buildinfo, os.R_OK):
+ if pkg_has_buildinfo(package, version):
url = BUILDINFO_URI + '/' + package + '_' + strip_epoch(version) + '_amd64.buildinfo'
links += '<a href="' + url + '" target="main">buildinfo</a>\n'
if not default_view: