New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix error message when package install fails due to missing Java #36077
Conversation
Currently is `java` is not in $PATH the preinst script fails prematurely and prevents an appropriate message from getting displayed for the user. Make package installation more user friendly when java is not in $PATH. Also use a she-bang in the preinst script, as, at least in Debian, maintainer scripts must start with the #! convention [1]. Relates: elastic#31845 [1] https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html
Pinging @elastic/es-core-infra |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I left one comment for change and one question.
@@ -45,7 +45,7 @@ else | |||
fi | |||
|
|||
if [ ! -x "$JAVA" ]; then | |||
echo "could not find java; set JAVA_HOME or ensure java is in PATH" | |||
echo "could not find java; set JAVA_HOME or ensure java is in PATH" >&2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice that you changed the mode on this file. Is that intentional? We do not intend for this file to be executed directly, so it doesn't need the execute bit set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did? I only redirected the err msg to stderr instead of stdout, am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the change in permissions shows up in the diff 100644 → 100755
. I can't comment anywhere else except on this line in the file yet I'm talking about the file permissions on distribution/src/bin/elasticsearch-env
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, good catch! Truly odd, I definitely didn't do any chmod's yet something changed it. I've reverted it in 1b4f895
@@ -1,3 +1,4 @@ | |||
#!/bin/sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be /bin/bash
, that's what all of our scripts require.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ I think consistency on this is especially important for people trying to figure out what we assume prior to installation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we could switch to /bin/bash it would be great to make the code more readable too e.g. conditionals etc. as now I was limited to POSIX only. Defaulting to /bin/bash
however, I fear it is dangerous, as the script is common across all platforms and there's no guarantee that /bin/bash is present on all platforms, e.g. Debian defaults to /bin/dash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, our packages already depend on bash
so we should be safe. I will commit this change ASAP. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in f1fd2a2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We require /bin/bash
since a long time. 😇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
When I added PackageTestCase, I tried to do something similar (echoing that java message to stderr instead of stdout) and found it didn't work in one type of package (can't remember if it was deb or rpm) because the message just was never outputted. But it looks like the full packaging tests are passing here so I must have been doing something wrong. So nothing actionable but just wanted to note that
Thanks @andyb-elastic ! The reason the err message wasn't outputted was that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@jasontedor Any suggestions how far back to go wrt backports? |
@dliappis On top of master, 6.5 and 6.x. |
) Currently is `java` is not in $PATH the preinst script fails prematurely and prevents an appropriate message from getting displayed to the user. Make package installation more user friendly when java is not in $PATH and add a test for it. Also use a she-bang in the preinst script, as, at least in Debian, maintainer scripts must start with the #! convention [1]. Relates #31845 [1] https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html
) Currently is `java` is not in $PATH the preinst script fails prematurely and prevents an appropriate message from getting displayed to the user. Make package installation more user friendly when java is not in $PATH and add a test for it. Also use a she-bang in the preinst script, as, at least in Debian, maintainer scripts must start with the #! convention [1]. Relates #31845 [1] https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html
Currently if
java
is not in $PATH the preinst script failsprematurely and prevents an appropriate message from getting displayed
to the user.
Make package installation more user friendly when java is not in
$PATH, by emitting a message to stderr. Also improve the current test case for
installation
exit 1
when java isn't present by also testing for the output ofthe error message.
Finally use a she-bang in the preinst script, as, at least in Debian,
maintainer scripts must start with the #! convention [1].
Relates: #31845
[1] https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html