scripts: Allow passing make flags to git-update.sh
[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-libav"
16 EXTRA_MODULES="\
17     gst-editing-services \
18     gst-rtsp-server \
19     gst-python"
20
21 MAKE_FLAGS=
22
23 tmp=${TMPDIR-/tmp}
24 tmp=$tmp/git-update.$(date +%Y%m%d-%H%M-).$RANDOM.$RANDOM.$RANDOM.$$
25
26 (umask 077 && mkdir "$tmp") || {
27   echo "Could not create temporary directory! Exiting." 1>&2
28   exit 1
29 }
30
31 ERROR_LOG="$tmp/failures.log"
32 ERROR_RETURN=255
33
34 for m in $CORE $MODULES $EXTRA_MODULES; do
35   if test -d $m; then
36     echo "+ updating $m"
37     cd $m
38
39     git pull --rebase
40     if test $? -ne 0
41     then
42       echo "$m: update (trying stash, pull, stash apply)" >> $ERROR_LOG
43       git stash
44       git pull --rebase
45       if test $? -ne 0
46       then 
47         echo "$m: update" >> $ERROR_LOG
48         cd ..
49         continue
50       fi
51       git stash apply
52     fi
53
54     git submodule update
55     if test $? -ne 0
56     then
57       echo "$m: update (submodule)" >> $ERROR_LOG
58       cd ..
59       continue
60     fi
61     cd ..
62   fi
63 done
64
65 build()
66 {
67   if test -d $1; then
68     cd $1
69     if test ! -e Makefile
70     then
71       if test -e autoregen.sh
72       then
73         echo "+ $1: autoregen.sh"
74         ./autoregen.sh > "$tmp/$1-regen.log" 2>&1
75         if test $? -ne 0
76         then
77           echo "$1: autoregen.sh [$tmp/$1-regen.log]" >> $ERROR_LOG
78           cd ..
79           return $ERROR_RETURN
80         fi
81         echo "+ $1: autoregen.sh done"
82       else
83         echo "+ $1: autogen.sh"
84         ./autogen.sh > "$tmp/$1-gen.log" 2>&1
85         if test $? -ne 0
86         then
87           echo "$1: autogen.sh [$tmp/$1-gen.log]" >> $ERROR_LOG
88           cd ..
89           return $ERROR_RETURN
90         fi
91         echo "+ $1: autogen.sh done"
92       fi
93     fi
94
95     echo "+ $1: make"
96     make $MAKE_FLAGS > "$tmp/$1-make.log" 2>&1
97     if test $? -ne 0
98     then
99       echo "$1: make [$tmp/$1-make.log]" >> $ERROR_LOG
100       cd ..
101       return $ERROR_RETURN
102     fi
103     echo "+ $1: make done"
104
105     if test "x$CHECK" != "x"; then
106       echo "+ $1: make check"
107       make check > "$tmp/$1-check.log" 2>&1
108       if test $? -ne 0
109       then
110         echo "$1: check [$tmp/$1-check.log]" >> $ERROR_LOG
111         cd ..
112         return
113       fi
114       echo "+ $1: make check done"
115     fi
116     cd ..
117   fi
118 }
119
120 beach()
121 {
122 if test -e $ERROR_LOG;  then
123   echo "Failures:"
124   echo
125   cat $ERROR_LOG
126 else
127   echo "Update done"
128   rm -rf "$tmp"
129 fi
130 exit
131 }
132
133 MAKE_FLAGS=$@
134
135 # build core and base plugins sequentially
136 # exit if build fails (excluding checks)
137 for m in $CORE; do
138   build $m
139   if [ $? -eq $ERROR_RETURN ]; then
140   beach
141   fi
142 done
143
144 # build other modules in parallel
145 for m in $MODULES; do
146   build $m &
147   PIDS="$PIDS $!"
148 done
149 wait $PIDS
150
151 beach
152