Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 98c76bdc9034a2bf8d70f7c1eb9b7e6c204114ec (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
#!/usr/bin/env bash
#*******************************************************************************
# Copyright (c) 2017 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
#*******************************************************************************
#
# this localBuildProperties.shsource file is to ease local builds to
# override some variables.
# It should not be used for production builds.
source localBuildProperties.shsource 2>/dev/null

echo "[DEBUG] Producing checksums starting"
echo "[DEBUG] current directory: ${PWD}"
if [[ -z "${SCRIPT_PATH}" ]]
then
  echo -e "\n\tWARNING: SCRIPT_PATH not defined in ${0##*/}"
else
  source "${SCRIPT_PATH}/bashUtilities.shsource"
  checkSumStart="$(date +%s )"
fi

# This checkSums script is called twice, once while publishing Eclipse DL site, again
# when publishing Equinox DL site. We use a simple heuristic to
# make use of "eclipse" or "equinox".
# TODO: better design to require it to be passed in?
currentDirectory="${PWD}"
equinoxPattern="^.*equinox.*$"
eclipsePattern="^.*eclipse.*$"
if [[ "${currentDirectory}" =~ $equinoxPattern ]]
then
  client="equinox"
elif [[ "${currentDirectory}" =~ $eclipsePattern ]]
then
  client="eclipse"
else
  echo -e "\n\t[ERROR]: Unknown client: ${client} in ${0##*/}\n"
  exit 1
fi

allCheckSumsSHA256=checksum/${client}-${BUILD_ID}-SUMSSHA256
allCheckSumsSHA512=checksum/${client}-${BUILD_ID}-SUMSSHA512

#  Remove the "all" files, here at beginning if they all ready exist,
#  so that subsequent calls can all use append (i.e. ">>")

if [[ -e ${allCheckSumsSHA256} ]]
then
  rm ${allCheckSumsSHA256}
fi
if [[ -e ${allCheckSumsSHA512} ]]
then
  rm ${allCheckSumsSHA512}
fi

#array of zipfiles
zipfiles=`ls *.zip`

for zipfile in ${zipfiles}
do
  # There is one zip file to not list, eclipse.platform.releng.aggregator-<hash>.zip, which is merely
  # a collected utility scripts used to run unit tests.
  aggrPattern="^eclipse.platform.releng.aggregator.*.zip$"
  if [[ ! "${zipfile}" =~ $aggrPattern ]]
  then
    echo [sha256] ${zipfile}
    sha256sum -b ${zipfile} | tee checksum/${zipfile}.sha256 >>${allCheckSumsSHA256}
    echo [sha512] ${zipfile}
    sha512sum -b ${zipfile} | tee checksum/${zipfile}.sha512  >>${allCheckSumsSHA512}
  fi
done

#array of dmgfiles
dmgfiles=`ls *.dmg`

for dmgfile in ${dmgfiles}
do
  echo [sha256] ${dmgfile}
  sha256sum -b ${dmgfile} | tee checksum/${dmgfile}.sha256  >>${allCheckSumsSHA256}
  echo [sha512] ${dmgfile}
  sha512sum -b ${dmgfile} | tee checksum/${dmgfile}.sha512  >>${allCheckSumsSHA512}
done

#array of tar.gzip files
gzipfiles=`ls *.gz`

for gzipfile in ${gzipfiles}
do
  echo [sha256] ${gzipfile}
  sha256sum -b ${gzipfile} | tee checksum/${gzipfile}.sha256 >>${allCheckSumsSHA256}
  echo [sha512] ${gzipfile}
  sha512sum -b ${gzipfile} | tee checksum/${gzipfile}.sha512 >>${allCheckSumsSHA512}
done


#array of .jar files
jarfiles=`ls *.jar`

for jarfile in ${jarfiles}
do
  echo [sha256] ${jarfile}
  sha256sum -b ${jarfile} | tee checksum/${jarfile}.sha256 >>${allCheckSumsSHA256}
  echo [sha512] ${jarfile}
  sha512sum -b ${jarfile} | tee checksum/${jarfile}.sha512 >>${allCheckSumsSHA512}
done

# We'll always try to sign checksum files, if passphrase file exists
echo "[DEBUG] Producing GPG signatures starting."
# We make double use of the "client". One to simplify signing script. Second to identify times in timefile.
# remember, this "HOME" is for genie.releng for production builds.
key_passphrase_file=${key_passphrase_file:-${HOME}/${client}-dev.passphrase}
if [[ -r $key_passphrase_file ]]
then
  signer=${signer:-${client}-dev@eclipse.org}
  signature_file256=${allCheckSumsSHA256}.asc
  signature_file512=${allCheckSumsSHA512}.asc
  fileToSign256=${allCheckSumsSHA256}
  fileToSign512=${allCheckSumsSHA512}

  cat ${key_passphrase_file} | gpg --local-user ${signer} --sign --armor --output ${signature_file256} --batch --yes --passphrase-fd 0 --detach-sig ${fileToSign256}
  cat ${key_passphrase_file} | gpg --local-user ${signer} --sign --armor --output ${signature_file512} --batch --yes --passphrase-fd 0 --detach-sig ${fileToSign512}
else
  # We don't treat as ERROR since would be normal in a "local build".
  # But, would be an ERROR in production build so could be improved.
  echo -e "\n\t[WARNING] The key_passphrase_file did not exist or was not readable.\n"
fi
# if SCRIPT_PATH not defined, we can not call elapsed time
if [[ -n "${SCRIPT_PATH}" ]]
then
  checkSumEnd="$(date +%s )"
  elapsedTime $checkSumStart $checkSumEnd "${client} Elapsed Time computing checksums"
fi
echo "[DEBUG] Producing checksums ended normally"

Back to the top