[Tizen][WebRTC] Appsink implementation with fimcconvert
[platform/framework/web/chromium-efl.git] / tizen_src / sync_repos.sh
1 #!/bin/bash
2
3 BRANCH=beta/m40_2214_t
4 URLBASE=$(git ls-remote --get-url)
5 if echo "$@" | grep -c "\-\-reset" &> /dev/null; then
6   isReset=1
7 fi
8
9 # Remove untracked files and directories.
10 # This is needed by buildbot to avoid conflict when applying a patch.
11 # Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=9584
12 # WARNING: Be careful when using this since it'll delete your local changes.
13 CleanCommand=':'
14 if echo "$@" | grep -c "\-\-clean" &> /dev/null; then
15   CleanCommand='git clean -df'
16 fi
17 $CleanCommand
18
19 isLocalGit=$([ -d "$URLBASE" ] && echo 1 || echo 0)
20 if [ $isLocalGit == "1" ]; then
21   declare -a REPOS
22   local_gits=$(find $URLBASE/src -name .git -type d | xargs dirname | sort)
23   for REPO in $local_gits; do
24     REPOPATH=${REPO#$URLBASE/}
25     echo $REPO $REPOPATH
26     if [ -d $REPOPATH ] ; then
27       pushd $REPOPATH 2>&1 > /dev/null
28       $CleanCommand
29       git fetch $REPO
30       if [ "$isReset" == "1" ]; then
31         git reset --hard FETCH_HEAD
32       else
33         git rebase FETCH_HEAD || exit $?
34       fi
35       popd 2>&1 >/dev/null
36     else
37       git clone $REPO $REPOPATH
38     fi
39   done
40
41   if [ -d $URLBASE/out.x64/Dependencies ] && [ ! -d out.x64/Dependencies ]; then
42     SCRIPTDIR=$(cd $(dirname $0); pwd -P)
43     SRCDIR=$URLBASE/out.x64/Dependencies
44     TGTDIR=$SCRIPTDIR/out.x64/Dependencies
45     mkdir out.x64 || :
46     cp -al $SRCDIR out.x64/
47     find out.x64/Dependencies -name *.pc -exec sed -i "s:$SRCDIR:$TGTDIR:g" {} \;
48   fi
49   exit
50 fi
51
52 URLBASE=$(dirname $URLBASE)
53 REPOS=( "src|$URLBASE/s-chromium.git" \
54         "src/third_party/WebKit|$URLBASE/s-blink" \
55         "src/third_party/skia|$URLBASE/s-skia.git" \
56         "src/third_party/libjingle/source/talk|$URLBASE/s-libjingle_source_talk.git" \
57         "src/third_party/webrtc|$URLBASE/s-webrtc.git" \
58         "src/v8|$URLBASE/s-v8" )
59
60 function rmdir_if_not_repo {
61   REPOPATH=$1
62   REPOURL=$2
63   if [ -d $REPOPATH ] ; then
64     isDesiredRepo=$(git --git-dir=$REPOPATH/.git --work-tree=$REPOPATH ls-remote --get-url \
65                     | grep -c $REPOURL || :)
66     if [ "$isDesiredRepo" == "0" ] ; then
67       echo "... Deleting ${REPOPATH} (backup: ${REPOPATH}.bak)"
68       mv ${REPOPATH} ${REPOPATH}.bak 2>&1 > /dev/null
69     fi
70   fi
71 }
72
73 for K in ${REPOS[@]} ; do
74   L=(${K//\|/ })
75   REPOPATH=${L[0]}
76   REPO=${L[1]}
77   rmdir_if_not_repo $REPOPATH $REPO
78   if [ -d $REPOPATH ] ; then
79     pushd $REPOPATH 2>&1 > /dev/null
80     $CleanCommand
81     CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD`
82     if [ "x$CURRENT_BRANCH" == "x$BRANCH" ] ; then
83       echo Updating branch $BRANCH of $REPO in $REPOPATH
84       git fetch $REPO $BRANCH
85       if [ "$isReset" == "1" ]; then
86         git reset --hard FETCH_HEAD
87       else
88         git rebase FETCH_HEAD || exit $?
89       fi
90     else
91       echo Fetching branch $BRANCH of $REPO into $REPOPATH
92       REMOTENAME=$(git remote -v | grep -m 1 $REPO | cut -f1)
93       git remote set-branches --add $REMOTENAME $BRANCH
94       git fetch $REMOTENAME $BRANCH
95       git checkout ${isReset:+-f} -B $BRANCH --track $REMOTENAME/$BRANCH
96     fi
97     popd 2>&1 >/dev/null
98   else
99     echo Cloning branch $BRANCH of $REPO into $REPOPATH
100     git clone --single-branch -b $BRANCH $REPO $REPOPATH
101   fi
102 done
103
104 if [ "$isReset" == "1" ]; then
105     gclient sync -R -f
106 fi