summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorValerie R Young <spectranaut@riseup.net>2016-07-05 08:35:41 -0400
committerHolger Levsen <holger@layer-acht.org>2016-07-05 17:42:44 +0200
commita8d02c004bb864307c297db5af5e5730d9ee6f9a (patch)
treea823291a1aa67e83d738c35dab5f1584df3019b6
parentb4ea329bf29b4e4d101d85a68dcc04305d8cb97e (diff)
downloadjenkins.debian.net-a8d02c004bb864307c297db5af5e5730d9ee6f9a.tar.xz
reproducible debian: replace bash write_page_footer with mustache template
Signed-off-by: Mattia Rizzolo <mattia@debian.org> Signed-off-by: Holger Levsen <holger@layer-acht.org>
-rwxr-xr-xbin/reproducible_common.py7
-rwxr-xr-xbin/reproducible_common.sh41
-rw-r--r--bin/templates/default_page_footer.mustache5
3 files changed, 29 insertions, 24 deletions
diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py
index f7a2a7d6..ed095e07 100755
--- a/bin/reproducible_common.py
+++ b/bin/reproducible_common.py
@@ -171,17 +171,14 @@ try:
except KeyError:
JOB_URL = ''
JOB_NAME = ''
- JOB_FOOTER = ''
else:
JOB_NAME = os.path.basename(JOB_URL[:-1])
- JOB_FOOTER = 'This page was built by the jenkins job <a href="'+JOB_URL+'">'
- JOB_FOOTER += JOB_NAME+'</a> which is configured via this '
- JOB_FOOTER += '<a href="https://anonscm.debian.org/git/qa/jenkins.debian.net.git/">git repo</a>.'
def create_default_page_footer(date):
return renderer.render(default_page_footer_template, {
'date': date,
- 'job_footer': JOB_FOOTER,
+ 'job_url': JOB_URL,
+ 'job_name': JOB_NAME,
'jenkins_url': JENKINS_URL,
})
diff --git a/bin/reproducible_common.sh b/bin/reproducible_common.sh
index 651299b3..9e5f38f2 100755
--- a/bin/reproducible_common.sh
+++ b/bin/reproducible_common.sh
@@ -42,6 +42,7 @@ REPRODUCIBLE_DOT_ORG_URL=https://reproducible-builds.org
JENKINS_URL=${JENKINS_URL:0:-1}
DBDSUITE="unstable"
BIN_PATH=/srv/jenkins/bin
+TEMPLATE_PATH=$BIN_PATH/templates
# Debian suites being tested
SUITES="testing unstable experimental"
@@ -103,6 +104,9 @@ do
META_PKGSET[$col1]=$col2
done < $BIN_PATH/meta_pkgset.csv
+# mustache templates
+PAGE_FOOTER_TEMPLATE=$TEMPLATE_PATH/default_page_footer.mustache
+
# sleep 1-23 secs to randomize start times
delay_start() {
/bin/sleep $(echo "scale=1 ; $(shuf -i 1-230 -n 1)/10" | bc )
@@ -367,33 +371,34 @@ write_page_intro() {
fi
}
-# See the python equivalent of this function: reproducible_common.py's create_default_page_footer
write_page_footer() {
- write_page "<hr id=\"footer_separator\" /><p style=\"font-size:0.9em;\"><div id=\"page_footer\">"
- if [ -n "$JOB_URL" ] ; then
- write_page "This page was built by the jenkins job"
- write_page "<a href=\"$JOB_URL\">$(basename $JOB_URL)</a> which is configured"
- write_page "via this <a href=\"https://anonscm.debian.org/git/qa/jenkins.debian.net.git/\">git repo</a>."
- fi
- write_page "There is more information <a href=\"https://jenkins.debian.net/userContent/about.html\">about jenkins.debian.net</a> and about <a href=\"https://wiki.debian.org/ReproducibleBuilds\"> reproducible builds of Debian</a> available elsewhere."
- write_page "<br /> Last update: $(date +'%Y-%m-%d %H:%M %Z'). Copyright 2014-2016 <a href=\"mailto:holger@layer-acht.org\">Holger Levsen</a> and <a href=\"https://jenkins.debian.net//userContent/thanks.html\">many others</a>."
- write_page "The code of <a href=\"https://anonscm.debian.org/git/qa/jenkins.debian.net.git/\">jenkins.debian.net.git</a> is mostly GPL-2 licensed. The weather icons are public domain and have been taken from the <a href=\"http://tango.freedesktop.org/Tango_Icon_Library\" target=\"_blank\">Tango Icon Library</a>."
- write_page "<br />"
if [ "$1" = "coreboot" ] ; then
- write_page "The <a href=\"http://www.coreboot.org\">Coreboot</a> logo is Copyright © 2008 by Konsult Stuge and coresystems GmbH and can be freely used to refer to the Coreboot project."
+ other_distro_details="The <a href=\"http://www.coreboot.org\">Coreboot</a> logo is Copyright © 2008 by Konsult Stuge and coresystems GmbH and can be freely used to refer to the Coreboot project."
elif [ "$1" = "NetBSD" ] ; then
- write_page "NetBSD® is a registered trademark of The NetBSD Foundation, Inc."
+ other_distro_details="NetBSD® is a registered trademark of The NetBSD Foundation, Inc."
elif [ "$1" = "FreeBSD" ] ; then
- write_page "FreeBSD is a registered trademark of The FreeBSD Foundation. The FreeBSD logo and The Power to Serve are trademarks of The FreeBSD Foundation."
+ other_distro_details="FreeBSD is a registered trademark of The FreeBSD Foundation. The FreeBSD logo and The Power to Serve are trademarks of The FreeBSD Foundation."
elif [ "$1" = "Arch Linux" ] ; then
- write_page "The <a href=\"https://www.archlinux.org\">Arch Linux</a> name and logo are recognized trademarks. Some rights reserved. The registered trademark Linux® is used pursuant to a sublicense from LMI, the exclusive licensee of Linus Torvalds, owner of the mark on a world-wide basis."
+ other_distro_details="The <a href=\"https://www.archlinux.org\">Arch Linux</a> name and logo are recognized trademarks. Some rights reserved. The registered trademark Linux® is used pursuant to a sublicense from LMI, the exclusive licensee of Linus Torvalds, owner of the mark on a world-wide basis."
elif [ "$1" = "fedora-23" ] ; then
- write_page "FIXME: add fedora copyright+trademark disclaimers here."
+ other_distro_details="FIXME: add fedora copyright+trademark disclaimers here."
+ else
+ other_distro_details=''
fi
- write_page "</div></p>"
+ now=$(date +'%Y-%m-%d %H:%M %Z')
+
+ # The context for pystache3 CLI must be json
+ context=$(printf '{
+ "job_url" : "%s",
+ "job_name" : "%s",
+ "date" : "%s",
+ "other_distro_details" : "%s"
+ }' "${JOB_URL:-""}" "${JOB_NAME:-""}" "$now" "$other_distro_details")
+
+ write_page "$(pystache3 $PAGE_FOOTER_TEMPLATE "$context")"
write_page "</div>"
write_page "</body></html>"
-}
+ }
# A mustache equivalent of this function has been created. See TEMPLATE_PATH/pkg_list_key.mustache
write_page_meta_sign() {
diff --git a/bin/templates/default_page_footer.mustache b/bin/templates/default_page_footer.mustache
index 1a8c46c5..a2160d3e 100644
--- a/bin/templates/default_page_footer.mustache
+++ b/bin/templates/default_page_footer.mustache
@@ -1,7 +1,10 @@
<hr id="footer_separator" />
<p style="font-size:0.9em;">
<div id="page_footer">
- {{job_footer}}
+ {{#job_url}}
+ This page was built by the jenkins job <a href="{{job_url}}"> {{job_name}}</a>
+ which is configured via this <a href="https://anonscm.debian.org/git/qa/jenkins.debian.net.git/">git repo</a>.
+ {{/job_url}}
There is more information
<a href="{{jenkins_url}}/userContent/about.html">about jenkins.debian.net</a>
and about <a href="https://wiki.debian.org/ReproducibleBuilds"> reproducible builds of Debian</a>