From 4f61623501be3ad617c104f7d4e2243a7dab17e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 17 Mar 2013 12:29:54 +0100 Subject: [PATCH 1/2] Better scan --- fdroidserver/common.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index ee59f058..2a0ea00c 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -1961,26 +1961,30 @@ def scan_source(build_dir, root_dir, thisbuild): for r,d,f in os.walk(build_dir): for curfile in f: - if r.find('/.hg/') == -1: + if r.find('/.hg') != -1 or r.find('/.git') != -1: + continue - # Path (relative) to the file... - fp = os.path.join(r, curfile) + # Path (relative) to the file... + fp = os.path.join(r, curfile) - for suspect in usual_suspects: - if curfile.lower().find(suspect) != -1: - msg = 'Found probable non-free blob ' + fp - problems.append(msg) - - if curfile.endswith('.apk'): - msg = 'Found apk file, which should not be in the source - ' + fp + for suspect in usual_suspects: + if curfile.lower().find(suspect) != -1: + msg = 'Found probable non-free blob ' + fp problems.append(msg) - if curfile.endswith('.java'): - for line in file(fp): + if curfile.endswith('.apk'): + msg = 'Found apk file, which should not be in the source - ' + fp + problems.append(msg) - if line.find('DexClassLoader') != -1: - msg = 'Found DexClassLoader in ' + fp - problems.append(msg) + elif curfile.endswith('.so') or curfile.endswith('.elf'): + msg = 'Found ELF at ' + fp + problems.append(msg) + + elif curfile.endswith('.java'): + for line in file(fp): + if line.find('DexClassLoader') != -1: + msg = 'Found DexClassLoader in ' + fp + problems.append(msg) # Presence of a jni directory without buildjni=yes might # indicate a problem... (if it's not a problem, explicitly use From 2b4b4845309ac0e5267239a6b171e0bc3c9804e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 17 Mar 2013 12:44:06 +0100 Subject: [PATCH 2/2] Don't need to use find() --- fdroidserver/common.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 2a0ea00c..808d80cf 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -1961,14 +1961,14 @@ def scan_source(build_dir, root_dir, thisbuild): for r,d,f in os.walk(build_dir): for curfile in f: - if r.find('/.hg') != -1 or r.find('/.git') != -1: + if '/.hg' in r or '/.git' in r or '/.svn' in r: continue # Path (relative) to the file... fp = os.path.join(r, curfile) for suspect in usual_suspects: - if curfile.lower().find(suspect) != -1: + if suspect in curfile.lower(): msg = 'Found probable non-free blob ' + fp problems.append(msg) @@ -1982,7 +1982,7 @@ def scan_source(build_dir, root_dir, thisbuild): elif curfile.endswith('.java'): for line in file(fp): - if line.find('DexClassLoader') != -1: + if 'DexClassLoader' in line: msg = 'Found DexClassLoader in ' + fp problems.append(msg)