mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-14 06:52:39 +03:00
Rework path glob expansion
Slightly simplifies the whole thing and lets us map what each resulting path comes from. This will be useful to fix #110 later on.
This commit is contained in:
parent
75bde83fb8
commit
59f5d19dfe
2 changed files with 19 additions and 8 deletions
|
@ -1383,7 +1383,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
|
||||||
# Delete unwanted files
|
# Delete unwanted files
|
||||||
if build['rm']:
|
if build['rm']:
|
||||||
logging.info("Removing specified files")
|
logging.info("Removing specified files")
|
||||||
for part in getpaths(build_dir, build, 'rm'):
|
for part in getpaths(build_dir, build['rm']):
|
||||||
dest = os.path.join(build_dir, part)
|
dest = os.path.join(build_dir, part)
|
||||||
logging.info("Removing {0}".format(part))
|
logging.info("Removing {0}".format(part))
|
||||||
if os.path.lexists(dest):
|
if os.path.lexists(dest):
|
||||||
|
@ -1462,14 +1462,25 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
|
||||||
return (root_dir, srclibpaths)
|
return (root_dir, srclibpaths)
|
||||||
|
|
||||||
|
|
||||||
# Split and extend via globbing the paths from a field
|
# Extend via globbing the paths from a field and return them as a map from
|
||||||
def getpaths(build_dir, build, field):
|
# original path to resulting paths
|
||||||
paths = []
|
def getpaths_map(build_dir, globpaths):
|
||||||
for p in build[field]:
|
paths = dict()
|
||||||
|
for p in globpaths:
|
||||||
p = p.strip()
|
p = p.strip()
|
||||||
full_path = os.path.join(build_dir, p)
|
full_path = os.path.join(build_dir, p)
|
||||||
full_path = os.path.normpath(full_path)
|
full_path = os.path.normpath(full_path)
|
||||||
paths += [r[len(build_dir) + 1:] for r in glob.glob(full_path)]
|
paths[p] = [r[len(build_dir) + 1:] for r in glob.glob(full_path)]
|
||||||
|
return paths
|
||||||
|
|
||||||
|
|
||||||
|
# Extend via globbing the paths from a field and return them as a set
|
||||||
|
def getpaths(build_dir, globpaths):
|
||||||
|
paths_map = getpaths_map(build_dir, globpaths)
|
||||||
|
paths = set()
|
||||||
|
for k, v in paths_map.iteritems():
|
||||||
|
for p in v:
|
||||||
|
paths.add(p)
|
||||||
return paths
|
return paths
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -72,8 +72,8 @@ def scan_source(build_dir, root_dir, thisbuild):
|
||||||
if r.match(s):
|
if r.match(s):
|
||||||
yield n
|
yield n
|
||||||
|
|
||||||
scanignore = common.getpaths(build_dir, thisbuild, 'scanignore')
|
scanignore = common.getpaths(build_dir, thisbuild['scanignore'])
|
||||||
scandelete = common.getpaths(build_dir, thisbuild, 'scandelete')
|
scandelete = common.getpaths(build_dir, thisbuild['scandelete'])
|
||||||
|
|
||||||
scanignore_worked = set()
|
scanignore_worked = set()
|
||||||
scandelete_worked = set()
|
scandelete_worked = set()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue