mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 22:42:29 +03:00
New field: scandelete, like scanignore but deleting
Also, many improvements: * scanning algorithm is much clearer * Now paths start by '/', which means the repo dir root. - If they don't, '/' is added - If they start by './', the dot is removed - If "." is in the paths, it is replaced by "/" * Handling/removing of problems is much easier * Removed last initfun/funambol bits
This commit is contained in:
parent
d507b2e894
commit
e07d35f913
2 changed files with 58 additions and 28 deletions
|
@ -346,7 +346,7 @@ Along similar lines (and only in conjunction with @code{--test}, you can use
|
||||||
@code{--force} to force a build of a Disabled application, where normally it
|
@code{--force} to force a build of a Disabled application, where normally it
|
||||||
would be completely ignored. Similarly a version that was found to contain
|
would be completely ignored. Similarly a version that was found to contain
|
||||||
ELFs or known non-free libraries can be forced to build. See also —
|
ELFs or known non-free libraries can be forced to build. See also —
|
||||||
scanignore= in the Build Version section.
|
scanignore= and scandelete= in the Build Version section.
|
||||||
|
|
||||||
If the build was unsuccessful, you can find out why by looking at the output
|
If the build was unsuccessful, you can find out why by looking at the output
|
||||||
in the logs/ directory. If that isn't illuminating, try building the app the
|
in the logs/ directory. If that isn't illuminating, try building the app the
|
||||||
|
@ -908,17 +908,17 @@ You can use $$SDK$$, $$NDK$$ and $$MVN3$$ to substitute the paths to the
|
||||||
android SDK and NDK directories, and maven 3 executable respectively e.g.
|
android SDK and NDK directories, and maven 3 executable respectively e.g.
|
||||||
for when you need to run @code{android update project} explicitly.
|
for when you need to run @code{android update project} explicitly.
|
||||||
|
|
||||||
@item initfun=yes
|
|
||||||
Enables a selection of mad hacks to make com.funambol.android build.
|
|
||||||
Probably not useful for any other application.
|
|
||||||
|
|
||||||
@item scanignore=path1;path2;...
|
@item scanignore=path1;path2;...
|
||||||
Enables one or more files/paths to be exlcuded from the scan process.
|
Enables one or more files/paths to be exlcuded from the scan process.
|
||||||
This should only be used where there is a very good reason, and
|
This should only be used where there is a very good reason, and
|
||||||
probably accompanied by a comment explaining why it is necessary.
|
probably accompanied by a comment explaining why it is necessary.
|
||||||
|
|
||||||
When scanning, files whose relative paths start with any of the paths
|
When scanning the source tree for problems, matching files whose relative
|
||||||
given here are ignored.
|
paths start with any of the paths given here are ignored.
|
||||||
|
|
||||||
|
@item scandelete=path1;path2;...
|
||||||
|
Similar to scanignore=, but instead of ignoring files under the given paths,
|
||||||
|
it tells f-droid to delete the matching files directly.
|
||||||
|
|
||||||
@item build=xxxx
|
@item build=xxxx
|
||||||
As for 'prebuild', but runs during the actual build phase (but before the
|
As for 'prebuild', but runs during the actual build phase (but before the
|
||||||
|
|
|
@ -805,7 +805,7 @@ def write_metadata(dest, app, verbose=False):
|
||||||
'oldsdkloc', 'target', 'compilesdk', 'update',
|
'oldsdkloc', 'target', 'compilesdk', 'update',
|
||||||
'encoding', 'forceversion', 'forcevercode', 'rm',
|
'encoding', 'forceversion', 'forcevercode', 'rm',
|
||||||
'fixtrans', 'fixapos', 'extlibs', 'srclibs',
|
'fixtrans', 'fixapos', 'extlibs', 'srclibs',
|
||||||
'patch', 'prebuild', 'initfun', 'scanignore', 'build',
|
'patch', 'prebuild', 'scanignore', 'scandelete', 'build',
|
||||||
'buildjni', 'gradle', 'maven', 'preassemble',
|
'buildjni', 'gradle', 'maven', 'preassemble',
|
||||||
'bindir', 'antcommand', 'novcheck']
|
'bindir', 'antcommand', 'novcheck']
|
||||||
|
|
||||||
|
@ -1640,14 +1640,50 @@ def scan_source(build_dir, root_dir, thisbuild):
|
||||||
'youtubeandroidplayerapi',
|
'youtubeandroidplayerapi',
|
||||||
'bugsense']
|
'bugsense']
|
||||||
|
|
||||||
if 'scanignore' in thisbuild:
|
def getpaths(field):
|
||||||
ignore = [p.strip() for p in thisbuild['scanignore'].split(';')]
|
paths = []
|
||||||
else:
|
if field not in thisbuild:
|
||||||
ignore = []
|
return paths
|
||||||
|
for p in thisbuild[field].split(';'):
|
||||||
|
p = p.strip()
|
||||||
|
if p == '.':
|
||||||
|
p = '/'
|
||||||
|
elif p.startswith('./'):
|
||||||
|
p = p[1:]
|
||||||
|
elif not p.startswith('/'):
|
||||||
|
p = '/' + p;
|
||||||
|
if p not in paths:
|
||||||
|
paths.append(p)
|
||||||
|
return paths
|
||||||
|
|
||||||
|
scanignore = getpaths('scanignore')
|
||||||
|
scandelete = getpaths('scandelete')
|
||||||
|
|
||||||
ms = magic.open(magic.MIME_TYPE)
|
ms = magic.open(magic.MIME_TYPE)
|
||||||
ms.load()
|
ms.load()
|
||||||
|
|
||||||
|
def toignore(fd):
|
||||||
|
for i in scanignore:
|
||||||
|
if fd.startswith(i):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def todelete(fd):
|
||||||
|
for i in scandelete:
|
||||||
|
if fd.startswith(i):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def removeproblem(what, fd, fp):
|
||||||
|
print 'Removing %s at %s' % (what, fd)
|
||||||
|
os.remove(fp)
|
||||||
|
|
||||||
|
def handleproblem(what, fd, fp):
|
||||||
|
if todelete(fd):
|
||||||
|
removeproblem(what, fd, fp)
|
||||||
|
else:
|
||||||
|
problems.append('Found %s at %s' % (what, fd))
|
||||||
|
|
||||||
# Iterate through all files in the source code...
|
# Iterate through all files in the source code...
|
||||||
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:
|
||||||
|
@ -1657,36 +1693,30 @@ def scan_source(build_dir, root_dir, thisbuild):
|
||||||
|
|
||||||
# Path (relative) to the file...
|
# Path (relative) to the file...
|
||||||
fp = os.path.join(r, curfile)
|
fp = os.path.join(r, curfile)
|
||||||
fd = fp[len(build_dir)+1:]
|
fd = fp[len(build_dir):]
|
||||||
|
|
||||||
# Check if this file has been explicitly excluded from scanning...
|
# Check if this file has been explicitly excluded from scanning...
|
||||||
ignorethis = False
|
if toignore(fd):
|
||||||
for i in ignore:
|
|
||||||
if fd.startswith(i):
|
|
||||||
ignorethis = True
|
|
||||||
break
|
|
||||||
if ignorethis:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for suspect in usual_suspects:
|
for suspect in usual_suspects:
|
||||||
if suspect in curfile.lower():
|
if suspect in curfile.lower():
|
||||||
problems.append('Found usual supect in filename ' + fp)
|
handleproblem('usual supect', fd, fp)
|
||||||
|
|
||||||
mime = ms.file(fp)
|
mime = ms.file(fp)
|
||||||
if mime == 'application/x-sharedlib':
|
if mime == 'application/x-sharedlib':
|
||||||
problems.append('Found shared library at %s' % fd)
|
handleproblem('shared library', fd, fp)
|
||||||
elif mime == 'application/x-archive':
|
elif mime == 'application/x-archive':
|
||||||
problems.append('Found static library at %s' % fd)
|
handleproblem('static library', fd, fp)
|
||||||
elif mime == 'application/x-executable':
|
elif mime == 'application/x-executable':
|
||||||
problems.append('Found binary executable at %s' % fd)
|
handleproblem('binary executable', fd, fp)
|
||||||
elif mime == 'application/jar' and fp.endswith('.apk'):
|
elif mime == 'application/jar' and fp.endswith('.apk'):
|
||||||
print 'Removing apk file at %s' % fd
|
removeproblem('APK file', fd, fp)
|
||||||
os.remove(fp)
|
|
||||||
|
|
||||||
elif curfile.endswith('.java'):
|
elif curfile.endswith('.java'):
|
||||||
for line in file(fp):
|
for line in file(fp):
|
||||||
if 'DexClassLoader' in line:
|
if 'DexClassLoader' in line:
|
||||||
problems.append('Found DexClassLoader in ' + fp)
|
handleproblem('DexClassLoader', fd, fp)
|
||||||
break
|
break
|
||||||
ms.close()
|
ms.close()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue