diff --git a/bin/bsauto b/bin/bsauto index 1ddfab71fbe45f2a0a86c40e0b17b9bcf70a2a32..c0f41d718109b9da584d29ca6c1122c71e137559 100755 --- a/bin/bsauto +++ b/bin/bsauto @@ -54,67 +54,7 @@ function do_execute { echo -e $NORMAL "Completed" } -while getopts "dhpst" option -do - case $option in - h) - usage - exit - ;; - t) - RELEASE=testing - ;; - p) - RELEASE=production - ;; - d) - DRYRUN=1 - ;; - s) - STEPBYSTEP=1 - ;; - esac -done - -if [ -z $RELEASE ]; then - usage - exit -fi - -if [ -f $BIN/.freeze ]; then - echo "Freeze file $BIN/.freeze detected, exiting" - exit -fi - -if [ ! -f /etc/linuxci.credential ]; then - echo "Cannot authenticate as linuxci, exiting" - exit -fi -cat /etc/linuxci.credential | kinit -if [ $? -ne 0 ]; then - echo "Cannot authenticate as linuxci, exiting" - exit -fi - -if [ $RELEASE == "testing" ]; then - - if ls /mnt/data2/home/build/packages/logs/build2test/$DIST*$DATE* > /dev/null 2>&1 ; then - echo -n "The testing release process has already been executed for $DATE, do you still want to proceed? (y/n): " - read -n1 choice - if [ "$choice" == "y" ] || [ "$choice" == "Y" ]; then - echo -e "\nContinuing ..." - else - exit - fi - fi - - if [ $(date --date="$DATE" +%u) -eq 4 ]; then - if ! ls /mnt/data2/home/build/packages/logs/test2prod/$DIST*$DATE* > /dev/null 2>&1 ; then - echo "Today is Thursday however the production release hasn't been executed yet, Exiting" - exit - fi - fi - +function do_testing { INTERNAL_PACKAGES=`find /mnt/data2/home/build/packages/incoming/$DIST -type f -name *rpm` if [ "$INTERNAL_PACKAGES" != "" ]; then INTERNAL_SRC=`find /mnt/data2/home/build/packages/incoming/$DIST -type f -name *.src.rpm` @@ -131,7 +71,6 @@ if [ $RELEASE == "testing" ]; then # Start the daily process, check for new packages from upstream do_execute "/mnt/data2/home/build/bin/bscentos2test -d $DIST -r all" - REPOLIST=`find /mnt/data2/home/build/packages/logs/build2test -size +0c -name $DIST*$DATE* | /usr/bin/cut -d. -f2` if [ "$REPOLIST" == "" ]; then echo "No new packages today, exiting" @@ -161,7 +100,6 @@ if [ $RELEASE == "testing" ]; then fi done done - echo "Found updates for: `echo $REPOLIST | paste -sd " "`" TESTINGREPO="" for REPO in $REPOLIST; do @@ -171,12 +109,9 @@ if [ $RELEASE == "testing" ]; then do_execute "/mnt/data2/home/build/bin/bssync -t data1 -d $DIST -r \"$TESTINGREPO\"" do_execute "/mnt/data2/home/build/bin/bssync -t eos -d $DIST -r \"$TESTINGREPO\"" do_execute "/mnt/data2/home/build/bin/bsmailusers -d $DIST -r testing -s -w -c" -# production run -else - if [ $(date --date="$DATE" +%u) -ne 4 ]; then - echo "Today is not Thursday, refusing to run the production release" - exit - fi +} + +function do_production { REPOLIST=`/mnt/data2/home/build/bin/generaterepolist -d $DIST | /usr/bin/cut -d= -f2 | /bin/sed 's/\"//g'` REPOLIST="\"$REPOLIST\" \*" do_execute "/mnt/data2/home/build/bin/bstest2prod -d $DIST -r $REPOLIST" @@ -185,4 +120,78 @@ else do_execute "/mnt/data2/home/build/bin/bssync -t data1 -d $DIST -r \"$REPOLIST\"" do_execute "/mnt/data2/home/build/bin/bssync -t eos -d $DIST -r \"$REPOLIST\"" do_execute "/mnt/data2/home/build/bin/bsmailusers -d $DIST -r updates -s -w -c" +} + +while getopts "dhpst" option +do + case $option in + h) + usage + exit + ;; + t) + RELEASE=testing + ;; + p) + RELEASE=production + ;; + d) + DRYRUN=1 + ;; + s) + STEPBYSTEP=1 + ;; + esac +done + +if [ ! -f /etc/linuxci.credential ]; then + echo "Cannot authenticate as linuxci, exiting" + exit +fi +cat /etc/linuxci.credential | kinit +if [ $? -ne 0 ]; then + echo "Cannot authenticate as linuxci, exiting" + exit +fi + +if [ -f $BIN/.freeze ]; then + echo "Freeze file $BIN/.freeze detected, exiting" + exit +fi + +# If running via nomad, the machines know what to do +if [ -v $NOMAD_ALLOC_ID ]; then + if [ $(date --date="$DATE" +%u) -eq 4 ]; then + do_production + fi + do_testing +else # warning, humans ahead + if [ -z $RELEASE ]; then + usage + exit + fi + if [ $RELEASE == "testing" ]; then + if ls /mnt/data2/home/build/packages/logs/build2test/$DIST*$DATE* > /dev/null 2>&1 ; then + echo -n "The testing release process has already been executed for $DATE, do you still want to proceed? (y/n): " + read -n1 choice + if [ "$choice" == "y" ] || [ "$choice" == "Y" ]; then + echo -e "\nContinuing ..." + else + exit + fi + fi + if [ $(date --date="$DATE" +%u) -eq 4 ]; then + if ! ls /mnt/data2/home/build/packages/logs/test2prod/$DIST*$DATE* > /dev/null 2>&1 ; then + echo "Today is Thursday however the production release hasn't been executed yet, Exiting" + exit + fi + fi + do_testing + else # $RELEASE == "production" + if [ $(date --date="$DATE" +%u) -ne 4 ]; then + echo "Today is not Thursday, refusing to run the production release" + exit + fi + do_production + fi fi