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 Wed, 16 Nov 2022 19:57:39 GMT, Magnus Ihse Bursie <ihse 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 
> ...

(Warning: untested code)

I also would like to clarify the use of bash. For configure script, and scripts started by the makefiles, we rely on and enforce bash, so in those cases bashisms are accepted (and almost encouraged, at least good ones). But in "user facing" scripts like this, or the top level `configure` script, we want to make minimal assumptions about the shell used, since the shebang path means nothing in our case.

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

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



More information about the build-dev mailing list