From d605e52ca7b4f5d47820751e7ae9a3e4f2864e6f Mon Sep 17 00:00:00 2001 From: Valerie R Young Date: Wed, 27 Jul 2016 13:00:40 -0400 Subject: reproducible debian: create arch specific history pages for packages Signed-off-by: Holger Levsen --- bin/reproducible_html_packages.py | 59 +++++++++++++++------- .../reproducible/package_history.mustache | 17 +++++++ .../reproducible/package_navigation.mustache | 8 ++- 3 files changed, 65 insertions(+), 19 deletions(-) create mode 100644 mustache-templates/reproducible/package_history.mustache diff --git a/bin/reproducible_html_packages.py b/bin/reproducible_html_packages.py index 2270ef9c..118edb8a 100755 --- a/bin/reproducible_html_packages.py +++ b/bin/reproducible_html_packages.py @@ -26,6 +26,9 @@ suitearch_details_template = renderer.load_template( os.path.join(TEMPLATE_PATH, 'package_suitearch_details')) project_links_template = renderer.load_template( os.path.join(TEMPLATE_PATH, 'project_links')) +package_history_template = renderer.load_template( + os.path.join(TEMPLATE_PATH, 'package_history')) + def sizeof_fmt(num): for unit in ['B','KB','MB','GB']: @@ -274,19 +277,24 @@ def shorten_if_debiannet(hostname): hostname = hostname[:-11] return hostname -def gen_history_page(package): - keys = ('build date', 'version', 'suite', 'architecture', 'result', - 'build duration', 'node1', 'node2', 'job') +def gen_history_page(package, arch=None): + keys = ['build date', 'version', 'suite', 'architecture', 'result', + 'build duration', 'node1', 'node2', 'job'] + + context = {} try: head = package.history[0] except IndexError: - html = '

No historical data available for this package.

' + context['arch'] = arch else: - html = '\n{tab}\n{tab}{tab}'.format(tab=tab) - for i in keys: - html += ''.format(i) - html += '\n{tab}'.format(tab=tab) - for record in package.history: + context['keys'] = [{'key': key} for key in keys] + rows = [] + for r in package.history: + # make a copy, since we modify in place + record = dict(r) + # skip records for other archs if we care about arch + if arch and record['architecture'] != arch: + continue # remove trailing .debian.net from hostnames record['node1'] = shorten_if_debiannet(record['node1']) record['node2'] = shorten_if_debiannet(record['node2']) @@ -297,17 +305,22 @@ def gen_history_page(package): # human formatting of build duration record['build duration'] = convert_into_hms_string( int(record['build duration'])) - html += '\n{tab}\n{tab}{tab}'.format(tab=tab) - for i in keys: - html += ''.format(record[i]) - html += '\n{tab}'.format(tab=tab) - html += '
{}
{}
' - destfile = os.path.join(HISTORY_PATH, package.name+'.html') + row_items = [{'item': record[key]} for key in keys] + rows.append({'row_items': row_items}) + context['rows'] = rows + + html = renderer.render(package_history_template, context) + if arch: + destfile = os.path.join(HISTORY_PATH, arch, package.name+'.html') + else: + destfile = os.path.join(HISTORY_PATH, package.name+'.html') title = 'build history of {}'.format(package.name) + print(arch) + if arch: + title += ' on {}'.format(arch) write_html_page(title=title, body=html, destfile=destfile, noendpage=True) - def gen_packages_html(packages, no_clean=False): """ generate the /rb-pkg/package.html pages. @@ -318,6 +331,9 @@ def gen_packages_html(packages, no_clean=False): for package in sorted(packages, key=lambda x: x.name): assert isinstance(package, Package) gen_history_page(package) + for arch in ARCHS: + gen_history_page(package, arch) + pkg = package.name notes_uri = '' @@ -339,7 +355,13 @@ def gen_packages_html(packages, no_clean=False): suitearch_section_html, default_view, reproducible = \ gen_suitearch_section(package, suite, arch) - history = '{}/{}.html'.format(HISTORY_URI, pkg) + history_uri = '{}/{}.html'.format(HISTORY_URI, pkg) + history_archs = [] + for a in ARCHS: + history_archs.append({ + 'history_arch': a, + 'history_arch_uri': '{}/{}/{}.html'.format(HISTORY_URI, a, pkg) + }) project_links = renderer.render(project_links_template) navigation_html = renderer.render(package_navigation_template, { @@ -347,7 +369,8 @@ def gen_packages_html(packages, no_clean=False): 'suite': suite, 'arch': arch, 'version': version, - 'history': history, + 'history_uri': history_uri, + 'history_archs': history_archs, 'notes_uri': notes_uri, 'notify_maintainer': package.notify_maint, 'suitearch_section_html': suitearch_section_html, diff --git a/mustache-templates/reproducible/package_history.mustache b/mustache-templates/reproducible/package_history.mustache new file mode 100644 index 00000000..8326e8dc --- /dev/null +++ b/mustache-templates/reproducible/package_history.mustache @@ -0,0 +1,17 @@ +{{^rows}} +

No historical data available for this package{{#arch}} on architecture: {{arch}}{{/arch}}.

+{{/rows}} + + + {{#keys}} + + {{/keys}} + + {{#rows}} + + {{#row_items}} + + {{/row_items}} + + {{/rows}} +
{{key}}
{{{item}}}
diff --git a/mustache-templates/reproducible/package_navigation.mustache b/mustache-templates/reproducible/package_navigation.mustache index 0d579b7d..e90d2612 100644 --- a/mustache-templates/reproducible/package_navigation.mustache +++ b/mustache-templates/reproducible/package_navigation.mustache @@ -17,7 +17,13 @@ {{/reproducible}} {{/notes_uri}}
  • - test history + test history +
  • Suite and Architecture

    {{{suitearch_section_html}}} -- cgit v1.2.3-54-g00ecf