#!/bin/bash # You may want to set PORTAGE_TMPDIR= to a slow directory like an NFS share. # Also, ensure that MAKEOPTS=-jN where N is high. usage() { echo "$0 [champion] [contender] " echo " champion - The original ebuild to be compiled" echo " contender - The revised ebuild to be compiled" echo " rounds - The number of times each is compiled" exit 1 } champion="${1}" contender="${2}" rounds="${3}" champion_down="0" contender_down="0" # Configuration if [ -z ${champion} ] || [ -z ${contender} ] || [ ${champion} = -h* ] ; then # Are both required arguments present? usage elif [ ! -f ${champion} ] || [ ! -f ${contender} ]; then # Are both required arguments files? usage elif [ -z ${rounds} ]; then # Is the third argument set? If not, set rounds to 10 rounds=10 fi # Set up the scoreboard echo "EBUILD BUILD-NR EXIT_STATUS" for i in $(seq 1 ${rounds}); do # Champion gets to go first echo -n "${champion} $i/${rounds} " for j in clean compile; do ebuild ${champion} ${j} >/dev/null 2>&1 done exit_status="${?}" [ "${exit_status}" == "0" ] || champion_down=$((${champion_down} + 1)) echo "${exit_status}" # Contender's turn echo -n "${contender} $i/${rounds} " for j in clean compile; do ebuild ${contender} ${j} >/dev/null 2>&1 done exit_status="${?}" [ "${exit_status}" == "0" ] || contender_down=$((${contender_down} +1)) echo "${exit_status}" done # Clean the build directories one last time for i in ${champion} ${contender}; do ebuild ${i} clean > /dev/null 2>&1 done # Announcement echo echo "At the end of ${rounds} rounds, the score is" echo "${champion} : ${champion_down} failures" echo "${contender} : ${contender_down} failures"