From 45bfd3dac14c2e20c26736808db956058bb9f6e2 Mon Sep 17 00:00:00 2001 From: Thomas Date: Jul 14 2017 14:54:42 +0000 Subject: - Better performance, caching target list. - Allow script to run without the lock with option -t --- diff --git a/scripts/mash_run.sh b/scripts/mash_run.sh index c37fe8a..48aa5df 100755 --- a/scripts/mash_run.sh +++ b/scripts/mash_run.sh @@ -153,32 +153,37 @@ mash_run () { # Ensure the cache directory is available [ ! -d $MASH_CACHE ] && mkdir -p $MASH_CACHE -# Ensure we do not have parallel runs -pidfile=/var/tmp/mash-run.pid -if [ -e $pidfile ]; then - pid=`cat $pidfile` - if kill -0 &> /dev/null $pid; then - ( $optionv ) && echo "Mash is already running PID:$pid" - exit 1 - else - rm $pidfile &>/dev/null - fi +if ( ! ${optiont} ) +then + # Ensure we do not have parallel runs + pidfile=/var/tmp/mash-run.pid + if [ -e $pidfile ]; then + pid=`cat $pidfile` + if kill -0 &> /dev/null $pid; then + ( $optionv ) && echo "Mash is already running PID:$pid" + exit 1 + else + rm $pidfile &>/dev/null + fi + fi + echo $$ > $pidfile fi -echo $$ > $pidfile +# Cache target list as it cannot include unknown tag at this point +TARGETS=`mktemp` +${KOJI} list-targets --quiet > $TARGETS for TAG in ${TAGS} do - ( $optionv ) && echo "Checking $TAG ..." + ( $optionv ) && echo "Checking $TAG ..." ARCHES="" BUILDTAG="" LOG="${LOG_DIR}/mash.${TAG}.log" FAKETAG=${TAG/testing/candidate} FAKETAG=${FAKETAG/release/candidate} - BUILDTAG=`${KOJI} list-targets --quiet | grep ${FAKETAG}| awk '{print $2}'` + BUILDTAG=`grep ${FAKETAG} ${TARGETS} | awk '{print $2}'` [ ! -z "$BUILDTAG" ] && ARCHES=`${KOJI} taginfo ${BUILDTAG} | grep Arches | cut -d ":" -f 2-` [ -z "$ARCHES" ] && ARCHES="x86_64" - [ -z "$ARCHES" ] && ARCHES="x86_64" mash_prepare "${TAG}" "${LOG}" "${ARCHES}" if [ ! -f $MASH_CACHE/$TAG.buildlist ] then @@ -186,15 +191,15 @@ do else BUILDLIST=`mktemp` ${KOJI} list-tagged $TAG > $BUILDLIST - diff $BUILDLIST $MASH_CACHE/$TAG.buildlist &>> $LOG - if [ $? -eq 0 ] - then - echo " -> skipping. No new build in $TAG" &>> $LOG + diff $BUILDLIST $MASH_CACHE/$TAG.buildlist &>> $LOG + if [ $? -eq 0 ] + then + echo " -> skipping. No new build in $TAG" &>> $LOG rm -rf $BUILDLIST - continue - else - echo " -> updating cache for $TAG" &>> $LOG - cp $BUILDLIST $MASH_CACHE/$TAG.buildlist + continue + else + echo " -> updating cache for $TAG" &>> $LOG + cp $BUILDLIST $MASH_CACHE/$TAG.buildlist fi rm -rf $BUILDLIST fi