[Qa-jenkins-scm] [jenkins.debian.net] 07/10: reproducible debian: add link for diffoscope results to every suite/arch

Holger Levsen holger at layer-acht.org
Thu Jul 28 18:14:13 UTC 2016


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch master
in repository jenkins.debian.net.

commit c6ac981c4c0eec62aca518fb74845a505701c211
Author: Valerie R Young <spectranaut at riseup.net>
Date:   Wed Jul 27 11:27:39 2016 -0400

    reproducible debian: add link for diffoscope results to every suite/arch
    
    Direct links to diffoscope results for every suite and arch on the package
    pages now exist. In order to do this, we publish a page that displays
    the diffoscope results in the iframe by default for each suite and arch
    (where diffoscope results exist). These pages can be found at:
    DEBIAN_URL/rb-pkg/{suite}/{arch}/{package}/diffoscope.html
    
    The default iframe, when navigating to the package page,
    remains the same (DEBIAN_URL/rb-pkg/{suite}/{arch}/{package}.html).
    
    Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
 bin/reproducible_html_packages.py                  | 106 +++++++++++++++++----
 .../package_suitearch_details.mustache             |   8 +-
 .../package_suitearch_section.mustache             |   5 +
 3 files changed, 94 insertions(+), 25 deletions(-)

diff --git a/bin/reproducible_html_packages.py b/bin/reproducible_html_packages.py
index b058827..2270ef9 100755
--- a/bin/reproducible_html_packages.py
+++ b/bin/reproducible_html_packages.py
@@ -53,27 +53,64 @@ def get_buildlog_links_context(package, eversion, suite, arch):
     return context
 
 
-def get_dbd_link_context(package, eversion, suite, arch, status):
-
-    dbd = DBD_PATH + '/' + suite + '/' + arch + '/' + package + '_' + \
-          eversion + '.diffoscope.html'
-    dbdtxt = DBDTXT_PATH + '/' + suite + '/' + arch + '/' + package + '_' + \
-             eversion + '.diffoscope.txt.gz'
-    dbd_url = DBD_URI + '/' + suite + '/' + arch + '/' +  package + '_' + \
+def get_dbd_links(package, eversion, suite, arch):
+    """Returns dictionary of links to diffoscope pages.
+
+    dictionary keys:
+    dbd_uri -- included only if file for formatted diffoscope results exists
+    dbdtxt_uri -- included only if file for unformatted diffoscope results
+                  exists
+    dbd_page_uri -- included only if file for formatted diffoscope results
+                    (dbd_uri) exists. This uri is a package page with diffoscope
+                    results in main iframe by default.
+    dbd_page_file -- always returned, check existence of dbd_uri to know whether
+                     it this file is valid
+    """
+    dbd_file = os.path.join(DBD_PATH, suite, arch, package + '_' + eversion
+                       + '.diffoscope.html')
+    dbdtxt_file = os.path.join(DBDTXT_PATH, suite, arch, package + '_' + eversion
+                          + '.diffoscope.txt.gz')
+    dbd_page_file = os.path.join(RB_PKG_PATH, suite, arch, package,
+                                 'diffoscope.html')
+    dbd_uri = DBD_URI + '/' + suite + '/' + arch + '/' +  package + '_' + \
               eversion + '.diffoscope.html'
-    dbdtxt_url = DBDTXT_URI + '/' + suite + '/' + arch + '/' +  package + '_' + \
+    dbdtxt_uri = DBDTXT_URI + '/' + suite + '/' + arch + '/' +  package + '_' + \
                 eversion + '.diffoscope.txt'
-
-    context = {}
-    if os.access(dbd, os.R_OK):
-        context['dbd_url'] = dbd_url
-        if os.access(dbdtxt, os.R_OK):
-            context['dbdtxt_url'] = dbdtxt_url
+    dbd_page_uri = RB_PKG_URI + '/' + suite + '/' + arch + '/' +  package + \
+                   '/diffoscope.html'
+    links = {}
+    # only return dbd_uri and dbdtext_uri if they exist
+    if os.access(dbd_file, os.R_OK):
+        links['dbd_uri'] = dbd_uri
+        links['dbd_page_uri'] = dbd_page_uri
+        if os.access(dbdtxt_file, os.R_OK):
+            links['dbdtxt_uri'] = dbdtxt_uri
+
+    # always return dbd_page_file, because we might need to delete it
+    links['dbd_page_file'] = dbd_page_file
+    return links
+
+
+def get_and_clean_dbd_links(package, eversion, suite, arch, status):
+    links = get_dbd_links(package, eversion, suite, arch)
+
+    dbd_links = {}
+    if 'dbd_uri' in links:
+        dbd_links = {
+            'dbd_page_file': links['dbd_page_file'],
+            'dbd_page_uri': links['dbd_page_uri'],
+            'dbd_uri': links['dbd_uri'],
+        }
     else:
         if status == 'unreproducible' and not args.ignore_missing_files:
             log.critical(DEBIAN_URL + '/' + suite + '/' + arch + '/' + package +
                          ' is unreproducible, but without diffoscope output.')
-    return context, dbd_url
+        # if there are no diffoscope results, we want to remove the old package
+        # page used to display diffoscope results
+        if os.access(links['dbd_page_file'], os.R_OK):
+            os.remove(links['dbd_page_file'])
+
+    return dbd_links
 
 
 def gen_suitearch_details(package, version, suite, arch, status, spokenstatus,
@@ -97,10 +134,14 @@ def gen_suitearch_details(package, version, suite, arch, status, spokenstatus,
     context['build_date'] =  build_date
 
     # Get diffoscope differences context
-    dbd = get_dbd_link_context(package, eversion, suite, arch, status)
-    if dbd[0]:
-        context['dbd'] = dbd[0]
-        default_view = default_view if default_view else dbd[1]
+    dbd_links = get_dbd_links(package, eversion, suite, arch)
+    dbd_uri = dbd_links.get('dbd_uri', '')
+    if dbd_uri:
+        context['dbd'] = {
+            'dbd_page_uri': dbd_links['dbd_page_uri'],
+            'dbdtxt_uri': dbd_links.get('dbdtxt_uri', ''),
+        }
+        default_view = default_view if default_view else dbd_uri
 
     # Get buildinfo context
     if pkg_has_buildinfo(package, version, suite, arch):
@@ -200,6 +241,8 @@ def gen_suitearch_section(package, current_suite, current_arch):
                 suitearch_details_html, default_view = gen_suitearch_details(
                     package.name, version, s, a, status, spokenstatus, build_date)
 
+            dbd_links = get_dbd_links(package.name, strip_epoch(version), s, a)
+            dbd_page_uri = dbd_links.get('dbd_page_uri', '')
             suites.append({
                 'status': status,
                 'version': version,
@@ -213,6 +256,7 @@ def gen_suitearch_section(package, current_suite, current_arch):
                 'current_suitearch': s == current_suite and a == current_arch,
                 'package_uri': package_uri,
                 'suitearch_details_html': suitearch_details_html,
+                'dbd_page_uri': dbd_page_uri
             })
 
         if len(suites):
@@ -316,8 +360,7 @@ def gen_packages_html(packages, no_clean=False):
                     'default_view': default_view,
                 })
 
-                destfile = RB_PKG_PATH + '/' + suite + '/' + arch + '/' + \
-                           pkg + '.html'
+                destfile = os.path.join(RB_PKG_PATH, suite, arch, pkg + '.html')
                 desturl = REPRODUCIBLE_URL + RB_PKG_URI + '/' + suite + \
                           '/' + arch + '/' + pkg + '.html'
                 title = pkg + ' - reproducible builds result'
@@ -325,6 +368,27 @@ def gen_packages_html(packages, no_clean=False):
                                 no_header=True, noendpage=True,
                                 left_nav_html=navigation_html)
                 log.debug("Package page generated at " + desturl)
+
+                # Optionally generate a page in which the main iframe shows the
+                # diffoscope results by default. Needed for navigation between
+                # diffoscope pages for different suites/archs
+                eversion = strip_epoch(version)
+                dbd_links = get_and_clean_dbd_links(pkg, eversion, suite, arch,
+                                                    status)
+                # only generate the diffoscope page if diffoscope results exist
+                if 'dbd_uri' in dbd_links:
+                    body_html = renderer.render(package_page_template, {
+                        'default_view': dbd_links['dbd_uri'],
+                    })
+                    destfile = dbd_links['dbd_page_file']
+                    desturl = REPRODUCIBLE_URL + "/" + dbd_links['dbd_page_uri']
+                    title = "{} ({}) diffoscope results in {}/{}".format(
+                        pkg, version, suite, arch)
+                    write_html_page(title=title, body=body_html, destfile=destfile,
+                                    no_header=True, noendpage=True,
+                                    left_nav_html=navigation_html)
+                    log.debug("Package diffoscope page generated at " + desturl)
+
     if not no_clean:
         purge_old_pages()  # housekeep is always good
 
diff --git a/mustache-templates/reproducible/package_suitearch_details.mustache b/mustache-templates/reproducible/package_suitearch_details.mustache
index ac74be5..90a760a 100644
--- a/mustache-templates/reproducible/package_suitearch_details.mustache
+++ b/mustache-templates/reproducible/package_suitearch_details.mustache
@@ -8,13 +8,13 @@
   {{#dbd}}
   <li>
     <div>
-      <a href="{{dbd_url}}" title="Show: formatted diffoscope results" target="main">
+      <a href="{{dbd_page_uri}}" title="Show: formatted diffoscope results">
        <img src="/static/diffoscope-logo.png" alt="diffoscope logo" />
        differences
       </a>
-      {{#dbdtxt_url}}
-      <a href="{{dbdtxt_url}}" target="main">(txt)</a>
-      {{/dbdtxt_url}}
+      {{#dbdtxt_uri}}
+      <a href="{{dbdtxt_uri}}" target="main">(txt)</a>
+      {{/dbdtxt_uri}}
     </div>
   </li>
   {{/dbd}}
diff --git a/mustache-templates/reproducible/package_suitearch_section.mustache b/mustache-templates/reproducible/package_suitearch_section.mustache
index d8ac530..d98c579 100644
--- a/mustache-templates/reproducible/package_suitearch_section.mustache
+++ b/mustache-templates/reproducible/package_suitearch_section.mustache
@@ -21,6 +21,11 @@
         {{#current_suitearch}}
         {{version}} in <a href="/debian/{{suite}}/{{arch}}/" title="Go to: summary of all tests for {{arch}}/{{suite}}" target="_parent">{{suite}}</a>
         {{/current_suitearch}}
+		{{#dbd_page_uri}}{{^current_suitearch}}
+		<a href="{{dbd_page_uri}}" class="diff-link" title="Show: formatted diffoscope results">
+		  <img src="/static/diffoscope-logo.png" alt="diffoscope logo" />
+		</a>
+		{{/current_suitearch}}{{/dbd_page_uri}}
         {{{suitearch_details_html}}}
       </li>
       {{/suites}}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/qa/jenkins.debian.net.git



More information about the Qa-jenkins-scm mailing list