Be consistent about root_dir/build_dir naming

This commit is contained in:
Daniel Martí 2015-10-25 11:41:46 +01:00
parent 7e7d67f0d7
commit fa55ec0e87
2 changed files with 20 additions and 18 deletions

View file

@ -117,10 +117,11 @@ def check_tags(app, pattern):
vcs.gotorevision(None) vcs.gotorevision(None)
root_dir = build_dir
flavours = [] flavours = []
if len(app['builds']) > 0: if len(app['builds']) > 0:
if app['builds'][-1]['subdir']: if app['builds'][-1]['subdir']:
build_dir = os.path.join(build_dir, app['builds'][-1]['subdir']) root_dir = os.path.join(build_dir, app['builds'][-1]['subdir'])
if app['builds'][-1]['gradle']: if app['builds'][-1]['gradle']:
flavours = app['builds'][-1]['gradle'] flavours = app['builds'][-1]['gradle']
@ -145,7 +146,7 @@ def check_tags(app, pattern):
vcs.gotorevision(tag) vcs.gotorevision(tag)
# Only process tags where the manifest exists... # Only process tags where the manifest exists...
paths = common.manifest_paths(build_dir, flavours) paths = common.manifest_paths(root_dir, flavours)
version, vercode, package = \ version, vercode, package = \
common.parse_androidmanifests(paths, app['Update Check Ignore']) common.parse_androidmanifests(paths, app['Update Check Ignore'])
if not app_matches_packagename(app, package) or not version or not vercode: if not app_matches_packagename(app, package) or not version or not vercode:
@ -204,17 +205,18 @@ def check_repomanifest(app, branch=None):
elif repotype == 'bzr': elif repotype == 'bzr':
vcs.gotorevision(None) vcs.gotorevision(None)
root_dir = build_dir
flavours = [] flavours = []
if len(app['builds']) > 0: if len(app['builds']) > 0:
if app['builds'][-1]['subdir']: if app['builds'][-1]['subdir']:
build_dir = os.path.join(build_dir, app['builds'][-1]['subdir']) root_dir = os.path.join(build_dir, app['builds'][-1]['subdir'])
if app['builds'][-1]['gradle']: if app['builds'][-1]['gradle']:
flavours = app['builds'][-1]['gradle'] flavours = app['builds'][-1]['gradle']
if not os.path.isdir(build_dir): if not os.path.isdir(root_dir):
return (None, "Subdir '" + app['builds'][-1]['subdir'] + "'is not a valid directory") return (None, "Subdir '" + app['builds'][-1]['subdir'] + "'is not a valid directory")
paths = common.manifest_paths(build_dir, flavours) paths = common.manifest_paths(root_dir, flavours)
version, vercode, package = \ version, vercode, package = \
common.parse_androidmanifests(paths, app['Update Check Ignore']) common.parse_androidmanifests(paths, app['Update Check Ignore'])

View file

@ -132,28 +132,28 @@ def get_metadata_from_url(app, url):
# Get a copy of the source so we can extract some info... # Get a copy of the source so we can extract some info...
logging.info('Getting source from ' + repotype + ' repo at ' + repo) logging.info('Getting source from ' + repotype + ' repo at ' + repo)
src_dir = os.path.join(tmp_dir, 'importer') build_dir = os.path.join(tmp_dir, 'importer')
if os.path.exists(src_dir): if os.path.exists(build_dir):
shutil.rmtree(src_dir) shutil.rmtree(build_dir)
vcs = common.getvcs(repotype, repo, src_dir) vcs = common.getvcs(repotype, repo, build_dir)
vcs.gotorevision(options.rev) vcs.gotorevision(options.rev)
root_dir = get_subdir(src_dir) root_dir = get_subdir(build_dir)
app['Repo Type'] = repotype app['Repo Type'] = repotype
app['Repo'] = repo app['Repo'] = repo
return root_dir, src_dir return root_dir, build_dir
config = None config = None
options = None options = None
def get_subdir(src_dir): def get_subdir(build_dir):
if options.subdir: if options.subdir:
return os.path.join(src_dir, options.subdir) return os.path.join(build_dir, options.subdir)
return src_dir return build_dir
def main(): def main():
@ -178,10 +178,10 @@ def main():
app['Update Check Mode'] = "Tags" app['Update Check Mode'] = "Tags"
root_dir = None root_dir = None
src_dir = None build_dir = None
if options.url: if options.url:
root_dir, src_dir = get_metadata_from_url(app, options.url) root_dir, build_dir = get_metadata_from_url(app, options.url)
elif os.path.isdir('.git'): elif os.path.isdir('.git'):
if options.url: if options.url:
app['Web Site'] = options.url app['Web Site'] = options.url
@ -242,8 +242,8 @@ def main():
# Keep the repo directory to save bandwidth... # Keep the repo directory to save bandwidth...
if not os.path.exists('build'): if not os.path.exists('build'):
os.mkdir('build') os.mkdir('build')
if src_dir is not None: if build_dir is not None:
shutil.move(src_dir, os.path.join('build', package)) shutil.move(build_dir, os.path.join('build', package))
with open('build/.fdroidvcs-' + package, 'w') as f: with open('build/.fdroidvcs-' + package, 'w') as f:
f.write(app['Repo Type'] + ' ' + app['Repo']) f.write(app['Repo Type'] + ' ' + app['Repo'])