Compare commits
No commits in common. "e1f937bb2ccf656136dbd29b3dc565b2c1468f87" and "64bdcfc7a94067555b5f9389802ea2449daccafd" have entirely different histories.
e1f937bb2c
...
64bdcfc7a9
103
warp4j
103
warp4j
@ -93,22 +93,6 @@ function get_this_platform() {
|
||||
esac
|
||||
}
|
||||
|
||||
# platform Machine
|
||||
X64=x64
|
||||
AARCH64=aarch64
|
||||
|
||||
# returns this platform machine
|
||||
function get_this_machine() {
|
||||
local this_machine="$(uname -m)"
|
||||
case $this_machine in
|
||||
x86_64) echo $X64 ;;
|
||||
aarch64) echo $AARCH64 ;;
|
||||
*)
|
||||
fail_with "Unsupported machine $this_machine"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# show help if no arguments specified
|
||||
if [[ $# -eq 0 ]]; then
|
||||
print_help
|
||||
@ -185,7 +169,6 @@ done
|
||||
set -- "${POSITIONAL[@]}" # restore positional arguments
|
||||
|
||||
THIS_PLATFORM=$(get_this_platform)
|
||||
THIS_MACHINE=$(get_this_machine)
|
||||
|
||||
# checks if all dependencies are available
|
||||
function check_deps() {
|
||||
@ -277,15 +260,15 @@ JAVA_DISTRO_TYPE=$(choose_distro_type)
|
||||
|
||||
# generates adoptium api url
|
||||
function api_url() {
|
||||
local platform=$1 # windows/linux/macos
|
||||
local architecture=$2
|
||||
local request=$1 # info/binary
|
||||
local platform=$2 # windows/linux/macos
|
||||
# adoptium uses "mac" instead of "macos"
|
||||
if [[ $platform == "macos" ]]; then
|
||||
platform="mac"
|
||||
fi
|
||||
|
||||
echo -n "https://api.adoptium.net/v3/assets/feature_releases/\
|
||||
$JAVA_VERSION_BASE/ga?architecture=$architecture&heap_size=normal&image_type=jdk&\
|
||||
$JAVA_VERSION_BASE/ga?architecture=x64&heap_size=normal&image_type=jdk&\
|
||||
os=$platform&page=0&page_size=20&project=$JAVA_DISTRO_TYPE&\
|
||||
sort_method=DEFAULT&sort_order=DESC&vendor=eclipse"
|
||||
|
||||
@ -294,9 +277,8 @@ sort_method=DEFAULT&sort_order=DESC&vendor=eclipse"
|
||||
# requests info about all releases for given platform and java branch
|
||||
function fetch_distro_info() {
|
||||
local platform=$1 # platform ID
|
||||
local architecture=$2
|
||||
local branch=$3 # 8/9/10/11...
|
||||
curl -s $(api_url $platform $architecture)
|
||||
local branch=$2 # 8/9/10/11...
|
||||
curl -s $(api_url info $platform)
|
||||
fail_if $? "Failed to fetch java $branch info"
|
||||
}
|
||||
|
||||
@ -326,7 +308,7 @@ function list_releases() {
|
||||
local matched
|
||||
local printed
|
||||
local platform="linux" # just picked any
|
||||
info=$(fetch_distro_info $platform $X64 $JAVA_VERSION_BASE)
|
||||
info=$(fetch_distro_info $platform $JAVA_VERSION_BASE)
|
||||
matched=$(find_matched_versions "$info" $JAVA_VERSION)
|
||||
if [[ $matched ]]; then
|
||||
echo "Releases that match $JAVA_VERSION:"
|
||||
@ -347,8 +329,8 @@ if [[ $LIST_RELEASES ]]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
JAR_FILE_BASE_NAME=$(basename -- "$JAR") # "my-app.jar"
|
||||
JAR_EXTENSION="${JAR_FILE_BASE_NAME##*.}" # "jar"
|
||||
JAR_FILE_BASE_NAME=$(basename -- "$JAR") # "my-app.jAr"
|
||||
JAR_EXTENSION="${JAR_FILE_BASE_NAME##*.}" # "jAr"
|
||||
JAR_EXTENSION_LOWERCASE=$(printf "%s" "$JAR_EXTENSION" | tr '[:upper:]' '[:lower:]') # "jar"
|
||||
JAR_NAME="${JAR_FILE_BASE_NAME%.*}" # "my-app"
|
||||
|
||||
@ -370,8 +352,7 @@ fi
|
||||
# even if this platform is not targeted, we still need
|
||||
# a JDK for this platform to optimize JDKs for other platforms
|
||||
TARGETS_TO_CACHE=${TARGETS[@]}
|
||||
if [[ $THIS_MACHINE == $X64 ]] && # if architecture is x86
|
||||
[[ $JAVA_DISTRO_TYPE == $DISTRO_TYPE_JDK ]] && # and if using JDK (not JRE)
|
||||
if [[ $JAVA_DISTRO_TYPE == $DISTRO_TYPE_JDK ]] && # if usind JDK (not JRE)
|
||||
[[ ${TARGETS[@]} != *"$THIS_PLATFORM"* ]]; then # and this platform is not targeted
|
||||
TARGETS_TO_CACHE+=($THIS_PLATFORM)
|
||||
fi
|
||||
@ -449,9 +430,8 @@ MARKER_UNPACKED="unpacked" # after runtime uncompress
|
||||
# returns latest cached version that matches version specified by user
|
||||
function find_latest_cached() {
|
||||
local platform=$1
|
||||
local architecture=$2
|
||||
local user_version=$3
|
||||
local platform_dir=$JAVA_DOWNLOAD_PATH/$platform/$architecture
|
||||
local user_version=$2
|
||||
local platform_dir=$JAVA_DOWNLOAD_PATH/$platform/
|
||||
# turning something like "11.0.1+13" into regexp like "^11\.0\.1\+13"
|
||||
local pattern="^"$(echo $user_version \
|
||||
| sed -e 's/\./\\\./g' -e 's/\+/\\\+/g')
|
||||
@ -518,11 +498,9 @@ function find_distro_link() {
|
||||
# downloads runtime distro
|
||||
function download_distro() {
|
||||
local platform=$1
|
||||
local architecture=$2
|
||||
local version=$3
|
||||
local link=$4
|
||||
local download_dir=$JAVA_DOWNLOAD_PATH/$platform/$architecture/$version
|
||||
echo "Download link: $link"
|
||||
local version=$2
|
||||
local link=$3
|
||||
local download_dir=$JAVA_DOWNLOAD_PATH/$platform/$version
|
||||
echo "Downloading $JVM_IMPL-$JAVA_DISTRO_TYPE-$version-$platform..."
|
||||
rm -rf "$download_dir"
|
||||
mkdir -p "$download_dir"
|
||||
@ -539,61 +517,55 @@ function download_distro() {
|
||||
# ensures required distro is in cache
|
||||
function ensure_distro_cached() {
|
||||
local platform=$1
|
||||
local architecture=$2
|
||||
local distro_info
|
||||
local distro_link
|
||||
if [[ -z $PULL ]]; then
|
||||
if [[ -z $JAVA_VERSION_OVERRIDEN ]]; then
|
||||
if [[ ! $(find_latest_cached $platform $architecture $LATEST_LTS) ]]; then
|
||||
distro_info=$(fetch_distro_info $platform $architecture $LATEST_LTS)
|
||||
if [[ ! $(find_latest_cached $platform $LATEST_LTS) ]]; then
|
||||
distro_info=$(fetch_distro_info $platform $LATEST_LTS)
|
||||
CONCRETE_JAVA_VERSION=$(find_latest_version "$distro_info" $LATEST_LTS)
|
||||
distro_link=$(find_distro_link "$distro_info" $CONCRETE_JAVA_VERSION)
|
||||
download_distro $platform $architecture $CONCRETE_JAVA_VERSION "$distro_link"
|
||||
download_distro $platform $CONCRETE_JAVA_VERSION "$distro_link"
|
||||
else
|
||||
CONCRETE_JAVA_VERSION=$(find_latest_cached $platform $architecture $LATEST_LTS)
|
||||
CONCRETE_JAVA_VERSION=$(find_latest_cached $platform $LATEST_LTS)
|
||||
fi
|
||||
else
|
||||
if [[ ! $(find_latest_cached $platform $architecture $JAVA_VERSION) ]]; then
|
||||
distro_info=$(fetch_distro_info $platform $architecture $JAVA_VERSION_BASE)
|
||||
if [[ ! $(find_latest_cached $platform $JAVA_VERSION) ]]; then
|
||||
distro_info=$(fetch_distro_info $platform $JAVA_VERSION_BASE)
|
||||
CONCRETE_JAVA_VERSION=$(find_latest_version "$distro_info" $JAVA_VERSION)
|
||||
distro_link=$(find_distro_link "$distro_info" $CONCRETE_JAVA_VERSION)
|
||||
download_distro $platform $architecture $CONCRETE_JAVA_VERSION "$distro_link"
|
||||
download_distro $platform $CONCRETE_JAVA_VERSION "$distro_link"
|
||||
else
|
||||
CONCRETE_JAVA_VERSION=$(find_latest_cached $architecture $platform $JAVA_VERSION)
|
||||
CONCRETE_JAVA_VERSION=$(find_latest_cached $platform $JAVA_VERSION)
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [[ -z $JAVA_VERSION ]]; then
|
||||
distro_info=$(fetch_distro_info $platform $architecture $LATEST_LTS)
|
||||
distro_info=$(fetch_distro_info $platform $LATEST_LTS)
|
||||
CONCRETE_JAVA_VERSION=$(find_latest_version "$distro_info" $LATEST_LTS)
|
||||
else
|
||||
distro_info=$(fetch_distro_info $platform $architecture $JAVA_VERSION_BASE)
|
||||
distro_info=$(fetch_distro_info $platform $JAVA_VERSION_BASE)
|
||||
CONCRETE_JAVA_VERSION=$(find_latest_version "$distro_info" $JAVA_VERSION)
|
||||
fi
|
||||
if [[ ! $(find_latest_cached $platform $architecture $CONCRETE_JAVA_VERSION) ]]; then
|
||||
if [[ ! $(find_latest_cached $platform $CONCRETE_JAVA_VERSION) ]]; then
|
||||
distro_link=$(find_distro_link "$distro_info" $CONCRETE_JAVA_VERSION)
|
||||
download_distro $platform $architecture $CONCRETE_JAVA_VERSION "$distro_link"
|
||||
download_distro $platform $CONCRETE_JAVA_VERSION "$distro_link"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# actually ensure required distro is in cache
|
||||
for target in ${TARGETS_TO_CACHE[@]}; do
|
||||
ensure_distro_cached $target $X64
|
||||
ensure_distro_cached $target
|
||||
done
|
||||
|
||||
if [[ $THIS_MACHINE == $AARCH64 ]]; then
|
||||
ensure_distro_cached $THIS_PLATFORM $AARCH64
|
||||
fi
|
||||
|
||||
UNPACKED_SUBDIR="distro"
|
||||
|
||||
# ensures required distro uncompressed
|
||||
function ensure_distro_unpacked() {
|
||||
local platform=$1
|
||||
local architecture=$2
|
||||
local version=$3
|
||||
local download_dir=$JAVA_DOWNLOAD_PATH/$platform/$architecture/$version
|
||||
local version=$2
|
||||
local download_dir=$JAVA_DOWNLOAD_PATH/$platform/$version
|
||||
local unpacked_dir=$download_dir/$UNPACKED_SUBDIR
|
||||
if [[ ! -e $download_dir/$MARKER_UNPACKED ]]; then
|
||||
echo "Uncompressing $JVM_IMPL-$JAVA_DISTRO_TYPE-$version-$platform"
|
||||
@ -644,15 +616,10 @@ function ensure_distro_unpacked() {
|
||||
|
||||
# actually ensure required distro uncompressed
|
||||
for target in ${TARGETS[@]}; do
|
||||
ensure_distro_unpacked $target $X64 $CONCRETE_JAVA_VERSION
|
||||
ensure_distro_unpacked $target $CONCRETE_JAVA_VERSION
|
||||
done
|
||||
|
||||
# actually ensure required distro for build is uncompressed when it is not x64
|
||||
if [[ $THIS_MACHINE == $AARCH64 ]]; then
|
||||
ensure_distro_unpacked $THIS_PLATFORM $AARCH64 $CONCRETE_JAVA_VERSION
|
||||
fi
|
||||
|
||||
JDK_PATH=$JAVA_DOWNLOAD_PATH/$THIS_PLATFORM/$THIS_MACHINE/$CONCRETE_JAVA_VERSION/$UNPACKED_SUBDIR
|
||||
JDK_PATH=$JAVA_DOWNLOAD_PATH/$THIS_PLATFORM/$CONCRETE_JAVA_VERSION/$UNPACKED_SUBDIR
|
||||
JLINK=$JDK_PATH/bin/jlink
|
||||
JDEPS=$JDK_PATH/bin/jdeps
|
||||
|
||||
@ -680,8 +647,7 @@ fi
|
||||
# creates minimized runtime for the platform
|
||||
function create_optimized_runtime() {
|
||||
local platform=$1
|
||||
local machine=$2
|
||||
local jmods=$JAVA_DOWNLOAD_PATH/$platform/$machine/$CONCRETE_JAVA_VERSION/$UNPACKED_SUBDIR/jmods
|
||||
local jmods=$JAVA_DOWNLOAD_PATH/$platform/$CONCRETE_JAVA_VERSION/$UNPACKED_SUBDIR/jmods
|
||||
echo "Creating minimal runtime for $platform..."
|
||||
"$JLINK" \
|
||||
--no-header-files \
|
||||
@ -689,14 +655,13 @@ function create_optimized_runtime() {
|
||||
--strip-debug \
|
||||
--module-path "$jmods" \
|
||||
--add-modules $MODULES \
|
||||
--output "$BUNDLES_PATH/$platform/$machine/$BUNDLED_DISTRO_SUBDIR"
|
||||
--output "$BUNDLES_PATH/$platform/$BUNDLED_DISTRO_SUBDIR"
|
||||
fail_if $? "Failed to optimize runtime"
|
||||
}
|
||||
|
||||
# creates warp bundle for the platform
|
||||
function create_bundle() {
|
||||
local platform=$1
|
||||
local machine=$2
|
||||
|
||||
if [[ $SILENT ]] && [[ $platform == $WIN ]]; then
|
||||
JAVA_EXEC=javaw
|
||||
@ -709,7 +674,7 @@ function create_bundle() {
|
||||
create_optimized_runtime $platform
|
||||
;;
|
||||
$DISTRO_TYPE_JRE)
|
||||
mkdir -p "$BUNDLES_PATH/$platform/$machine/$BUNDLED_DISTRO_SUBDIR"
|
||||
mkdir -p "$BUNDLES_PATH/$platform/$BUNDLED_DISTRO_SUBDIR"
|
||||
cp -r "$JAVA_DOWNLOAD_PATH/$platform/$CONCRETE_JAVA_VERSION/$UNPACKED_SUBDIR"/* \
|
||||
"$BUNDLES_PATH/$platform/$BUNDLED_DISTRO_SUBDIR"
|
||||
;;
|
||||
|
Loading…
Reference in New Issue
Block a user