RFR: JDK-8297000 [jib] Add more friendly warning for proxy issues

Magnus Ihse Bursie ihse at openjdk.org
Wed Nov 16 20:02:57 UTC 2022


On Tue, 15 Nov 2022 09:55:38 GMT, Ludvig Janiuk <lujaniuk at openjdk.org> wrote:

> When jib tries to download itself behind a proxy, sometimes it can get a different file than it expected. This can result in cryptic errors that are hard to troubleshoot. Let's handle this a little more gracefully by detecting it in the bootstrapper and printing an error.

bin/jib.sh line 137:

> 135:     FILEOUTPUT=`file ${installed_jib_script}.gz`
> 136:     # ${X:${#Y}} gives X without the first ${#Y} characters, and ${#Y} is length of Y.
> 137:     FILEOUTPUT=${FILEOUTPUT:${#PREFIX}}

I think this is a bashism. While we do have /bin/bash in the shebang, this does not really matter since we have no executable bit on the script, so users will have to explicitly call it with a shell. So many users are likely to do `sh bin/jib.sh`, and then this will break.

My recommendation would be to use standard tools like cut or grep instead, something like:

file $installedscript.gz | grep "gzip compressed data" -q
if test $? -neq 0; then 
...

-------------

PR: https://git.openjdk.org/jdk/pull/11159



More information about the build-dev mailing list