From 0345d2c79f11501110b69307a4f9922dd8bb1d7b Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 18 May 2017 17:20:24 +0200 Subject: [PATCH] update: find aapt when it is not in the PATH 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 | 2 +- fdroidserver/common.py | 2 +- fdroidserver/update.py | 2 +- tests/androguard_test.py | 9 +++------ 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/fdroidserver/build.py b/fdroidserver/build.py index 5b21939b..bf790970 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -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) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index df90e5f4..cc1df84e 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -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) diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 2c590ac9..71277c3e 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -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) diff --git a/tests/androguard_test.py b/tests/androguard_test.py index 9e5d845a..c708b85f 100644 --- a/tests/androguard_test.py +++ b/tests/androguard_test.py @@ -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() -- 2.30.2