mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-09-17 18:50:11 +02:00
metadata: Make ArchivePolicy an interger internally
This commit is contained in:
parent
cf887583c0
commit
337974cbed
@ -57,6 +57,7 @@ metadata_v0:
|
|||||||
- cd fdroiddata
|
- cd fdroiddata
|
||||||
- ../tests/dump_internal_metadata_format.py
|
- ../tests/dump_internal_metadata_format.py
|
||||||
- sed -i
|
- sed -i
|
||||||
|
-e '/ArchivePolicy:/d'
|
||||||
-e '/RequiresRoot:/d'
|
-e '/RequiresRoot:/d'
|
||||||
metadata/dump_*/*.yaml
|
metadata/dump_*/*.yaml
|
||||||
- diff -uw metadata/dump_*
|
- diff -uw metadata/dump_*
|
||||||
|
@ -635,6 +635,17 @@ def check_app_field_types(app):
|
|||||||
fieldtype=v.__class__.__name__,
|
fieldtype=v.__class__.__name__,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
elif t == metadata.TYPE_INT and not isinstance(v, int):
|
||||||
|
yield (
|
||||||
|
_(
|
||||||
|
"{appid}: {field} must be a '{type}', but it is a '{fieldtype}'!"
|
||||||
|
).format(
|
||||||
|
appid=app.id,
|
||||||
|
field=field,
|
||||||
|
type='int',
|
||||||
|
fieldtype=v.__class__.__name__,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def check_antiFeatures(app):
|
def check_antiFeatures(app):
|
||||||
@ -693,8 +704,7 @@ def check_for_unsupported_metadata_files(basedir=""):
|
|||||||
|
|
||||||
def check_current_version_code(app):
|
def check_current_version_code(app):
|
||||||
"""Check that the CurrentVersionCode is currently available."""
|
"""Check that the CurrentVersionCode is currently available."""
|
||||||
archive_policy = app.get('ArchivePolicy')
|
if app.get('ArchivePolicy') == 0:
|
||||||
if archive_policy and archive_policy.split()[0] == "0":
|
|
||||||
return
|
return
|
||||||
cv = app.get('CurrentVersionCode')
|
cv = app.get('CurrentVersionCode')
|
||||||
if cv is not None and cv == 0:
|
if cv is not None and cv == 0:
|
||||||
@ -724,13 +734,11 @@ def check_current_version_code(app):
|
|||||||
|
|
||||||
def check_updates_expected(app):
|
def check_updates_expected(app):
|
||||||
"""Check if update checking makes sense."""
|
"""Check if update checking makes sense."""
|
||||||
if (
|
if (app.get('NoSourceSince') or app.get('ArchivePolicy') == 0) and not all(
|
||||||
app.get('NoSourceSince') or app.get('ArchivePolicy') == '0 versions'
|
|
||||||
) and not all(
|
|
||||||
app.get(key, 'None') == 'None' for key in ('AutoUpdateMode', 'UpdateCheckMode')
|
app.get(key, 'None') == 'None' for key in ('AutoUpdateMode', 'UpdateCheckMode')
|
||||||
):
|
):
|
||||||
yield _(
|
yield _(
|
||||||
'App has NoSourceSince or ArchivePolicy "0 versions" but AutoUpdateMode or UpdateCheckMode are not None'
|
'App has NoSourceSince or ArchivePolicy "0 versions" or 0 but AutoUpdateMode or UpdateCheckMode are not None'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -195,6 +195,7 @@ fieldtypes = {
|
|||||||
'Builds': TYPE_BUILD,
|
'Builds': TYPE_BUILD,
|
||||||
'VercodeOperation': TYPE_LIST,
|
'VercodeOperation': TYPE_LIST,
|
||||||
'CurrentVersionCode': TYPE_INT,
|
'CurrentVersionCode': TYPE_INT,
|
||||||
|
'ArchivePolicy': TYPE_INT,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -447,10 +448,6 @@ valuetypes = {
|
|||||||
r'^[a-fA-F0-9]{64}$',
|
r'^[a-fA-F0-9]{64}$',
|
||||||
["AllowedAPKSigningKeys"]),
|
["AllowedAPKSigningKeys"]),
|
||||||
|
|
||||||
FieldValidator("Archive Policy",
|
|
||||||
r'^[0-9]+ versions$',
|
|
||||||
["ArchivePolicy"]),
|
|
||||||
|
|
||||||
FieldValidator("Auto Update Mode",
|
FieldValidator("Auto Update Mode",
|
||||||
r"^(Version.*|None)$",
|
r"^(Version.*|None)$",
|
||||||
["AutoUpdateMode"]),
|
["AutoUpdateMode"]),
|
||||||
@ -1017,6 +1014,9 @@ def post_parse_yaml_metadata(yamldata):
|
|||||||
if v or v == 0:
|
if v or v == 0:
|
||||||
yamldata[k] = _normalize_type_list(k, v)
|
yamldata[k] = _normalize_type_list(k, v)
|
||||||
elif _fieldtype == TYPE_INT:
|
elif _fieldtype == TYPE_INT:
|
||||||
|
# ArchivePolicy used to require " versions" in the value.
|
||||||
|
if k == 'ArchivePolicy' and isinstance(v, str):
|
||||||
|
v = v.split(' ', maxsplit=1)[0]
|
||||||
v = _normalize_type_int(k, v)
|
v = _normalize_type_int(k, v)
|
||||||
if v or v == 0:
|
if v or v == 0:
|
||||||
yamldata[k] = v
|
yamldata[k] = v
|
||||||
@ -1210,7 +1210,7 @@ def _app_to_yaml(app):
|
|||||||
insert_newline = True
|
insert_newline = True
|
||||||
else:
|
else:
|
||||||
value = app.get(field)
|
value = app.get(field)
|
||||||
if value or field == 'Builds':
|
if value or field in ('Builds', 'ArchivePolicy'):
|
||||||
_fieldtype = fieldtype(field)
|
_fieldtype = fieldtype(field)
|
||||||
if field == 'Builds':
|
if field == 'Builds':
|
||||||
if app.get('Builds'):
|
if app.get('Builds'):
|
||||||
@ -1226,6 +1226,10 @@ def _app_to_yaml(app):
|
|||||||
if len(value) == 1:
|
if len(value) == 1:
|
||||||
cm[field] = value[0]
|
cm[field] = value[0]
|
||||||
else:
|
else:
|
||||||
|
elif field == 'ArchivePolicy':
|
||||||
|
if value is None:
|
||||||
|
continue
|
||||||
|
cm[field] = _field_to_yaml(fieldtype(field), value)
|
||||||
cm[field] = value
|
cm[field] = value
|
||||||
elif _fieldtype == TYPE_MULTILINE:
|
elif _fieldtype == TYPE_MULTILINE:
|
||||||
v = _format_multiline(value)
|
v = _format_multiline(value)
|
||||||
|
@ -176,7 +176,7 @@ def status_update_json(apps, apks):
|
|||||||
validapks = 0
|
validapks = 0
|
||||||
if app.get('Disabled'):
|
if app.get('Disabled'):
|
||||||
output['disabled'].append(appid)
|
output['disabled'].append(appid)
|
||||||
elif app.get("ArchivePolicy") and int(app["ArchivePolicy"][:-9]) == 0:
|
elif app["ArchivePolicy"] == 0:
|
||||||
output['archivePolicy0'].append(appid)
|
output['archivePolicy0'].append(appid)
|
||||||
else:
|
else:
|
||||||
for build in app.get('Builds', []):
|
for build in app.get('Builds', []):
|
||||||
@ -1877,7 +1877,7 @@ def archive_old_apks(apps, apks, archapks, repodir, archivedir, defaultkeepversi
|
|||||||
for appid, app in apps.items():
|
for appid, app in apps.items():
|
||||||
|
|
||||||
if app.get('ArchivePolicy'):
|
if app.get('ArchivePolicy'):
|
||||||
keepversions = int(app['ArchivePolicy'][:-9])
|
keepversions = app['ArchivePolicy']
|
||||||
else:
|
else:
|
||||||
keepversions = defaultkeepversions
|
keepversions = defaultkeepversions
|
||||||
if app.get('VercodeOperation'):
|
if app.get('VercodeOperation'):
|
||||||
|
@ -95,7 +95,7 @@ Builds:
|
|||||||
versionCode: 51
|
versionCode: 51
|
||||||
disable: Labelled as pre-release, so skipped
|
disable: Labelled as pre-release, so skipped
|
||||||
|
|
||||||
ArchivePolicy: 0 versions
|
ArchivePolicy: 0
|
||||||
AutoUpdateMode: None
|
AutoUpdateMode: None
|
||||||
UpdateCheckMode: None
|
UpdateCheckMode: None
|
||||||
CurrentVersion: 2.1.2
|
CurrentVersion: 2.1.2
|
||||||
|
@ -944,7 +944,7 @@ Builds:
|
|||||||
gradle:
|
gradle:
|
||||||
- yes
|
- yes
|
||||||
|
|
||||||
ArchivePolicy: 12 versions
|
ArchivePolicy: 12
|
||||||
AutoUpdateMode: None
|
AutoUpdateMode: None
|
||||||
UpdateCheckMode: Static
|
UpdateCheckMode: Static
|
||||||
CurrentVersion: 0.102.3
|
CurrentVersion: 0.102.3
|
||||||
|
@ -1866,7 +1866,7 @@ class MetadataTest(unittest.TestCase):
|
|||||||
- NonFreeAssets
|
- NonFreeAssets
|
||||||
- UpstreamNonFree
|
- UpstreamNonFree
|
||||||
|
|
||||||
ArchivePolicy: 4 versions
|
ArchivePolicy: 4
|
||||||
AutoUpdateMode: Version v%v
|
AutoUpdateMode: Version v%v
|
||||||
UpdateCheckMode: Tags
|
UpdateCheckMode: Tags
|
||||||
CurrentVersion: '1.5'
|
CurrentVersion: '1.5'
|
||||||
|
@ -94,7 +94,7 @@ Builds:
|
|||||||
versionCode: 51
|
versionCode: 51
|
||||||
disable: Labelled as pre-release, so skipped
|
disable: Labelled as pre-release, so skipped
|
||||||
|
|
||||||
ArchivePolicy: 0 versions
|
ArchivePolicy: 0
|
||||||
AutoUpdateMode: None
|
AutoUpdateMode: None
|
||||||
UpdateCheckMode: None
|
UpdateCheckMode: None
|
||||||
CurrentVersion: 2.1.2
|
CurrentVersion: 2.1.2
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
AllowedAPKSigningKeys: []
|
AllowedAPKSigningKeys: []
|
||||||
AntiFeatures:
|
AntiFeatures:
|
||||||
UpstreamNonFree: {}
|
UpstreamNonFree: {}
|
||||||
ArchivePolicy: 0 versions
|
ArchivePolicy: 0
|
||||||
AuthorEmail: null
|
AuthorEmail: null
|
||||||
AuthorName: null
|
AuthorName: null
|
||||||
AuthorWebSite: null
|
AuthorWebSite: null
|
||||||
|
@ -3,7 +3,7 @@ AntiFeatures:
|
|||||||
NoSourceSince:
|
NoSourceSince:
|
||||||
en-US: '1.5'
|
en-US: '1.5'
|
||||||
NonFreeNet: {}
|
NonFreeNet: {}
|
||||||
ArchivePolicy: 4 versions
|
ArchivePolicy: 4
|
||||||
AuthorEmail: null
|
AuthorEmail: null
|
||||||
AuthorName: null
|
AuthorName: null
|
||||||
AuthorWebSite: null
|
AuthorWebSite: null
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
AllowedAPKSigningKeys: []
|
AllowedAPKSigningKeys: []
|
||||||
AntiFeatures: {}
|
AntiFeatures: {}
|
||||||
ArchivePolicy: 9 versions
|
ArchivePolicy: 9
|
||||||
AuthorEmail: null
|
AuthorEmail: null
|
||||||
AuthorName: null
|
AuthorName: null
|
||||||
AuthorWebSite: null
|
AuthorWebSite: null
|
||||||
|
@ -1411,7 +1411,7 @@ class UpdateTest(unittest.TestCase):
|
|||||||
self.assertDictEqual(
|
self.assertDictEqual(
|
||||||
metadata_content,
|
metadata_content,
|
||||||
{
|
{
|
||||||
'ArchivePolicy': '',
|
'ArchivePolicy': None,
|
||||||
'AuthorEmail': '',
|
'AuthorEmail': '',
|
||||||
'AuthorName': '',
|
'AuthorName': '',
|
||||||
'AuthorWebSite': '',
|
'AuthorWebSite': '',
|
||||||
|
Loading…
Reference in New Issue
Block a user