chiark / gitweb /
update: find aapt when it is not in the PATH
authorHans-Christoph Steiner <hans@eds.org>
Thu, 18 May 2017 15:20:24 +0000 (17:20 +0200)
committerHans-Christoph Steiner <hans@eds.org>
Thu, 18 May 2017 15:21:05 +0000 (17:21 +0200)
This is some very messy logic built up since 2010.  This will all go away
once we have a python3 version of androguard available.

The removed imports and `dir(APK)` is to silence pyflakes

closes #303

fdroidserver/build.py
fdroidserver/common.py
fdroidserver/update.py
tests/androguard_test.py

index 5b21939b630c124731e99ed24f568a6d46c2e40b..bf790970ae891a32eb14ecc34253e8228a05b5f8 100644 (file)
@@ -544,7 +544,7 @@ def get_apk_metadata_androguard(apkfile):
 def get_metadata_from_apk(app, build, apkfile):
     """get the required metadata from the built APK"""
 
-    if common.set_command_in_config('aapt'):
+    if common.SdkToolsPopen(['aapt', 'version'], output=False):
         vercode, version, foundid, nativecode = get_apk_metadata_aapt(apkfile)
     else:
         vercode, version, foundid, nativecode = get_apk_metadata_androguard(apkfile)
index df90e5f4be8f403147b1e3b6cdede1480e8f1ccd..cc1df84e6af495ac225c48661a62a955a1e2242f 100644 (file)
@@ -1727,7 +1727,7 @@ def isApkAndDebuggable(apkfile, config):
     if get_file_extension(apkfile) != 'apk':
         return False
 
-    if set_command_in_config('aapt'):
+    if SdkToolsPopen(['aapt', 'version'], output=False):
         return get_apk_debuggable_aapt(apkfile)
     else:
         return get_apk_debuggable_androguard(apkfile)
index 2c590ac9766ddd98d5b334e7747b590e5dcedc92..71277c3e6ad9a84f625d7c54f9efd34f23552e36 100644 (file)
@@ -1128,7 +1128,7 @@ def scan_apk(apkcache, apkfilename, repodir, knownapks, use_date_from_apk):
             apk['antiFeatures'].add('KnownVuln')
 
         try:
-            if common.set_command_in_config('aapt'):
+            if SdkToolsPopen(['aapt', 'version'], output=False):
                 scan_apk_aapt(apk, apkfile)
             else:
                 scan_apk_androguard(apk, apkfile)
index 9e5d845a2fe30a68fc056e1d1c714c69a3feee5b..c708b85f75985e1c332f5bd3b620d7861ea6f428 100644 (file)
@@ -4,12 +4,8 @@ import inspect
 import logging
 import optparse
 import os
-import shutil
 import sys
-import tempfile
 import unittest
-import yaml
-from binascii import unhexlify
 
 localmodule = os.path.realpath(
     os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..'))
@@ -53,9 +49,10 @@ class UpdateTest(unittest.TestCase):
         fdroidserver.update.options.clean = True
         fdroidserver.update.options.delete_unknown = True
 
-        self.assertTrue(fdroidserver.common.set_command_in_config('aapt'))
+        self.assertTrue(fdroidserver.common.SdkToolsPopen('aapt'))
         try:
             from androguard.core.bytecodes.apk import APK
+            dir(APK)
         except ImportError:
             raise Exception("androguard not installed!")
 
@@ -89,4 +86,4 @@ if __name__ == "__main__":
 
     newSuite = unittest.TestSuite()
     newSuite.addTest(unittest.makeSuite(UpdateTest))
-    unittest.main()
\ No newline at end of file
+    unittest.main()