gst-inspect: fix unused-const-variable error in windows
[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 tmp=${TMPDIR-/tmp}
22 tmp=$tmp/git-update.$(date +%Y%m%d-%H%M-).$RANDOM.$RANDOM.$RANDOM.$$
23
24 (umask 077 && mkdir "$tmp") || {
25   echo "Could not create temporary directory! Exiting." 1>&2
26   exit 1
27 }
28
29 ERROR_LOG="$tmp/failures.log"
30 ERROR_RETURN=255
31
32 CPUCORES=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu  2>/dev/null || echo "1")
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     MAKEFLAGS="-j$CPUCORES $MAKEFLAGS" make > "$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 # build core and base plugins sequentially
134 # exit if build fails (excluding checks)
135 for m in $CORE; do
136   build $m
137   if [ $? -eq $ERROR_RETURN ]; then
138   beach
139   fi
140 done
141
142 # build other modules in parallel
143 for m in $MODULES $EXTRA_MODULES; do
144   build $m &
145   PIDS="$PIDS $!"
146 done
147 wait $PIDS
148
149 beach
150