Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 866a18a7c938758f2a768f3306f89fb5ecd0d432 (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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
#!/bin/bash
#*******************************************************************************
# Copyright (c) 2020 IBM Corporation and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
#     Sravan Kumar Lakkimsetti - initial API and implementation
#*******************************************************************************

function renamefile ()
{
  # file name is input parameter
  # if the file name ends in gif, do not rename (due to performance analysis gifs).
  if [[ ! $1 =~ .*\.gif  ]]
  then
    if [[ $1 =~ (.*)($oldlabel)(.*) ]]
    then
      echo "changing $1 to ${BASH_REMATCH[1]}$newlabel${BASH_REMATCH[3]}"
      mv "$1" "${BASH_REMATCH[1]}$newlabel${BASH_REMATCH[3]}"
    fi
  fi
}

function renameBuild ()
{
  oldname=$1
  oldlabel=$2
  newdirname=$3
  newlabel=$4
  export dirname=$5
  if [[ -z "${dirname}" ]]
  then
    export dirname=$oldname
  fi
  printf "\n\tInput to renameBuild:\n"
  printf "\t\toldname: ${oldname}\n"
  printf "\t\toldlabel: ${oldlabel}\n"
  printf "\t\tnewdirname: ${newdirname}\n"
  printf "\t\tnewlabel: ${newlabel}\n"
  printf "\t\tdirname: ${dirname}\n\n"

  echo "Renaming build $oldname to $newdirname with $newlabel"

  # save original copy, for easy "compare" or "diff"
  mkdir -p ${dirname}/ORIG
  for file in ${dirname}/buildproperties.*
  do
    cp --backup=numbered "${file}" "${dirname}/ORIG/"
  done

  fromString="EQ_BUILD_DIR_SEG = \"${oldname}\""
  toString="EQ_BUILD_DIR_SEG = \"${EQUINOX_DL_DROP_DIR_SEGMENT}\""
  replaceDirCommand="s!${fromString}!${toString}!g"
  echo "replaceDirCommand: $replaceDirCommand"
  perl -w -pi -e "${replaceDirCommand}" ${dirname}/buildproperties.php

  # ===============================
  # specific "replace" to make sure checksums URLs are correct for eclipse
  fromString="BUILD_DIR_SEG = \"${oldname}\""
  toString="BUILD_DIR_SEG = \"${ECLIPSE_DL_DROP_DIR_SEGMENT}\""
  replaceDirCommand="s!${fromString}!${toString}!g"
  echo "replaceDirCommand: $replaceDirCommand"
  perl -w -pi -e "${replaceDirCommand}" ${dirname}/buildproperties.php



  replaceDirCommand="s!/${oldname}/!/${newdirname}/!g"
  perl -w -pi -e "${replaceDirCommand}" ${dirname}/buildproperties.php

  fromString=$oldlabel
  toString=$newlabel
  replaceCommand="s!${fromString}!${toString}!g"
  perl -w -pi -e "${replaceCommand}" ${dirname}/buildproperties.php
  # ===============================
  # It appears THIS is the one required ... changing label, inside files,
  # not "directory name" as above.
  perl -w -pi -e "${replaceCommand}" ${dirname}/checksum/*

  # ===============================
  # Integration --> Stable
  # Integration --> Release Candidate
  # Integration --> Release
  # These are for cases where used in headers, titles, etc.

  OLD_BUILD_TYPE=${BUILD_TYPE}
  # ===============================
  if [[ "${oldlabel}" =~ .*RC.* ]]
  then
    oldString="Release Candidate Build"
  elif [[ "${OLD_BUILD_TYPE}" == "I" ]]
  then
    oldString="Integration Build"
  elif [[ "${OLD_BUILD_TYPE}" == "S" ]]
  then
    oldString="Stable Build"
  else
    echo -e "ERROR: Unexpected OLD_BUILD_TYPE: ${OLD_BUILD_TYPE}"
    exit 1
  fi

  if [[ "${newlabel}" =~ .*RC.* ]]
  then
    newString="Release Candidate Build"
  elif [[ "${DL_TYPE}" == "R" ]]
  then
    newString="Release Build"
  elif [[ "${DL_TYPE}" == "S" ]]
  then
    newString="Stable Build"
  else
    echo -e "ERROR: Unexpected DL_TYPE: ${DL_TYPE}"
    exit 1
  fi

  echo -e "\n\tReplacing ${oldString} with ${newString} in ${dirname}/buildproperties.php\n"

  replaceBuildNameCommand="s!${oldString}!${newString}!g"
  # quotes are critical here, since strings contain spaces!
  perl -w -pi -e "${replaceBuildNameCommand}" ${dirname}/buildproperties.php

  oldString="BUILD_TYPE = \"${OLD_BUILD_TYPE}\""
  # We export explicitly what new TYPE should be, from promoteSites.sh script.
  newString="BUILD_TYPE = \"${DL_TYPE}\""

  replaceBuildNameCommand="s!${oldString}!${newString}!g"
  # quotes are critical here, since strings contain spaces!
  perl -w -pi -e "${replaceBuildNameCommand}" ${dirname}/buildproperties.php

  oldString="BUILD_ID = \"${BUILD_LABEL}\""
  # We export explicitly what new TYPE should be, from promoteSites.sh script.
  newString="BUILD_ID = \"${DL_LABEL}\""

  replaceBuildNameCommand="s!${oldString}!${newString}!g"
  # quotes are critical here, since strings contain spaces!
  perl -w -pi -e "${replaceBuildNameCommand}" ${dirname}/buildproperties.php

  if [[ "${oldlabel}" =~ .*RC.* ]]
  then
    oldString="BUILD_TYPE_NAME = \"Release Candidate\""
  elif [[ $OLD_BUILD_TYPE == "I" ]]
  then
    oldString="BUILD_TYPE_NAME = \"Integration\""
  elif [[ $OLD_BUILD_TYPE == "S" ]]
  then
    oldString="BUILD_TYPE_NAME = \"Stable\""
  else
    echo -e "\n\tERROR: Unexpected OLD_BUILD_TYPE value. ${OLD_BUILD_TYPE}, in $0."
    exit 1
  fi

  if [[ "${newlabel}" =~ .*RC.* ]]
  then
    newString="BUILD_TYPE_NAME = \"Release Candidate\""
  elif [[ "${DL_TYPE}" == "R" ]]
  then
    newString="BUILD_TYPE_NAME = \"Release\""
  elif [[ "${DL_TYPE}" == "S" ]]
  then
    newString="BUILD_TYPE_NAME = \"Stable\""
  else
    echo -e "\n\tERROR: Unexpected DL_TYPE value, ${DL_TYPE}, in $0."
    exit 1
  fi

  echo -e "\n\tReplacing ${oldString} with ${newString} in ${dirname}/buildproperties.php\n"

  replaceBuildNameCommand="s!${oldString}!${newString}!g"
  # quotes are critical here, since strings might contain spaces!
  perl -w -pi -e "${replaceBuildNameCommand}" ${dirname}/buildproperties.php

  echo -e "\n\tMove old directory, $oldname, to new directory, $newdirname. (before file renames)\n"
  mv $oldname $newdirname

  echo -e "\n\tRename files in new directory, ./${newdirname}, to new name."
  echo -e "\tLooking for file names containing oldlabel: \"*${oldlabel}*\""
  nFiles=$(find ./${newdirname} -mindepth 1 -maxdepth 2 -name "*${oldlabel}*" -print | wc -l)
  echo -e "\n\t $nFiles files found to rename.\n"

  for file in $(find ./${newdirname} -mindepth 1 -maxdepth 2 -name "*${oldlabel}*" -print)
  do
    renamefile $file
  done
}

function createBaseBuilder ()
{
  epRelDir=$(ssh genie.releng@projects-storage.eclipse.org ls -d --format=single-column ${BUILDMACHINE_BASE_DL}/R-*|sort|tail -1)
  BASEBUILDER_DIR=${WORKSPACE}/basebuilder
  export BASEBUILDER_DIR
  mkdir -p ${BASEBUILDER_DIR}
  mkdir -p ${WORKSPACE}/tempEclipse
  pushd ${WORKSPACE}/tempEclipse
    scp genie.releng@projects-storage.eclipse.org:${epRelDir}/eclipse-platform-*-linux-gtk-x86_64.tar.gz eclipse-platform.tar.gz
    tar xvzf eclipse-platform.tar.gz
    ${WORKSPACE}/tempEclipse/eclipse/eclipse -nosplash \
        -debug -consolelog -data ${WORKSPACE}/workspace-toolsinstall \
        -application org.eclipse.equinox.p2.director \
        -repository "https://download.eclipse.org/eclipse/updates/4.15/","https://download.eclipse.org/eclipse/updates/buildtools/","https://download.eclipse.org/webtools/downloads/drops/R3.17.0/R-3.17.0-20200306035042/repositoryunittests" \
        -installIU org.eclipse.platform.ide,org.eclipse.pde.api.tools,org.eclipse.releng.build.tools.feature.feature.group,org.eclipse.wtp.releng.tools.feature.feature.group,org.apache.derby.core.feature.feature.group \
        -destination ${BASEBUILDER_DIR} \
        -profile SDKProfile
  popd
  export ECLIPSE_EXE=${BASEBUILDER_DIR}/eclipse
  rm -rf ${WORKSPACE}/tempEclipse
}

function addRepoProperties ()
{
  APP_NAME=org.eclipse.wtp.releng.tools.addRepoProperties 
  devworkspace=${devworkspace:-${WORKSPACE}/workspaceAddRepoProperties}

  REPO=$1
  REPO_TYPE=$2
  BUILD_ID=$3

  createBaseBuilder
  MIRRORURL=/eclipse/updates/${REPO_TYPE}/${BUILD_ID} 
  MIRRORURL_ARG="https://www.eclipse.org/downloads/download.php?format=xml&file=${MIRRORURL}"

  ART_REPO_NAME="Eclipse Project Repository for ${TRAIN_NAME}"
  CON_REPO_NAME="Eclipse Project Repository for ${TRAIN_NAME}"

  MIRRORS_URL_ARG=-Dp2MirrorsURL=${MIRRORURL_ARG}
  ART_REPO_ARG=-DartifactRepoDirectory=${REPO}
  CON_REPO_ARG=-DmetadataRepoDirectory=${REPO}
  ART_REPO_NAME_ARG=-Dp2ArtifactRepositoryName=\"${ART_REPO_NAME}\"
  CON_REPO_NAME_ARG=-Dp2MetadataRepositoryName=\"${CON_REPO_NAME}\"

  ${ECLIPSE_EXE} --launcher.suppressErrors -nosplash -consolelog -debug -data ${devworkspace} -application ${APP_NAME} -vmargs ${MIRRORS_URL_ARG} -Dp2ArtifactRepositoryName="${ART_REPO_NAME}" -Dp2MetadataRepositoryName="${CON_REPO_NAME}" ${ART_REPO_ARG} ${CON_REPO_ARG}
}

function createXZ
{
  BUILDMACHINE_SITE=$1

  CONTENT_JAR_FILE="${BUILDMACHINE_SITE}/content.jar"
  if [[ ! -e "${CONTENT_JAR_FILE}" ]]
  then
    echo -e "\n\tERROR: content.jar file did not exist at ${BUILDMACHINE_SITE}."
    return 1
  fi
  ARTIFACTS_JAR_FILE="${BUILDMACHINE_SITE}/artifacts.jar"
  if [[ ! -e "${ARTIFACTS_JAR_FILE}" ]]
  then
    echo -e "\n\tERROR: artifacts.jar file did not exist at ${BUILDMACHINE_SITE}."
    return 1
  fi

  # Notice we overwrite the XML files, if they already exists.
  unzip -q -o "${CONTENT_JAR_FILE}" -d "${BUILDMACHINE_SITE}"
  RC=$?
  if [[ $RC != 0 ]]
  then
    echo "ERROR: could not unzip ${CONTENT_JAR_FILE}."
    return $RC
  fi
  # Notice we overwrite the XML files, if they already exists.
  unzip -q -o "${ARTIFACTS_JAR_FILE}" -d "${BUILDMACHINE_SITE}"
  RC=$?
  if [[ $RC != 0 ]]
  then
    echo "ERROR: could not unzip ${ARTIFACTS_JAR_FILE}."
    return $RC
  fi

  CONTENT_XML_FILE="${BUILDMACHINE_SITE}/content.xml"
  ARTIFACTS_XML_FILE="${BUILDMACHINE_SITE}/artifacts.xml"
  # We will check the content.xml and artifacts.xml files really exists. In some strange world, the jars could contain something else.
  if [[ ! -e "${CONTENT_XML_FILE}" || ! -e "${ARTIFACTS_XML_FILE}" ]]
  then
    echo -e "\n\tERROR: content.xml or artifacts.xml file did not exist as expected at ${BUILDMACHINE_SITE}."
    return 1
  fi

  # finally, compress them, using "extra effort"
  # Notice we use "force" to over write any existing file, presumably there from a previous run?
  XZ_EXE=$(which xz)
  if [[ $? != 0 || -z "${XZ_EXE}" ]]
  then
    echo -e "\n\tERROR: xz executable did not exist."
    return 1
  fi
  echo -e "\n\tXZ compression of ${CONTENT_XML_FILE} ... "
  $XZ_EXE -e --force "${CONTENT_XML_FILE}"
  RC=$?
  if [[ $RC != 0 ]]
  then
    echo "ERROR: could not compress, using $XZ_EXE -e ${CONTENT_XML_FILE}."
    return $RC
  fi

  echo -e "\tXZ compression of ${ARTIFACTS_XML_FILE} ... "
  $XZ_EXE -e --force "${ARTIFACTS_XML_FILE}"
  RC=$?
  if [[ $RC != 0 ]]
  then
    echo "ERROR: could not compress, using $XZ_EXE -e ${ARTIFACTS_XML_FILE}."
    return $RC
  fi


  # Notice we just write over any existing p2.index file.
  # May want to make backup of this and other files, for production use.
  P2_INDEX_FILE="${BUILDMACHINE_SITE}/p2.index"
  echo "version=1" > "${P2_INDEX_FILE}"
  echo "metadata.repository.factory.order= content.xml.xz,content.xml,!" >> "${P2_INDEX_FILE}"
  echo "artifact.repository.factory.order= artifacts.xml.xz,artifacts.xml,!" >> "${P2_INDEX_FILE}"
  echo -e "\tCreated ${P2_INDEX_FILE}"

  return 0
}

DROP_ID=$(echo $DROP_ID|tr -d ' ')

if [[ -z "${DROP_ID}" ]]
then
  echo -e "\n\t[ERROR] DROP_ID must be defined for ${0##*/}"
  exit 1
else
  export DROP_ID
  echo -e "\n\t[INFO] DROP_ID: $DROP_ID"  
fi

# CHECKPOINT is the code for either milestone (M1, M2, ...) 
# or release candidate (RC1, RC2, ...). 
# It should be empty for the final release.
CHECKPOINT=$(echo $CHECKPOINT|tr -d ' ')
if [[ -z "${CHECKPOINT}" ]]
then
  echo -e "\n\t[WARNING] CHECKPOINT was blank in ${0##*/}"
else
  export CHECKPOINT
  echo -e "\n\t[INFO] CHECKPOINT: $CHECKPOINT"  
fi

# This SIGNOFF_BUG should not be defined, if there are no errors in JUnit tests.
SIGNOFF_BUG=$(echo $SIGNOFF_BUG|tr -d ' ')
if [[ -z "${SIGNOFF_BUG}" ]]
then
  echo -e "\n\t[WARNING] SIGNOFF_BUG was not defined. That is valid if no Unit Tests failures but otherwise should be defined."
  echo -e "\t\tCan be added by hand to buildproperties.php in drop site, if in fact there were errors, and simply forgot to specify."
else
  export SIGNOFF_BUG
  echo -e "\t\t[INFO] SIGNOFF_BUG: $SIGNOFF_BUG"
fi


TRAIN_NAME=$(echo $TRAIN_NAME|tr -d ' ')
if [[ -z "${TRAIN_NAME}" ]]
then
  echo -e "\n\t[ERROR] TRAIN_NAME must be defined for ${0##*/}"
  exit 1
else
  export TRAIN_NAME
  echo -e "\n\t[INFO] TRAIN_NAME: $TRAIN_NAME"  
fi

# STREAM is the three digit release number, such as 4.7.0 or 4.6.1.
STREAM=$(echo $STREAM|tr -d ' ')
if [[ -z "${STREAM}" ]]
then
  echo -e "\n\t[ERROR] STREAM must be defined for ${0##*/}"
  exit 1
else
  export STREAM
  echo -e "\n\t[INFO] STREAM: $STREAM"  
fi

# DL_TYPE ("download type") is the build type we are naming 
# the build *TO*
# for main line (master) code, it is always 'S' (from I-build) until it's 'R'
#export DL_TYPE=S
#export DL_TYPE=R
DL_TYPE=$(echo $DL_TYPE|tr -d ' ')
if [[ -z "${DL_TYPE}" ]]
then
  echo -e "\n\t[ERROR] DL_TYPE must be defined for ${0##*/}"
  exit 1
else
  # Could probably define default - or validate! - based on first letter of DROP_ID
  # M --> M
  # I --> S
  export DL_TYPE
  echo -e "\n\t[INFO] DL_TYPE: $DL_TYPE"  
fi

SSH_PREFIX="ssh genie.releng@projects-storage.eclipse.org"
export STAGE2DIRSEG=stage2output${TRAIN_NAME}${CHECKPOINT}
export CL_SITE=${WORKSPACE}/${STAGE2DIRSEG}
mkdir -p "${CL_SITE}"

# Main promotion scripts starts here

if [[ "${STREAM}" =~ ^([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)$ ]]
then
  export BUILD_MAJOR=${BASH_REMATCH[1]}
  export BUILD_MINOR=${BASH_REMATCH[2]}
  export BUILD_SERVICE=${BASH_REMATCH[3]}
else
  echo "STREAM must contain major, minor, and service versions, such as 4.3.0"
  echo "    but found ${STREAM}"
  exit 1
fi

# regex section
# BUILD_TYPE is the prefix of the build --
# that is, for what we are renaming the build FROM
PATTERN="^([MI])([[:digit:]]{8})-([[:digit:]]{4})$"
if [[ "${DROP_ID}" =~ $PATTERN ]]
then
  export BUILD_TYPE=${BASH_REMATCH[1]}
  export BUILD_TIMESTAMP=${BASH_REMATCH[2]}${BASH_REMATCH[3]}
  # Label and ID are the same, in this case
  export BUILD_LABEL=$DROP_ID
  export BUILD_LABEL_EQ=$DROP_ID
  export DROP_ID_EQ=$DROP_ID
else
  echo -e "\n\tERROR: DROP_ID, ${DROP_ID}, did not match any expected pattern."
  exit 1
fi

# For initial releases, do not include service in label
if [[ "${BUILD_SERVICE}" == "0" ]]
then
  export DL_LABEL=${BUILD_MAJOR}.${BUILD_MINOR}${CHECKPOINT}
else
  export DL_LABEL=${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_SERVICE}${CHECKPOINT}
fi

export DL_LABEL_EQ=${DL_LABEL}

# This is DL_DROP_ID for Eclipse. The one for equinox has DL_LABEL_EQ in middle.
export DL_DROP_ID=${DL_TYPE}-${DL_LABEL}-${BUILD_TIMESTAMP}
export DL_DROP_ID_EQ=${DL_TYPE}-${DL_LABEL_EQ}-${BUILD_TIMESTAMP}

# for I builds, stable and RCs go to in milestones
# for M builds, even RCs also go in <version>-M-builds
case ${DL_TYPE} in
  "S" )
    export REPO_SITE_SEGMENT=${BUILD_MAJOR}.${BUILD_MINOR}milestones
    if [[ "${CHECKPOINT}" =~ ^M.*$ ]]
    then
      export NEWS_ID=${BUILD_MAJOR}.${BUILD_MINOR}
    fi
    # except for RC4. Since it it intended to be "final" we include the variables
    # just like they were for an "R" build. (See bug 495252).
    # to accomidate "respins", we use a regex so that adding an "a" or "b",
    # will still match.
    RCPATH=^RC.[abcd]?$
    if [[ "${CHECKPOINT}" =~  $RCPATH ]]
    then
      export NEWS_ID=${BUILD_MAJOR}.${BUILD_MINOR}
      export ACK_ID=${BUILD_MAJOR}.${BUILD_MINOR}
      export README_ID=${BUILD_MAJOR}.${BUILD_MINOR}
    fi
    ;;
  "R" )
    export REPO_SITE_SEGMENT=${BUILD_MAJOR}.${BUILD_MINOR}
    export NEWS_ID=${BUILD_MAJOR}.${BUILD_MINOR}
    export ACK_ID=${BUILD_MAJOR}.${BUILD_MINOR}
    export README_ID=${BUILD_MAJOR}.${BUILD_MINOR}
    ;;
  *)
    echo -e "\n\tERROR: case statement for repo output did not match any pattern."
    echo -e   "\t       Not written to handle DL_TYPE of ${DL_TYPE}\n"
    exit 1
esac

export HIDE_SITE=true
# Build machine locations (would very seldom change)
export BUILD_ROOT=${BUILD_ROOT:-/home/data/httpd/download.eclipse.org}
export BUILDMACHINE_BASE_SITE=${BUILD_ROOT}/eclipse/updates/${BUILD_MAJOR}.${BUILD_MINOR}-${BUILD_TYPE}-builds

export BUILDMACHINE_BASE_DL=${BUILD_ROOT}/eclipse/downloads/drops4
export BUILDMACHINE_BASE_EQ=${BUILD_ROOT}/equinox/drops

# Eclipse Drop Site (final segment)
export ECLIPSE_DL_DROP_DIR_SEGMENT=${DL_TYPE}-${DL_LABEL}-${BUILD_TIMESTAMP}
# Equinox Drop Site (final segment)
export EQUINOX_DL_DROP_DIR_SEGMENT=${DL_TYPE}-${DL_LABEL_EQ}-${BUILD_TIMESTAMP}

export INITIAL_MAIL_LINES="We are pleased to announce that ${TRAIN_NAME} ${CHECKPOINT} is available for download and updates."
export CLOSING_MAIL_LINES="Thank you to everyone who made this checkpoint possible."

echo -e "\n\t[INFO] INITIAL_MAIL_LINES: $INITIAL_MAIL_LINES"  
echo -e "\n\t[INFO] CLOSING_MAIL_LINES: $CLOSING_MAIL_LINES"  

printf "\n\t%s\n\n" "Promoted on: $( date )" > "${CL_SITE}/checklist.txt"
printf "\n\t%20s%25s" "DROP_ID" "$DROP_ID" >> "${CL_SITE}/checklist.txt"
printf "\n\t%20s%25s" "BUILD_LABEL" "$BUILD_LABEL" >> "${CL_SITE}/checklist.txt"
printf "\n\t%20s%25s" "DROP_ID_EQ" "$DROP_ID_EQ" >> "${CL_SITE}/checklist.txt"
printf "\n\t%20s%25s" "BUILD_LABEL_EQ" "$BUILD_LABEL_EQ" >> "${CL_SITE}/checklist.txt"
printf "\n" >> "${CL_SITE}/checklist.txt"
printf "\n\t%20s%25s" "DL_TYPE" "$DL_TYPE" >> "${CL_SITE}/checklist.txt"
printf "\n\t%20s%25s" "DL_LABEL" "$DL_LABEL" >> "${CL_SITE}/checklist.txt"
printf "\n\t%20s%25s" "DL_LABEL_EQ" "$DL_LABEL_EQ" >> "${CL_SITE}/checklist.txt"
printf "\n\t%20s%25s" "ECLIPSE_DL_DROP_DIR_SEGMENT" "$ECLIPSE_DL_DROP_DIR_SEGMENT" >> "${CL_SITE}/checklist.txt"
printf "\n\t%20s%25s" "EQUINOX_DL_DROP_DIR_SEGMENT" "$EQUINOX_DL_DROP_DIR_SEGMENT" >> "${CL_SITE}/checklist.txt"
printf "\n\t%20s%25s" "REPO_SITE_SEGMENT" "$REPO_SITE_SEGMENT" >> "${CL_SITE}/checklist.txt"
printf "\n\t%20s%25s\n" "HIDE_SITE" "${HIDE_SITE}" >> "${CL_SITE}/checklist.txt"

printf "\t%s\n" "Eclipse downloads:" >> "${CL_SITE}/checklist.txt"
printf "\t%s\n\n" "https://download.eclipse.org/eclipse/downloads/drops4/${ECLIPSE_DL_DROP_DIR_SEGMENT}/" >> "${CL_SITE}/checklist.txt"

printf "\t%s\n" "Update existing (non-production) installs:" >> "${CL_SITE}/checklist.txt"
printf "\t%s\n\n" "https://download.eclipse.org/eclipse/updates/${REPO_SITE_SEGMENT}/" >> "${CL_SITE}/checklist.txt"

printf "\t%s\n" "Specific repository good for building against:" >> "${CL_SITE}/checklist.txt"
printf "\t%s\n\n" "https://download.eclipse.org/eclipse/updates/${REPO_SITE_SEGMENT}/${ECLIPSE_DL_DROP_DIR_SEGMENT}/" >> "${CL_SITE}/checklist.txt"

printf "\t%s\n" "Equinox specific downloads:" >> "${CL_SITE}/checklist.txt"
printf "\t%s\n\n" "https://download.eclipse.org/equinox/drops/${EQUINOX_DL_DROP_DIR_SEGMENT}/" >> "${CL_SITE}/checklist.txt"

# mail template

# start with empty line, and '>' to be sure re-created if exists already.
printf "\n" > "${CL_SITE}/mailtemplate.txt"

printf "\n%s\n\n" "${INITIAL_MAIL_LINES}" >> "${CL_SITE}/mailtemplate.txt"

printf "\t%s\n" "Eclipse downloads:" >> "${CL_SITE}/mailtemplate.txt"
printf "\t%s\n\n" "https://download.eclipse.org/eclipse/downloads/drops4/${ECLIPSE_DL_DROP_DIR_SEGMENT}/" >> "${CL_SITE}/mailtemplate.txt"

printf "\t%s\n" "New and Noteworthy:" >> "${CL_SITE}/mailtemplate.txt"
printf "\t%s\n\n" "https://www.eclipse.org/eclipse/news/${NEWS_ID}/" >> "${CL_SITE}/mailtemplate.txt"

printf "\t%s\n" "Update existing (non-production) installs:" >> "${CL_SITE}/mailtemplate.txt"
printf "\t%s\n\n" "https://download.eclipse.org/eclipse/updates/${REPO_SITE_SEGMENT}/" >> "${CL_SITE}/mailtemplate.txt"

printf "\t%s\n" "Specific repository good for building against:" >> "${CL_SITE}/mailtemplate.txt"
printf "\t%s\n\n" "https://download.eclipse.org/eclipse/updates/${REPO_SITE_SEGMENT}/${ECLIPSE_DL_DROP_DIR_SEGMENT}/" >> "${CL_SITE}/mailtemplate.txt"

printf "\t%s\n" "Equinox specific downloads:" >> "${CL_SITE}/mailtemplate.txt"
printf "\t%s\n\n" "https://download.eclipse.org/equinox/drops/${EQUINOX_DL_DROP_DIR_SEGMENT}/" >> "${CL_SITE}/mailtemplate.txt"

printf "\n\n%s\n" "${CLOSING_MAIL_LINES}" >> "${CL_SITE}/mailtemplate.txt"

#Take backup of current build
LOCAL_EP_DIR=${WORKSPACE}/eclipse
LOCAL_EQ_DIR=${WORKSPACE}/equinox
LOCAL_REPO=${WORKSPACE}/updates
mkdir -p ${LOCAL_EP_DIR}
mkdir -p ${LOCAL_EQ_DIR}
mkdir -p ${LOCAL_REPO}

pushd ${LOCAL_EP_DIR}
scp -r genie.releng@projects-storage.eclipse.org:${BUILDMACHINE_BASE_DL}/${DROP_ID} .
popd

pushd ${LOCAL_EQ_DIR}
scp -r genie.releng@projects-storage.eclipse.org:${BUILDMACHINE_BASE_EQ}/${DROP_ID_EQ} .
popd

pushd ${LOCAL_REPO}
scp -r genie.releng@projects-storage.eclipse.org:${BUILDMACHINE_BASE_SITE}/${DROP_ID} .
popd

# ### Begins the point of making modifications to the build ###
if [[ "${DL_TYPE}" != "R" ]]
then
  if [[ "${CHECKPOINT}" =~ $RCPATH ]]
  then
    echo -e "\$NEWS_ID = \"${BUILD_MAJOR}.${BUILD_MINOR}\";" >> "${LOCAL_EP_DIR}/${DROP_ID}/buildproperties.php"
    echo -e "\$ACK_ID = \"${BUILD_MAJOR}.${BUILD_MINOR}\";" >> "${LOCAL_EP_DIR}/${DROP_ID}/buildproperties.php"
    echo -e "\$README_ID = \"${BUILD_MAJOR}.${BUILD_MINOR}\";" >> "${LOCAL_EP_DIR}/${DROP_ID}/buildproperties.php"
  fi
else
  printf "\tINFO: %s\n" "But, we did create NEWS_ID, ACK_ID and README_ID and added to buildproperties.php, since doing Release promote."
  echo -e "\$NEWS_ID = \"${BUILD_MAJOR}.${BUILD_MINOR}\";" >> "${LOCAL_EP_DIR}/${DROP_ID}/buildproperties.php"
  echo -e "\$ACK_ID = \"${BUILD_MAJOR}.${BUILD_MINOR}\";" >> "${LOCAL_EP_DIR}/${DROP_ID}/buildproperties.php"
  echo -e "\$README_ID = \"${BUILD_MAJOR}.${BUILD_MINOR}\";" >> "${LOCAL_EP_DIR}/${DROP_ID}/buildproperties.php"
fi



# SIGNOFF_BUG should not be defined if there are no JUnit failures to investigate and explain
if [[ -n "${SIGNOFF_BUG}" ]]
then
  echo -e "<p>Any unit test failures below have been investigated and found to be test-related and do not affect the quality of the build.\nSee the sign-off page <a href=\"https://bugs.eclipse.org/bugs/show_bug.cgi?id=${SIGNOFF_BUG}\">(bug ${SIGNOFF_BUG})</a> for details.</p>" > "${LOCAL_EP_DIR}/${DROP_ID}/testNotes.html"
fi

# promote equinox
pushd ${LOCAL_EQ_DIR}

  renameBuild ${DROP_ID_EQ} ${BUILD_LABEL_EQ} ${DL_DROP_ID_EQ} ${DL_LABEL}
  if [[ "${HIDE_SITE}" == "true" ]]
  then
    touch ${DL_DROP_ID_EQ}/buildHidden
  fi

  printf "\n\t%s\n" "Promoting Equinox"
  scp -r ${LOCAL_EQ_DIR}/${DL_DROP_ID_EQ} genie.releng@projects-storage.eclipse.org:/home/data/httpd/download.eclipse.org/equinox/drops/

  if [[ "${DL_TYPE}" == "R" ]]
  then
    printf "\n\t%s\n" "Creating archive"
    scp -r ${LOCAL_EQ_DIR}/${DL_DROP_ID_EQ} genie.releng@projects-storage.eclipse.org:/home/data/httpd/archive.eclipse.org/equinox/drops/
  fi

popd

# Promote Eclipse platform
pushd ${LOCAL_EP_DIR}

  renameBuild ${DROP_ID} ${BUILD_LABEL} ${DL_DROP_ID} ${DL_LABEL}
  if [[ "${HIDE_SITE}" == "true" ]]
  then
    touch ${DL_DROP_ID}/buildHidden
  fi

  printf "\n\t%s\n" "Promoting Platform"
  scp -r ${LOCAL_EP_DIR}/${DL_DROP_ID} genie.releng@projects-storage.eclipse.org:/home/data/httpd/download.eclipse.org/eclipse/downloads/drops4/

  if [[ "${DL_TYPE}" == "R" ]]
  then
    printf "\n\t%s\n" "Creating archive"
    scp -r ${LOCAL_EP_DIR}/${DL_DROP_ID} genie.releng@projects-storage.eclipse.org:/home/data/httpd/archive.eclipse.org/eclipse/downloads/drops4/
  fi

popd


#Promote Repository
pushd ${LOCAL_REPO}
  BUILDMACHINE_SITE=${LOCAL_REPO}/${DROP_ID}
  addRepoProperties ${BUILDMACHINE_SITE} ${REPO_SITE_SEGMENT} ${DL_DROP_ID}
  createXZ ${BUILDMACHINE_SITE}
  mv ${DROP_ID} ${DL_DROP_ID}
  scp -r ${LOCAL_REPO}/${DL_DROP_ID} genie.releng@projects-storage.eclipse.org:/home/data/httpd/download.eclipse.org/eclipse/updates/${REPO_SITE_SEGMENT}
popd

Back to the top