Upgrade the RAP Incubator build scripts
* Use only *one* environment initilizer script.
* Set default to Maven 3.0.4 on build server.
* Use private local Maven repository for all RAP builds.
* Add more security checks to build scripts.
diff --git a/releng/org.eclipse.rap.incubator.releng/scripts/build.sh b/releng/org.eclipse.rap.incubator.releng/scripts/build.sh
index 0f738de..5de7857 100755
--- a/releng/org.eclipse.rap.incubator.releng/scripts/build.sh
+++ b/releng/org.eclipse.rap.incubator.releng/scripts/build.sh
@@ -8,16 +8,21 @@
# initial argument checks
if [ $# -lt 1 ]
then
- echo "Usage: `basename $0` COMPONENT_NAME [M|S]"
+ echo "Usage: `basename $0` COMPONENT_NAME [N|S]"
exit 1
fi
-BUILD_TYPE=${2:-"M"}
+BUILD_TYPE=${2:-"N"}
######################################################################
# setup and initialization
-
SCRIPTS_DIR=$(dirname $(readlink -nm $0))
-test -f ${SCRIPTS_DIR}/init-functions.sh && . ${SCRIPTS_DIR}/init-functions.sh
+if [ -e "${SCRIPTS_DIR}/init-environment.sh" ]
+then
+ . ${SCRIPTS_DIR}/init-environment.sh
+else
+ echo "init-environment.sh script not found at ${SCRIPTS_DIR}"
+ exit 1
+fi
COMPONENT_NAME=${1}
REPOSITORY_NAME="org.eclipse.rap.incubator.${COMPONENT_NAME}"
@@ -31,8 +36,9 @@
fi
######################################################################
-# arbitrary checks and clean-ups
-test -d ${WORKSPACE} || exit 1
+# arbitrary checks
+# TODO mknauer - check if variable is set
+test -d "${WORKSPACE}" || exit 1
######################################################################
# configuration check and debug
@@ -66,7 +72,7 @@
BUILD_DIRECTORY=${WORKSPACE}/${REPOSITORY_NAME}/${BUILD_PROJECT_PATH}
echo "Starting build in ${BUILD_DIRECTORY}"
cd ${BUILD_DIRECTORY}
-${MVN} -e clean package -Dsign=$sign
+${MVN} -e clean package -Dsign=${sign} -Dmaven.repo.local=${MAVEN_LOCAL_REPO_PATH}
EXITCODE=$?
if [ "$EXITCODE" != "0" ]; then
echo "Maven exited with error code " + ${EXITCODE}
@@ -101,11 +107,15 @@
# clean-up target location
echo "Removing old repositories from ${COMPONENT_DIRECTORY}, keeping the ${NUM_TO_KEEP} most recent"
cd ${COMPONENT_DIRECTORY}
-while [ $(find . -maxdepth 1 -type d | grep '.*[0-9]$' | wc -l) -gt ${NUM_TO_KEEP} ]
-do
- TO_DELETE=`ls -ldtr --time-style=long-iso *[0-9] | grep '^d' | head -1 | awk '{print $8}'`
- echo "Deleting ${COMPONENT_DIRECTORY}/${TO_DELETE}"
- rm -rf ${TO_DELETE}
+II=0
+for DIR in `ls -r ${COMPONENT_DIRECTORY} | grep '.*[0-9]$'`; do
+ if [ -d ${COMPONENT_DIRECTORY}/${DIR} ]; then
+ if [ $II -ge $NUM_TO_KEEP ]; then
+ echo "Removing outdated repository ${DIR}"
+ rm -r ${COMPONENT_DIRECTORY}/${DIR} || exit 1
+ fi
+ let II=II+1;
+ fi
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
index 9e7f7f7..d7a3b7e 100755
--- a/releng/org.eclipse.rap.incubator.releng/scripts/init-environment.sh
+++ b/releng/org.eclipse.rap.incubator.releng/scripts/init-environment.sh
@@ -1,11 +1,12 @@
-# This script sets up common environment variables for the RAP builds
+# This script sets up common environment variables and defines functions
+# for the RAP builds.
echo "***********************************************************************"
export WORKSPACE=${WORKSPACE:-$PWD}
echo "Workspace location: ${WORKSPACE}"
-export MVN=${MVN:-"/opt/public/common/apache-maven-3.0.3/bin/mvn"}
+export MVN=${MVN:-"/opt/public/common/apache-maven-3.0.4/bin/mvn"}
echo "Maven path: ${MVN}"
export ECLIPSE_HOME=${ECLIPSE_HOME:-"/shared/rt/rap/build-runtimes/eclipse"}
@@ -29,3 +30,33 @@
export NUM_TO_KEEP=${NUM_TO_KEEP:-"5"}
echo "Number of p2 repositories to keep: ${NUM_TO_KEEP}"
+export MAVEN_LOCAL_REPO_PATH=${MAVEN_LOCAL_REPO_PATH:-"/shared/rt/rap/m2/repository"}
+echo "Local Maven repository location: ${MAVEN_LOCAL_REPO_PATH}"
+
+
+######################################################################
+# functions used in the build
+
+p2AddContent() {
+ if [ $# -lt 3 ]
+ then
+ echo "Usage: `p2AddContent` SOURCE_REPO TARGET_REPO REPO_NAME"
+ exit 1
+ fi
+
+ SOURCE=file://${1}
+ DESTINATION=file://${2}
+ DESTINATION_NAME="${3}"
+
+ ${ECLIPSE_HOME}/eclipse -nosplash -verbose \
+ -application org.eclipse.equinox.p2.metadata.repository.mirrorApplication \
+ -source ${SOURCE} \
+ -destination ${DESTINATION} \
+ -destinationName ${DESTINATION_NAME}
+ ${ECLIPSE_HOME}/eclipse -nosplash -verbose \
+ -application org.eclipse.equinox.p2.artifact.repository.mirrorApplication \
+ -source ${SOURCE} \
+ -destination ${DESTINATION} \
+ -destinationName ${DESTINATION_NAME}
+}
+
diff --git a/releng/org.eclipse.rap.incubator.releng/scripts/init-functions.sh b/releng/org.eclipse.rap.incubator.releng/scripts/init-functions.sh
deleted file mode 100755
index 4994e25..0000000
--- a/releng/org.eclipse.rap.incubator.releng/scripts/init-functions.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-# Functions used in the RAP build
-
-test -f ${SCRIPTS_DIR}/init-environment.sh && . ${SCRIPTS_DIR}/init-environment.sh
-
-echo "***********************************************************************"
-
-p2AddContent() {
- if [ $# -lt 2 ]
- then
- echo "Usage: `p2AddContent` SOURCE_REPO TARGET_REPO [NAME]"
- exit 1
- fi
-
- SOURCE=file://${1}
- DESTINATION=file://${2}
- DESTINATION_NAME=${3:-"A RAP p2 Repository"}
-
- ${ECLIPSE_HOME}/eclipse -nosplash -verbose \
- -application org.eclipse.equinox.p2.metadata.repository.mirrorApplication \
- -source ${SOURCE} \
- -destination ${DESTINATION} \
- -destinationName ${DESTINATION_NAME}
- ${ECLIPSE_HOME}/eclipse -nosplash -verbose \
- -application org.eclipse.equinox.p2.artifact.repository.mirrorApplication \
- -source ${SOURCE} \
- -destination ${DESTINATION} \
- -destinationName ${DESTINATION_NAME}
-}
-