From: Hans-Christoph Steiner Date: Wed, 5 Aug 2015 13:18:22 +0000 (+0200) Subject: build: set default config for .fdroid.* metadata X-Git-Tag: 0.7.0~75^2~4 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=578218a8b083c8e31be46d5c7f55b0cdbe1b3008;p=fdroidserver.git build: set default config for .fdroid.* metadata The default config for .fdroid.* metadata that is included in a git repo is different than for the standard metadata/ layout because the expectations are different. In this case, the most common user will be the app developer working on the latest update of the app on their own machine. --- diff --git a/fdroidserver/build.py b/fdroidserver/build.py index b64cc920..7f647b8f 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -1002,17 +1002,25 @@ def main(): options, parser = parse_commandline() - metadata_files = glob.glob('.fdroid.*[a-z]') # ignore files ending in ~ - if os.path.isdir('metadata'): - pass - elif len(metadata_files) == 0: - raise FDroidException("No app metadata found, nothing to process!") - elif len(metadata_files) > 1: + # The defaults for .fdroid.* metadata that is included in a git repo are + # different than for the standard metadata/ layout because expectations + # are different. In this case, the most common user will be the app + # developer working on the latest update of the app on their own machine. + local_metadata_files = common.get_local_local_metadata_files() + if len(local_metadata_files) == 1: # there is local metadata in an app's source + config = dict(common.default_config) + # `fdroid build` should build only the latest version by default since + # most of the time the user will be building the most recent update + if not options.all: + options.latest = True + elif len(local_metadata_files) > 1: raise FDroidException("Only one local metadata file allowed! Found: " - + " ".join(metadata_files)) - - if not options.appid and not options.all: - parser.error("option %s: If you really want to build all the apps, use --all" % "all") + + " ".join(local_metadata_files)) + else: + if not os.path.isdir('metadata') and len(local_metadata_files) == 0: + raise FDroidException("No app metadata found, nothing to process!") + if not options.appid and not options.all: + parser.error("option %s: If you really want to build all the apps, use --all" % "all") config = common.read_config(options) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index df7977af..72af49d8 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -214,7 +214,7 @@ def read_config(opts, config_file='config.py'): with io.open(config_file, "rb") as f: code = compile(f.read(), config_file, 'exec') exec(code, None, config) - elif len(glob.glob('.fdroid.[a-z]*')) == 0: + elif len(get_local_metadata_files()) == 0: logging.critical("Missing config file - is this a repo directory?") sys.exit(2) @@ -361,6 +361,16 @@ def write_password_file(pwtype, password=None): config[pwtype + 'file'] = filename +def get_local_metadata_files(): + '''get any metadata files local to an app's source repo + + This tries to ignore anything that does not count as app metdata, + including emacs cruft ending in ~ and the .fdroid.key*pass.txt files. + + ''' + return glob.glob('.fdroid.[a-jl-z]*[a-rt-z]') + + # Given the arguments in the form of multiple appid:[vc] strings, this returns # a dictionary with the set of vercodes specified for each package. def read_pkg_args(args, allow_vercodes=False):