Skip to content

Commit

Permalink
Add wget curl wrapper (#2772)
Browse files Browse the repository at this point in the history
* Add wget curl wrapper

* lint
  • Loading branch information
ddadon10 authored Nov 3, 2021
1 parent 99f89b1 commit 7ac221a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea/
*.iml
.vscode/
workspace
**/.DS_Store
Expand Down
19 changes: 17 additions & 2 deletions docker/buildDocker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,24 @@ JDK_VERSION=
JDK_MAX=
JDK_GA=

getFile() {
if [ $# -ne 2 ]; then
echo "getFile takes 2 arguments, $# argument(s) given"
echo 'Usage: getFile https://example.com file_name'
exit 1;
elif command -v wget &> /dev/null; then
wget -q "$1" -O "$2"
elif command -v curl &> /dev/null; then
curl -s "$1" -o "$2"
else
echo 'Please install wget or curl to continue'
exit 1;
fi
}

# shellcheck disable=SC2002 # Disable UUOC error
setJDKVars() {
wget -q https://api.adoptium.net/v3/info/available_releases
getFile https://api.adoptium.net/v3/info/available_releases available_releases
JDK_MAX=$(awk -F: '/tip_version/{gsub("[, ]","",$2); print$2}' < available_releases)
JDK_GA=$(awk -F: '/most_recent_feature_release/{gsub("[, ]","",$2); print$2}' < available_releases)
rm available_releases
Expand Down Expand Up @@ -100,7 +115,7 @@ useEclipseOpenJ9DockerFiles()

mkdir -p "$dockerfileDir"
cd "$dockerfileDir" || { echo "Dockerfile directory ($dockerfileDir) was not found"; exit 3; }
wget https://raw.githubusercontent.com/eclipse-openj9/openj9/master/buildenv/docker/mkdocker.sh
getFile https://raw.githubusercontent.com/eclipse-openj9/openj9/master/buildenv/docker/mkdocker.sh mkdocker.sh
chmod +x mkdocker.sh
# Generate an Ubuntu1804 Dockerfile using mkdocker.sh
"$dockerfileDir/mkdocker.sh" --dist=ubuntu --version=18 --print >> "$dockerfileDir/Dockerfile"
Expand Down
17 changes: 16 additions & 1 deletion docker/dockerfile-generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,24 @@ JDK_VERSION=8
JDK_MAX=
JDK_GA=

getFile() {
if [ $# -ne 2 ]; then
echo "getFile takes 2 arguments, $# argument(s) given"
echo 'Usage: getFile https://example.com file_name'
exit 1;
elif command -v wget &> /dev/null; then
wget -q "$1" -O "$2"
elif command -v curl &> /dev/null; then
curl -s "$1" -o "$2"
else
echo 'Please install wget or curl to continue'
exit 1;
fi
}

# shellcheck disable=SC2002 # Disable UUOC error
setJDKVars() {
wget -q https://api.adoptium.net/v3/info/available_releases
getFile https://api.adoptium.net/v3/info/available_releases available_releases
JDK_MAX=$(cat available_releases \
| grep 'tip_version' \
| cut -d':' -f 2 \
Expand Down

0 comments on commit 7ac221a

Please sign in to comment.