git-update.sh: Fix issues
[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
30 for m in $CORE $MODULES; do
31   if test -d $m; then
32     echo "+ updating $m"
33     cd $m
34
35     git pull origin master
36     if test $? -ne 0
37     then
38       echo "$m: update (trying stash, pull, stash apply)" >> $ERROR_LOG
39       git stash
40       git pull origin master
41       if test $? -ne 0
42       then 
43         echo "$m: update" >> $ERROR_LOG
44         cd ..
45         continue
46       fi
47       git stash apply
48     fi
49
50     git submodule update
51     if test $? -ne 0
52     then
53       echo "$m: update (submodule)" >> $ERROR_LOG
54       cd ..
55       continue
56     fi
57     cd ..
58   fi
59 done
60
61 build()
62 {
63   if test -d $1; then
64     cd $1
65     if test ! -e Makefile
66     then
67       echo "+ $1: autoregen.sh"
68       ./autoregen.sh > "$tmp/$1-regen.log" 2>&1
69       if test $? -ne 0
70       then
71         echo "$1: autoregen.sh [$tmp/$1-regen.log]" >> $ERROR_LOG
72         cd ..
73         return -1
74       fi
75       echo "+ $1: autoregen.sh done"
76     fi
77
78     echo "+ $1: make"
79     make > "$tmp/$1-make.log" 2>&1
80     if test $? -ne 0
81     then
82       echo "$1: make [$tmp/$1-make.log]" >> $ERROR_LOG
83       cd ..
84       return -1
85     fi
86     echo "+ $1: make done"
87
88     if test "x$CHECK" != "x"; then
89       echo "+ $1: make check"
90       make check > "$tmp/$1-check.log" 2>&1
91       if test $? -ne 0
92       then
93         echo "$1: check [$tmp/$1-check.log]" >> $ERROR_LOG
94         cd ..
95         return
96       fi
97       echo "+ $1: make check done"
98     fi
99     cd ..
100   fi
101 }
102
103 beach()
104 {
105 if test -e $ERROR_LOG;  then
106   echo "Failures:"
107   echo
108   cat $ERROR_LOG
109 else
110   rm -rf "$tmp"
111 fi
112 }
113
114 # build core and base plugins sequentially
115 # exit if build fails (excluding checks)
116 for m in $CORE; do
117   build $m
118   if [ $? == -1 ]; then
119   beach
120   fi
121 done
122
123 # build other modules in parallel
124 for m in $MODULES; do
125   build $m &
126   PIDS="$PIDS $!"
127 done
128 wait $PIDS
129
130 beach
131