From 59c469d7dd3ea608e5582ef3faa0d306b33afafa Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Thu, 9 Oct 2014 12:21:38 +0200 Subject: reproducible: show notes managed in yaml in git.debian.org/git/reproducible/notes.git. add index page for all packages with notes --- bin/reproducible_stats.sh | 217 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 213 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/reproducible_stats.sh b/bin/reproducible_stats.sh index 1e999cf0..42576ac1 100755 --- a/bin/reproducible_stats.sh +++ b/bin/reproducible_stats.sh @@ -63,6 +63,183 @@ SPOKENTARGET["last_24h"]="packages tested in the last 24h" SPOKENTARGET["last_48h"]="packages tested in the last 48h" SPOKENTARGET["all_abc"]="all tested packages (sorted alphabetically)" SPOKENTARGET["dd-list"]="maintainers of unreproducible packages" +SPOKENTARGET["notes"]="packages with notes" + +# +# gather notes +# +WORKSPACE=$PWD +cd /var/lib/jenkins +if [ -d notes.git ] ; then + cd notes.git + git pull +else + git clone git://git.debian.org/git/reproducible/notes.git notes.git +fi +cd $WORKSPACE +PACKAGES_YML=/var/lib/jenkins/notes.git/packages.yml +ISSUES_YML=/var/lib/jenkins/notes.git/issues.yml +NOTES_PATH=/var/lib/jenkins/userContent/notes +mkdir -p $NOTES_PATH +rm -f $NOTES_PATH/*.html + +declare -A NOTES_PACKAGE +declare -A NOTES_VERSION +declare -A NOTES_ISSUES +declare -A NOTES_BUGS +declare -A NOTES_COMMENTS +declare -A ISSUES_DESCRIPTION +declare -A ISSUES_URL + +show_multi_values() { + TMPFILE=$(mktemp) + echo "$@" > $TMPFILE + while IFS= read -r p ; do + if [ "$p" = "-" ] || [ "$p" = "" ] ; then + continue + elif [ "${p:0:2}" = "- " ] ; then + p="${p:2}" + fi + echo " $PROPERTY = $p" + done < $TMPFILE + unset IFS + rm $TMPFILE +} + +ISSUES=$(cat ${ISSUES_YML} | /srv/jenkins/bin/shyaml keys) +for ISSUE in ${ISSUES} ; do + echo " Issue = ${ISSUE}" + for PROPERTY in url description ; do + VALUE="$(cat ${ISSUES_YML} | /srv/jenkins/bin/shyaml get-value ${ISSUE}.${PROPERTY} )" + if [ "$VALUE" != "" ] ; then + case $PROPERTY in + url) ISSUES_URL[${ISSUE}]=$VALUE + echo " $PROPERTY = $VALUE" + ;; + description) ISSUES_DESCRIPTION[${ISSUE}]=$VALUE + show_multi_values "$VALUE" + ;; + esac + fi + done +done + +tag_property_loop() { + BEFORE=$1 + shift + AFTER=$1 + shift + TMPFILE=$(mktemp) + echo "$@" > $TMPFILE + while IFS= read -r p ; do + if [ "$p" = "-" ] || [ "$p" = "" ] ; then + continue + elif [ "${p:0:2}" = "- " ] ; then + p="${p:2}" + fi + echo "$BEFORE" >> ${NOTE} + if $BUG ; then + # turn bugs into links + p="#$p" + else + # turn URLs into links + p="$(echo $p |sed -e 's|http[s:]*//[^ ]*|\0|g')" + fi + echo "$p" >> ${NOTE} + echo "$AFTER" >> ${NOTE} + done < $TMPFILE + unset IFS + rm $TMPFILE +} + +issues_loop() { + TTMPFILE=$(mktemp) + echo "$@" > $TTMPFILE + FIRST=true + while IFS= read -r p ; do + if [ "${p:0:2}" = "- " ] ; then + p="${p:2}" + fi + if ! $FIRST ; then + echo " " >> ${NOTE} + fi + FIRST=false + if [ "${ISSUES_URL[$p]}" != "" ] ; then + echo "$p" >> ${NOTE} + else + echo "$p" >> ${NOTE} + fi + tag_property_loop "" "
" "${ISSUES_DESCRIPTION[$p]}" + echo "" >> ${NOTE} + done < $TTMPFILE + unset IFS + rm $TTMPFILE +} + +create_pkg_note() { + echo "" > ${NOTE} + echo "" >> ${NOTE} + echo "" >> ${NOTE} + + echo "" >> ${NOTE} + BUG=false + + if [ "${NOTES_ISSUES[$1]}" != "" ] ; then + echo "" >> ${NOTE} + issues_loop "${NOTES_ISSUES[$1]}" + fi + BUG=true + if [ "${NOTES_BUGS[$1]}" != "" ] ; then + echo "" >> ${NOTE} + echo "" >> ${NOTE} + fi + BUG=false + if [ "${NOTES_COMMENTS[$1]}" != "" ] ; then + echo "" >> ${NOTE} + echo "" >> ${NOTE} + fi + echo "" >> ${NOTE} + echo "" >> ${NOTE} + echo "
Version annotated:${NOTES_VERSION[$1]}
Identified issues:
Bugs noted:
 " >> ${NOTE} + tag_property_loop "" "
" "${NOTES_BUGS[$1]}" + echo "
Comments:
 " >> ${NOTE} + tag_property_loop "" "
" "${NOTES_COMMENTS[$1]}" + echo "
 
" >> ${NOTE} + echo "Notes are stored in notes.git." >> ${NOTE} + echo "
" >> ${NOTE} +} + +PACKAGES_WITH_NOTES=$(cat ${PACKAGES_YML} | /srv/jenkins/bin/shyaml keys) +for PKG in $PACKAGES_WITH_NOTES ; do + echo " Package = ${PKG}" + NOTES_PACKAGE[${PKG}]=" notes " + for PROPERTY in version issues bugs comments ; do + VALUE="$(cat ${PACKAGES_YML} | /srv/jenkins/bin/shyaml get-value ${PKG}.${PROPERTY} )" + if [ "$VALUE" != "" ] ; then + case $PROPERTY in + version) NOTES_VERSION[${PKG}]=$VALUE + echo " $PROPERTY = $VALUE" + ;; + issues) NOTES_ISSUES[${PKG}]=$VALUE + show_multi_values "$VALUE" + ;; + bugs) NOTES_BUGS[${PKG}]=$VALUE + show_multi_values "$VALUE" + ;; + comments) NOTES_COMMENTS[${PKG}]=$VALUE + show_multi_values "$VALUE" + ;; + esac + fi + done + NOTE=$NOTES_PATH/${PKG}_note.html + create_pkg_note $PKG +done + +# +# end note parsing +# + write_summary() { @@ -118,7 +295,7 @@ append2navi_frame() { } finish_navi_frame() { - echo "bugs/stats for reproducible builds" >> $NAVI + echo "notes/bugs/stats for reproducible builds" >> $NAVI } process_packages() { @@ -135,9 +312,11 @@ process_packages() { # only build $PKG pages if they don't exist or are older than $BUILD_DATE NAVI="/var/lib/jenkins/userContent/rb-pkg/${PKG}_navigation.html" FILE=$(find $(dirname $NAVI) -name $(basename $NAVI) ! -newermt "$BUILD_DATE" 2>/dev/null || true) - if [ ! -f $NAVI ] || [ "$FILE" != "" ] ; then + # if no navigation exists, or is older than last build_date or if a note exist... + if [ ! -f $NAVI ] || [ "$FILE" != "" ] || [ "${NOTES_PACKAGE[${PKG}]}" != "" ] ; then MAINLINK="" init_navi_frame "$PKG" "$VERSION" "$STATUS" "$BUILD_DATE" "${STAR[$PKG]}" + append2navi_frame "${NOTES_PACKAGE[${PKG}]}" if [ -f "/var/lib/jenkins/userContent/buildinfo/${PKG}_${EVERSION}_amd64.buildinfo" ] ; then append2navi_frame " buildinfo " MAINLINK="$JENKINS_URL/userContent/buildinfo/${PKG}_${EVERSION}_amd64.buildinfo" @@ -159,17 +338,31 @@ process_packages() { append2navi_frame " sources " append2navi_frame " debian/rules " + if [ "${NOTES_PACKAGE[${PKG}]}" != "" ] ; then + MAINLINK="$JENKINS_URL/userContent/notes/${PKG}_note.html" + fi finish_navi_frame write_pkg_frameset "$PKG" "$MAINLINK" fi if [ -f "/var/lib/jenkins/userContent/rbuild/${PKG}_${EVERSION}.rbuild.log" ] ; then - LINKTARGET[$PKG]="$PKG${STAR[$PKG]}" + if [ "${NOTES_PACKAGE[${PKG}]}" != "" ] ; then + NOTED="N" + else + NOTED="" + fi + LINKTARGET[$PKG]="$PKG${STAR[$PKG]}$NOTED" else LINKTARGET[$PKG]="$PKG" fi done } +force_package_targets() { + for PKG in $@ ; do + LINKTARGET[$PKG]="$PKG${STAR[$PKG]}" + done +} + link_packages() { for PKG in $@ ; do write_summary " ${LINKTARGET[$PKG]} " @@ -191,7 +384,7 @@ write_summary_header() { fi write_summary "

" write_summary "