no longr build 31/sfapy2
[infrastructure.git] / scripts / all-modules.sh
index a2854ea..77259b2 100755 (executable)
 #!/bin/bash
 
+# feb 2013 - mainline is now known as 5.2, remove that step in the output
+# meaning results are now in merely
+# http://build.onelab.eu/modules/version.html
+#
+# reviewed in dec. 2010
+# moving back to running on the EU side
+# 
 # this script is a wrapper around the module-tools (version and diff)
-# it is invoked every 30 minutes on onelab build box
+# it is invoked cyclically
 # prior to that, the following directories will have been svn updated :
-# /root/svn-build
-# /root/svn-build-4.2
+# ~/git-build
 
+# avoid running several instances of this script
+# when the svn server has problems, this can very well last quite a while
+
+COMMAND=$(basename $0)
+
+# running as root on liquid
 OUTPUT=/build/modules
+WWWNAME=mainline
+LOCK=~/all-modules.run
+# make sure the cyclic tasks do not interfere with manual usage
+# (i.e. do not use ~/modules)
+WORKDIR_GIT=${HOME}/all-modules-git
+########## sample config running on liquid
+#svnpath=http://svn.planet-lab.org/svn/
+#gitserver=git.onelab.eu
+#gituser=root
+#build=build
+#username=not-needed-as-we-dont-write
+#email=not-needed-as-we-dont-write
+##########
+
+function do_update() {
+    build_dir=$1; shift
+    if [ -f $build_dir/auto-update.sh ] ; then
+       $build_dir/auto-update.sh
+    elif [ -d $build_dir/.git ] ; then
+       ( cd $build_dir; git pull > .update.log 2>&1 )
+    else
+       ( cd $build_dir; svn update > .update.log 2>&1 )
+    fi
+}
 
-# usage: do_version name dir 
+# usage: do_version dir workdir 
 function do_version () {
-    name=$1; shift
     build_dir=$1; shift
+    workdir=$1; shift
 
-    out_dir=$OUTPUT/$name
-    out_file=$out_dir/version.txt
-    out_tmp=$out_file.new
+    out_dir=$OUTPUT
+    out_file=$out_dir/version.html
+    out_tmp=$out_dir/.version.html
     
     mkdir -p $out_dir
-    
-    ( echo $name ; \
-      date ; \ 
-      $build_dir/module-version -a ; \
-      date ) > $out_tmp
+    $build_dir/module-version $VERBOSE -w $workdir --www $WWWNAME -a &> $out_tmp
     mv -f $out_tmp $out_file
 }
 
-# usage: do_version name dir 
+# usage: do_diff dir workdir
 function do_diff () {
-    name=$1; shift
     build_dir=$1; shift
+    workdir=$1; shift
 
-    out_dir=$OUTPUT/$name
-    out_file=$out_dir/version.txt
-    out_tmp=$out_file.new
+    out_dir=$OUTPUT
+    out_file=$out_dir/diff.html
+    out_tmp=$out_dir/.diff.html
     
     mkdir -p $out_dir
+    $build_dir/module-diff $VERBOSE -w $workdir --www $WWWNAME -a &> $out_tmp
+    mv -f $out_tmp $out_file
+
+}
+
+function usage () {
+    echo "Usage: $COMMAND [-v] [-f] [-i]"
+}
+
+function main () {
+
+    while [[ -n "$@" ]] ; do
+       case "$1" in 
+           -f) rm -f $LOCK ;;
+           -i) ls -l $LOCK ; exit 0 ;;
+           -v) set -x ; VERBOSE=-v ;;
+           *) usage; exit 1;;
+       esac
+       shift
+    done
+
+    # is the stamp older than 2 hours ? 
+    # in minutes
+    GRACE=120
+    is_old=$(find $LOCK -mmin +$GRACE 2> /dev/null)
+    if [ -n "$is_old" ] ; then
+       echo "$LOCK is older than $GRACE minutes - removing"
+       rm -f $LOCK
+    fi
+
+    [ -f $LOCK ] && exit 1
     
-    ( echo $name ; \
-      date ; \ 
-      $build_dir/module-diff -a -o -q ; \
-      date ) > $out_tmp
-
-    ( echo 'WARNINGS (if any)' ; \
-      egrep 'was not found|Skipping failed' $out_tmp ;
-      cat $out_tmp ) > $out_file
+    echo $$ > $LOCK
+
+    do_update  ~/git-build
+    do_version ~/git-build     $WORKDIR_GIT 
+    do_diff    ~/git-build     $WORKDIR_GIT 
+
+    rm $LOCK
+
 }
 
-do_version trunk /root/svn-build
-do_diff    trunk /root/svn-build
-do_version 4.2 /root/svn-build-4.2
-do_diff    4.2 /root/svn-build-4.2
+main "$@"
+
+########################################
+# this applied to the older version that was running at princeton
+# NOTE
+# as the svn diff operations from a remote location are so sssssslllllllooooooooowwwwww...
+# what we do:
+# maintain codebase in onelab.eu for historical reasons
+# (1) push scripts on princeton (manually run all-modules-update.sh)
+# (2) run the scripts cyclically over there through cron
+# and push the results on build.onelab.eu with all-modules.push.sh (as part of the cron job)
+#