# Figure out what kind of project it is...
projecttype = None
- app['Web Site'] = url # by default, we might override it
+ app.WebSite = url # by default, we might override it
if url.startswith('git://'):
projecttype = 'git'
repo = url
repotype = 'git'
- app['Source Code'] = ""
- app['Web Site'] = ""
+ app.SourceCode = ""
+ app.WebSite = ""
elif url.startswith('https://github.com'):
projecttype = 'github'
repo = url
repotype = 'git'
- app['Source Code'] = url
- app['issuetracker'] = url + '/issues'
- app['Web Site'] = ""
+ app.SourceCode = url
+ app.IssueTracker = url + '/issues'
+ app.WebSite = ""
elif url.startswith('https://gitlab.com/'):
projecttype = 'gitlab'
# git can be fussy with gitlab URLs unless they end in .git
else:
repo = url + '.git'
repotype = 'git'
- app['Source Code'] = url + '/tree/HEAD'
- app['issuetracker'] = url + '/issues'
+ app.SourceCode = url + '/tree/HEAD'
+ app.IssueTracker = url + '/issues'
elif url.startswith('https://bitbucket.org/'):
if url.endswith('/'):
url = url[:-1]
projecttype = 'bitbucket'
- app['Source Code'] = url + '/src'
- app['issuetracker'] = url + '/issues'
+ app.SourceCode = url + '/src'
+ app.IssueTracker = url + '/issues'
# Figure out the repo type and adddress...
- repotype, repo = getrepofrompage(app['Source Code'])
+ repotype, repo = getrepofrompage(app.SourceCode)
if not repotype:
logging.error("Unable to determine vcs type. " + repo)
sys.exit(1)
# Get a copy of the source so we can extract some info...
logging.info('Getting source from ' + repotype + ' repo at ' + repo)
- src_dir = os.path.join(tmp_dir, 'importer')
- if os.path.exists(src_dir):
- shutil.rmtree(src_dir)
- vcs = common.getvcs(repotype, repo, src_dir)
+ build_dir = os.path.join(tmp_dir, 'importer')
+ if os.path.exists(build_dir):
+ shutil.rmtree(build_dir)
+ vcs = common.getvcs(repotype, repo, build_dir)
vcs.gotorevision(options.rev)
- if options.subdir:
- root_dir = os.path.join(src_dir, options.subdir)
- else:
- root_dir = src_dir
+ root_dir = get_subdir(build_dir)
- app['Repo Type'] = repotype
- app['Repo'] = repo
+ app.RepoType = repotype
+ app.Repo = repo
- return root_dir, src_dir
+ return root_dir, build_dir
config = None
options = None
+def get_subdir(build_dir):
+ if options.subdir:
+ return os.path.join(build_dir, options.subdir)
+
+ return build_dir
+
+
def main():
global config, options
# Parse command line...
parser = ArgumentParser()
- parser.add_argument("-v", "--verbose", action="store_true", default=False,
- help="Spew out even more information than normal")
- parser.add_argument("-q", "--quiet", action="store_true", default=False,
- help="Restrict output to warnings and errors")
+ common.setup_global_opts(parser)
parser.add_argument("-u", "--url", default=None,
help="Project URL to import from.")
parser.add_argument("-s", "--subdir", default=None,
config = common.read_config(options)
apps = metadata.read_metadata()
- package, app = metadata.get_default_app_info_list(apps)
- app['Update Check Mode'] = "Tags"
+ app = metadata.App()
+ app.UpdateCheckMode = "Tags"
- if os.path.isdir('.git'):
+ root_dir = None
+ build_dir = None
+
+ if options.url:
+ root_dir, build_dir = get_metadata_from_url(app, options.url)
+ elif os.path.isdir('.git'):
if options.url:
- app['Web Site'] = options.url
- elif options.url:
- root_dir, src_dir = get_metadata_from_url(app, options.url)
+ app.WebSite = options.url
+ root_dir = get_subdir(os.getcwd())
else:
logging.error("Specify project url.")
sys.exit(1)
paths = common.manifest_paths(root_dir, [])
if paths:
- version, vercode, package = common.parse_androidmanifests(paths)
+ version, vercode, package = common.parse_androidmanifests(paths, app)
if not package:
logging.error("Couldn't find package ID")
sys.exit(1)
sys.exit(1)
# Create a build line...
- build = {}
- build['version'] = version or '?'
- build['vercode'] = vercode or '?'
- build['commit'] = '?'
- build['disable'] = 'Generated by import.py - check/set version fields and commit id'
+ build = metadata.Build()
+ build.version = version or '?'
+ build.vercode = vercode or '?'
+ build.commit = '?'
+ build.disable = 'Generated by import.py - check/set version fields and commit id'
if options.subdir:
- build['subdir'] = options.subdir
+ build.subdir = options.subdir
if os.path.exists(os.path.join(root_dir, 'jni')):
- build['buildjni'] = ['yes']
-
- for flag, value in metadata.flag_defaults.iteritems():
- if flag in build:
- continue
- build[flag] = value
+ build.buildjni = ['yes']
- app['builds'].append(build)
+ app.builds.append(build)
# Keep the repo directory to save bandwidth...
if not os.path.exists('build'):
os.mkdir('build')
- if src_dir is not None:
- shutil.move(src_dir, os.path.join('build', package))
+ if build_dir is not None:
+ shutil.move(build_dir, os.path.join('build', package))
with open('build/.fdroidvcs-' + package, 'w') as f:
- f.write(app['Repo Type'] + ' ' + app['Repo'])
+ f.write(app.RepoType + ' ' + app.Repo)
metadatapath = os.path.join('metadata', package + '.txt')
- metadata.write_metadata(metadatapath, app)
+ with open(metadatapath, 'w') as f:
+ metadata.write_metadata('txt', f, app)
logging.info("Wrote " + metadatapath)