mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 22:42:29 +03:00
Use python-magic, filemagic's official python binding lib
This commit is contained in:
parent
bd59b2f77d
commit
fb5a2209fc
2 changed files with 40 additions and 37 deletions
|
@ -139,7 +139,7 @@ Paramiko (debian package python-paramiko)
|
||||||
@item
|
@item
|
||||||
Imaging (debian package python-imaging)
|
Imaging (debian package python-imaging)
|
||||||
@item
|
@item
|
||||||
Filemagic (pip install filemagic)
|
Magic (debian package python-magic)
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import subprocess
|
||||||
import time
|
import time
|
||||||
import operator
|
import operator
|
||||||
import cgi
|
import cgi
|
||||||
|
import magic
|
||||||
|
|
||||||
def getvcs(vcstype, remote, local, sdk_path):
|
def getvcs(vcstype, remote, local, sdk_path):
|
||||||
if vcstype == 'git':
|
if vcstype == 'git':
|
||||||
|
@ -1589,9 +1590,10 @@ def scan_source(build_dir, root_dir, thisbuild):
|
||||||
else:
|
else:
|
||||||
ignore = []
|
ignore = []
|
||||||
|
|
||||||
|
ms = magic.open(magic.MIME_TYPE)
|
||||||
|
ms.load()
|
||||||
|
|
||||||
# Iterate through all files in the source code...
|
# Iterate through all files in the source code...
|
||||||
import magic
|
|
||||||
with magic.Magic(flags=magic.MAGIC_MIME_TYPE) as m:
|
|
||||||
for r,d,f in os.walk(build_dir):
|
for r,d,f in os.walk(build_dir):
|
||||||
for curfile in f:
|
for curfile in f:
|
||||||
|
|
||||||
|
@ -1615,7 +1617,7 @@ def scan_source(build_dir, root_dir, thisbuild):
|
||||||
if suspect in curfile.lower():
|
if suspect in curfile.lower():
|
||||||
problems.append('Found probable non-free blob ' + fp)
|
problems.append('Found probable non-free blob ' + fp)
|
||||||
|
|
||||||
mime = m.id_filename(fp)
|
mime = ms.file(fp)
|
||||||
if mime == 'application/x-sharedlib':
|
if mime == 'application/x-sharedlib':
|
||||||
problems.append('Found shared library at %s' % fd)
|
problems.append('Found shared library at %s' % fd)
|
||||||
elif mime == 'application/x-archive':
|
elif mime == 'application/x-archive':
|
||||||
|
@ -1630,6 +1632,7 @@ def scan_source(build_dir, root_dir, thisbuild):
|
||||||
if 'DexClassLoader' in line:
|
if 'DexClassLoader' in line:
|
||||||
problems.append('Found DexClassLoader in ' + fp)
|
problems.append('Found DexClassLoader in ' + fp)
|
||||||
break
|
break
|
||||||
|
ms.close()
|
||||||
|
|
||||||
# Presence of a jni directory without buildjni=yes might
|
# Presence of a jni directory without buildjni=yes might
|
||||||
# indicate a problem... (if it's not a problem, explicitly use
|
# indicate a problem... (if it's not a problem, explicitly use
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue