1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-05 06:50:10 +01:00

automatically detect various installed JDKs and set JAVA[6-9]_HOME

This checks for which JDKs are installed in common locations, then sets the
JAVA[6-9]_HOME env vars needed by some build environments.
This commit is contained in:
Hans-Christoph Steiner 2016-02-06 00:29:07 +01:00
parent 7f451a815b
commit fdf17e809c

View File

@ -62,10 +62,7 @@ default_config = {
'r10e': "$ANDROID_NDK",
},
'build_tools': "23.0.2",
'java_paths': {
'1.7': "/usr/lib/jvm/java-7-openjdk",
'1.8': None,
},
'java_paths': None,
'ant': "ant",
'mvn3': "mvn",
'gradle': 'gradle',
@ -131,6 +128,32 @@ def fill_config_defaults(thisconfig):
thisconfig[k] = exp
thisconfig[k + '_orig'] = v
# find all installed JDKs for keytool, jarsigner, and JAVA[6-9]_HOME env vars
if thisconfig['java_paths'] is None:
thisconfig['java_paths'] = dict()
for d in sorted(glob.glob('/usr/lib/jvm/j*[6-9]*')
+ glob.glob('/usr/java/jdk1.[6-9]*')
+ glob.glob('/System/Library/Java/JavaVirtualMachines/1.[6-9].0.jdk')
+ glob.glob('/Library/Java/JavaVirtualMachines/*jdk*[6-9]*')):
if os.path.islink(d):
continue
j = os.path.basename(d)
# the last one found will be the canonical one, so order appropriately
for regex in (r'1\.([6-9])\.0\.jdk', # OSX
r'jdk1\.([6-9])\.0_[0-9]+.jdk', # OSX and Oracle tarball
r'jdk([6-9])-openjdk', # Arch
r'java-1\.([6-9])\.0-.*', # RedHat
r'java-([6-9])-oracle', # Debian WebUpd8
r'jdk-([6-9])-oracle-.*', # Debian make-jpkg
r'java-([6-9])-openjdk-[^c][^o][^m].*'): # Debian
m = re.match(regex, j)
if m:
osxhome = os.path.join(d, 'Contents', 'Home')
if os.path.exists(osxhome):
thisconfig['java_paths'][m.group(1)] = osxhome
else:
thisconfig['java_paths'][m.group(1)] = d
for k in ['ndk_paths', 'java_paths']:
d = thisconfig[k]
for k2 in d.copy():
@ -194,10 +217,8 @@ def read_config(opts, config_file='config.py'):
for n in ['ANDROID_HOME', 'ANDROID_SDK']:
env[n] = config['sdk_path']
for v in ['7', '8']:
cpath = config['java_paths']['1.%s' % v]
if cpath:
env['JAVA%s_HOME' % v] = cpath
for k, v in config['java_paths'].items():
env['JAVA%s_HOME' % k] = v
for k in ["keystorepass", "keypass"]:
if k in config: