Remove unused functions
[scm/bb/tizen.git] / tools / gitCloneAll.sh
1 #!/bin/bash -e
2 #
3 # Copyright 2013, Intel Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; version 2 of the License.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU Library General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 # native
18 #
19 #Created on  05 fevr. 2013
20 #
21 #@author: ronan@fridu.net
22 #
23
24 PROTODIR=$(spec2yocto working_dir)
25
26 cd ${PROTODIR}
27
28 mkdir -p git_package
29 mkdir -p specfile-initial
30
31 GIT_CLONE="git cclone"
32
33 cd git_package
34
35 getgit() {
36     local gitName=$1 gitPath=$2 gitTag=$3 gitServer=$4
37
38     if [ -d ${gitName}/.git ]; then
39         cd ${gitName}
40         echo git fetch --all
41         sed  -e 's@+refs/heads/\*@+refs/\*@' .git/config -i
42         git remote prune origin
43         git fetch --all
44         if [ $? == 0  ] ; then ERROR_FETCH_LIST=${ERROR_FETCH_LIST}${gitName}' '  ; fi
45         cd -
46     else
47         echo ${GIT_CLONE} $gitServer:$gitPath ${gitName}
48         ${GIT_CLONE} $gitServer:$gitPath ${gitName}
49         cd ${gitName}
50         sed  -e 's@+refs/heads/\*@+refs/\*@' .git/config -i
51         git remote prune origin 
52         git fetch --all
53         if [ $? == 0  ] ; then ERROR_CLONE_LIST=${ERROR_CLONE_LIST}${gitName}' '  ; fi
54     fi
55 }
56
57 if  [ -z $1 ]; then
58 spec2yocto  manifestToList > /tmp/manifestToList.txt
59 else
60 spec2yocto  manifestToList | grep $1 > /tmp/manifestToList.txt
61 fi
62
63
64
65 TOTALPKG=$(cat /tmp/manifestToList.txt | wc -l)
66 CURPKG=1
67
68 ERROR_FETCH_LIST=
69 ERROR_CLONE_LIST=
70 ERROR_RESET_LIST=
71 ERROR_COPYSPEC_LIST=
72
73
74 cat /tmp/manifestToList.txt |
75 while read gitName gitPath gitTag gitServer; do
76
77     CURDIR=`pwd`
78     echo "--------------------------------------------------------------" ${CURPKG}/${TOTALPKG}
79     echo gitName ${gitName}
80     getgit $gitName $gitPath $gitTag $gitServer
81     cd $CURDIR/${gitName}
82     echo
83     echo git reset --hard "$gitTag"
84     git reset --hard "$gitTag"
85     if [ $? == 0  ] ; then ERROR_RESET_LIST=${ERROR_RESET_LIST}${gitName}' '  ; fi
86     cd "$CURDIR"
87
88     rm -fr ../specfile-initial/${gitName}/*
89     mkdir -p ../specfile-initial/${gitName}/packaging/
90
91     SPEC_FILE=$(spec2yocto findBestSpecFile ${gitName}/packaging --package_pn=${gitName})
92     cp  ${SPEC_FILE} ../specfile-initial/${gitName}/packaging/
93     if [ $? == 0  ] ; then ERROR_COPYSPEC_LIST=${ERROR_COPYSPEC_LIST}${gitName}' '  ; fi
94
95     CURPKG=$(( ${CURPKG} +1 ))
96 done
97
98 rm /tmp/manifestToList.txt
99
100 cd ..
101
102 echo ________________________________________________________________________________
103 echo package git fetch error:
104 for package_error in ${ERROR_FETCH_LIST}; do
105  echo '    '${package_error}
106 done
107 echo ________________________________________________________________________________
108 echo package git clone error:
109 for package_error in ${ERROR_CLONE_LIST}; do
110  echo '    '${package_error}
111 done
112  echo ________________________________________________________________________________
113 echo package git reset error:
114 for package_error in ${ERROR_RESET_LIST}; do
115  echo '    '${package_error}
116 done
117  echo ________________________________________________________________________________
118 echo package copy spec file error:
119 for package_error in ${ERROR_COPYSPEC_LIST}; do
120  echo '    '${package_error}
121 done
122
123
124
125