sdkman / sdkman-disco-integration

10 stars 11 forks source link

Bug: Error in format of downloading and installing Liberica NIK Java SDK zip package #6

Closed nibocn closed 1 year ago

nibocn commented 1 year ago

Bug report

Using the command sdk install java 22.3.r11-nik to install Java SDK, the failure prompt is shown at the end:

Download has failed, aborting!

Can not install java 22.3.r11-nik at this time...

To reproduce

  1. Execute the command sdk install java 22.3.r11-nik;

System info

macOS Monterey 12.6.3 (21G419)

zsh 5.9 (x86_64-apple-darwin21.3.0)

SDKMAN! script: 5.18.1 native: 0.2.2

Debug mode log information From the final log information, it appears that the /Users/richard/.sdkman/tmp/hook_post_java_22.3.r11-nik.sh script verifies the format of the downloaded package and terminates execution if the format of the downloaded package does not match.

verification code:

function __sdkman_validate_binary_input {
    if ! tar tzf "$1" &> /dev/null; then
        echo "Download has failed, aborting!"
        echo ""
        echo "Can not install java 22.3.r11-nik at this time..."
        return 1
    fi
}

debug info:

Validate java 22.3.r11-nik for darwinx64: valid
Validation URL: https://api.sdkman.io/2/candidates/validate/java/22.3.r11-nik/darwinx64
Get pre-installation hook: https://api.sdkman.io/2/hooks/pre/java/22.3.r11-nik/darwinx64
Copy remote pre-installation hook: /Users/richard/.sdkman/tmp/hook_pre_java_22.3.r11-nik.sh
No macOS 64bit pre-install hook found for Java 22.3.r11-nik.
Completed pre-installation hook...

Downloading: java 22.3.r11-nik

In progress...

#################################################################################################################################################################################################################### 100.0%*   Trying 45.55.42.78:443...
* Connected to api.sdkman.io (45.55.42.78) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* (304) (OUT), TLS handshake, Client hello (1):
} [318 bytes data]
* (304) (IN), TLS handshake, Server hello (2):
{ [122 bytes data]
* (304) (IN), TLS handshake, Unknown (8):
{ [25 bytes data]
* (304) (IN), TLS handshake, Certificate (11):
{ [4578 bytes data]
* (304) (IN), TLS handshake, CERT verify (15):
{ [264 bytes data]
* (304) (IN), TLS handshake, Finished (20):
{ [52 bytes data]
* (304) (OUT), TLS handshake, Finished (20):
} [52 bytes data]
* SSL connection using TLSv1.3 / AEAD-AES256-GCM-SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: CN=*.sdkman.io
*  start date: Apr 10 00:00:00 2022 GMT
*  expire date: Apr 28 23:59:59 2023 GMT
*  subjectAltName: host "api.sdkman.io" matched cert's "*.sdkman.io"
*  issuer: C=GB; ST=Greater Manchester; L=Salford; O=Sectigo Limited; CN=Sectigo RSA Domain Validation Secure Server CA
*  SSL certificate verify ok.
> GET /2/broker/download/java/22.3.r11-nik/darwinx64 HTTP/1.1
> Host: api.sdkman.io
> Range: bytes=282468529-
> User-Agent: curl/7.79.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Found
< Server: nginx/1.19.10
< Date: Fri, 07 Apr 2023 01:58:38 GMT
< Content-Length: 0
< Connection: keep-alive
< X-Sdkman-ArchiveType: zip
< location: https://download.bell-sw.com/vm/22.3.0/bellsoft-liberica-vm-openjdk11.0.17+7-22.3.0+2-macos-amd64.zip
<
* Connection #0 to host api.sdkman.io left intact
* Issue another request to this URL: 'https://download.bell-sw.com/vm/22.3.0/bellsoft-liberica-vm-openjdk11.0.17+7-22.3.0+2-macos-amd64.zip'
*   Trying 2606:4700::6812:b3:443...
*   Trying 104.18.0.179:443...
* Connected to download.bell-sw.com (2606:4700::6812:b3) port 443 (#1)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* (304) (OUT), TLS handshake, Client hello (1):
} [325 bytes data]
* (304) (IN), TLS handshake, Server hello (2):
{ [122 bytes data]
* (304) (IN), TLS handshake, Unknown (8):
{ [19 bytes data]
* (304) (IN), TLS handshake, Certificate (11):
{ [4675 bytes data]
* (304) (IN), TLS handshake, CERT verify (15):
{ [264 bytes data]
* (304) (IN), TLS handshake, Finished (20):
{ [52 bytes data]
* (304) (OUT), TLS handshake, Finished (20):
} [52 bytes data]
* SSL connection using TLSv1.3 / AEAD-AES256-GCM-SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=*.bell-sw.com
*  start date: Nov  3 00:00:00 2022 GMT
*  expire date: Dec  4 23:59:59 2023 GMT
*  subjectAltName: host "download.bell-sw.com" matched cert's "*.bell-sw.com"
*  issuer: C=GB; ST=Greater Manchester; L=Salford; O=Sectigo Limited; CN=Sectigo RSA Domain Validation Secure Server CA
*  SSL certificate verify ok.
* Using HTTP2, server supports multiplexing
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7fe772812000)
> GET /vm/22.3.0/bellsoft-liberica-vm-openjdk11.0.17+7-22.3.0+2-macos-amd64.zip HTTP/2
> Host: download.bell-sw.com
> range: bytes=282468529-
> user-agent: curl/7.79.1
> accept: */*
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 256)!
< HTTP/2 416
< date: Fri, 07 Apr 2023 01:58:39 GMT
< content-type: text/html
< x-content-type-options: nosniff
< content-security-policy: sandbox allow-forms allow-modals allow-popups allow-presentation allow-scripts allow-top-navigation
< x-xss-protection: 1; mode=block
< content-disposition: inline
< cache-control: public, max-age=2592000
< expires: Sun, 07 May 2023 01:58:39 GMT
< content-range: bytes */282468529
< cf-cache-status: HIT
< server: cloudflare
< cf-ray: 7b3eaab1ed569872-SJC
<
{ [596 bytes data]
#################################################################################################################################################################################################################### 100.0%* Connection sdkman/sdkman-cli#1 to host download.bell-sw.com left intact

Downloaded binary to: /Users/richard/.sdkman/tmp/java-22.3.r11-nik.bin (HTTP headers written to: /Users/richard/.sdkman/var/metadata/java-22.3.r11-nik.headers)
Get post-installation hook: https://api.sdkman.io/2/hooks/post/java/22.3.r11-nik/darwinx64
Copy remote post-installation hook: /Users/richard/.sdkman/tmp/hook_post_java_22.3.r11-nik.sh
A macOS 64bit post-install hook was found for Java 22.3.r11-nik-openjdk.
Download has failed, aborting!

Can not install java 22.3.r11-nik at this time...
marc0der commented 1 year ago

Hi @nibocn, so it seems like the binary is downloaded successfully, but the internal structure might be a bit funky. I tried installing this on my Linux machine, but that binary has no issues. I don't have a Mac, but maybe @eddumelendez can see if the macOS binary is compliant.

eddumelendez commented 1 year ago

Sorry for the delay. No issues installing on M1.

nibocn commented 1 year ago

I also find it strange because after that, I was able to install it successfully using Liberica. My current approach is to use Liberica for installation, which works in most cases. However, when I need Liberica NIK, I install it manually. This is how I have temporarily resolved the issue.

My current version of SDKMAN: SDKMAN! script: 5.18.1 native: 0.2.9

image
eddumelendez commented 1 year ago

Did you try again with sdkman? If no, can you try, please?

nibocn commented 1 year ago

I have also tried again, and the effect is still the same for Liberica NIK. On May 26, 2023 at 20:59 +0800, Eddú Meléndez Gonzales @.***>, wrote:

Did you try again with sdkman? If no, can you try, please? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

eddumelendez commented 1 year ago

what about running sdk flush first and then trying to install again?

nibocn commented 1 year ago

what about running sdk flush first and then trying to install again?

Yes, I ran the sdk flush command, but I am still encountering the same error when downloading java 22.3.2.r17-nik.

Downloading: java 22.3.2.r17-nik

In progress...

########################################################################################################################################## 100.0%
Download has failed, aborting!

Can not install java 22.3.2.r17-nik at this time...

Then I also downloaded java 20.0.1-librca and it was successful. I checked the generated related files in the ~/.sdkman/tmp directory, and the specific details are as follows:

image

hook_post_java_22.3.2.r17-nik.sh file:

#!/bin/bash
#Post Hook: osx-java-tarball
function __sdkman_post_installation_hook {
    __sdkman_echo_debug "A macOS 64bit post-install hook was found for Java 22.3.2.r17-nik-openjdk."

     __sdkman_validate_binary_input "$binary_input" || return 1

    local present_dir="$(pwd)"
    local work_dir="${SDKMAN_DIR}/tmp/out"
    local work_jdk_dir="${SDKMAN_DIR}/tmp/Java-22.3.2.r17-nik"

    echo ""
    __sdkman_echo_green "Repackaging Java 22.3.2.r17-nik..."

    mkdir -p "$work_dir"
    /usr/bin/env tar zxf "$binary_input" -C "$work_dir"

    cd "$work_dir"/*/Contents
    mv -f Home "$work_jdk_dir"
    cd "${SDKMAN_DIR}"/tmp
    /usr/bin/env zip -qyr "$zip_output" "Java-22.3.2.r17-nik"
    cd "$present_dir"

    echo ""
    __sdkman_echo_green "Done repackaging..."

    __sdkman_echo_green "Cleaning up residual files..."
    rm -f "$binary_input"
    rm -rf "$work_dir"
    rm -rf "$work_jdk_dir"
}

function __sdkman_validate_binary_input {
    if ! tar tzf "$1" &> /dev/null; then
        echo "Download has failed, aborting!"
        echo ""
        echo "Can not install java 22.3.2.r17-nik at this time..."
        return 1
    fi
}

hook_post_java_20.0.1-librca.sh file:

#!/bin/bash
#Post Hook: default-zip
function __sdkman_post_installation_hook {
    __sdkman_echo_debug "No macOS 64bit post-install hook found for Java 20.0.1-librca."
    __sdkman_echo_debug "Moving $binary_input to $zip_output"
    mv -f "$binary_input" "$zip_output"
}

java-22.3.2.r17-nik.headers.tmp file:

HTTP/1.1 200 Connection established

HTTP/1.1 302 Found
Server: nginx/1.19.10
Date: Thu, 06 Jul 2023 09:31:33 GMT
Content-Length: 0
Connection: keep-alive
X-Sdkman-ArchiveType: zip
location: https://download.bell-sw.com/vm/22.3.2/bellsoft-liberica-vm-openjdk17.0.7+7-22.3.2+1-macos-amd64.zip

HTTP/1.1 200 Connection established

HTTP/2 200 
date: Thu, 06 Jul 2023 09:31:34 GMT
content-type: application/zip
content-length: 303579959
x-content-type-options: nosniff
content-security-policy: sandbox allow-forms allow-modals allow-popups allow-presentation allow-scripts allow-top-navigation
x-xss-protection: 1; mode=block
last-modified: Wed, 26 Apr 2023 08:16:05 GMT
content-disposition: inline
cache-control: public, max-age=2592000
cf-cache-status: HIT
expires: Sat, 05 Aug 2023 09:31:34 GMT
accept-ranges: bytes
server: cloudflare
cf-ray: 7e26d5e1ef5b0443-HKG

java-20.0.1-librca.headers.tmp file:

HTTP/1.1 200 Connection established

HTTP/1.1 302 Found
Server: nginx/1.19.10
Date: Thu, 06 Jul 2023 09:32:44 GMT
Content-Length: 0
Connection: keep-alive
X-Sdkman-ArchiveType: zip
location: https://github.com/bell-sw/Liberica/releases/download/20.0.1+10/bellsoft-jdk20.0.1+10-macos-amd64.zip

HTTP/1.1 200 Connection established

HTTP/2 302 
server: GitHub.com
date: Thu, 06 Jul 2023 09:32:44 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, Accept-Encoding, Accept, X-Requested-With
location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/115621629/744a56bd-66b6-4b08-a7d0-141c72d4491e?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230706%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230706T093244Z&X-Amz-Expires=300&X-Amz-Signature=2ecc70ca8c015412258b12391aa27d49778e16fdcc96b0a3a26183f56a2adadd&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=115621629&response-content-disposition=attachment%3B%20filename%3Dbellsoft-jdk20.0.1%2B10-macos-amd64.zip&response-content-type=application%2Foctet-stream
cache-control: no-cache
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; block-all-mixed-content; child-src github.com/assets-cdn/worker/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com objects-origin.githubusercontent.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com cdn.optimizely.com logx.optimizely.com/v1/events *.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ wss://*.actions.githubusercontent.com github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com objects-origin.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; worker-src github.com/assets-cdn/worker/ gist.github.com/assets-cdn/worker/
content-length: 0
x-github-request-id: B33D:1BBE:917BE9:98F9B3:64A68A3C

HTTP/1.1 200 Connection established

HTTP/2 200 
content-type: application/octet-stream
content-md5: Yo4BHJKl6xyqc25aFZoOkA==
last-modified: Fri, 14 Apr 2023 00:20:51 GMT
etag: "0x8DB3C7E1A6DD7E9"
server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-request-id: 691bf428-901e-004a-28ec-af42da000000
x-ms-version: 2020-04-08
x-ms-creation-time: Fri, 14 Apr 2023 00:20:51 GMT
x-ms-lease-status: unlocked
x-ms-lease-state: available
x-ms-blob-type: BlockBlob
content-disposition: attachment; filename=bellsoft-jdk20.0.1+10-macos-amd64.zip
x-ms-server-encrypted: true
via: 1.1 varnish, 1.1 varnish
fastly-restarts: 1
accept-ranges: bytes
age: 0
date: Thu, 06 Jul 2023 09:32:45 GMT
x-served-by: cache-iad-kcgs7200116-IAD, cache-hkg17923-HKG
x-cache: MISS, MISS
x-cache-hits: 0, 0
x-timer: S1688635965.009654,VS0,VE497
content-length: 218198043

I don't know if this information will be of any help. The hook_post_java_22.3.2.r17-nik.sh script indeed has some judgements regarding the file type. In addition, there are some differences between the java-22.3.2.r17-nik.headers.tmp file and java-20.0.1-librca.headers.tmp file.

eddumelendez commented 1 year ago

20.0.1-librca was installed sucessfully? Do you only have issues with Liberica NIK?

nibocn commented 1 year ago

20.0.1-librca was installed sucessfully? Do you only have issues with Liberica NIK?

Yes, currently it has been found that there are issues with "Liberica NIK," but "Liberica" and "Java.net" are both working successfully.

image
eddumelendez commented 1 year ago

I was able to run it and install it sucessfully

▶ cat ~/.sdkman/tmp/hook_post_java_22.3.2.r17-nik.sh
#!/bin/bash
#Post Hook: osx-java-tarball
function __sdkman_post_installation_hook {
    __sdkman_echo_debug "A macOS 64bit post-install hook was found for Java 22.3.2.r17-nik-openjdk."

     __sdkman_validate_binary_input "$binary_input" || return 1

    local present_dir="$(pwd)"
    local work_dir="${SDKMAN_DIR}/tmp/out"
    local work_jdk_dir="${SDKMAN_DIR}/tmp/Java-22.3.2.r17-nik"

    echo ""
    __sdkman_echo_green "Repackaging Java 22.3.2.r17-nik..."

    mkdir -p "$work_dir"
    /usr/bin/env tar zxf "$binary_input" -C "$work_dir"

    cd "$work_dir"/*/Contents
    mv -f Home "$work_jdk_dir"
    cd "${SDKMAN_DIR}"/tmp
    /usr/bin/env zip -qyr "$zip_output" "Java-22.3.2.r17-nik"
    cd "$present_dir"

    echo ""
    __sdkman_echo_green "Done repackaging..."

    __sdkman_echo_green "Cleaning up residual files..."
    rm -f "$binary_input"
    rm -rf "$work_dir"
    rm -rf "$work_jdk_dir"
}

function __sdkman_validate_binary_input {
    if ! tar tzf "$1" &> /dev/null; then
        echo "Download has failed, aborting!"
        echo ""
        echo "Can not install java 22.3.2.r17-nik at this time..."
        return 1
    fi
}

~/Downloads/git
▶ cat ~/.sdkman/tmp/java-22.3.2.r17-nik.headers.tmp
HTTP/1.1 302 Found
Server: nginx/1.19.10
Date: Thu, 06 Jul 2023 10:06:24 GMT
Content-Length: 0
Connection: keep-alive
X-Sdkman-ArchiveType: zip
location: https://download.bell-sw.com/vm/22.3.2/bellsoft-liberica-vm-openjdk17.0.7+7-22.3.2+1-macos-amd64.zip

HTTP/2 200
date: Thu, 06 Jul 2023 10:06:25 GMT
content-type: application/zip
content-length: 303579959
x-content-type-options: nosniff
content-security-policy: sandbox allow-forms allow-modals allow-popups allow-presentation allow-scripts allow-top-navigation
x-xss-protection: 1; mode=block
last-modified: Wed, 26 Apr 2023 08:16:05 GMT
content-disposition: inline
cache-control: public, max-age=2592000
cf-cache-status: MISS
expires: Sat, 05 Aug 2023 10:06:25 GMT
accept-ranges: bytes
server: cloudflare
cf-ray: 7e2708ec5ba2aa07-DFW

I'm closing this as no reproducible.