Skip to main content
summaryrefslogtreecommitdiffstats
blob: 8277ce00c7fd8c3d7fe04cdeced41905cf8ae5cc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/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


Back to the top