chiark / gitweb /
init: prompt user for Android SDK path using platform-specific default
authorHans-Christoph Steiner <hans@eds.org>
Tue, 19 Sep 2017 08:55:16 +0000 (10:55 +0200)
committerHans-Christoph Steiner <hans@eds.org>
Tue, 19 Sep 2017 18:13:36 +0000 (20:13 +0200)
fdroidserver/init.py

index 0067ffcd6dd44efed95158cbfa86426e0750efa8..3aa0b61aaf0b66e17517c4e07451cd4197b7ec35 100644 (file)
@@ -100,11 +100,21 @@ def main():
             # make sure at least aapt is found, since this can't do anything without it
             test_config['aapt'] = common.find_sdk_tools_cmd('aapt')
         else:
-            # if neither --android-home nor the default sdk_path exist, prompt the user
+            # if neither --android-home nor the default sdk_path
+            # exist, prompt the user using platform-specific default
             default_sdk_path = '/opt/android-sdk'
             if sys.platform == 'win32' or sys.platform == 'cygwin':
-                default_sdk_path = os.path.join(os.getenv('USERPROFILE'),
-                                                'AppData', 'Local', 'Android', 'android-sdk')
+                p = os.path.join(os.getenv('USERPROFILE'),
+                                 'AppData', 'Local', 'Android', 'android-sdk')
+            elif sys.platform == 'darwin':
+                # on OSX, Homebrew is common and has an easy path to detect
+                p = '/usr/local/opt/android-sdk'
+            else:
+                # if the Debian packages are installed, suggest them
+                p = '/usr/lib/android-sdk'
+            if os.path.exists(p):
+                default_sdk_path = p
+
             while not options.no_prompt:
                 try:
                     s = input(_('Enter the path to the Android SDK (%s) here:\n> ') % default_sdk_path)