discard current pid
[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 pid=$$
14 running=$(pgrep $COMMAND 2> /dev/null | grep -v "^${pid}"'^' )
15 # bail out if another instance is already running
16 [ -n "$running" ] && exit 1
17
18 OUTPUT=/build/modules
19
20 # usage: do_version dir name 
21 function do_version () {
22     build_dir=$1; shift
23     name=$1; shift
24
25     out_dir=$OUTPUT/$name
26     out_file=$out_dir/version.txt
27     out_tmp=$out_dir/.version.txt
28     
29     mkdir -p $out_dir
30     
31     ( echo $name ; \
32       date ; \
33       $build_dir/module-version -a ; \
34       date ) &> $out_tmp
35     mv -f $out_tmp $out_file
36 }
37
38 # usage: do_version dir name 
39 function do_diff () {
40     build_dir=$1; shift
41     name=$1; shift
42
43     out_dir=$OUTPUT/$name
44     out_file=$out_dir/diff.txt
45     out_tmp=$out_dir/.diff.txt
46     
47     mkdir -p $out_dir
48     
49     ( echo $name ; \
50       date ; \
51       $build_dir/module-diff -a -o -q ; \
52       date ) &> $out_tmp
53
54     ( echo 'WARNINGS (if any)' ; \
55       egrep 'was not found|Skipping failed' $out_tmp ;
56       cat $out_tmp ) > $out_file
57
58     rm -f $out_tmp
59 }
60
61 do_version /root/svn-build-4.2 4.2 
62 do_diff    /root/svn-build-4.2 4.2 
63 do_version /root/svn-build     trunk 
64 do_diff    /root/svn-build     trunk