#!/bin/bash
# Copyright 2015 Holger Levsen
# released under the GPLv=2
DEBUG=false
. /srv/jenkins/bin/common-functions.sh
common_init "$@"
# common code defining db access
. /srv/jenkins/bin/reproducible_common.sh
VIEW=repositories
PAGE=index_${VIEW}.html
SOURCES=$(mktemp --tmpdir=$TEMPDIR repo-comp-XXXXXXXXX)
PACKAGES=$(mktemp --tmpdir=$TEMPDIR repo-comp-XXXXXXXXX)
TMPFILE=$(mktemp --tmpdir=$TEMPDIR repo-comp-XXXXXXXXX)
MODIFIED_IN_SID=0
MODIFIED_IN_EXP=0
echo "$(date) - starting to write $PAGE page."
write_page_header $VIEW "Comparison between the reproducible builds apt repository and regular Debian suites"
write_page "These source packages are different from unstable in our apt repository on alioth. They are available for testing using these sources.lists entries:
"
write_page "deb http://reproducible.alioth.debian.org/debian/ ./"
write_page "deb-src http://reproducible.alioth.debian.org/debian/ ./"
write_page "
"
write_page "package | git repo | PTS link | usertagged bug | old versions in our repo (needed for reproducing old builds) | version in our repo | version in 'testing' | version in 'unstable' | version in 'experimental' |
"
curl http://reproducible.alioth.debian.org/debian/Sources > $SOURCES
curl http://reproducible.alioth.debian.org/debian/Packages > $PACKAGES
SOURCEPKGS=$(grep-dctrl -n -s Package -r -FPackage . $SOURCES | sort -u)
for PKG in $SOURCEPKGS ; do
echo "Processing $PKG..."
if [ "${PKG:0:3}" = "lib" ] ; then
PREFIX=${PKG:0:4}
else
PREFIX=${PKG:0:1}
fi
VERSIONS=$(grep-dctrl -n -s version -S $PKG $SOURCES|sort -u)
CRUFT=""
BET=""
OBSOLETE_IN_SID=false
OBSOLETE_IN_TESTING=false
OBSOLETE_IN_EXP=false
#
# gather versions of a package
#
for VERSION in ${VERSIONS} ; do
if [ "$BET" = "" ] ; then
BET=${VERSION}
continue
elif dpkg --compare-versions "$BET" lt "${VERSION}" ; then
BET=${VERSION}
fi
done
SID=$(rmadison -s unstable $PKG | egrep -v '^(debian|new):' | cut -d "|" -f2|xargs echo)
for VERSION in ${VERSIONS} ; do
if [ "${VERSION}" != "$BET" ] ; then
CRUFT="$CRUFT ${VERSION}"
fi
done
TESTING=$(rmadison -s testing $PKG | egrep -v '^(debian|new):' | cut -d "|" -f2|xargs echo)
EXPERIMENTAL=$(rmadison -s experimental $PKG | egrep -v '^(debian|new):' | cut -d "|" -f2|xargs echo)
#
# format output
#
CSID=""
CTEST=""
CEXP=""
if [ ! -z "$TESTING" ] ; then
for i in $TESTING ; do
if dpkg --compare-versions "$i" gt "$BET" ; then
CTEST="$CTEST$i
"
OBSOLETE_IN_TESTING=true
OBSOLETE_IN_SID=true
OBSOLETE_IN_EXP=true
else
CTEST="$CTEST$i
"
fi
done
fi
if [ ! -z "$EXPERIMENTAL" ] ; then
for i in $EXPERIMENTAL ; do
if dpkg --compare-versions "$i" gt "$BET" ; then
CEXP="$CEXP$i
"
OBSOLETE_IN_EXP=true
else
CEXP="$CEXP$i
"
fi
done
fi
for i in $SID ; do
if dpkg --compare-versions "$i" gt "$BET" ; then
CSID="$CSID$i
"
if [ ! -z "$BET" ] ; then
CRUFT="$BET $CRUFT"
BET=""
OBSOLETE_IN_SID=true
OBSOLETE_IN_EXP=true
fi
else
CSID="$CSID$i
"
fi
done
if [ ! -z "$BET" ] ; then
BINARIES=""
for ARCH in $ARCHS ; do
i="$ARCH: $(grep-dctrl -n -s Package -r -FPackage $PKG --and -FVersion $BET --and -FArchitecture all --or -FArchitecture $ARCH $PACKAGES|xargs -r echo)"
BINARIES="$BINARIES$i
"
done
BET="$BET"
else
BINARIES=""
BET=" "
fi
if [ ! -z "$CRUFT" ] ; then
CRUFT="$(echo $CRUFT|sed 's# #
#g')"
fi
#
# write output
#
write_page "src:$PKG | "
write_page " "
case $PKG in
strip-nondeterminism|debbindiff)
URL="http://anonscm.debian.org/cgit/reproducible/$PKG.git" ;;
*)
URL="http://anonscm.debian.org/cgit/reproducible/$PKG.git/?h=pu/reproducible_builds" ;;
esac
curl $URL > $TMPFILE
if [ "$(grep "'error'>No repositories found" $TMPFILE 2>/dev/null)" ] ; then
write_page "$URL (no git repository found)"
elif [ "$(grep "'error'>Invalid branch" $TMPFILE 2>/dev/null)" ] ; then
URL="http://anonscm.debian.org/cgit/reproducible/$PKG.git/?h=merged/reproducible_builds"
curl $URL > $TMPFILE
if [ "$(grep "'error'>Invalid branch" $TMPFILE 2>/dev/null)" ] ; then
if ! $OBSOLETE_IN_SID ; then
write_page "$PKG.git non-standard branch"
else
write_page "$PKG.git non-standard branch (but that is ok, our package aint't used in unstable)"
fi
else
write_page "$PKG.git"
write_page " (merged"
if $OBSOLETE_IN_TESTING ; then
write_page "and available in testing and unstable)"
elif $OBSOLETE_IN_SID ; then
write_page "and available in unstable)"
elif $OBSOLETE_IN_EXP ; then
write_page "and available in experimental)"
fi
fi
else
write_page "$PKG.git"
if [ "$PKG" != "strip-nondeterminism" ] && [ "$PKG" != "debbindiff" ] ; then
if $OBSOLETE_IN_TESTING && $OBSOLETE_IN_SID && $OBSOLETE_IN_EXP ; then
write_page " (unused?"
write_page " Then the branch should probably renamed."
elif $OBSOLETE_IN_SID && $OBSOLETE_IN_EXP ; then
write_page " (only used in testing, fixed in sid,"
write_page " branch should probably renamed)"
elif $OBSOLETE_IN_EXP ; then
write_page " (only used in testing and unstable, fixed in experimental)"
fi
elif ( [ "$PKG" = "strip-nondeterminism" ] || [ "$PKG" = "debbindiff" ] ) && $OBSOLETE_IN_SID ; then
write_page " (this repo is always used)"
fi
fi
if ! $OBSOLETE_IN_SID ; then
let "MODIFIED_IN_SID+=1"
fi
if ! $OBSOLETE_IN_EXP ; then
let "MODIFIED_IN_EXP+=1"
fi
write_page " | "
write_page " PTS | "
URL="https://bugs.debian.org/cgi-bin/pkgreport.cgi?src=$PKG&users=reproducible-builds@lists.alioth.debian.org&archive=both"
for TAG in $USERTAGS ; do
URL="$URL&tag=$TAG"
done
write_page " bugs | "
write_page " $CRUFT | "
write_page " $BET $BINARIES | "
write_page " $CTEST | "
write_page " $CSID | "
write_page " $CEXP | "
write_page "
"
done
write_page "
"
write_page_footer
publish_page
echo "$MODIFIED_IN_SID" > /srv/reproducible-results/modified_in_sid.txt
echo "$MODIFIED_IN_EXP" > /srv/reproducible-results/modified_in_exp.txt
# cleanup
rm $SOURCES $PACKAGES $TMPFILE