chiark / gitweb /
build: set default config for .fdroid.* metadata
authorHans-Christoph Steiner <hans@eds.org>
Wed, 5 Aug 2015 13:18:22 +0000 (15:18 +0200)
committerHans-Christoph Steiner <hans@eds.org>
Wed, 23 Mar 2016 16:16:28 +0000 (17:16 +0100)
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.

fdroidserver/build.py
fdroidserver/common.py

index b64cc9207952146bf0c596f4a94a3f80bc0c2d4a..7f647b8fda798efe1e622f95f105cc0486f01b2d 100644 (file)
@@ -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)
 
index df7977af20610f70c3e12047da79f47aa903b433..72af49d8035a979114a57cbcaa55ce5fc77f707e 100644 (file)
@@ -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):