mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-15 23:42:37 +03: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:
parent
7f451a815b
commit
fdf17e809c
1 changed files with 29 additions and 8 deletions
|
@ -62,10 +62,7 @@ default_config = {
|
||||||
'r10e': "$ANDROID_NDK",
|
'r10e': "$ANDROID_NDK",
|
||||||
},
|
},
|
||||||
'build_tools': "23.0.2",
|
'build_tools': "23.0.2",
|
||||||
'java_paths': {
|
'java_paths': None,
|
||||||
'1.7': "/usr/lib/jvm/java-7-openjdk",
|
|
||||||
'1.8': None,
|
|
||||||
},
|
|
||||||
'ant': "ant",
|
'ant': "ant",
|
||||||
'mvn3': "mvn",
|
'mvn3': "mvn",
|
||||||
'gradle': 'gradle',
|
'gradle': 'gradle',
|
||||||
|
@ -131,6 +128,32 @@ def fill_config_defaults(thisconfig):
|
||||||
thisconfig[k] = exp
|
thisconfig[k] = exp
|
||||||
thisconfig[k + '_orig'] = v
|
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']:
|
for k in ['ndk_paths', 'java_paths']:
|
||||||
d = thisconfig[k]
|
d = thisconfig[k]
|
||||||
for k2 in d.copy():
|
for k2 in d.copy():
|
||||||
|
@ -194,10 +217,8 @@ def read_config(opts, config_file='config.py'):
|
||||||
for n in ['ANDROID_HOME', 'ANDROID_SDK']:
|
for n in ['ANDROID_HOME', 'ANDROID_SDK']:
|
||||||
env[n] = config['sdk_path']
|
env[n] = config['sdk_path']
|
||||||
|
|
||||||
for v in ['7', '8']:
|
for k, v in config['java_paths'].items():
|
||||||
cpath = config['java_paths']['1.%s' % v]
|
env['JAVA%s_HOME' % k] = v
|
||||||
if cpath:
|
|
||||||
env['JAVA%s_HOME' % v] = cpath
|
|
||||||
|
|
||||||
for k in ["keystorepass", "keypass"]:
|
for k in ["keystorepass", "keypass"]:
|
||||||
if k in config:
|
if k in config:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue