File: debian-java-detection.patch

package info (click to toggle)
fdroidserver 2.4.2-1~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 18,948 kB
  • sloc: python: 34,131; xml: 2,186; sh: 1,362; java: 293; makefile: 54; javascript: 23
file content (44 lines) | stat: -rw-r--r-- 2,079 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Description:
 Normally fdroid auto-detects Java's keytool and jarsigner, but if the
 user changes the default JDK to something other than Java 1.7, then
 fdroid will break.  So this package first uses the path to the
 default Debian version of the tools.
Forwarded: not-needed
Author: Hans-Christoph Steiner <hans@eds.org>
Date: Thu, 18 Feb 2016 12:27:16 +0100

--- a/fdroidserver/common.py
+++ b/fdroidserver/common.py
@@ -416,16 +416,22 @@
             pathlist += glob.glob(os.path.join(os.getenv('PROGRAMFILES'), 'Java', 'jdk1.[126-9][0-9]?.*'))
         _add_java_paths_to_config(pathlist, thisconfig)
 
-    for java_version in range(29, 6, -1):
-        java_version = str(java_version)
-        if java_version not in thisconfig['java_paths']:
-            continue
-        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
+    # for Debian/Ubuntu packaging, always prefer the built-in, unless it does not exist
+    default_java = '/usr/lib/jvm/default-java'
+    if os.path.exists(default_java):
+        thisconfig['jarsigner'] = os.path.join(default_java, 'bin', 'jarsigner')
+        thisconfig['keytool'] = os.path.join(default_java, 'bin', 'keytool')
+    else:
+        for java_version in range(29, 6, -1):
+            java_version = str(java_version)
+            if java_version not in thisconfig['java_paths']:
+                continue
+            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
 
     if 'jarsigner' not in thisconfig and shutil.which('jarsigner'):
         thisconfig['jarsigner'] = shutil.which('jarsigner')