From 4f21045cadc0a83065fe07b2bc8554b29b5cc390 Mon Sep 17 00:00:00 2001 From: Cyril Russo Date: Fri, 17 Aug 2018 15:32:29 +0200 Subject: [PATCH 1/4] Fix keytool not found on MacOSX (when using Java from Apple) Fix keytool parsing error due to localisation keytool -list command. Always fallback to english so the parsing makes sense. --- examples/config.py | 3 +++ fdroidserver/common.py | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/config.py b/examples/config.py index 7e2be2e4..180b1cee 100644 --- a/examples/config.py +++ b/examples/config.py @@ -118,6 +118,9 @@ The repository of older versions of applications from the main demo repository. # keystore. # repo_pubkey = "..." +# The keytool command to run to get Java's keytool version +keytool = "keytool" + # The keystore to use for release keys when building. This needs to be # somewhere safe and secure, and backed up! The best way to manage these # sensitive keys is to use a "smartcard" (aka Hardware Security Module). To diff --git a/fdroidserver/common.py b/fdroidserver/common.py index f3c277dc..f0d0abae 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -2907,7 +2907,8 @@ def genkeystore(localconfig): '-validity', '10000', '-storepass:env', 'FDROID_KEY_STORE_PASS', '-keypass:env', 'FDROID_KEY_PASS', - '-dname', localconfig['keydname']], envs=env_vars) + '-dname', localconfig['keydname'], + '-J-Duser.language=en'], envs=env_vars) if p.returncode != 0: raise BuildException("Failed to generate key", p.output) os.chmod(localconfig['keystore'], 0o0600) @@ -2916,7 +2917,7 @@ def genkeystore(localconfig): p = FDroidPopen([config['keytool'], '-list', '-v', '-keystore', localconfig['keystore'], '-alias', localconfig['repo_keyalias'], - '-storepass:env', 'FDROID_KEY_STORE_PASS'], envs=env_vars) + '-storepass:env', 'FDROID_KEY_STORE_PASS', '-J-Duser.language=en'], envs=env_vars) logging.info(p.output.strip() + '\n\n') # get the public key p = FDroidPopenBytes([config['keytool'], '-exportcert', From ace33bcfc09386f18241be81f05d29dddc039711 Mon Sep 17 00:00:00 2001 From: Cyril Russo Date: Fri, 17 Aug 2018 16:46:46 +0200 Subject: [PATCH 2/4] Reverted the change in the default config.py Improved the detection of keytool and jarsigner by also searching the PATH environment variable --- examples/config.py | 3 --- fdroidserver/common.py | 12 ++++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/examples/config.py b/examples/config.py index 180b1cee..7e2be2e4 100644 --- a/examples/config.py +++ b/examples/config.py @@ -118,9 +118,6 @@ The repository of older versions of applications from the main demo repository. # keystore. # repo_pubkey = "..." -# The keytool command to run to get Java's keytool version -keytool = "keytool" - # The keystore to use for release keys when building. This needs to be # somewhere safe and secure, and backed up! The best way to manage these # sensitive keys is to use a "smartcard" (aka Hardware Security Module). To diff --git a/fdroidserver/common.py b/fdroidserver/common.py index f0d0abae..49a6950b 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -236,6 +236,18 @@ def fill_config_defaults(thisconfig): thisconfig['keytool'] = os.path.join(java_home, 'bin', 'keytool') break + if 'jarsigner' not in thisconfig: + for path in os.environ['PATH'].split(':'): + jarsigner = os.path.join(path, 'jarsigner') + if os.path.exists(jarsigner): + thisconfig['jarsigner'] = jarsigner + else: + continue + keytool = os.path.join(path, 'keytool') + if os.path.exists(keytool): + thisconfig['keytool'] = keytool + break + for k in ['ndk_paths', 'java_paths']: d = thisconfig[k] for k2 in d.copy(): From 4303b0fac1a4a8d94212d881e54070b4ee29cfef Mon Sep 17 00:00:00 2001 From: Cyril Russo Date: Fri, 17 Aug 2018 20:14:54 +0200 Subject: [PATCH 3/4] Apply suggestion from @uniqx to using shutil.which instead of iterating path by hand --- fdroidserver/common.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 49a6950b..23f1527b 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -236,17 +236,10 @@ def fill_config_defaults(thisconfig): thisconfig['keytool'] = os.path.join(java_home, 'bin', 'keytool') break + if 'jarsigner' not in thisconfig: - for path in os.environ['PATH'].split(':'): - jarsigner = os.path.join(path, 'jarsigner') - if os.path.exists(jarsigner): - thisconfig['jarsigner'] = jarsigner - else: - continue - keytool = os.path.join(path, 'keytool') - if os.path.exists(keytool): - thisconfig['keytool'] = keytool - break + thisconfig['jarsigner'] = shutil.which('jarsigner') + thisconfig['keytool'] = shutil.which('keytool') for k in ['ndk_paths', 'java_paths']: d = thisconfig[k] From 81641b4628c7178eacdbeb8d5c0e8292a154e2f7 Mon Sep 17 00:00:00 2001 From: Cyril Russo Date: Mon, 20 Aug 2018 11:17:36 +0200 Subject: [PATCH 4/4] Fixed precommit checks --- fdroidserver/common.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 23f1527b..85b15d70 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -236,7 +236,6 @@ def fill_config_defaults(thisconfig): thisconfig['keytool'] = os.path.join(java_home, 'bin', 'keytool') break - if 'jarsigner' not in thisconfig: thisconfig['jarsigner'] = shutil.which('jarsigner') thisconfig['keytool'] = shutil.which('keytool') @@ -2913,7 +2912,7 @@ def genkeystore(localconfig): '-storepass:env', 'FDROID_KEY_STORE_PASS', '-keypass:env', 'FDROID_KEY_PASS', '-dname', localconfig['keydname'], - '-J-Duser.language=en'], envs=env_vars) + '-J-Duser.language=en'], envs=env_vars) if p.returncode != 0: raise BuildException("Failed to generate key", p.output) os.chmod(localconfig['keystore'], 0o0600)