Skip to content

Commit b3807b1

Browse files
committed
make-jdk-tarball-new.sh: add parallel downloading
1 parent 970bad9 commit b3807b1

File tree

1 file changed

+28
-42
lines changed

1 file changed

+28
-42
lines changed

make-jdk-tarball-new.sh

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,52 @@
1-
#!/bin/bash
1+
#!/bin/bash -e
2+
REPO_SLUG='aarch64-port/jdk8u-shenandoah'
23
REPO='jdk'
3-
JDK_VER='8u232-ga'
4-
ICEDTEA_WEB='1.8.3'
4+
JDK_VER='8u262-b09'
5+
TAG_NAME="aarch64-shenandoah-jdk${JDK_VER}-shenandoah-merge-2020-07-03"
6+
7+
# 1: REPO_SLUG 2: i (component) 3: TAG_NAME 4: JDK_VER 5: extra wget args
8+
function download_single_comp() {
9+
echo "${2}: Downloading tarball ..."
10+
rm -f "${2}-jdk${4}.tar.gz"
11+
wget "$5" "http://hg.openjdk.java.net/${1}/${2}/archive/${3}.tar.gz" \
12+
-O "${2}-jdk${4}.tar.gz"
13+
echo "${2}: Download completed."
14+
}
515

616
function download_jdk_src() {
7-
wget http://hg.openjdk.java.net/jdk8u/jdk8u/archive/${REPO}${JDK_VER}.tar.gz \
17+
wget http://hg.openjdk.java.net/${REPO_SLUG}/archive/${TAG_NAME}.tar.gz \
818
-O jdk8u-jdk${JDK_VER}.tar.gz
919

10-
for i in corba hotspot jdk jaxws jaxp langtools nashorn; do
11-
wget http://hg.openjdk.java.net/jdk8u/jdk8u/${i}/archive/${REPO}${JDK_VER}.tar.gz \
12-
-O ${i}-jdk${JDK_VER}.tar.gz
13-
done
20+
if ! command -v parallel; then
21+
echo "[!] Not using parallel to download jdk."
22+
for i in corba hotspot jdk jaxws jaxp langtools nashorn; do
23+
download_single_comp "${REPO_SLUG}" "${i}" "${TAG_NAME}" "${JDK_VER}" "--"
24+
done
25+
else
26+
echo "[+] Using parallel to download jdk."
27+
export -f download_single_comp
28+
parallel --lb download_single_comp "${REPO_SLUG}" ::: corba hotspot jdk jaxws jaxp langtools nashorn \
29+
::: "${TAG_NAME}" ::: "${JDK_VER}" ::: "-q"
30+
fi
1431

1532
for i in *.tar.gz; do
1633
echo "Decompressing ${i}..."
1734
tar xf "$i"
1835
done
1936

20-
mv jdk8u-jdk${JDK_VER}/ openjdk-${JDK_VER}/
37+
mv "$(basename "${REPO_SLUG}")-${TAG_NAME}" openjdk-${JDK_VER}/
2138
cd openjdk-${JDK_VER}/ || exit 2
2239
for i in corba hotspot jdk jaxws jaxp langtools nashorn; do
23-
mv ../"${i}-jdk${JDK_VER}" ${i}
40+
mv ../"${i}-${TAG_NAME}" ${i}
2441
done
2542
cd .. || exit 2
2643
}
2744

28-
function guess_download_link() {
29-
cat << EOF > /tmp/fetch.js
30-
var JDK_DL_PAGE="http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html",page=require("webpage").create(),url=JDK_DL_PAGE;
31-
page.open(url,function(a){"success"!=a&&phantom.exit(1);a=page.evaluate(function(){var JDK_VER="${JDK_BIN_VER/-*/}";var b="";document.getElementById("agreementjdk-"+JDK_VER+"-oth-JPR-a").click();suffixes=["-linux-arm32-vfp-hflt.tar.gz","-linux-arm64-vfp-hflt.tar.gz","-linux-x64.tar.gz"];for(var c=0;c<suffixes.length;c++){console.log("jdk-"+JDK_VER+"-oth-JPRXXXjdk-"+JDK_VER+suffixes[c]);var a=document.getElementById("jdk-"+JDK_VER+"-oth-JPRXXXjdk-"+JDK_VER+suffixes[c]).href,b=a?b+(a+" "):b+"err "}return b});console.log("js-out: "+a);phantom.exit()});
32-
EOF
33-
phantomjs /tmp/fetch.js | grep 'js-out:' | sed 's|js-out: ||'
34-
}
35-
3645
download_jdk_src
37-
mkdir binary; cd binary
38-
39-
# disable automated extraction for now
40-
if ! which phantomjs-no > /dev/null 2>&1; then
41-
LINKS=("https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u242-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u242b08.tar.gz")
42-
LINKS=${LINKS[*]}
43-
echo "PhantomJS not found, not able to dynamically extract links. Using default links to download binaries..."
44-
else
45-
LINKS=$(guess_download_link)
46-
fi
47-
wget -c --no-cookies \
48-
${LINKS}
49-
echo "Decompressing prebuilt binaries..."
50-
tar xf OpenJDK8U-jdk_x64_linux_hotspot_*.tar.gz
51-
mv jdk8u*/ amd64/
52-
rm -rf -- *.tar.gz
53-
54-
cd .. || exit 2
55-
mv binary openjdk-${JDK_VER}/
56-
57-
wget -c "https://github.com/AdoptOpenJDK/IcedTea-Web/archive/icedtea-web-$ICEDTEA_WEB.tar.gz"
58-
tar xf "icedtea-web-$ICEDTEA_WEB.tar.gz"
59-
mv "IcedTea-Web-icedtea-web-$ICEDTEA_WEB" openjdk-${JDK_VER}/icedtea-web
6046

6147
if ! which pixz > /dev/null 2>&1; then
6248
echo "Compressing final tarball..."
63-
tar cJf openjdk-${JDK_VER/-b/b}.tar.xz openjdk-${JDK_VER}/
49+
tar cf - openjdk-${JDK_VER}/ | xz -T0 > openjdk-${JDK_VER/-b/b}.tar.xz
6450
else
6551
echo "Compressing final tarball using pixz..."
6652
tar -Ipixz -cf openjdk-${JDK_VER/-b/b}.tar.xz openjdk-${JDK_VER}/

0 commit comments

Comments
 (0)