# released under the GPLv=2
. /srv/jenkins/bin/common-functions.sh
common_init "$@"
set +x
# define db
PACKAGES_DB=/var/lib/jenkins/reproducible.db
INIT=/var/lib/jenkins/reproducible.init
if [ ! -f $PACKAGES_DB ] ; then
echo "$PACKAGES_DB doesn't exist, no stats possible."
exit 1
fi
SUITE=sid
AMOUNT=$(sqlite3 -init $INIT $PACKAGES_DB "SELECT amount FROM source_stats WHERE suite = \"$SUITE\"" | xargs echo)
GOOD=$(sqlite3 -init $INIT $PACKAGES_DB "SELECT name FROM source_packages WHERE status = \"reproducible\" ORDER BY name" | xargs echo)
COUNT_GOOD=$(sqlite3 -init $INIT $PACKAGES_DB "SELECT COUNT(name) FROM source_packages WHERE status = \"reproducible\"")
BAD=$(sqlite3 -init $INIT $PACKAGES_DB "SELECT name FROM source_packages WHERE status = \"unreproducible\" ORDER BY build_date DESC" | xargs echo)
COUNT_BAD=$(sqlite3 -init $INIT $PACKAGES_DB "SELECT COUNT(name) FROM source_packages WHERE status = \"unreproducible\"")
UGLY=$(sqlite3 -init $INIT $PACKAGES_DB "SELECT name FROM source_packages WHERE status = \"FTBFS\" ORDER BY build_date DESC" | xargs echo)
COUNT_UGLY=$(sqlite3 -init $INIT $PACKAGES_DB "SELECT COUNT(name) FROM source_packages WHERE status = \"FTBFS\"")
SOURCELESS=$(sqlite3 -init $INIT $PACKAGES_DB "SELECT name FROM source_packages WHERE status = \"404\" ORDER BY build_date DESC" | xargs echo)
COUNT_SOURCELESS=$(sqlite3 -init $INIT $PACKAGES_DB "SELECT COUNT(name) FROM source_packages WHERE status = \"404\"" | xargs echo)
NOTFORUS=$(sqlite3 -init $INIT $PACKAGES_DB "SELECT name FROM source_packages WHERE status = \"not for us\" ORDER BY build_date DESC" | xargs echo)
COUNT_NOTFORUS=$(sqlite3 -init $INIT $PACKAGES_DB "SELECT COUNT(name) FROM source_packages WHERE status = \"not for us\"" | xargs echo)
BLACKLISTED=$(sqlite3 -init $INIT $PACKAGES_DB "SELECT name FROM source_packages WHERE status = \"blacklisted\" ORDER BY build_date DESC" | xargs echo)
COUNT_BLACKLISTED=$(sqlite3 -init $INIT $PACKAGES_DB "SELECT COUNT(name) FROM source_packages WHERE status = \"blacklisted\"" | xargs echo)
COUNT_TOTAL=$(sqlite3 -init $INIT $PACKAGES_DB "SELECT COUNT(name) FROM source_packages")
PERCENT_TOTAL=$(echo "scale=1 ; ($COUNT_TOTAL*100/$AMOUNT)" | bc)
PERCENT_GOOD=$(echo "scale=1 ; ($COUNT_GOOD*100/$COUNT_TOTAL)" | bc)
PERCENT_BAD=$(echo "scale=1 ; ($COUNT_BAD*100/$COUNT_TOTAL)" | bc)
PERCENT_UGLY=$(echo "scale=1 ; ($COUNT_UGLY*100/$COUNT_TOTAL)" | bc)
PERCENT_NOTFORUS=$(echo "scale=1 ; ($COUNT_NOTFORUS*100/$COUNT_TOTAL)" | bc)
PERCENT_SOURCELESS=$(echo "scale=1 ; ($COUNT_SOURCELESS*100/$COUNT_TOTAL)" | bc)
GUESS_GOOD=$(echo "$PERCENT_GOOD*$AMOUNT/100" | bc)
write_index() {
echo "$1" >> index.html
}
mkdir -p /var/lib/jenkins/userContent/rb-pkg/
write_pkg_frameset() {
FRAMESET="/var/lib/jenkins/userContent/rb-pkg/$1.html"
cat > $FRAMESET <<-EOF
EOF
}
init_navi_frame() {
NAVI="/var/lib/jenkins/userContent/rb-pkg/$1_navigation.html"
echo "" > $NAVI
echo "$1 " >> $NAVI
RESULT=$(sqlite3 -init $INIT $PACKAGES_DB "SELECT build_date,version FROM source_packages WHERE name = \"$PKG\"")
BUILD_DATE=$(echo $RESULT|cut -d "|" -f1)
VERSION=$(echo $RESULT|cut -d "|" -f2)
echo "($VERSION) " >> $NAVI
echo "at $BUILD_DATE: " >> $NAVI
}
append2navi_frame() {
echo "$1" >> $NAVI
}
finish_navi_frame() {
echo "
" >> $NAVI
}
link_packages() {
for PKG in $@ ; do
echo -n "."
VERSION=$(sqlite3 -init $INIT $PACKAGES_DB "SELECT version FROM source_packages WHERE name = \"$PKG\"")
# remove epoch
EVERSION=$(echo $VERSION | cut -d ":" -f2)
# FIXME: remove unused code once all diffp.log and pbuilder.log files are gone
if [ -f "/var/lib/jenkins/userContent/dbd/${PKG}_${EVERSION}.debbindiff.html" ] || [ -f "/var/lib/jenkins/userContent/dbd/${PKG}_${EVERSION}.diffp.log" ] || [ -f "/var/lib/jenkins/userContent/pbuilder/${PKG}_${EVERSION}.pbuilder.log" ] || [ -f "/var/lib/jenkins/userContent/buildinfo/${PKG}_${EVERSION}_amd64.buildinfo" ] || [ -f "/var/lib/jenkins/userContent/rbuild/${PKG}_${EVERSION}.rbuild.log" ]; then
STAR=""
MAINLINK=""
init_navi_frame "$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"
elif $EXTRA_STAR ; then
STAR="*"
fi
if [ -f "/var/lib/jenkins/userContent/dbd/${PKG}_${EVERSION}.debbindiff.html" ] ; then
append2navi_frame " debbindiff "
MAINLINK="$JENKINS_URL/userContent/dbd/${PKG}_${EVERSION}.debbindiff.html"
elif [ -f "/var/lib/jenkins/userContent/dbd/${PKG}_${EVERSION}.diffp.log" ] ; then
append2navi_frame " diffp "
MAINLINK="$JENKINS_URL/userContent/dbd/${PKG}_${EVERSION}.diffp.log"
fi
if [ -f "/var/lib/jenkins/userContent/rbuild/${PKG}_${EVERSION}.rbuild.log" ] ; then
append2navi_frame " rbuild "
if [ "$MAINLINK" = "" ] ; then
MAINLINK="$JENKINS_URL/userContent/rbuild/${PKG}_${EVERSION}.rbuild.log"
fi
fi
if [ -f "/var/lib/jenkins/userContent/pbuilder/${PKG}_${EVERSION}.pbuilder.log" ] ; then
append2navi_frame " pbuilder "
if [ "$MAINLINK" = "" ] ; then
MAINLINK="$JENKINS_URL/userContent/pbuilder/${PKG}_${EVERSION}.pbuilder.log"
fi
fi
append2navi_frame " PTS "
append2navi_frame " BTS "
append2navi_frame " sources "
finish_navi_frame
write_pkg_frameset "$PKG" "$MAINLINK"
write_index " $PKG$STAR "
else
write_index " $PKG "
fi
done
}
echo "Starting to write statistics index page."
write_index "" > index.html
write_index "Statistics for reproducible builds
"
write_index "Results were obtained by several jobs running on jenkins.debian.net. This page is updated after each job run.
"
write_index "$COUNT_TOTAL packages attempted to build so far, that's $PERCENT_TOTAL% of $AMOUNT source packages in Debian $SUITE currently. Out of these, $PERCENT_GOOD% were successful, so quite wildly guessing this roughy means about $GUESS_GOOD packages should be reproducibly buildable!
"
write_index "$COUNT_BAD packages ($PERCENT_BAD% of $COUNT_TOTAL) failed to built reproducibly: "
echo -n "Starting to loop through the packages tested"
EXTRA_STAR=true
link_packages $BAD
EXTRA_STAR=false
write_index "
"
write_index
write_index "$COUNT_UGLY packages ($PERCENT_UGLY%) failed to build from source: "
link_packages $UGLY
write_index "
"
if [ $COUNT_SOURCELESS -gt 0 ] ; then
write_index "$COUNT_SOURCELESS ($PERCENT_SOURCELESS%) packages where the source could not be downloaded. $SOURCELESS
"
fi
if [ $COUNT_NOTFORUS -gt 0 ] ; then
write_index "$COUNT_NOTFORUS ($PERCENT_NOTFORUS%) packages which are neither Architecture: 'any' nor 'all' nor 'amd64' nor 'linux-amd64': $NOTFORUS
"
fi
if [ $COUNT_BLACKLISTED -gt 0 ] ; then
write_index "$COUNT_BLACKLISTED packages are blacklisted and will never be tested here: $BLACKLISTED
"
fi
write_index "$COUNT_GOOD packages ($PERCENT_GOOD%) successfully built reproducibly: "
link_packages $GOOD
write_index "
"
write_index "
Packages which failed to build reproducibly, sorted by Maintainers: and Uploaders: fields."
write_index "
$(echo $BAD | dd-list -i)