#!/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_dir=$OUTPUT/$wwwname
out_file=$out_dir/version.html
out_tmp=$out_dir/.version.html
mkdir -p $out_dir
- $build_dir/module-version --www $name -a --url &> $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_dir=$OUTPUT/$wwwname
out_file=$out_dir/diff.html
out_tmp=$out_dir/.diff.html
mkdir -p $out_dir
- $build_dir/module-diff --www $name -a &> $out_tmp
+ $build_dir/module-diff $VERBOSE -w $workdir --www $wwwname -a &> $out_tmp
mv -f $out_tmp $out_file
}
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
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.3
- do_diff /root/svn-build-4.3 4.3
- do_version /root/svn-build-4.3 4.3
+# 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