[enh] Prevent non-updated multi-instances apps installation (close #126)

This commit is contained in:
Jérôme Lebleu 2016-04-25 13:58:17 +02:00
parent 7a87fa7ebc
commit aca251e981
2 changed files with 15 additions and 1 deletions

View file

@ -34,6 +34,8 @@
"app_extraction_failed" : "Unable to extract installation files",
"app_install_files_invalid" : "Invalid installation files",
"app_manifest_invalid" : "Invalid app manifest",
"app_incompatible" : "The app is incompatible with your YunoHost version",
"app_package_need_update" : "The app package need to be updated to follow YunoHost changes",
"app_argument_choice_invalid" : "Invalid choice for argument '{name:s}', it must be one of {choices:s}",
"app_argument_invalid" : "Invalid value for argument '{name:s}': {error:s}",
"app_argument_required" : "Argument '{name:s}' is required",

View file

@ -1385,12 +1385,24 @@ def _encode_string(value):
def _check_manifest_requirements(manifest):
"""Check if required packages are met from the manifest"""
requirements = manifest.get('requirements', dict())
# FIXME: Deprecate min_version key
if 'min_version' in manifest:
requirements['yunohost'] = '>> {0}'.format(manifest['min_version'])
logger.debug("the manifest key 'min_version' is deprecated, "
"use 'requirements' instead.")
if not requirements:
# Validate multi-instance app
if manifest.get('multi_instance', False):
# Handle backward-incompatible change introduced in yunohost >= 2.3.6
# See https://dev.yunohost.org/issues/156
yunohost_req = requirements.get('yunohost', None)
if (not yunohost_req or
not packages.SpecifierSet(yunohost_req) & '>= 2.3.6'):
raise MoulinetteError(errno.EINVAL, '{0}{1}'.format(
m18n.g('colon', m18n.n('app_incompatible')),
m18n.n('app_package_need_update')))
elif not requirements:
return
logger.info(m18n.n('app_requirements_checking'))