-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Add package pre-install check for java binary #31343
Changes from 1 commit
85ee81a
442023c
a1a1e2c
127799e
084f9ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,18 @@ | |
# $1=1 : indicates an new install | ||
# $1=2 : indicates an upgrade | ||
|
||
# Check for these at preinst time due to failures in postinst if they do not exist | ||
if [ -x "$JAVA_HOME/bin/java" ]; then | ||
JAVA="$JAVA_HOME/bin/java" | ||
else | ||
JAVA=`which java` | ||
fi | ||
|
||
if [ ! -x "$JAVA" ]; then | ||
echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this block is needed we have |
||
exit 1 | ||
fi | ||
|
||
case "$1" in | ||
|
||
# Debian #################################################### | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,14 @@ setup() { | |
[ "$status" -eq 1 ] | ||
} | ||
|
||
@test "[DEB] temporarily remove java and ensure the install fails" { | ||
move_java | ||
run dpkg -i elasticsearch-oss-$(cat version).deb | ||
output=$status | ||
unmove_java | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💯 |
||
[ "$output" -eq 1 ] | ||
} | ||
|
||
@test "[DEB] install package" { | ||
dpkg -i elasticsearch-oss-$(cat version).deb | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,14 @@ setup() { | |
[ "$status" -eq 1 ] | ||
} | ||
|
||
@test "[RPM] temporarily remove java and ensure the install fails" { | ||
move_java | ||
run rpm -i elasticsearch-oss-$(cat version).rpm | ||
output=$status | ||
unmove_java | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💯 |
||
[ "$output" -eq 1 ] | ||
} | ||
|
||
@test "[RPM] install package" { | ||
rpm -i elasticsearch-oss-$(cat version).rpm | ||
} | ||
|
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.
Does this ever execute in a failing case? I think that these scripts are always executed with
set +e
or does it differ by packaging system? If we get here it's because$JAVA_HOME/bin/java
exists which we setJAVA
to, orwhich java
failed and we should have exited?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.
yea i copied this from https://github.com/elastic/elasticsearch/blob/master/distribution/packages/src/deb/init.d/elasticsearch#L83-L94 , and i think the logic is wrong. Ill fix up.
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.
Changed the bash test check to see if
$JAVA
is set.