mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Merge remote-tracking branch 'origin/unstable' into unstable
This commit is contained in:
commit
220c40969b
2 changed files with 16 additions and 2 deletions
|
@ -24,15 +24,26 @@
|
|||
## Packages versions
|
||||
|
||||
def get_version(package):
|
||||
"""Get the version of package"""
|
||||
from moulinette.utils import process
|
||||
return process.check_output(
|
||||
"dpkg-query -W -f='${{Version}}' {0}".format(package)
|
||||
).strip()
|
||||
|
||||
def get_versions(*args, **kwargs):
|
||||
"""Get the version of each YunoHost package"""
|
||||
from collections import OrderedDict
|
||||
return OrderedDict([
|
||||
('moulinette', get_version('moulinette')),
|
||||
('yunohost', get_version('yunohost')),
|
||||
('yunohost-admin', get_version('yunohost-admin')),
|
||||
])
|
||||
|
||||
def has_min_version(min_version, package='yunohost', strict=False):
|
||||
"""Check if a package has minimum version"""
|
||||
from distutils.version import LooseVersion, StrictVersion
|
||||
cmp_cls = StrictVersion if strict else LooseVersion
|
||||
version = cmp_cls(get_version(package))
|
||||
if version >= cmp_cls(min_version):
|
||||
return True
|
||||
return False
|
||||
|
|
|
@ -39,6 +39,7 @@ import subprocess
|
|||
from moulinette.core import MoulinetteError
|
||||
from moulinette.utils.log import getActionLogger
|
||||
|
||||
from . import has_min_version
|
||||
from .service import service_log
|
||||
|
||||
logger = getActionLogger('yunohost.app')
|
||||
|
@ -344,7 +345,8 @@ def app_upgrade(auth, app=[], url=None, file=None):
|
|||
continue
|
||||
|
||||
# Check min version
|
||||
if 'min_version' in manifest and __version__ < manifest['min_version']:
|
||||
if 'min_version' in manifest \
|
||||
and not has_min_version(manifest['min_version']):
|
||||
raise MoulinetteError(errno.EPERM,
|
||||
m18n.n('app_recent_version_required', app_id))
|
||||
|
||||
|
@ -448,7 +450,8 @@ def app_install(auth, app, label=None, args=None):
|
|||
app_id = manifest['id']
|
||||
|
||||
# Check min version
|
||||
if 'min_version' in manifest and __version__ < manifest['min_version']:
|
||||
if 'min_version' in manifest \
|
||||
and not has_min_version(manifest['min_version']):
|
||||
raise MoulinetteError(errno.EPERM,
|
||||
m18n.n('app_recent_version_required', app_id))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue