git-update.sh: use autogen.sh instead of autoregen.sh on fresh repositories.
[platform/upstream/gstreamer.git] / scripts / git-update.sh
1 #!/bin/bash
2
3 # update all known gstreamer modules
4 # build them one by one
5 # report failures at the end
6 # run this from a directory that contains the checkouts for each of the
7 # modules
8
9 PIDS=
10
11 CORE="\
12     gstreamer gst-plugins-base"
13 MODULES="\
14     gst-plugins-good gst-plugins-ugly gst-plugins-bad \
15     gst-ffmpeg \
16     gst-python \
17     gnonlin"
18
19 tmp=${TMPDIR-/tmp}
20 tmp=$tmp/git-update.$(date +%Y%m%d-%H%M-).$RANDOM.$RANDOM.$RANDOM.$$
21
22 (umask 077 && mkdir "$tmp") || {
23   echo "Could not create temporary directory! Exiting." 1>&2
24   exit 1
25 }
26
27 ERROR_LOG="$tmp/failures.log"
28 touch $ERROR_LOG
29 ERROR_RETURN=255
30
31 for m in $CORE $MODULES; do
32   if test -d $m; then
33     echo "+ updating $m"
34     cd $m
35
36     git pull origin master
37     if test $? -ne 0
38     then
39       echo "$m: update (trying stash, pull, stash apply)" >> $ERROR_LOG
40       git stash
41       git pull origin master
42       if test $? -ne 0
43       then 
44         echo "$m: update" >> $ERROR_LOG
45         cd ..
46         continue
47       fi
48       git stash apply
49     fi
50
51     git submodule update
52     if test $? -ne 0
53     then
54       echo "$m: update (submodule)" >> $ERROR_LOG
55       cd ..
56       continue
57     fi
58     cd ..
59   fi
60 done
61
62 build()
63 {
64   if test -d $1; then
65     cd $1
66     if test ! -e Makefile -a -e autoregen.sh
67     then
68       echo "+ $1: autoregen.sh"
69       ./autoregen.sh > "$tmp/$1-regen.log" 2>&1
70       if test $? -ne 0
71       then
72         echo "$1: autoregen.sh [$tmp/$1-regen.log]" >> $ERROR_LOG
73         cd ..
74         return $ERROR_RETURN
75       fi
76       echo "+ $1: autoregen.sh done"
77     fi
78     else if test ! -e Makefile
79     then
80        echo "+ $1: autogen.sh"
81       ./autogen.sh > "$tmp/$1-gen.log" 2>&1
82       if test $? -ne 0
83       then
84         echo "$1: autogen.sh [$tmp/$1-gen.log]" >> $ERROR_LOG
85         cd ..
86         return $ERROR_RETURN
87       fi
88       echo "+ $1: autogen.sh done"
89     fi
90
91     echo "+ $1: make"
92     make > "$tmp/$1-make.log" 2>&1
93     if test $? -ne 0
94     then
95       echo "$1: make [$tmp/$1-make.log]" >> $ERROR_LOG
96       cd ..
97       return $ERROR_RETURN
98     fi
99     echo "+ $1: make done"
100
101     if test "x$CHECK" != "x"; then
102       echo "+ $1: make check"
103       make check > "$tmp/$1-check.log" 2>&1
104       if test $? -ne 0
105       then
106         echo "$1: check [$tmp/$1-check.log]" >> $ERROR_LOG
107         cd ..
108         return
109       fi
110       echo "+ $1: make check done"
111     fi
112     cd ..
113   fi
114 }
115
116 beach()
117 {
118 if test -e $ERROR_LOG;  then
119   echo "Failures:"
120   echo
121   cat $ERROR_LOG
122 else
123   rm -rf "$tmp"
124 fi
125 exit
126 }
127
128 # build core and base plugins sequentially
129 # exit if build fails (excluding checks)
130 for m in $CORE; do
131   build $m
132   if [ $? -eq $ERROR_RETURN ]; then
133   beach
134   fi
135 done
136
137 # build other modules in parallel
138 for m in $MODULES; do
139   build $m &
140   PIDS="$PIDS $!"
141 done
142 wait $PIDS
143
144 beach
145