Skip to main content
summaryrefslogblamecommitdiffstats
blob: 405e8a34be90bee6c85e6d498d62d0c428c85c8b (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12











                                                                               
                                
































































































                                                                                             

                                                            

                                                        









                                                                 


                                          
                                            


                                                   












                                                                               
    

 
#!/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

# NOTE: if BUILD_ID is already set, we need to make sure it 
# is one of "our" BUILD_IDs,  
# since if we try to run on Hudson, it gets's Hudson's 
# version of BUILD_D which is like "2016-03-13_17-12-03"
# Therefore, we not only check "if set", we also check 
# it's format to be sure it matches the pattern we use.
# We do not expect S or R in this context
# if we ever do, it is a 3 part id, not 2 part.
# Either of the two "digits" forms should work.
#buildIdPattern="^[MNIPY][0-9]{8}-[0-9]{4}$"
buildIdPattern="^[MNIPY][[:digit:]]{8}-[[:digit:]]{4}$"

  if [[ -z "${BUILD_ID}" || ! "${BUILD_ID}" =~ $buildIdPattern ]]
  then
    BUILD_ID=$(fn-build-id "$BUILD_TYPE" )
    assertNotEmpty BUILD_ID
    export BUILD_ID
    echo "BUILD_ID was defined as $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


Back to the top