Skip to content
This repository has been archived by the owner on Aug 8, 2022. It is now read-only.

[corretto8] java executable is broken #1

Open
gavindidrichsen opened this issue Aug 18, 2020 · 1 comment
Open

[corretto8] java executable is broken #1

gavindidrichsen opened this issue Aug 18, 2020 · 1 comment

Comments

@gavindidrichsen
Copy link
Contributor

This is a placeholder for the issue raised against core-plans. See habitat-sh/core-plans#3448.

In summary, java -version is producing the following output:

[5][default:/src/corretto8:100]# /hab/pkgs/core/corretto8/8.265.01.1/20200818151532/bin/java -version
bash: /hab/pkgs/core/corretto8/8.265.01.1/20200818151532/bin/java: No such file or directory
[6][default:/src/corretto8:127]#

when it should be producing something like:

[5][default:/src/corretto8:100]# /hab/pkgs/core/corretto8/8.202.08.2/20200405000401/bin/java -version 
openjdk version "1.8.0_202"
OpenJDK Runtime Environment Corretto-8.202.08.2 (build 1.8.0_202-b08)
OpenJDK 64-Bit Server VM Corretto-8.202.08.2 (build 25.202-b08, mixed mode)
@gavindidrichsen
Copy link
Contributor Author

PR #2 fixes this issue.

The cause is that the plan's regex failed to select its binaries for patchelf injection. The file type of the binaries used to be application/x-executable but has become application/x-pie-executable. Even though the hab build succeeded, nevertheless the executables failed to work as described above.

The fix was to amend the regex in the plan.sh as follows:

diff --git a/plan.sh b/plan.sh
index 03499da..aa294aa 100644
--- a/plan.sh
+++ b/plan.sh
@@ -54,11 +54,11 @@ do_install() {
   build_line "Setting rpath for all libraries to '${LD_RUN_PATH}'"
 
   find "${pkg_prefix}"/bin -type f -executable \
-    -exec sh -c 'file -i "$1" | grep -q "x-executable; charset=binary"' _ {} \; \
+    -exec sh -c 'file -i "$1" | grep -q "-executable; charset=binary"' _ {} \; \
     -exec patchelf --set-interpreter "$(pkg_path_for glibc)/lib/ld-linux-x86-64.so.2" --set-rpath "${LD_RUN_PATH}" {} \;
 
   find "${pkg_prefix}"/jre/bin -type f -executable \
-    -exec sh -c 'file -i "$1" | grep -q "x-executable; charset=binary"' _ {} \; \
+    -exec sh -c 'file -i "$1" | grep -q "-executable; charset=binary"' _ {} \; \
     -exec patchelf --set-interpreter "$(pkg_path_for glibc)/lib/ld-linux-x86-64.so.2" --set-rpath "${LD_RUN_PATH}" {} \;
 
   find "${pkg_prefix}/lib" -type f -name "*.so" \

New inspec tests were added to verify the fix.

Before the fix, the tests fail like:

...

Profile Summary: 1 successful control, 2 control failures, 0 controls skipped
Test Summary: 259 successful, 125 failures, 0 skipped

However, after re-building with the fix applied the tests all pass now:

...
Profile Summary: 3 successful controls, 0 control failures, 0 controls skipped
Test Summary: 384 successful, 0 failures, 0 skipped

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant