update-common: gst-omx wants an updated common module too
[platform/upstream/gst-common.git] / update-common
1 #!/bin/bash
2 #
3 # This script will update all the modules listed below so that
4 # common points to master in the common module.
5 #
6 # If you have many of the GStreamer modules checked out in a particular
7 # directory, it's best to run this script from that directory.  For
8 # example, I check everything out in ~/gst, so this file is
9 # ~/gst/common/update-common.  To do an update, I do
10 # 'cd ~/gst ; ./common/update-common'.  This will automatically use
11 # the refs in your existing checkout when cloning the temporary
12 # checkout.  Alternatively, you can use the reference variable below.
13 #
14
15 # Set this variable to point to any directory containing existing
16 # git # checkouts, and git will pull objects from there, decreasing
17 # network usage.
18 BRANCH=master
19 reference=~/gst
20 PUSHURL=ssh://git.freedesktop.org/git/gstreamer
21
22 set -e
23 set -x
24
25 modules="gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad \
26         gst-plugins-ugly gst-ffmpeg gst-omx \
27         gnonlin gst-plugins-gl gst-rtsp-server gst-editing-services"
28
29 topdir=`pwd`
30 dir=`mktemp -d $topdir/common-update-XXXXXX`
31
32 for module in $modules
33 do
34   cd $dir
35   if test -e $reference/$module/.git ; then
36     pushd $reference/$module
37     PUSHURL=`git config remote.origin.url | sed 's@\(git/gstreamer\).*@\1@'`
38     popd
39     git clone --reference $reference/$module/.git --shared ssh://git.freedesktop.org/git/gstreamer/$module
40   elif test -e $topdir/$module/.git ; then
41     pushd $topdir/$module
42     PUSHURL=`git config remote.origin.url | sed 's@\(git/gstreamer\).*@\1@'`
43     popd
44     git clone --reference $topdir/$module/.git --shared $PUSHURL/$module
45   else
46     git clone $PUSHURL/$module
47   fi
48   cd $dir/$module
49
50   # ignore modules that don't have such a branch
51   if ! git show-ref origin/$BRANCH >/dev/null; then
52     continue;
53   fi
54
55   if test $BRANCH = 'master'; then
56     git checkout $BRANCH
57   else
58     git checkout -b $BRANCH origin/$BRANCH
59   fi
60
61   git submodule init
62   git submodule update
63   cd $dir/$module/common
64   ref_from=`git log --pretty=format:%h -n 1 HEAD`
65   if test $BRANCH = 'master'; then
66     git checkout $BRANCH
67   else
68     git checkout -b $BRANCH origin/$BRANCH
69   fi
70   git pull origin
71   ref_to=`git log --pretty=format:%h -n 1 HEAD`
72   echo updating common from $ref_from to $ref_to
73   if [ "$ref_from" != "$ref_to" ] ; then
74     cd $dir/$module
75     git add common
76     git commit -m "Automatic update of common submodule
77
78 From $ref_from to $ref_to"
79   fi
80   cd $dir
81 done
82
83 for module in $modules
84 do
85   cd $dir/$module
86   if git show-ref origin/$BRANCH >/dev/null; then
87     git push origin $BRANCH
88   fi
89 done
90
91 rm -rf $dir