hopefully the last fix
[infrastructure.git] / scripts / all-modules.sh
1 #!/bin/bash
2 # $Id$
3 # this script is a wrapper around the module-tools (version and diff)
4 # it is invoked every 30 minutes on onelab build box
5 # prior to that, the following directories will have been svn updated :
6 # /root/svn-build
7 # /root/svn-build-4.2
8
9 # avoid running several instances of this script
10 # when the svn server has problems, this can very well last quite a while
11
12 COMMAND=$(basename $0)
13 OUTPUT=/build/modules
14 LOCK=/var/run/all-modules.pid
15
16 function do_update() {
17     build_dir=$1; shift
18     if [ -f $build_dir/auto-update.sh ] ; then
19         $build_dir/auto-update.sh
20     else
21         pushd $build_dir; svn update > .update.log 2>&1 ; popd
22     fi
23 }
24
25 # usage: do_version dir name 
26 function do_version () {
27     build_dir=$1; shift
28     name=$1; shift
29
30     out_dir=$OUTPUT/$name
31     out_file=$out_dir/version.html
32     out_tmp=$out_dir/.version.html
33     
34     mkdir -p $out_dir
35     $build_dir/module-version --www $name -a --url &> $out_tmp
36     mv -f $out_tmp $out_file
37 }
38
39 # usage: do_version dir name 
40 function do_diff () {
41     build_dir=$1; shift
42     name=$1; shift
43
44     out_dir=$OUTPUT/$name
45     out_file=$out_dir/diff.html
46     out_tmp=$out_dir/.diff.html
47     
48     mkdir -p $out_dir
49     $build_dir/module-diff --www $name -a &> $out_tmp
50     mv -f $out_tmp $out_file
51
52 }
53
54 function usage () {
55     echo "Usage: $COMMAND [-v] [-f] [-i]"
56 }
57
58 function main () {
59
60     while [[ -n "$@" ]] ; do
61         case "$1" in 
62             -f) rm -f $LOCK ;;
63             -i) ls -l $LOCK ; exit 0 ;;
64             -v) set -x ;;
65             *) usage; exit 1;;
66         esac
67         shift
68     done
69
70     [ -f $LOCK ] && exit 1
71     
72     echo $$ > $LOCK
73
74     do_update  /root/svn-build
75     do_diff    /root/svn-build     trunk 
76     do_version /root/svn-build     trunk 
77 #    do_update  /root/svn-build-4.2
78 #    do_diff    /root/svn-build-4.2 4.2 
79 #    do_version /root/svn-build-4.2 4.2 
80
81     rm $LOCK
82
83 }
84
85 main "$@"