2011-01-23 12:45:18 +01:00
|
|
|
#!/bin/sh
|
|
|
|
DIRECTORY=$(cd `dirname $0` && pwd)
|
|
|
|
|
2011-10-11 21:38:51 +02:00
|
|
|
BRANCHES_CHANGED=0
|
2011-01-23 12:45:18 +01:00
|
|
|
GIT_DIR="$DIRECTORY"/osmand-git
|
|
|
|
GIT_ORIGIN_NAME=origin
|
|
|
|
BUILD_DIR="$DIRECTORY"/builds
|
2011-04-20 12:17:22 +02:00
|
|
|
LATESTS_DIR="$DIRECTORY"/latests
|
2011-01-23 12:45:18 +01:00
|
|
|
VERSION_FILE=./DataExtractionOSM/src/net/osmand/Version.java
|
2011-06-07 11:34:17 +02:00
|
|
|
DATE=$(date +%Y-%m-%d)
|
2011-04-19 00:05:32 +02:00
|
|
|
SHORT_DATE=$(date +%d-%m)
|
2011-01-23 12:45:18 +01:00
|
|
|
|
|
|
|
# clean all files in build directory
|
|
|
|
rm -r "$BUILD_DIR"
|
|
|
|
mkdir "$BUILD_DIR"
|
2011-04-20 12:17:22 +02:00
|
|
|
rm -r "$LATESTS_DIR"
|
|
|
|
mkdir "$LATESTS_DIR"
|
2011-01-23 12:45:18 +01:00
|
|
|
cd "${GIT_DIR}"
|
2011-08-15 01:41:34 +02:00
|
|
|
|
|
|
|
# clear old branches
|
|
|
|
git remote prune origin
|
2011-01-23 12:45:18 +01:00
|
|
|
|
2011-08-15 01:32:30 +02:00
|
|
|
git branch -r | grep origin | while read i
|
2011-01-23 12:45:18 +01:00
|
|
|
do
|
|
|
|
cd "${GIT_DIR}"
|
|
|
|
ch=$(expr index "$i" ">")
|
|
|
|
if [ $ch = 0 ]; then
|
|
|
|
BRANCH=${i#"$GIT_ORIGIN_NAME/"}
|
2011-04-20 12:17:22 +02:00
|
|
|
git diff --exit-code "$BRANCH" "$GIT_ORIGIN_NAME/$BRANCH" --quiet
|
|
|
|
RES_DIFF=$?
|
|
|
|
if [ $RES_DIFF != 0 ]; then
|
|
|
|
echo "Checkouting branch and create build for $BRANCH"
|
|
|
|
## reset all previous changes in working tree
|
2011-10-11 21:38:51 +02:00
|
|
|
BRANCHES_CHANGED=1
|
2011-04-20 12:17:22 +02:00
|
|
|
git checkout .
|
|
|
|
git reset HEAD --hard
|
2011-06-09 04:02:29 +02:00
|
|
|
git checkout -f $BRANCH
|
2011-04-20 12:17:22 +02:00
|
|
|
git reset $GIT_ORIGIN_NAME/$BRANCH --hard
|
|
|
|
sed -e "s/\(APP_DESCRIPTION.*=.*\"\).*\(\".*\)/\1$SHORT_DATE $BRANCH\2/g" $VERSION_FILE > ${VERSION_FILE}.bak
|
|
|
|
mv ${VERSION_FILE}.bak ${VERSION_FILE}
|
2011-01-23 12:45:18 +01:00
|
|
|
|
2011-04-18 10:18:53 +02:00
|
|
|
## build map creator
|
|
|
|
cd ./DataExtractionOSM/
|
|
|
|
ant clean compile build
|
2011-04-20 12:17:22 +02:00
|
|
|
if [ "$BRANCH" = "release" ]; then
|
|
|
|
cp build.zip "$LATESTS_DIR/OsmAndMapCreator-stable.zip"
|
|
|
|
elif [ "$BRANCH" = "master" ]; then
|
|
|
|
cp build.zip "$LATESTS_DIR/OsmAndMapCreator-development.zip"
|
|
|
|
fi
|
2011-04-18 10:18:53 +02:00
|
|
|
mv build.zip "$BUILD_DIR/OsmAndMapCreator-$BRANCH-nb-$DATE.zip"
|
2011-01-23 12:45:18 +01:00
|
|
|
|
2011-04-18 10:18:53 +02:00
|
|
|
## build osmand app
|
|
|
|
cd ../OsmAnd/
|
|
|
|
cp "$DIRECTORY"/local.properties local.properties
|
|
|
|
rm -r bin
|
|
|
|
mkdir bin
|
|
|
|
if [ ! -d assets ]; then
|
|
|
|
mkdir assets
|
|
|
|
fi
|
2011-10-11 21:38:51 +02:00
|
|
|
ant clean debug
|
2011-10-11 21:09:37 +02:00
|
|
|
|
2011-04-20 12:17:22 +02:00
|
|
|
if [ "$BRANCH" = "release" ]; then
|
|
|
|
cp bin/OsmAnd-debug.apk "$LATESTS_DIR/OsmAnd-stable.apk"
|
|
|
|
elif [ "$BRANCH" = "master" ]; then
|
|
|
|
cp bin/OsmAnd-debug.apk "$LATESTS_DIR/OsmAnd-development.apk"
|
|
|
|
fi
|
2011-10-10 22:09:02 +02:00
|
|
|
mv bin/OsmAnd-debug.apk "$BUILD_DIR/OsmAnd-$BRANCH-nb-$DATE.apk"
|
|
|
|
|
|
|
|
#clear success status
|
2011-10-11 21:26:55 +02:00
|
|
|
# what is it?
|
2011-10-10 22:09:02 +02:00
|
|
|
rm -f $DIRECTORY/$BRANCH.fixed
|
|
|
|
#put the log to std out
|
|
|
|
cat $DIRECTORY/build.log
|
|
|
|
BUILD=`grep FAILED $DIRECTORY/build.log | wc -l`
|
|
|
|
if [ ! $BUILD -eq 0 ]; then
|
|
|
|
touch $DIRECTORY/$BRANCH.failed
|
|
|
|
else
|
|
|
|
if [ -f $DIRECTORY/$BRANCH.failed ]; then
|
|
|
|
echo "Build fixed"
|
|
|
|
rm $DIRECTORY/$BRANCH.failed
|
|
|
|
touch $DIRECTORY/$BRANCH.fixed
|
|
|
|
fi
|
|
|
|
fi
|
2011-04-20 12:17:22 +02:00
|
|
|
fi
|
2011-01-23 12:45:18 +01:00
|
|
|
fi
|
|
|
|
done
|
2011-10-11 21:38:51 +02:00
|
|
|
|
2011-10-11 21:56:33 +02:00
|
|
|
exit $BRANCHES_CHANGED
|