This patch modifies existing openjdk8-from-host module to make
it work on aarch64 Linux host.

Signed-off-by: Waldemar Kozaczuk <[email protected]>
---
 modules/openjdk8-from-host/Makefile  | 12 ++++++++----
 modules/openjdk8-from-host/module.py | 28 +++++++++++++++++++---------
 2 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/modules/openjdk8-from-host/Makefile 
b/modules/openjdk8-from-host/Makefile
index 7bf1db6b..e5552df4 100644
--- a/modules/openjdk8-from-host/Makefile
+++ b/modules/openjdk8-from-host/Makefile
@@ -1,16 +1,20 @@
 .PHONY: module clean
 
+include ../common.gmk
+ifneq ($(arch),$(host_arch))
+$(error Cannot provide JDK when cross-compiling)
+endif
+
 SRC = $(shell readlink -f ../..)
 
 javac_exe_path = $(shell realpath $$(which javac))
 javac_bin_path = $(shell dirname $(javac_exe_path))
 java_jdk_path = $(shell dirname $(javac_bin_path))
-
-very-quiet = $(if $V, $1, @$1)
+libsunec_path = $(shell find $(java_jdk_path) -name libsunec.so)
 
 module:
-       $(call very-quiet, $(SRC)/scripts/manifest_from_host.sh 
$(java_jdk_path)/jre/lib/amd64/libsunec.so > usr.manifest)
+       $(call very-quiet, $(SRC)/scripts/manifest_from_host.sh 
$(libsunec_path) > usr.manifest)
        $(call very-quiet, $(SRC)/scripts/manifest_from_host.sh -li 
libfreeblpriv3.so >> usr.manifest)
 
 clean:
-       rm -rf usr.manifest
+       rm -f usr.manifest
diff --git a/modules/openjdk8-from-host/module.py 
b/modules/openjdk8-from-host/module.py
index faab8c36..f6b388e4 100644
--- a/modules/openjdk8-from-host/module.py
+++ b/modules/openjdk8-from-host/module.py
@@ -3,23 +3,33 @@ from osv.modules import api
 import os, os.path
 import subprocess
 
+host_arch = os.uname().machine
+if host_arch == 'aarch64':
+    arch_dir = 'aarch64'
+elif host_arch == 'x86_64':
+    arch_dir = 'amd64'
+else:
+    print('Unsupported architecture: %s' % host_arch)
+    exit(-1)
+
 api.require('java-cmd')
 provides = ['java','java8']
 
 #Verify that the jdk exists by trying to locate javac (java compiler)
 if subprocess.call(['which', 'javac']) != 0:
-     print('Could not find any jdk on the host. Please install openjdk8!')
-     os.exit(-1)
-
-java_version = subprocess.check_output(['java', '-version'], 
stderr=subprocess.STDOUT).decode('utf-8')
-if not 'openjdk version "1.8.0' in java_version:
-    print('Could not find openjdk version 8 on the host. Please install 
openjdk8!')
-    os.exit(-1)
+    print('Could not find any jdk on the host. Please install openjdk8!')
+    exit(-1)
 
 javac_path = subprocess.check_output(['which', 
'javac']).decode('utf-8').split('\n')[0]
 javac_real_path = os.path.realpath(javac_path)
+java_real_path = os.path.dirname(javac_real_path) + '/java'
 jdk_path = os.path.dirname(os.path.dirname(javac_real_path))
 
+java_version = subprocess.check_output([java_real_path, '-version'], 
stderr=subprocess.STDOUT).decode('utf-8')
+if not 'openjdk version "1.8.0' in java_version:
+    print('Could not find openjdk version 8 on the host. Please install 
openjdk8!')
+    exit(-1)
+
 usr_files = FileMap()
 
 jdk_dir = os.path.basename(jdk_path)
@@ -27,8 +37,8 @@ jdk_dir = os.path.basename(jdk_path)
 usr_files.add(jdk_path).to('/usr/lib/jvm/java') \
     .include('jre/**') \
     .exclude('jre/lib/security/cacerts') \
-    .exclude('jre/lib/amd64/*audio*') \
-    .exclude('jre/lib/amd64/*sound*') \
+    .exclude('jre/lib/%s/*audio*' % arch_dir) \
+    .exclude('jre/lib/%s/*sound*' % arch_dir) \
     .exclude('') \
     .exclude('jre/man/**') \
     .exclude('jre/bin/**') \
-- 
2.30.2

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/20210614042047.13437-2-jwkozaczuk%40gmail.com.

Reply via email to