Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 25d1e5b4a47a884bbfcab2fbc2b1c9ed86ed036f (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
#!/usr/bin/env bash
#*******************************************************************************
# Copyright (c) 2016 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
#     David Williams - initial API and implementation
#*******************************************************************************
#

if [ $# -ne 1 ]; then
  echo USAGE: $0 env_file
  exit 1
fi

if [ ! -r "$1" ]; then
  echo "$1" cannot be read
  echo USAGE: $0 env_file
  exit 1
fi

source "$1"

export SCRIPT_PATH=${SCRIPT_PATH:-$(pwd)}

source $SCRIPT_PATH/build-functions.shsource

# derived values
gitCache=$( fn-git-cache "$BUILD_ROOT")
aggDir=$( fn-git-dir "$gitCache" "$AGGREGATOR_REPO" )

if [ -z "$BUILD_ID" ]; then
  BUILD_ID=$(fn-build-id "$BUILD_TYPE" )
fi

buildDirectory=$( fn-build-dir "$BUILD_ROOT" "$BUILD_ID" "$STREAM" )
basebuilderDir=$( fn-basebuilder-dir "$BUILD_ROOT" "$BUILD_ID" "$STREAM" )

$SCRIPT_PATH/getEBuilderForDropDir.sh $buildDirectory $EBUILDER_HASH

fn-checkout-basebuilder "$basebuilderDir"

launcherJar=$( fn-basebuilder-launcher "$basebuilderDir" )

EBuilderDir="${buildDirectory}/eclipse.platform.releng.aggregator/eclipse.platform.releng.tychoeclipsebuilder"

# compute update site parent directory on build server
function updateSiteParent()
{
  checkNArgs $# 3
  ROOT="$1"; shift
  BUILD_ID="$1"; shift
  STREAM="$1"; shift

  buildType=${BUILD_ID:0:1}


  # contrary to intuition (and previous behavior, bash 3.1) do NOT use quotes around right side of expression.
  if [[ "${STREAM}" =~ ^([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)$ ]]
  then
    eclipseStreamMajor=${BASH_REMATCH[1]}
    eclipseStreamMinor=${BASH_REMATCH[2]}
    eclipseStreamService=${BASH_REMATCH[3]}
  else
    echo "STREAM, $STREAM, must contain major, minor, and service versions, such as 4.3.0" >${TRACE_OUTPUT}
    return 1
  fi

  siteDir=${ROOT}/siteDir
  updatesSuffix="builds"
  siteDirParent=$siteDir/updates/${eclipseStreamMajor}.${eclipseStreamMinor}-${buildType}-${updatesSuffix}
  mkdir -p ${siteDirParent}
  RC=$?
  if [[ $RC != 0 ]]
  then
    echo "ERROR: could not create update site parent on build machine. RC: $RC" >${TRACE_OUTPUT}
    echo "       obtained error trying to create ${updateSiteParent}" >${TRACE_OUTPUT}
    return 1
  fi

  echo $siteDirParent
}


# compute update site on build server
function updateSiteOnBuildMachine()
{
  checkNArgs $# 3
  ROOT="$1"; shift
  BUILD_ID="$1"; shift
  STREAM="$1"; shift

  buildType=${BUILD_ID:0:1}


  # contrary to intuition (and previous behavior, bash 3.1) do NOT use quotes around right side of expression.
  if [[ "${STREAM}" =~ ^([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)$ ]]
  then
    eclipseStreamMajor=${BASH_REMATCH[1]}
    eclipseStreamMinor=${BASH_REMATCH[2]}
    eclipseStreamService=${BASH_REMATCH[3]}
  else
    echo "STREAM, $STREAM, must contain major, minor, and service versions, such as 4.3.0" >${TRACE_OUTPUT}
    return 1
  fi

  siteDir=${ROOT}/siteDir
  updatesSuffix="builds"
  siteDirParentOnBuildMachine=$( updateSiteParent "$BUILD_ROOT" "$BUILD_ID" "$STREAM" )
  siteDirOnBuildMachine=${siteDirParentOnBuildMachine}/${BUILD_ID}
  mkdir -p ${siteDirOnBuildMachine}
  RC=$?
  if [[ $RC != 0 ]]
  then
    echo "ERROR: could not create update site on build machine. RC: $RC" >${TRACE_OUTPUT}
    echo "       obtained error trying to create ${siteDirOnBuildMachine}" >${TRACE_OUTPUT}
    return 1
  fi

  echo $siteDirOnBuildMachine
}

siteDirOnBuildMachine=$( updateSiteOnBuildMachine "$BUILD_ROOT" "$BUILD_ID" "$STREAM" )
echo "siteDirOnBuildMachine: ${siteDirOnBuildMachine}"
repositoryDir=${buildDirectory}/repository
echo "repositoryDir: ${repositoryDir}"

# leave both old and new methods for now, so true (1) ==> old straight copy.
# change to false (0) to test new method.
if (( 1 ))
then
  DO_NOT_MIRROR_IN_ASSEMBLY="-DdoNotMirror=true"
  # for now, straight copy from what was produced to local build machine directory.
  # This is partially done so that
  #   rest of scripts stay common
  #   but eventually, we might put in some mirror/comparator/remove tasks here.

  # NOTE: we are using the "safe copy" we put in drop directory on build machine.

  # make posiitive ${repositoryDir} is not empty, or we are basically copying
  # all of root! (and, if repositoryDir is empty if we had a failed build!
  # and should not be calling this method, anyway.)
  if [[ -n "${repositoryDir}" && -d "${repositoryDir}" && -n "${siteDirOnBuildMachine}" && -d "${siteDirOnBuildMachine}" ]]
  then
    rsync --times --omit-dir-times --recursive "${repositoryDir}/" "${siteDirOnBuildMachine}/"
    RC=$?
    if [[ $RC != 0 ]]
    then
      echo "ERROR: rsync of repo returned error. RC: $RC"
      echo "       obtained while copying"
      echo "       from ${repositoryDir}"
      echo "       to ${siteDirOnBuildMachine}"
      exit $RC
    fi

  else
    echo "ERROR: Some directory didn't exist for update site copy."
    echo "  repositoryDir: ${repositoryDir}"
    echo "  siteDirOnBuildMachine: ${siteDirOnBuildMachine}"
    exit $RC
  fi

fi

#TODO: the "logic" needs some TLC
# In master, we should not need DO_PATH or DO_REMOVE.
# See patch streams for when/why that might change for patches.
# But we will be sure defined empty by default, since used later in some calls.
DO_PACK=""
DO_REMOVE=""

#DO_PACK="-DdoPack=false"

# In some cases, we do not want to remove "categories", see bug 428099.
#if [[ -n "${PATCH_BUILD}" ]]
#then
#    DO_REMOVE="-DdoNotRemove=true"
#fi

java -Djava.io.tmpdir=$TMP_DIR -jar "$launcherJar" \
  -data ${buildDirectory}/workspace-processArtifacts \
  -application org.eclipse.ant.core.antRunner \
  -v \
  -buildfile "${EBuilderDir}/eclipse/buildScripts/process-artifacts.xml" \
  -DrepositoryDir=${repositoryDir} ${DO_REMOVE} ${DO_PACK} \
  -Dbuildlogs=$logsDirectory/comparatorlogs \
  -DsiteDirOnBuildMachine=$siteDirOnBuildMachine \
  -DcomparatorRepository=$comparatorRepository \
  -Djava.io.tmpdir=$TMP_DIR ${DO_NOT_MIRROR_IN_ASSEMBLY}

RC=$?
if [[ $RC != 0 ]]
then
  echo "ERROR: java invocation to process-artifacts did not return normally: $RC"
  exit $RC
fi


# If doing a "patch build", a "site.xml" is created,
# so a) we'll remove that that, to avoid confusion, and
# b) we must call "process-artifacts again, so this version
# has packgz files. (i.e. Tycho isn't doing it for us).
if [[ -n "${PATCH_BUILD}" ]]
then

  # no longer needed, will remove
#  rm "${siteDirOnBuildMachine}/site.xml"
#  RC=$?
#  if [[ $RC != 0 ]]
#  then
#    echo "ERROR: did not remove 'site.xml' as expected. RC: $RC"
#    #exit $RC
#  fi

  # before we created pack.gz files, we'll create zip file, of archive for
  # DL page ... and those zip files best without pack.gz files, since they
  # are not used if using local zip archive, so are "wasted" there.
  pushd ${siteDirOnBuildMachine}
  zipfile=${PATCH_BUILD}-${BUILD_ID}-repository.zip
  zip -r ${buildDirectory}/${zipfile}  .
  # I guess created after "publish"? The checksums are not created, so we'll just create 
  # them directly. (Note, adding 256, since we will do that for all, in future, so 
  # do not want to forget.
  pushd ${buildDirectory}
  echo [md5] ${zipfile}
  md5sum -b ${zipfile} > checksum/${zipfile}.md5
  echo [sha1] ${zipfile}
  sha1sum -b ${zipfile} > checksum/${zipfile}.sha1
  echo [sha256] ${zipfile}
  sha256sum -b ${zipfile} > checksum/${zipfile}.sha256
  echo [sha512] ${zipfile}
  sha512sum -b ${zipfile} > checksum/${zipfile}.sha512
  popd
  popd

  #    if [[ -n "${PATCH_BUILD}" ]]
  #    then
  #        # nothing to remove for patch builds, for now, and we
  #        # do not want to remove the category we put there intentionally.
  #        DO_REMOVE="-DdoNotRemove=true"
  #        # https://bugs.eclipse.org/bugs/show_bug.cgi?id=427873
  #        # uses 'false' for now.
  #        DO_PACK="-DdoPack=false"
  #    fi
  #
  #    java -Djava.io.tmpdir=$TMP_DIR -jar "$launcherJar" \
    #        -data ${buildDirectory}/workspace-processArtifacts2 \
    #        -application org.eclipse.ant.core.antRunner \
    #        -v \
    #        -buildfile "${EBuilderDir}/eclipse/buildScripts/process-artifacts.xml" \
    #        -DrepositoryDir=${repositoryDir} ${DO_REMOVE} ${DO_PACK} \
    #        -Dbuildlogs=$logsDirectory/comparatorlogs \
    #        -DsiteDirOnBuildMachine=$siteDirOnBuildMachine \
    #        -DcomparatorRepository=$comparatorRepository \
    #        -Djava.io.tmpdir=$TMP_DIR ${DO_NOT_MIRROR_IN_ASSEMBLY}
  #
  #    RC=$?
  #    if [[ $RC != 0 ]]
  #    then
  #        echo "ERROR: java invocation to process-artifacts did not return normally: $RC"
  #        #exit $RC
  #    fi

  # == I do not see a need for this? dw 6/3/2016
  # == BUT, if needed, need to "mkdir" first! 
  # Make composite directly on build machine, for patches only
  # repodir is absolute path to composite repository,
  # complocation is the (relative) child repository (usually direcotry named 'buildId')
  # site parent is "one up" from siteDirOnBuildMachine.
  #siteDirParentOnBuildMachine=$( updateSiteParent "$BUILD_ROOT" "$BUILD_ID" "$STREAM" )
  #java -Djava.io.tmpdir=$TMP_DIR -jar "$launcherJar" \
  #  -data ${buildDirectory}/workspace-makeComposite \
  #  -application org.eclipse.ant.core.antRunner \
  #  -v \
  #  -buildfile "${EBuilderDir}/eclipse/buildScripts/addToComposite.xml" \
  #  -Drepodir=${siteDirParentOnBuildMachine}  \
  #  -Dcomplocation=${BUILD_ID}

  #RC=$?
  #if [[ $RC != 0 ]]
  #then
  #  echo "ERROR: java invocation to process-artifacts did not return normally: $RC"
    #exit $RC
  #fi

fi

exit 0

Back to the top