Add new incubator build scripts
* build.sh - master build script for all incubator components
* init-environment.sh - environment definitions
* init-functions.sh - common functions
diff --git a/releng/org.eclipse.rap.incubator.releng/scripts/build.sh b/releng/org.eclipse.rap.incubator.releng/scripts/build.sh
new file mode 100755
index 0000000..77002ca
--- /dev/null
+++ b/releng/org.eclipse.rap.incubator.releng/scripts/build.sh
@@ -0,0 +1,112 @@
+#!/bin/bash
+#
+# General build script for all RAP Incubator builds
+#
+#set -x
+
+######################################################################
+# initial argument checks
+if [ $# -lt 2 ]
+then
+ echo "Usage: `basename $0` GIT_REPOSITORY_NAME RELENG_PROEJCT_PATH [M|S]"
+ exit 1
+fi
+export BUILD_TYPE=${3:-"M"}
+
+######################################################################
+# setup and initialization
+
+SCRIPTS_DIR=$(dirname $(readlink -nm $0))
+test -f ${SCRIPTS_DIR}/init-environment.sh && . ${SCRIPTS_DIR}/init-environment.sh
+test -f ${SCRIPTS_DIR}/init-functions.sh && . ${SCRIPTS_DIR}/init-functions.sh
+
+REPOSITORY_NAME=${1}
+BUILD_PROJECT_PATH=${2}
+
+if [ "${BUILD_TYPE}" == "S" ]; then
+ SIGN=true
+else
+ SIGN=false
+fi
+
+######################################################################
+# arbitrary checks and clean-ups
+test -d ${WORKSPACE} || exit 1
+
+######################################################################
+# configuration check and debug
+echo "Git repository name: ${REPOSITORY_NAME}"
+echo "Build project path: ${BUILD_PROJECT_PATH}"
+echo "Build type: ${BUILD_TYPE}"
+echo "Signing enabled: ${SIGN}"
+
+######################################################################
+# git clone build repository
+RELENG_REPOSITORY_NAME="org.eclipse.rap.incubator.releng"
+REPOSITORY=${GIT_INCUBATOR_BASE}/${RELENG_REPOSITORY_NAME}
+echo "Git clone of releng repository ${REPOSITORY} into ${WORKSPACE}"
+cd ${WORKSPACE}
+rm -rf ${WORKSPACE}/${RELENG_REPOSITORY_NAME:-"DUMMYDIRECTORY"}
+git clone --branch=${GIT_BRANCH} ${REPOSITORY} ${RELENG_REPOSITORY_NAME}
+
+######################################################################
+# git clone
+REPOSITORY=${GIT_INCUBATOR_BASE}/${REPOSITORY_NAME}
+echo "Git clone of ${REPOSITORY} into ${WORKSPACE}"
+cd ${WORKSPACE}
+rm -rf ${WORKSPACE}/${REPOSITORY_NAME:-"DUMMYDIRECTORY"}
+git clone --branch=${GIT_BRANCH} ${REPOSITORY} ${REPOSITORY_NAME}
+
+######################################################################
+# execute build
+BUILD_DIRECTORY=${WORKSPACE}/${REPOSITORY_NAME}/${BUILD_PROJECT_PATH}
+echo "Starting build in ${BUILD_DIRECTORY}"
+cd ${BUILD_DIRECTORY}
+${MVN} -e clean package -Dsign=$sign
+EXITCODE=$?
+if [ "$EXITCODE" != "0" ]; then
+ echo "Maven exited with error code " + ${EXITCODE}
+ exit ${EXITCODE}
+fi
+
+######################################################################
+# extract build timestamp
+## TODO mknauer Find a better way to determine the TIMESTAMP
+REPOSITORY_DIRECTORY=${WORKSPACE}/${REPOSITORY_NAME}/${BUILD_PROJECT_PATH}/repository/target/repository
+VERSION=$(ls ${REPOSITORY_DIRECTORY}/features/org.eclipse.rap.*.feature_*.jar | sed 's/.*_\([0-9.-]\+\)\..*\.jar/\1/')
+TIMESTAMP=$(ls ${REPOSITORY_DIRECTORY}/features/org.eclipse.rap.*.feature_*.jar | sed 's/.*\.\([0-9-]\+\)\.jar/\1/')
+echo "Version is ${VERSION}"
+echo "Timestamp is ${TIMESTAMP}"
+test -n "${VERSION}" || exit 1
+test -n "${TIMESTAMP}" || exit 1
+
+######################################################################
+# copy repository to target location
+COMPONENT_NAME=$(echo ${REPOSITORY_NAME} | sed 's/.*\.incubator\.\(.*\)/\1/')
+test -n "${COMPONENT_NAME}" || exit 1
+COMPONENT_DIRECTORY=${REPOSITORY_BASE_PATH}/${COMPONENT_NAME}
+echo "Copy new ${TIMESTAMP} repository of ${COMPONENT_NAME} to ${COMPONENT_DIRECTORY}"
+mkdir -p ${COMPONENT_DIRECTORY}
+cp -a ${REPOSITORY_DIRECTORY} ${COMPONENT_DIRECTORY}/${TIMESTAMP}
+
+######################################################################
+# clean-up target location
+cd ${COMPONENT_DIRECTORY}
+echo "Removing old repositories from ${COMPONENT_DIRECTORY}, keeping the ${NUM_TO_KEEP} most recent"
+while [ $(find . -maxdepth 1 -type d | grep '.*[0-9]$' | wc -l) -gt ${NUM_TO_KEEP} ]
+do
+ TO_DELETE=`ls -ldrt --time-style=long-iso *[0-9] | grep '^d' | head -1 | awk '{print $8}'`
+ echo "Deleting ${COMPONENT_DIRECTORY}/${TO_DELETE}"
+ rm -rf $TO_DELETE
+done
+
+######################################################################
+# create final p2 repository
+## TODO mknauer Replace this with a more sophisticated implementation as soon as we have constant qualifiers
+cd ${COMPONENT_DIRECTORY}
+echo "Creating p2 repository in ${COMPONENT_DIRECTORY}"
+rm -rf content.jar artifact.jar plugins/ features/
+for II in [0-9]*-[0-9]*; do
+ echo "Adding data from ${II}"
+ p2AddContent ${COMPONENT_DIRECTORY}/${II} ${COMPONENT_DIRECTORY}
+done
diff --git a/releng/org.eclipse.rap.incubator.releng/scripts/init-environment.sh b/releng/org.eclipse.rap.incubator.releng/scripts/init-environment.sh
new file mode 100755
index 0000000..08d1f0a
--- /dev/null
+++ b/releng/org.eclipse.rap.incubator.releng/scripts/init-environment.sh
@@ -0,0 +1,29 @@
+# This script sets up common environment variables for the RAP builds
+
+export WORKSPACE=${WORKSPACE:-$PWD}
+echo "Workspace location: ${WORKSPACE}"
+
+export MVN=${MVN:-"/opt/public/common/apache-maven-3.0.3/bin/mvn"}
+echo "Maven path: ${MVN}"
+
+export ECLIPSE_HOME=${ECLIPSE_HOME:-"/shared/rt/rap/build-runtimes/eclipse-3.6.2"}
+echo "Eclipse location: ${ECLIPSE_HOME}"
+
+export SIGNING_LOCATION=${SIGNING_LOCATION:-"/opt/public/download-staging.priv/rt/rap"}
+echo "Signing location: ${SIGNING_LOCATION}"
+
+export GIT_BASE=${GIT_BASE:-"git://git.eclipse.org/gitroot/rap"}
+echo "Git base URL: ${GIT_BASE}"
+
+export GIT_INCUBATOR_BASE=${GIT_INCUBATOR_BASE:-"${GIT_BASE}/incubator"}
+echo "Git incubator base URL: ${GIT_INCUBATOR_BASE}"
+
+export GIT_BRANCH=${GIT_BRANCH:-"master"}
+echo "Git branch: ${GIT_BRANCH}"
+
+export REPOSITORY_BASE_PATH=${REPOSITORY_BASE_PATH:-"/shared/rt/rap"}
+echo "p2 repository base path: ${REPOSITORY_BASE_PATH}"
+
+export NUM_TO_KEEP=${NUM_TO_KEEP:-"5"}
+echo "Number of p2 repositories to keep: ${NUM_TO_KEEP}"
+
diff --git a/releng/org.eclipse.rap.incubator.releng/scripts/init-functions.sh b/releng/org.eclipse.rap.incubator.releng/scripts/init-functions.sh
new file mode 100644
index 0000000..b73d36f
--- /dev/null
+++ b/releng/org.eclipse.rap.incubator.releng/scripts/init-functions.sh
@@ -0,0 +1,24 @@
+# Functions used in the RAP build
+
+test -f ${SCRIPTS_DIR}/init-environment.sh && . ${SCRIPTS_DIR}/init-environment.sh
+
+p2AddContent() {
+ if [ $# -lt 2 ]
+ then
+ echo "Usage: `p2AddContent` SOURCE_REPO TARGET_REPO"
+ exit 1
+ fi
+
+ SOURCE=file://${1}
+ DESTINATION=file://${2}
+
+ ${ECLIPSE_HOME}/eclipse -nosplash -verbose \
+ -application org.eclipse.equinox.p2.metadata.repository.mirrorApplication \
+ -source ${SOURCE} \
+ -destination ${DESTINATION}
+ ${ECLIPSE_HOME}/eclipse -nosplash -verbose \
+ -application org.eclipse.equinox.p2.artifact.repository.mirrorApplication \
+ -source ${SOURCE} \
+ -destination ${DESTINATION}
+}
+