cp hook script instead of creating a symlink
[infrastructure.git] / scripts / all-modules.sh
index 792b4c5..b0f5abf 100755 (executable)
@@ -1,69 +1,76 @@
 #!/bin/bash
-# $Id$
+
+# 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)
+#
 # 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
+# ~/svn-build
+# ~/root/svn-build-4.2
 
 # avoid running several instances of this script
 # when the svn server has problems, this can very well last quite a while
 
 COMMAND=$(basename $0)
-OUTPUT=/build/modules
-LOCK=/var/run/all-modules.pid
+
+# make sure the cyclic tasks do not interfere with manual usage
+WORKDIR_SVN=${HOME}/all-modules-svn
+WORKDIR_GIT=${HOME}/all-modules-git
+
+# make the command usable as non-root user at Princeton for more efficiency
+if [ "$(id -u)" == "0" ] ; then
+    OUTPUT=/build/modules/slow
+    LOCK=/var/run/all-modules.pid
+else
+    OUTPUT=~/all-modules
+    LOCK=~/all-modules.run
+fi
 
 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
-       pushd $build_dir; svn update > .update.log 2>&1 ; popd
+       ( cd $build_dir; svn update > .update.log 2>&1 )
     fi
 }
 
-# usage: do_version dir name 
+# usage: do_version dir workdir wwwname 
 function do_version () {
     build_dir=$1; shift
-    name=$1; shift
+    workdir=$1; shift
+    wwwname=$1; shift
 
-    out_dir=$OUTPUT/$name
-    out_file=$out_dir/version.txt
-    out_tmp=$out_dir/.version.txt
+    out_dir=$OUTPUT/$wwwname
+    out_file=$out_dir/version.html
+    out_tmp=$out_dir/.version.html
     
     mkdir -p $out_dir
-    
-    ( echo $name ; \
-      date ; \
-      $build_dir/module-version -a --url ; \
-      date ) &> $out_tmp
+    $build_dir/module-version $VERBOSE -w $workdir --www $wwwname -a &> $out_tmp
     mv -f $out_tmp $out_file
 }
 
-# usage: do_version dir name 
+# usage: do_version dir workdir wwwname 
 function do_diff () {
     build_dir=$1; shift
-    name=$1; shift
+    workdir=$1; shift
+    wwwname=$1; shift
 
-    out_dir=$OUTPUT/$name
-    out_file=$out_dir/diff.txt
-    out_tmp=$out_dir/.diff.txt
+    out_dir=$OUTPUT/$wwwname
+    out_file=$out_dir/diff.html
+    out_tmp=$out_dir/.diff.html
     
     mkdir -p $out_dir
-    
-### older syntax was messy    
-#    ( echo $name ; \
-#      date ; \
-#      $build_dir/module-diff -a -o ; \
-#      date ) &> $out_tmp
-#
-#    ( echo 'WARNINGS (if any)' ; \
-#      egrep 'was not found|Skipping failed' $out_tmp ;
-#      cat $out_tmp ) > $out_file
-
-    $build_dir/module-diff -a -W $name &> $out_tmp
-
-    rm -f $out_tmp
+    $build_dir/module-diff $VERBOSE -w $workdir --www $wwwname -a &> $out_tmp
+    mv -f $out_tmp $out_file
 
 }
 
@@ -77,7 +84,7 @@ function main () {
        case "$1" in 
            -f) rm -f $LOCK ;;
            -i) ls -l $LOCK ; exit 0 ;;
-           -v) set -x ;;
+           -v) set -x ; VERBOSE=-v ;;
            *) usage; exit 1;;
        esac
        shift
@@ -87,12 +94,14 @@ function main () {
     
     echo $$ > $LOCK
 
-    do_update  /root/svn-build
-    do_diff    /root/svn-build     trunk 
-    do_version /root/svn-build     trunk 
-#    do_update  /root/svn-build-4.2
-#    do_diff    /root/svn-build-4.2 4.2 
-#    do_version /root/svn-build-4.2 4.2 
+# the 5.0 flavour now comes with a non-compatible flavour of the module-tools
+# and we need 2 distinc workdirs
+    do_update  ~/svn-build
+    do_version ~/svn-build     $WORKDIR_GIT 5.0 
+    do_diff    ~/svn-build     $WORKDIR_GIT 5.0
+    do_update  ~/svn-build-4.3
+    do_version ~/svn-build-4.3 $WORKDIR_SVN 4.3 
+    do_diff    ~/svn-build-4.3 $WORKDIR_SVN 4.3
 
     rm $LOCK