aboutsummaryrefslogtreecommitdiff
path: root/.github/scripts/prepare_JREs.sh
blob: b85e9c2f3a6d38e595d6f59e37e640ab1146e989 (plain)
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
#!/usr/bin/env bash

URL_JDK8="https://api.adoptium.net/v3/binary/latest/8/ga/linux/x64/jre/hotspot/normal/eclipse"
URL_JDK17="https://api.adoptium.net/v3/binary/latest/17/ga/linux/x64/jre/hotspot/normal/eclipse"

mkdir -p JREs
pushd JREs

wget --content-disposition "$URL_JDK8"
wget --content-disposition "$URL_JDK17"

for file in *;
do
    mkdir temp

    re='(OpenJDK([[:digit:]]+)U-jre_x64_linux_hotspot_([[:digit:]]+)(.*).tar.gz)'
    if [[ $file =~ $re ]];
    then
        version_major=${BASH_REMATCH[2]}
        version_trailing=${BASH_REMATCH[4]}

        if [ $version_major = 17 ];
        then
            hyphen='-'
        else
            hyphen=''
        fi

        version_edit=$(echo $version_trailing | sed -e 's/_/+/g' | sed -e 's/b/-b/g')
        dir_name=jdk$hyphen$version_major$version_edit-jre
        mkdir jre$version_major
        tar -xzf $file -C temp
        pushd temp/$dir_name
        cp -r . ../../jre$version_major
        popd
    fi

    rm -rf temp
done

popd