summaryrefslogtreecommitdiff
path: root/scripts/git-update.sh
blob: fba0c6e9f1190de1544dc90edcd8baec537a0b0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash

# update all known gstreamer modules
# build them one by one
# report failures at the end
# run this from a directory that contains the checkouts for each of the
# modules

PIDS=

CORE="\
    gstreamer gst-plugins-base"
MODULES="\
    gst-plugins-good gst-plugins-ugly gst-plugins-bad \
    gst-libav"
EXTRA_MODULES="\
    gst-editing-services \
    gst-rtsp-server \
    gst-python \
    gnonlin"

tmp=${TMPDIR-/tmp}
tmp=$tmp/git-update.$(date +%Y%m%d-%H%M-).$RANDOM.$RANDOM.$RANDOM.$$

(umask 077 && mkdir "$tmp") || {
  echo "Could not create temporary directory! Exiting." 1>&2
  exit 1
}

ERROR_LOG="$tmp/failures.log"
ERROR_RETURN=255

for m in $CORE $MODULES $EXTRA_MODULES; do
  if test -d $m; then
    echo "+ updating $m"
    cd $m

    git pull origin master
    if test $? -ne 0
    then
      echo "$m: update (trying stash, pull, stash apply)" >> $ERROR_LOG
      git stash
      git pull origin master
      if test $? -ne 0
      then 
        echo "$m: update" >> $ERROR_LOG
        cd ..
        continue
      fi
      git stash apply
    fi

    git submodule update
    if test $? -ne 0
    then
      echo "$m: update (submodule)" >> $ERROR_LOG
      cd ..
      continue
    fi
    cd ..
  fi
done

build()
{
  if test -d $1; then
    cd $1
    if test ! -e Makefile
    then
      if test -e autoregen.sh
      then
        echo "+ $1: autoregen.sh"
        ./autoregen.sh > "$tmp/$1-regen.log" 2>&1
        if test $? -ne 0
        then
          echo "$1: autoregen.sh [$tmp/$1-regen.log]" >> $ERROR_LOG
          cd ..
          return $ERROR_RETURN
        fi
        echo "+ $1: autoregen.sh done"
      else
        echo "+ $1: autogen.sh"
        ./autogen.sh > "$tmp/$1-gen.log" 2>&1
        if test $? -ne 0
        then
          echo "$1: autogen.sh [$tmp/$1-gen.log]" >> $ERROR_LOG
          cd ..
          return $ERROR_RETURN
        fi
        echo "+ $1: autogen.sh done"
      fi
    fi

    echo "+ $1: make"
    make > "$tmp/$1-make.log" 2>&1
    if test $? -ne 0
    then
      echo "$1: make [$tmp/$1-make.log]" >> $ERROR_LOG
      cd ..
      return $ERROR_RETURN
    fi
    echo "+ $1: make done"

    if test "x$CHECK" != "x"; then
      echo "+ $1: make check"
      make check > "$tmp/$1-check.log" 2>&1
      if test $? -ne 0
      then
        echo "$1: check [$tmp/$1-check.log]" >> $ERROR_LOG
        cd ..
        return
      fi
      echo "+ $1: make check done"
    fi
    cd ..
  fi
}

beach()
{
if test -e $ERROR_LOG;  then
  echo "Failures:"
  echo
  cat $ERROR_LOG
else
  echo "Update done"
  rm -rf "$tmp"
fi
exit
}

# build core and base plugins sequentially
# exit if build fails (excluding checks)
for m in $CORE; do
  build $m
  if [ $? -eq $ERROR_RETURN ]; then
  beach
  fi
done

# build other modules in parallel
for m in $MODULES; do
  build $m &
  PIDS="$PIDS $!"
done
wait $PIDS

beach