123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- #!/bin/bash
- # Arguments = -r qtbase,qtdeclarative,...,qtxmlpatterns -f
- set -e
- parts="qtchooser qtbase qtxmlpatterns qtimageformats qtdeclarative qtgraphicaleffects qtquickcontrols qtquickcontrols-tizen qtsensors qttools qtwayland qtmultimedia"
- parts_comma=$(echo $parts | sed "s/ /,/g")
- usage()
- {
- cat << EOF
- usage: $0 options
- This script will download and sync tizen repos with upstream
- OPTIONS:
- -h Show this message
- -r REPO_LIST comma separated list of qt repositories to sync
- -f push changes to origin
- -p push upstream branch
- -t TAGNAME Add tag TAGNAME pointing to upstream/HEAD
- -u fetch upstream_remote and reset local from upstream_remote
- -b BRANCH_NAME working with -u (only branch reposed which track upstream_remote/BRANCH_NAME will be updated)
- -o fetch origin and rebase local packaging branch with local origin upstream copy
- -s Sync local tizen branches with origin by pull --rebase
- -v Print which Qt upstream branches are tracked by tizen upstream branches
- -g VERSION_NAME Change version tag in spec file to VERSION_NAME
- -c <command> invoke command in each qtrepo directory. You can use QTREPO_TO_REPLACE string
- inside the command - it will be replaced with current qt repo directory (e.g. qtbase)
-
- Handled parts: $parts_comma
- example:
- $0 -r qtbase,qtdeclarative,qtquickcontrols-tizen -f
- EOF
- }
- forcedPushToGitorious="0"
- qtparts=""
- tagName=""
- fetchAndResetFromUpstream=""
- fetchAndRebaseFromOrigin=""
- pushUpstreamBranch=""
- syncTizenBranches=""
- commandToInvoke=""
- upstreamFilterBranch=""
- versionToChange=""
- function getUpstreamBranch {
- QtReleaseBranch=5.3.1
- qtchooser=master
- qtbase=$QtReleaseBranch
- qtdeclarative=$QtReleaseBranch
- qtgraphicaleffects=$QtReleaseBranch
- qtimageformats=$QtReleaseBranch
- qtquickcontrols=$QtReleaseBranch
- qtquickcontrols_tizen=wip/tizen
- qtsensors=$QtReleaseBranch
- qttools=$QtReleaseBranch
- qtwayland=5.3
- qtxmlpatterns=$QtReleaseBranch
- qtmultimedia=dev
- repo=$1
- if [ "$repo" == "qtquickcontrols-tizen" ]; then
- repo=qtquickcontrols_tizen
- fi
- echo ${!repo}
- }
- while getopts ":hfr:t:uposvc:b:g:" opt; do
- case $opt in
- h)
- usage
- exit
- ;;
- f)
- forcedPushToGitorious="1"
- ;;
- r)
- qtparts=$(echo $OPTARG| sed "s/,/ /gi")
- ;;
- t)
- tagName="$OPTARG"
- ;;
- u)
- fetchAndResetFromUpstream="1"
- ;;
- b)
- upstreamFilterBranch="$OPTARG"
- ;;
- p)
- pushUpstreamBranch="1"
- ;;
- o)
- fetchAndRebaseFromOrigin="1"
- ;;
- s)
- syncTizenBranches="1"
- ;;
- v)
- for tizenBranch in $parts; do
- trackedBranch=$(getUpstreamBranch $tizenBranch)
- echo "tizen/$tizenBranch/upstream is tracking qt/$tizenBranch/$trackedBranch"
- done
- exit
- ;;
- c) commandToInvoke="$OPTARG"
- ;;
- g) versionToChange="$OPTARG"
- ;;
- ?)
- echo "Invalid option: -$OPTARG"
- usage
- exit
- ;;
- esac
- done
- remote_repo_url=tizen:platform/upstream/
- remote_qt_repo_url=git@gitorious.org:qt/
-
- if [ "$qtparts" != "" ]; then
- parts="$qtparts"
- fi
- rootRepoDir=`pwd`
- scriptsDir=$(dirname $0)
- packagingBranch=tizen
- upstreamBranch=upstream
- if [ "$commandToInvoke" != "" ]; then
- for qtrepo in $parts; do
- cd $rootRepoDir/$qtrepo
- replacedCommand=$(echo $commandToInvoke| sed "s/QTREPO_TO_REPLACE/$qtrepo/gi")
- eval $replacedCommand
- done
- exit 0
- fi
- for qtrepo in $parts; do
- echo =============================================
- echo updating $qtrepo
- echo =============================================
-
- externalUpstreamBranch=$(getUpstreamBranch $qtrepo)
- if [ ! -d $rootRepoDir/$qtrepo ]; then
- echo "$qtrepo does not exist. Cloning from tizen"
- git clone -b tizen tizen:platform/upstream/"$qtrepo".git
- fi
-
- cd $rootRepoDir/$qtrepo
- git checkout tizen
- if [ "$versionToChange" != "" ]; then
- specFileName=$(find packaging/ -name *.spec)
- sed -i "s/^Version\:\s*.*/Version: $versionToChange/gi" $specFileName
- continue
- fi
- set +e
- upstreamRemoteExists=`git remote | grep -c upstream_remote`
- set -e
- if [ "$upstreamRemoteExists" == "0" ]; then
- echo adding upstream_remote $remote_qt_repo_url$qtrepo.git
- git remote add upstream_remote $remote_qt_repo_url$qtrepo.git
- git fetch upstream_remote
- git remote add gerrit ssh://codereview.qt-project.org/qt/$qtrepo
- scp -p codereview.qt-project.org:hooks/commit-msg .git/hooks
- fi
- if [ "$fetchAndRebaseFromOrigin" == "1" ]; then
- echo fetching origin
- git fetch origin
- fi
- if [ "$fetchAndResetFromUpstream" == "1" ]; then
- echo fetching upstream_remote
- git fetch upstream_remote
- fi
- echo checking out $upstream_branch
- set +e
- upstreamBranchExists=`git branch | grep -c $upstreamBranch`
- set -e
- if [ "$upstreamBranchExists" == "0" ]; then
- git checkout -b $upstreamBranch --track upstream_remote/$externalUpstreamBranch
- else
- git branch -q --set-upstream-to=upstream_remote/$externalUpstreamBranch $upstreamBranch
- git checkout $upstreamBranch
- fi
- if [ "$fetchAndResetFromUpstream" == "1" ]; then
- if [ "$upstreamFilterBranch" == "" -o "$upstreamFilterBranch" == "$externalUpstreamBranch" ]; then
- git reset --hard upstream_remote/$externalUpstreamBranch
- fi
- fi
- if [ "$tagName" != "" ]; then
- if [ "$qtparts" == "qtchooser" -o "$qtrepo" != "qtchooser" ]; then
- git tag -f $tagName
- tagNameForPush=$tagName
- fi
- fi
- if [ "$pushUpstreamBranch" == "1" ]; then
- echo pushing branch $upstreamBranch to origin
- git push -f origin $upstreamBranch $tagNameForPush
- fi
- git checkout tizen
- if [ "$syncTizenBranches" == "1" ]; then
- echo rebasing local tizen with origin tizen
- git pull --rebase origin tizen
- fi
- if [ "$fetchAndRebaseFromOrigin" == "1" ]; then
- echo rebasing branch tizen
- git rebase $upstreamBranch tizen
- fi
- if [ "$forcedPushToGitorious" != "0" ]; then
- echo forced push tizen origin
- git push -f origin tizen $tagName
- fi
- cd ..
- done
|