blob: 8277ce00c7fd8c3d7fe04cdeced41905cf8ae5cc [file] [log] [blame]
#!/usr/bin/env bash
# boot strap basic variable values, to drive Eclipse Platform builds.
# we set RAWDATE first thing, just to make it more accurate of "start of build"
if [[ -z "${RAWDATE}" ]]
then
RAWDATE=$( date +%s )
export RAWDATE
fi
source "${SCRIPT_PATH}/bashUtilities.shsource"
# USAGE: fn-git-cache BUILD_ROOT
# ROOT: /shared/eclipse/builds/${major}${type}
fn-git-cache ()
{
# we (now) leave branch our of git-cache path, or else "topic branches", such as
# 'david_williams/II20130409-0900' complicates directory structure
checkNArgs $# 1
if [[ $? != 0 ]]; then return 1; fi
ROOT="$1"; shift
echo $ROOT/gitCache
}
# USAGE: fn-git-dir GIT_CACHE URL
# GIT_CACHE: /shared/eclipse/builds/R4_2_maintenance/gitCache
# URL: file:///gitroot/platform/eclipse.platform.releng.aggregator.git
fn-git-dir ()
{
checkNArgs $# 2
if [[ $? != 0 ]]; then return 1; fi
GIT_CACHE="$1"; shift
URL="$1"; shift
echo $GIT_CACHE/$( basename "$URL" .git )
}
# USAGE: fn-build-id BUILD_TYPE
# BUILD_TYPE: I, M, N, X, Y, P
fn-build-id ()
{
checkNArgs $# 1
if [[ $? != 0 ]]; then return 1; fi
BUILD_TYPE="$1"; shift
TIMESTAMP=$( date +%Y%m%d-%H%M --date='@'$RAWDATE )
echo ${BUILD_TYPE}${TIMESTAMP}
}
# USAGE: fn-build-dir ROOT BUILD_ID STREAM
# ROOT: /shared/eclipse/builds
# BUILD_ID: M20121119-1900
# STREAM: 4.3.0
fn-build-dir ()
{
checkNArgs $# 3
if [[ $? != 0 ]]; then return 1; fi
ROOT="$1"; shift
BUILD_ID="$1"; shift
STREAM="$1"; shift
eclipseStreamMajor=${STREAM:0:1}
dropDirSegment=siteDir/eclipse/downloads/drops
if (( $eclipseStreamMajor > 3 ))
then
dropDirSegment=siteDir/eclipse/downloads/drops4
fi
echo $ROOT/$dropDirSegment/$BUILD_ID
}
# if not defined "externally", we use default for eclipse.org
if [[ -z "${REPO_AND_ACCESS}" ]]
then
# unless we are on 'build' machine
if [[ "build" == "$(hostname)" ]]
then
export REPO_AND_ACCESS=file:///gitroot
else
export REPO_AND_ACCESS=git://git.eclipse.org/gitroot
fi
fi
if [[ -z "${AGGREGATOR_REPO}" ]]
then
export AGGREGATOR_REPO=${REPO_AND_ACCESS}/platform/eclipse.platform.releng.aggregator.git
fi
assertNotEmpty BUILD_ROOT
assertNotEmpty AGGREGATOR_REPO
assertNotEmpty BUILD_TYPE
assertNotEmpty STREAM
if [[ -z "${gitCache}" ]]
then
gitCache=$( fn-git-cache "${BUILD_ROOT}" )
assertNotEmpty gitCache
export gitCache
else
echo "gitCache was already defined as $gitCache"
fi
if [[ -z "${aggDir}" ]]
then
aggDir=$( fn-git-dir "$gitCache" "$AGGREGATOR_REPO" )
assertNotEmpty aggDir
export aggDir
else
echo "aggDir was already defined as $aggDir"
fi
if [[ -z "${BUILD_ID}" ]]
then
BUILD_ID=$(fn-build-id "$BUILD_TYPE" )
assertNotEmpty BUILD_ID
export BUILD_ID
else
echo "BUILD_ID was already defined as $BUILD_ID"
fi
if [[ -z "${buildDirectory}" ]]
then
buildDirectory=$( fn-build-dir "$BUILD_ROOT" "$BUILD_ID" "$STREAM" )
assertNotEmpty buildDirectory
export buildDirectory
# this should be when we first create buildDirectory
echo "Making buildDirectory: ${buildDirectory}"
mkdir -p "${buildDirectory}"
# it appears GID bit is not always set correctly, so we'll do so explicitly
chmod -c g+s "${buildDirectory}"
else
echo "buildDirectory was already defined as $buildDirectory"
fi