#!/bin/bash # # This script checks each commit in a given interval by: # - checking out the commit in a clean manner # - compiling completely (with debug) # - running the testsuite # and rounding all up in a suitable log to tell what if went wrong. # check sufficiently given arguments if [ -z $4 ]; then echo "Usage: $0 [...parameters for configure...]" echo "This will check each of the commits in the inclusive interval [first, second]." exit 255 fi # check source SOURCEDIR=`realpath $1` shift if [ ! $? -eq 0 ]; then echo "Please install realpath package!" exit 128 fi DIR=$1 shift base=$1 shift limit=$1 shift # some variables LOG="`pwd`/commitcheck-${base}-${limit}" checkdir="commitchecking" cores=12 # check whether base dir contains valid repo if [ ! -e $SOURCEDIR ]; then echo "$SOURCEDIR does not exist!" exit 255 fi if [ ! -e $SOURCEDIR/HEAD ]; then if [ ! -e $SOURCEDIR/.git ]; then echo "$SOURCEDIR does not contain a git repository!" | tee -a ${LOG}.log exit 255 else SOURCEDIR="$SOURCEDIR/.git" fi fi # check whether target is empty and create clone of git repo if [ -e $DIR ]; then echo "Target directory $DIR must not be present!" exit 255 fi echo -e "#Begin of Logfile" >${LOG}.log git clone $SOURCEDIR $DIR | tee -a ${LOG}.log DIR=`realpath $DIR` # we are set go to target dir OLDDIR=`pwd` cd $DIR # check whether both given commit names are valid test=`git rev-list ${base}..${limit} &>/dev/null` if [ $? -eq 128 ]; then # try with remote on either side test=`git rev-list remotes/origin/${base}..${limit} &>/dev/null` if [ $? -eq 128 ]; then test=`git rev-list ${base}..remotes/origin/${limit} &>/dev/null` if [ $? -eq 128 ]; then test=`git rev-list remotes/origin/${base}..remotes/origin/${limit} &>/dev/null` if [ $? -eq 128 ]; then echo "At least one of the given commits ${base} or ${limit} does not exist!" | tee -a ${LOG}.log exit 255 else echo "Using remotes/origin/${base} instead of ${base} and remotes/origin/${limit} instead of ${limit}" base="remotes/origin/${base}" limit="remotes/origin/${limit}" fi else echo "Using remotes/origin/${limit} instead of ${limit}." limit="remotes/origin/${limit}" fi else echo "Using remotes/origin/${base} instead of ${base}." base="remotes/origin/${base}" fi fi # calculate the number of commits commitscount=`git rev-list --no-merges ${base}..${limit} | wc -l` if [ $commitscount -eq 0 ]; then echo "There are no commits to check!" | tee -a ${LOG}.log echo "Maybe you have given first and second wrong way round?" | tee -a ${LOG}.log echo "Remember: First has to be older than second." | tee -a ${LOG}.log exit 1 fi # DON't set limit for HEAD~: git starts counting at 0, wc however at 1, but git does not include last commit ${base} in the list! let commitlimit=$commitscount # and check whether it conincides with ${base} basecommitdescribe=`git describe ${base}` topcommitdescribe=`git describe ${limit}` basecommitdescribefromtop=`git describe ${limit}~${commitlimit}` if [ "$basecommitdescribe" != "$basecommitdescribefromtop" ]; then echo "Something went wrong internally!" | tee -a ${LOG}.log echo "Compared $basecommitdescribe with $basecommitdescribefromtop ..." echo "The number of commits calculated in between does not lead to the base commit." | tee -a ${LOG}.log exit 128 fi # ============== PERFORMING CHECKS ========================== echo "We are checking all commits from ${base} to ${limit}." | tee -a ${LOG}.log echo "Base: ${basecommitdescribe}" | tee -a ${LOG}.log echo -e "Top: ${topcommitdescribe}\n" | tee -a ${LOG}.log # first fast overview without debug, then thorough with debug for debug_option in "--disable-debug" "--enable-debug"; do i=${commitlimit} while [ $i -ge 0 ]; do let nr=${commitlimit}-$i git checkout -f ${limit}~${i} ./bootstrap rm -rf $checkdir mkdir -p $checkdir cd $checkdir echo "Now testing version `git describe --dirty --always` with $debug_option" &>${LOG}-${nr}.log ../configure --prefix=${DIR}/$checkdir ${debug_option} "$@" &>>${LOG}-${nr}.log make -k -j${cores} check &>>${LOG}-${nr}.log if [ $? -gt 0 ]; then echo -e "${nr}: `git describe --dirty --always`, ${debug_option}: FAILED." >>${LOG}.log else echo -e "${nr}: `git describe --dirty --always`, ${debug_option}: ok." >>${LOG}.log fi cd .. ((i-=1)); done done # =================== DONE ================================= echo -e "#End of Logfile" >>${LOG}.log cd $OLDDIR exit 0