cleanup svn keywords
[infrastructure.git] / scripts / all-modules.sh
1 #!/bin/bash
2
3 # NOTE
4 # as the svn diff operations from a remote location are so sssssslllllllooooooooowwwwww...
5 # what we do:
6 # maintain codebase in onelab.eu for historical reasons
7 # (1) push scripts on princeton (manually run all-modules-update.sh)
8 # (2) run the scripts cyclically over there through cron
9 # and push the results on build.onelab.eu with all-modules.push.sh (as part of the cron job)
10 #
11 # this script is a wrapper around the module-tools (version and diff)
12 # it is invoked cyclically
13 # prior to that, the following directories will have been svn updated :
14 # ~/svn-build
15 # ~/root/svn-build-4.2
16
17 # avoid running several instances of this script
18 # when the svn server has problems, this can very well last quite a while
19
20 COMMAND=$(basename $0)
21
22 # make the command usable as non-root user at Princeton for more efficiency
23 if [ "$(id -u)" == "0" ] ; then
24     OUTPUT=/build/modules/slow
25     LOCK=/var/run/all-modules.pid
26     MODULES_OPTION=""
27 else
28     OUTPUT=~/all-modules
29     LOCK=~/all-modules.run
30     # make sure the cyclic tasks do not interfere with manual usage
31     MODULES_OPTION="-w ${HOME}/all-modules-working-dir"
32 fi
33
34 function do_update() {
35     build_dir=$1; shift
36     if [ -f $build_dir/auto-update.sh ] ; then
37         $build_dir/auto-update.sh
38     else
39         ( cd $build_dir; svn update > .update.log 2>&1 )
40     fi
41 }
42
43 # usage: do_version dir name 
44 function do_version () {
45     build_dir=$1; shift
46     name=$1; shift
47
48     out_dir=$OUTPUT/$name
49     out_file=$out_dir/version.html
50     out_tmp=$out_dir/.version.html
51     
52     mkdir -p $out_dir
53     $build_dir/module-version $MODULES_OPTION --www $name -a --url &> $out_tmp
54     mv -f $out_tmp $out_file
55 }
56
57 # usage: do_version dir name 
58 function do_diff () {
59     build_dir=$1; shift
60     name=$1; shift
61
62     out_dir=$OUTPUT/$name
63     out_file=$out_dir/diff.html
64     out_tmp=$out_dir/.diff.html
65     
66     mkdir -p $out_dir
67     $build_dir/module-diff $MODULES_OPTION --www $name -a &> $out_tmp
68     mv -f $out_tmp $out_file
69
70 }
71
72 function usage () {
73     echo "Usage: $COMMAND [-v] [-f] [-i]"
74 }
75
76 function main () {
77
78     while [[ -n "$@" ]] ; do
79         case "$1" in 
80             -f) rm -f $LOCK ;;
81             -i) ls -l $LOCK ; exit 0 ;;
82             -v) set -x ;;
83             *) usage; exit 1;;
84         esac
85         shift
86     done
87
88     [ -f $LOCK ] && exit 1
89     
90     echo $$ > $LOCK
91
92     do_update  ~/svn-build
93     do_version ~/svn-build     5.0 
94     do_diff    ~/svn-build     5.0
95     do_update  ~/svn-build-4.3
96     do_version ~/svn-build-4.3 4.3 
97     do_diff    ~/svn-build-4.3 4.3
98
99     rm $LOCK
100
101 }
102
103 main "$@"