use jarsigner and keytool from same JDK as is being set in JAVA7_HOME

Using the same JDK throughout should prevent weird bugs where a setup might
use Java8's jarsigner and Java7's keytool.  This also allows the user to
set java_paths and have jarsigner and keytool used from that specified JDK.

This incorporates almost all of the patch that is in the Debian package
that forces fdroidserver to use the default JDK on that Debian release.

closes #93 https://gitlab.com/fdroid/fdroidserver/issues/93
This commit is contained in:
Hans-Christoph Steiner 2016-02-11 20:43:55 +01:00
parent fdf17e809c
commit 69c81c3817
5 changed files with 38 additions and 10 deletions

View file

@ -154,6 +154,14 @@ def fill_config_defaults(thisconfig):
else:
thisconfig['java_paths'][m.group(1)] = d
for java_version in ('7', '8', '9'):
java_home = thisconfig['java_paths'][java_version]
jarsigner = os.path.join(java_home, 'bin', 'jarsigner')
if os.path.exists(jarsigner):
thisconfig['jarsigner'] = jarsigner
thisconfig['keytool'] = os.path.join(java_home, 'bin', 'keytool')
break # Java7 is preferred, so quit if found
for k in ['ndk_paths', 'java_paths']:
d = thisconfig[k]
for k2 in d.copy():
@ -1810,7 +1818,7 @@ def verify_apks(signed_apk, unsigned_apk, tmp_dir):
for meta_inf_file in meta_inf_files:
unsigned_apk_as_zip.write(os.path.join(tmp_dir, meta_inf_file), arcname=meta_inf_file)
if subprocess.call(['jarsigner', '-verify', unsigned_apk]) != 0:
if subprocess.call([config['jarsigner'], '-verify', unsigned_apk]) != 0:
logging.info("...NOT verified - {0}".format(signed_apk))
return compare_apks(signed_apk, unsigned_apk, tmp_dir)
logging.info("...successfully verified")
@ -1912,7 +1920,7 @@ def genkeystore(localconfig):
write_password_file("keystorepass", localconfig['keystorepass'])
write_password_file("keypass", localconfig['keypass'])
p = FDroidPopen(['keytool', '-genkey',
p = FDroidPopen([config['keytool'], '-genkey',
'-keystore', localconfig['keystore'],
'-alias', localconfig['repo_keyalias'],
'-keyalg', 'RSA', '-keysize', '4096',
@ -1926,7 +1934,7 @@ def genkeystore(localconfig):
raise BuildException("Failed to generate key", p.output)
os.chmod(localconfig['keystore'], 0o0600)
# now show the lovely key that was just generated
p = FDroidPopen(['keytool', '-list', '-v',
p = FDroidPopen([config['keytool'], '-list', '-v',
'-keystore', localconfig['keystore'],
'-alias', localconfig['repo_keyalias'],
'-storepass:file', config['keystorepassfile']])