chiark / gitweb /
update: make icon extraction less dependent on aapt
[fdroidserver.git] / fdroidserver / init.py
index 36c2bf448b2ae3fa70dd52875482ca7d625591a9..b47d65b6219fd4b6433828eaed8c4f012ff6fa15 100644 (file)
@@ -65,28 +65,10 @@ def main():
                         help=_("Do not prompt for Android SDK path, just fail"))
     options = parser.parse_args()
 
-    # find root install prefix
-    tmp = os.path.dirname(sys.argv[0])
-    examplesdir = None
-    if os.path.basename(tmp) == 'bin':
-        egg_links = glob.glob(os.path.join(tmp, '..',
-                                           'local/lib/python3.*/site-packages/fdroidserver.egg-link'))
-        if egg_links:
-            # installed from local git repo
-            examplesdir = os.path.join(open(egg_links[0]).readline().rstrip(), 'examples')
-        else:
-            # try .egg layout
-            examplesdir = os.path.dirname(os.path.dirname(__file__)) + '/share/doc/fdroidserver/examples'
-            if not os.path.exists(examplesdir):  # use UNIX layout
-                examplesdir = os.path.dirname(tmp) + '/share/doc/fdroidserver/examples'
-    else:
-        # we're running straight out of the git repo
-        prefix = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
-        examplesdir = prefix + '/examples'
-
     aapt = None
     fdroiddir = os.getcwd()
     test_config = dict()
+    examplesdir = common.get_examples_dir()
     common.fill_config_defaults(test_config)
 
     # track down where the Android SDK is, the default is to use the path set
@@ -149,7 +131,9 @@ def main():
         logging.info('Try running `fdroid init` in an empty directory.')
         raise FDroidException('Repository already exists.')
 
-    if 'aapt' not in test_config or not os.path.isfile(test_config['aapt']):
+    if common.use_androguard():
+        pass
+    elif 'aapt' not in test_config or not os.path.isfile(test_config['aapt']):
         # try to find a working aapt, in all the recent possible paths
         build_tools = os.path.join(test_config['sdk_path'], 'build-tools')
         aaptdirs = []
@@ -162,7 +146,7 @@ def main():
             if os.path.isfile(os.path.join(d, 'aapt')):
                 aapt = os.path.join(d, 'aapt')
                 break
-        if os.path.isfile(aapt):
+        if aapt and os.path.isfile(aapt):
             dirname = os.path.basename(os.path.dirname(aapt))
             if dirname == 'build-tools':
                 # this is the old layout, before versioned build-tools
@@ -196,6 +180,7 @@ def main():
                              + '" does not exist, creating a new keystore there.')
     common.write_to_config(test_config, 'keystore', keystore)
     repo_keyalias = None
+    keydname = None
     if options.repo_keyalias:
         repo_keyalias = options.repo_keyalias
         common.write_to_config(test_config, 'repo_keyalias', repo_keyalias)
@@ -229,7 +214,16 @@ def main():
                                    flags=re.MULTILINE)
             with open('opensc-fdroid.cfg', 'w') as f:
                 f.write(opensc_fdroid)
-    elif not os.path.exists(keystore):
+    elif os.path.exists(keystore):
+        to_set = ['keystorepass', 'keypass', 'repo_keyalias', 'keydname']
+        if repo_keyalias:
+            to_set.remove('repo_keyalias')
+        if keydname:
+            to_set.remove('keydname')
+        logging.warning('\n' + _('Using existing keystore "{path}"').format(path=keystore)
+                        + '\n' + _('Now set these in config.py:') + ' '
+                        + ', '.join(to_set) + '\n')
+    else:
         password = common.genpassword()
         c = dict(test_config)
         c['keystorepass'] = password