chiark / gitweb /
Allow archive policy override for indivudual apps
authorCiaran Gultnieks <ciaran@ciarang.com>
Mon, 14 Oct 2013 15:16:34 +0000 (16:16 +0100)
committerCiaran Gultnieks <ciaran@ciarang.com>
Mon, 14 Oct 2013 15:16:34 +0000 (16:16 +0100)
docs/fdroid.texi
fdroidserver/common.py
fdroidserver/update.py

index 005fd70176f526fc4eea0ff3053d8979796d2981..40f5b362050e75be7618ea36d3a19f111767dbe2 100644 (file)
@@ -472,6 +472,7 @@ The following sections describe the fields recognised within the file.
 * AntiFeatures::
 * Disabled::
 * Requires Root::
+* Archive Policy::
 * Update Check Mode::
 * Update Check Data::
 * Auto Update Mode::
@@ -1123,6 +1124,19 @@ again, rather than retrieving a different one.
 
 Used in conjunction with @code{Update Check Mode} for certain modes.
 
+@node Archive Policy
+@section Archive Policy
+
+@cindex Archive Policy
+
+This determines the policy for moving old versions of an app to the archive
+repo, if one is configured. The configuration sets a default maximum number
+of versions kept in the main repo, after which older ones are moved to the
+archive. This app-specific policy setting can override that.
+
+Currently the only supported format is "n versions", where n is the number
+of versions to keep.
+
 @node Auto Update Mode
 @section Auto Update Mode
 
index 38791d5a67e54082401c7ab95bac0237a3bfdd6f..ff0e9edd822a5bfdc91fdbb21f7da653503fd6fd 100644 (file)
@@ -485,6 +485,7 @@ def parse_metadata(metafile, **kw):
     thisinfo['Litecoin'] = None
     thisinfo['Disabled'] = None
     thisinfo['AntiFeatures'] = None
+    thisinfo['Archive Policy'] = None
     thisinfo['Update Check Mode'] = 'None'
     thisinfo['Auto Update Mode'] = 'None'
     thisinfo['Current Version'] = ''
@@ -578,6 +579,17 @@ def parse_metadata(metafile, **kw):
     if len(thisinfo['Description']) == 0:
         thisinfo['Description'].append('No description available')
 
+    # Validate archive policy...
+    if thisinfo['Archive Policy']:
+        if not thisinfo['Archive Policy'].endswith(' versions'):
+            raise MetaDataException("Invalid archive policy")
+        try:
+            versions = int(thisinfo['Archive Policy'][:-9])
+            if versions < 1 or versions > 20:
+                raise MetaDataException("Silly number of days for archive policy")
+        except:
+            raise MetaDataException("Incomprehensible number of days for archive policy")
+
     # Ensure all AntiFeatures are recognised...
     if thisinfo['AntiFeatures']:
         parts = thisinfo['AntiFeatures'].split(",")
@@ -659,6 +671,8 @@ def write_metadata(dest, app):
             mf.write('\n')
     if len(app['builds']) > 0:
         mf.write('\n')
+    if app['Archive Policy']:
+        writefield('Archive Policy')
     writefield('Auto Update Mode')
     writefield('Update Check Mode')
     if 'Update Check Data' in app:
index a14489ef691f6c19428e41be3b36ebbad37d6e50..7675b9aea154a359f80541349249b3f55dd033e7 100644 (file)
@@ -644,7 +644,7 @@ def make_index(apps, apks, repodir, archive, categories):
 
 
 
-def archive_old_apks(apps, apks, repodir, archivedir, keepversions):
+def archive_old_apks(apps, apks, repodir, archivedir, defaultkeepversions):
 
     for app in apps:
 
@@ -657,6 +657,11 @@ def archive_old_apks(apps, apks, repodir, archivedir, keepversions):
         # Sort the apk list into version order...
         apklist = sorted(apklist, key=lambda apk: apk['versioncode'], reverse=True)
 
+        if app['Archive Policy']:
+            keepversions = int(app['Archive Policy'][:-9])
+        else:
+            keepversions = defaultkeepversions
+
         if len(apklist) > keepversions:
             for apk in apklist[keepversions:]:
                 print "Moving " + apk['apkname'] + " to archive"