| author | yjiang | 2012-08-23 05:19:24 (EDT) |
|---|---|---|
| committer | xgu | 2012-08-23 05:19:24 (EDT) |
| commit | 3adfe2ea9c13f188b4addda57306d8b3838554ee (patch) (side-by-side diff) | |
| tree | 94d7a8c87d54d95abb92b5f61ad26056971dfc00 | |
| parent | 758d984d7c74cbe70d79246f7bbbf02a6f2b48db (diff) | |
| download | org.eclipse.birt-3adfe2ea9c13f188b4addda57306d8b3838554ee.zip org.eclipse.birt-3adfe2ea9c13f188b4addda57306d8b3838554ee.tar.gz org.eclipse.birt-3adfe2ea9c13f188b4addda57306d8b3838554ee.tar.bz2 | |
Add AutoTag script to Birt 4.2.1
| -rw-r--r-- | build/org.eclipse.birt.releng.birtbuilder/bootstrap.sh | 58 | ||||
| -rw-r--r-- | build/org.eclipse.birt.releng.birtbuilder/extras/git-map.sh | 127 |
2 files changed, 184 insertions, 1 deletions
diff --git a/build/org.eclipse.birt.releng.birtbuilder/bootstrap.sh b/build/org.eclipse.birt.releng.birtbuilder/bootstrap.sh index 1258361..247f097 100644 --- a/build/org.eclipse.birt.releng.birtbuilder/bootstrap.sh +++ b/build/org.eclipse.birt.releng.birtbuilder/bootstrap.sh @@ -115,6 +115,8 @@ do -buildId) buildId="$2"; shift;; -buildLabel) buildLabel="$2"; shift;; -mapVersionTag) mapVersionTag="$2"; shift;; + -noAutoTag) noAutoTag=true;; + -ForceBuild) ForceBuild=true;; -tagMapFiles) tagMaps="-DtagMaps=true";; -skipPerf) skipPerf="-Dskip.performance.tests=true";; -skipTest) skipTest="-Dskip.tests=true";; @@ -189,7 +191,61 @@ echo "======[buildDirectory]: $buildDirectory" >> adb.log mkdir $builderDir cd $builderDir - +#Pull or clone a branch from a repository +#Usage: pull repositoryURL branch + +pull() { + mkdir -p $builderDir/gitClones + pushd $builderDir/gitClones + directory=$(basename $1 .git) + if [ ! -d $directory ]; then + echo git clone $1 + git clone $1 + fi + popd + pushd $builderDir/gitClones/$directory + echo git checkout $2 + git checkout $2 + echo git pull + git pull + popd +} + +if [ "$buildType" == "N" -o "$noAutoTag" ]; then + echo "Skipping auto plugins tagging for nightly build or -noAutoTag build" +else + pushd $builderDir + + #remove comments + rm -f repos-clean.txt clones.txt + GitRoot=ssh://git@git.eclipse.org/gitroot/birt + echo "$GitRoot/org.eclipse.birt.git $BranchName" > repos-clean.txt + #clone or pull each repository and checkout the appropriate branch + while read line; do + #each line is of the form <repository> <branch> + set -- $line + pull $1 $2 + echo $1 | sed 's/ssh:.*@git.eclipse.org/git:\/\/git.eclipse.org/g' >> clones.txt + done < repos-clean.txt + + cat clones.txt| xargs /bin/bash extras/git-map.sh $builderDir/gitClones \ + $builderDir/gitClones > maps.txt + + #Trim out lines that don't require execution + grep -v ^OK maps.txt | grep -v ^Executed >run.txt + if ( cat run.txt | grep sed ); then + /bin/bash run.txt + #mkdir -p $builderDir/report + #cp report.txt $builderDir/report/report$buildId.txt + elif [ "$ForceBuild" == "true" ]; then + echo "Continue to build even if no bundles changed for -ForceBuild build" + else + echo "No change detected. Build ($buildId) is canceled" + exit + fi + + popd +fi mkdir -p $postingDirectory/$buildLabel chmod -R 755 $builderDir diff --git a/build/org.eclipse.birt.releng.birtbuilder/extras/git-map.sh b/build/org.eclipse.birt.releng.birtbuilder/extras/git-map.sh new file mode 100644 index 0000000..c085a0b --- a/dev/null +++ b/build/org.eclipse.birt.releng.birtbuilder/extras/git-map.sh @@ -0,0 +1,127 @@ +#!/bin/bash
+#
+#
+# example usage - you must have your repos checked out on the branch you
+# expect to tag.
+#
+# USAGE: repoRoot relengRoot repoURL [repoURL]*
+# repoRoot - absolute path to a folder containing cloned git repositories
+# relengRoot - absolute path to releng project containing map files
+# repoURL - git repository urls to tag, must match entries in the map files
+# EXAMPLE: git-map.sh \
+# /opt/pwebster/git/eclipse \
+# /opt/pwebster/workspaces/gitMigration/org.eclipse.releng \
+# git://git.eclipse.org/gitroot/platform/eclipse.platform.runtime.git \
+# git://git.eclipse.org/gitroot/platform/eclipse.platform.ui.git >maps.txt
+# examine the file
+# grep -v ^OK maps.txt >run.txt
+# /bin/bash run.txt
+#
+
+PLATFORM=$( uname -s )
+
+get_repo_tag () {
+ REPO=$1
+ REPO_DIR=$( basename $REPO .git )
+ cd $ROOT/$REPO_DIR
+ REPO_COMMIT=$( git rev-list -1 HEAD )
+ NEW_DATE=$( git log -1 --format="%ci" "$REPO_COMMIT" )
+ if [ "$PLATFORM" == "Darwin" ]; then
+ echo v$( date -u -j -f "%s" "$NEW_DATE" "+%Y%m%d-%H%M" )
+ else
+ echo v$( date --date="$NEW_DATE" "+%Y%m%d%H%M" )
+ fi
+}
+
+tag_repo_commit () {
+ REPO=$1
+ REPO_DIR=$( basename $REPO .git )
+ NEW_TAG=$( get_repo_tag $REPO )
+ cd $ROOT/$REPO_DIR
+ REPO_COMMIT=$( git rev-list -1 HEAD )
+ if ! ( git log -1 --format="%d" "$REPO_COMMIT" | grep "[ (]$NEW_TAG[,)]" >/dev/null); then
+ OLD_TAG=$( git log --pretty=oneline --decorate | grep "[ (][vI][0-9]" \
+ | head -1 | sed 's/^[^(]* (.*\([vI][0-9][0-9][0-9][0-9]\)/\1/g' | sed 's/[,)].*$//g' )
+ SUBMISSION_ARGS="$SUBMISSION_ARGS $REPO $OLD_TAG $NEW_TAG"
+ echo "#OK Executed: cd $ROOT/$REPO_DIR \; git tag \"$NEW_TAG\" \"$REPO_COMMIT\""
+ cd $ROOT/$REPO_DIR ; git tag "$NEW_TAG" "$REPO_COMMIT"
+ fi
+}
+
+update_map () {
+ #echo update_map "$@"
+ REPO=$1
+ REPO_DIR=$( basename $REPO .git )
+ MAP=$2
+ cd $ROOT/$REPO_DIR
+ grep "repo=${REPO}," "$MAP" >/tmp/maplines_$$.txt
+ dos2unix /tmp/maplines_$$.txt
+ if [ ! -s /tmp/maplines_$$.txt ]; then
+ return
+ fi
+ while read LINE; do
+ LINE_START=$( echo $LINE | sed 's/^\([^=]*\)=.*$/\1/g' )
+ PROJ_PATH=$( echo $LINE | sed 's/^.*path=//g' )
+ CURRENT_TAG=$( echo $LINE | sed 's/.*tag=\([^,]*\),.*$/\1/g' )
+ LAST_COMMIT=$( git rev-list -1 HEAD -- "$PROJ_PATH" )
+ if [ -z "$LAST_COMMIT" ]; then
+ echo "#SKIPPING $LINE_START, no commits for $PROJ_PATH"
+ continue
+ fi
+
+ if ! ( git tag --contains $LAST_COMMIT | grep $CURRENT_TAG >/dev/null ); then
+ NEW_DATE=$( git log -1 --format="%ci" "$LAST_COMMIT" )
+ if [ "$PLATFORM" == "Darwin" ]; then
+ NEW_TAG=v$( date -u -j -f "%s" "$NEW_DATE" "+%Y%m%d-%H%M" )
+ else
+ NEW_TAG=v$( date --date="$NEW_DATE" "+%Y%m%d%H%M" )
+ fi
+
+ if ! ( git log -1 --format="%d" "$LAST_COMMIT" | grep "[ (]$NEW_TAG[,)]" >/dev/null); then
+ SUBMISSION_ARGS="$SUBMISSION_ARGS $REPO $CURRENT_TAG $NEW_TAG"
+ echo "#OK Executed: cd $ROOT/$REPO_DIR \; git tag \"$NEW_TAG\" \"$LAST_COMMIT\""
+ cd $ROOT/$REPO_DIR ; git tag "$NEW_TAG" "$LAST_COMMIT"
+ fi
+ echo sed "'s/$LINE_START=GIT,tag=$CURRENT_TAG/$LINE_START=GIT,tag=$NEW_TAG/g'" $MAP \>/tmp/t1_$$.txt \; mv /tmp/t1_$$.txt $MAP
+ #echo \( cd $ROOT/$REPO_DIR \; git commit -a -m \"Update map file for "$LINE_START" by auto tag script\" \)
+ else
+ echo OK $LINE_START $CURRENT_TAG
+ fi
+ done </tmp/maplines_$$.txt
+ rm -f /tmp/maplines_$$.txt
+ echo \( cd $ROOT/$REPO_DIR \; git commit -a -m \"Update map file for "$REPO_DIR" repository by auto tag script\" \)
+ echo \( cd $ROOT/$REPO_DIR \; git push \; git push --tags \)
+}
+
+
+STATUS=OK
+STATUS_MSG=""
+LATEST_SUBMISSION=""
+SUBMISSION_ARGS=""
+
+if [ $# -lt 3 ]; then
+ echo "USAGE: $0 repoRoot relengRoot repoURL [repoURL]*"
+ exit 1
+fi
+
+
+ROOT=$1; shift
+RELENG=$1; shift
+REPOS="$@"
+
+
+for REPO in $REPOS; do
+ cd $ROOT
+ #tag_repo_commit $REPO
+ MAPS=$( find $RELENG -name "*.map" -exec grep -l "repo=${REPO}," {} \; )
+ if [ ! -z "$MAPS" ]; then
+ for MAP in $MAPS; do
+ #Skip birt_i18n.map for Birt NL bundles
+ if ! ( echo $MAP | grep birt_i18n.map >/dev/null ); then
+ update_map $REPO $MAP
+ fi
+ done
+ fi
+done
+
+#echo "/bin/bash git-submission.sh $ROOT $SUBMISSION_ARGS > report.txt"
|

