forked from adoptium/aqa-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget.sh
executable file
·124 lines (106 loc) · 3.14 KB
/
get.sh
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
#!/bin/bash
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
SDKDIR=""
TESTDIR=""
PLATFORM=""
JVMVERSION=""
SDK_RESOURCE="nightly"
CUSTOMIZED_SDK_URL=""
usage ()
{
echo 'Usage : get.sh --testdir|-t openjdktestdir'
echo ' --platform|-p x64_linux | x64_mac | s390x_linux | ppc64le_linux | aarch64_linux | ppc64_aix'
echo ' --jvmversion|-v openjdk8 | openjdk8-openj9 | openjdk9 | openjdk9-openj9 | openjdk10 | openjdk10-sap'
echo ' [--sdkdir|-s binarySDKDIR] : if do not have a local sdk available, specify preferred directory'
echo ' [--sdk_resource|-r ] : indicate where to get sdk - releases, nightly , upstream or customized'
echo ' [--customizedURL|-c ] : indicate sdk url if sdk source is set as customized'
}
parseCommandLineArgs()
{
while [[ $# -gt 0 ]] && [[ ."$1" = .-* ]] ; do
opt="$1";
shift;
case "$opt" in
"--sdkdir" | "-s" )
SDKDIR="$1"; shift;;
"--testdir" | "-t" )
TESTDIR="$1"; shift;;
"--platform" | "-p" )
PLATFORM="$1"; shift;;
"--jvmversion" | "-v" )
JVMVERSION="$1"; shift;;
"--sdk_resource" | "-r" )
SDK_RESOURCE="$1"; shift;;
"--customizedURL" | "-c" )
CUSTOMIZED_SDK_URL="$1"; shift;;
"--help" | "-h" )
usage; exit 0;;
*) echo >&2 "Invalid option: ${opt}"; echo "This option was unrecognized."; usage; exit 1;
esac
done
}
getBinaryOpenjdk()
{
cd $SDKDIR
if [[ "$CUSTOMIZED_SDK_URL" == "" ]]; then
if [[ "$SDK_RESOURCE" == "nightly" || "$SDK_RESOURCE" == "releases" ]]; then
echo 'Get binary openjdk...'
mkdir openjdkbinary
download_url="https://api.adoptopenjdk.net/$JVMVERSION/$SDK_RESOURCE/$PLATFORM/latest/binary"
wgetSDK
fi
else
download_url=$CUSTOMIZED_SDK_URL
wgetSDK
fi
cd openjdkbinary
jar_file_name=`ls`
if [[ $jar_file_name == *zip || $jar_file_name == *jar ]]; then
unzip -q $jar_file_name -d .
else
echo $jar_file_name
tar -zxf $jar_file_name
fi
jarDir=`ls -d */`
dirName=${jarDir%?}
if [ "$dirName" != "j2sdk-image" ]; then
mv $dirName j2sdk-image
else
echo "dirName is equal to j2sdk-image, skip moving"
fi
}
getTestKitGen()
{
cd $TESTDIR
git clone --depth 1 https://github.com/eclipse/openj9.git
cd openj9
git filter-branch --subdirectory-filter test/TestConfig
cd $TESTDIR
mv openj9 TestConfig
}
wgetSDK()
{
wget -q --no-check-certificate --header 'Cookie: allow-download=1' ${download_url} --directory-prefix=${SDKDIR}/openjdkbinary
if [ $? -ne 0 ]; then
echo "Failed to retrieve the jdk binary, exiting"
exit 1
fi
}
parseCommandLineArgs "$@"
if [ ! -d "$TESTDIR/TestConfig" ]; then
getTestKitGen
fi
if [[ "$SDKDIR" != "" ]]; then
getBinaryOpenjdk
fi