1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-10-03 17:50:11 +02:00

Allow archive policy override for indivudual apps

This commit is contained in:
Ciaran Gultnieks 2013-10-14 16:16:34 +01:00
parent ded019291e
commit 25ae0e8d79
3 changed files with 34 additions and 1 deletions

View 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

View 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:

View 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"