Skip to content

Commit

Permalink
openjdk8: make it work with aarch64
Browse files Browse the repository at this point in the history
This patch modifies existing openjdk8-from-host module to make
it work on aarch64 Linux host.

Signed-off-by: Waldemar Kozaczuk <[email protected]>
Message-Id: <[email protected]>
  • Loading branch information
wkozaczuk authored and nyh committed Jun 14, 2021
1 parent bdf15a7 commit 615e456
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
12 changes: 8 additions & 4 deletions modules/openjdk8-from-host/Makefile
Original file line number Diff line number Diff line change
@@ -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
28 changes: 19 additions & 9 deletions modules/openjdk8-from-host/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,42 @@
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)

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/**') \
Expand Down

0 comments on commit 615e456

Please sign in to comment.