update_tizen_qt_repos 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. #!/bin/bash
  2. # Arguments = -r qtbase,qtdeclarative,...,qtxmlpatterns -f
  3. set -e
  4. parts="qtchooser qtbase qtxmlpatterns qtimageformats qtdeclarative qtgraphicaleffects qtquickcontrols qtquickcontrols-tizen qtsensors qttools qtwayland qtmultimedia"
  5. parts_comma=$(echo $parts | sed "s/ /,/g")
  6. usage()
  7. {
  8. cat << EOF
  9. usage: $0 options
  10. This script will download and sync tizen repos with upstream
  11. OPTIONS:
  12. -h Show this message
  13. -r REPO_LIST comma separated list of qt repositories to sync
  14. -f push changes to origin
  15. -p push upstream branch
  16. -t TAGNAME Add tag TAGNAME pointing to upstream/HEAD
  17. -u fetch upstream_remote and reset local from upstream_remote
  18. -b BRANCH_NAME working with -u (only branch reposed which track upstream_remote/BRANCH_NAME will be updated)
  19. -o fetch origin and rebase local packaging branch with local origin upstream copy
  20. -s Sync local tizen branches with origin by pull --rebase
  21. -v Print which Qt upstream branches are tracked by tizen upstream branches
  22. -g VERSION_NAME Change version tag in spec file to VERSION_NAME
  23. -c <command> invoke command in each qtrepo directory. You can use QTREPO_TO_REPLACE string
  24. inside the command - it will be replaced with current qt repo directory (e.g. qtbase)
  25. Handled parts: $parts_comma
  26. example:
  27. $0 -r qtbase,qtdeclarative,qtquickcontrols-tizen -f
  28. EOF
  29. }
  30. forcedPushToGitorious="0"
  31. qtparts=""
  32. tagName=""
  33. fetchAndResetFromUpstream=""
  34. fetchAndRebaseFromOrigin=""
  35. pushUpstreamBranch=""
  36. syncTizenBranches=""
  37. commandToInvoke=""
  38. upstreamFilterBranch=""
  39. versionToChange=""
  40. function getUpstreamBranch {
  41. QtReleaseBranch=5.3.1
  42. qtchooser=master
  43. qtbase=$QtReleaseBranch
  44. qtdeclarative=$QtReleaseBranch
  45. qtgraphicaleffects=$QtReleaseBranch
  46. qtimageformats=$QtReleaseBranch
  47. qtquickcontrols=$QtReleaseBranch
  48. qtquickcontrols_tizen=wip/tizen
  49. qtsensors=$QtReleaseBranch
  50. qttools=$QtReleaseBranch
  51. qtwayland=5.3
  52. qtxmlpatterns=$QtReleaseBranch
  53. qtmultimedia=dev
  54. repo=$1
  55. if [ "$repo" == "qtquickcontrols-tizen" ]; then
  56. repo=qtquickcontrols_tizen
  57. fi
  58. echo ${!repo}
  59. }
  60. while getopts ":hfr:t:uposvc:b:g:" opt; do
  61. case $opt in
  62. h)
  63. usage
  64. exit
  65. ;;
  66. f)
  67. forcedPushToGitorious="1"
  68. ;;
  69. r)
  70. qtparts=$(echo $OPTARG| sed "s/,/ /gi")
  71. ;;
  72. t)
  73. tagName="$OPTARG"
  74. ;;
  75. u)
  76. fetchAndResetFromUpstream="1"
  77. ;;
  78. b)
  79. upstreamFilterBranch="$OPTARG"
  80. ;;
  81. p)
  82. pushUpstreamBranch="1"
  83. ;;
  84. o)
  85. fetchAndRebaseFromOrigin="1"
  86. ;;
  87. s)
  88. syncTizenBranches="1"
  89. ;;
  90. v)
  91. for tizenBranch in $parts; do
  92. trackedBranch=$(getUpstreamBranch $tizenBranch)
  93. echo "tizen/$tizenBranch/upstream is tracking qt/$tizenBranch/$trackedBranch"
  94. done
  95. exit
  96. ;;
  97. c) commandToInvoke="$OPTARG"
  98. ;;
  99. g) versionToChange="$OPTARG"
  100. ;;
  101. ?)
  102. echo "Invalid option: -$OPTARG"
  103. usage
  104. exit
  105. ;;
  106. esac
  107. done
  108. remote_repo_url=tizen:platform/upstream/
  109. remote_qt_repo_url=git@gitorious.org:qt/
  110. if [ "$qtparts" != "" ]; then
  111. parts="$qtparts"
  112. fi
  113. rootRepoDir=`pwd`
  114. scriptsDir=$(dirname $0)
  115. packagingBranch=tizen
  116. upstreamBranch=upstream
  117. if [ "$commandToInvoke" != "" ]; then
  118. for qtrepo in $parts; do
  119. cd $rootRepoDir/$qtrepo
  120. replacedCommand=$(echo $commandToInvoke| sed "s/QTREPO_TO_REPLACE/$qtrepo/gi")
  121. eval $replacedCommand
  122. done
  123. exit 0
  124. fi
  125. for qtrepo in $parts; do
  126. echo =============================================
  127. echo updating $qtrepo
  128. echo =============================================
  129. externalUpstreamBranch=$(getUpstreamBranch $qtrepo)
  130. if [ ! -d $rootRepoDir/$qtrepo ]; then
  131. echo "$qtrepo does not exist. Cloning from tizen"
  132. git clone -b tizen tizen:platform/upstream/"$qtrepo".git
  133. fi
  134. cd $rootRepoDir/$qtrepo
  135. git checkout tizen
  136. if [ "$versionToChange" != "" ]; then
  137. specFileName=$(find packaging/ -name *.spec)
  138. sed -i "s/^Version\:\s*.*/Version: $versionToChange/gi" $specFileName
  139. continue
  140. fi
  141. set +e
  142. upstreamRemoteExists=`git remote | grep -c upstream_remote`
  143. set -e
  144. if [ "$upstreamRemoteExists" == "0" ]; then
  145. echo adding upstream_remote $remote_qt_repo_url$qtrepo.git
  146. git remote add upstream_remote $remote_qt_repo_url$qtrepo.git
  147. git fetch upstream_remote
  148. git remote add gerrit ssh://codereview.qt-project.org/qt/$qtrepo
  149. scp -p codereview.qt-project.org:hooks/commit-msg .git/hooks
  150. fi
  151. if [ "$fetchAndRebaseFromOrigin" == "1" ]; then
  152. echo fetching origin
  153. git fetch origin
  154. fi
  155. if [ "$fetchAndResetFromUpstream" == "1" ]; then
  156. echo fetching upstream_remote
  157. git fetch upstream_remote
  158. fi
  159. echo checking out $upstream_branch
  160. set +e
  161. upstreamBranchExists=`git branch | grep -c $upstreamBranch`
  162. set -e
  163. if [ "$upstreamBranchExists" == "0" ]; then
  164. git checkout -b $upstreamBranch --track upstream_remote/$externalUpstreamBranch
  165. else
  166. git branch -q --set-upstream-to=upstream_remote/$externalUpstreamBranch $upstreamBranch
  167. git checkout $upstreamBranch
  168. fi
  169. if [ "$fetchAndResetFromUpstream" == "1" ]; then
  170. if [ "$upstreamFilterBranch" == "" -o "$upstreamFilterBranch" == "$externalUpstreamBranch" ]; then
  171. git reset --hard upstream_remote/$externalUpstreamBranch
  172. fi
  173. fi
  174. if [ "$tagName" != "" ]; then
  175. if [ "$qtparts" == "qtchooser" -o "$qtrepo" != "qtchooser" ]; then
  176. git tag -f $tagName
  177. tagNameForPush=$tagName
  178. fi
  179. fi
  180. if [ "$pushUpstreamBranch" == "1" ]; then
  181. echo pushing branch $upstreamBranch to origin
  182. git push -f origin $upstreamBranch $tagNameForPush
  183. fi
  184. git checkout tizen
  185. if [ "$syncTizenBranches" == "1" ]; then
  186. echo rebasing local tizen with origin tizen
  187. git pull --rebase origin tizen
  188. fi
  189. if [ "$fetchAndRebaseFromOrigin" == "1" ]; then
  190. echo rebasing branch tizen
  191. git rebase $upstreamBranch tizen
  192. fi
  193. if [ "$forcedPushToGitorious" != "0" ]; then
  194. echo forced push tizen origin
  195. git push -f origin tizen $tagName
  196. fi
  197. cd ..
  198. done