mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] Properly define app upgradability / Fix app part of tools update (#255)
* Adding a 'upgradable' attribute directly in app_info Conflicts: src/yunohost/app.py src/yunohost/tools.py * Fixing a few weird stuff from cherry-picking
This commit is contained in:
parent
f646fdf272
commit
5820f79772
3 changed files with 37 additions and 32 deletions
|
@ -30,6 +30,7 @@
|
||||||
"app_unsupported_remote_type": "Unsupported remote type used for the app",
|
"app_unsupported_remote_type": "Unsupported remote type used for the app",
|
||||||
"app_upgrade_failed": "Unable to upgrade {app:s}",
|
"app_upgrade_failed": "Unable to upgrade {app:s}",
|
||||||
"app_upgraded": "{app:s} has been upgraded",
|
"app_upgraded": "{app:s} has been upgraded",
|
||||||
|
"app_already_up_to_date": "{app:s} is already up to date",
|
||||||
"appslist_fetched": "The application list {appslist:s} has been fetched",
|
"appslist_fetched": "The application list {appslist:s} has been fetched",
|
||||||
"appslist_removed": "The application list {appslist:s} has been removed",
|
"appslist_removed": "The application list {appslist:s} has been removed",
|
||||||
"appslist_unknown": "Application list {appslist:s} unknown.",
|
"appslist_unknown": "Application list {appslist:s} unknown.",
|
||||||
|
|
|
@ -332,6 +332,19 @@ def app_info(app, show_status=False, raw=False):
|
||||||
if raw:
|
if raw:
|
||||||
ret = app_list(filter=app, raw=True)[app]
|
ret = app_list(filter=app, raw=True)[app]
|
||||||
ret['settings'] = _get_app_settings(app)
|
ret['settings'] = _get_app_settings(app)
|
||||||
|
|
||||||
|
# Determine upgradability
|
||||||
|
local_update_time = ret['settings'].get('update_time', ret['settings']['install_time'])
|
||||||
|
|
||||||
|
if 'lastUpdate' not in ret or 'git' not in ret:
|
||||||
|
upgradable = "url_required"
|
||||||
|
elif ret['lastUpdate'] > local_update_time:
|
||||||
|
upgradable = "yes"
|
||||||
|
else:
|
||||||
|
upgradable = "no"
|
||||||
|
|
||||||
|
ret['upgradable'] = upgradable
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
app_setting_path = APPS_SETTING_PATH + app
|
app_setting_path = APPS_SETTING_PATH + app
|
||||||
|
@ -425,16 +438,19 @@ def app_upgrade(auth, app=[], url=None, file=None):
|
||||||
|
|
||||||
upgraded_apps = []
|
upgraded_apps = []
|
||||||
|
|
||||||
|
apps = app
|
||||||
|
user_specified_list = True
|
||||||
# If no app is specified, upgrade all apps
|
# If no app is specified, upgrade all apps
|
||||||
if not app:
|
if not apps:
|
||||||
if not url and not file:
|
if not url and not file:
|
||||||
app = [app["id"] for app in app_list(installed=True)["apps"]]
|
apps = [app["id"] for app in app_list(installed=True)["apps"]]
|
||||||
|
user_specified_list = False
|
||||||
elif not isinstance(app, list):
|
elif not isinstance(app, list):
|
||||||
app = [app]
|
apps = [app]
|
||||||
|
|
||||||
logger.info("Upgrading apps %s", ", ".join(app))
|
logger.info("Upgrading apps %s", ", ".join(app))
|
||||||
|
|
||||||
for app_instance_name in app:
|
for app_instance_name in apps:
|
||||||
installed = _is_installed(app_instance_name)
|
installed = _is_installed(app_instance_name)
|
||||||
if not installed:
|
if not installed:
|
||||||
raise MoulinetteError(errno.ENOPKG,
|
raise MoulinetteError(errno.ENOPKG,
|
||||||
|
@ -445,18 +461,18 @@ def app_upgrade(auth, app=[], url=None, file=None):
|
||||||
|
|
||||||
app_dict = app_info(app_instance_name, raw=True)
|
app_dict = app_info(app_instance_name, raw=True)
|
||||||
|
|
||||||
locale_update_time = app_dict['settings'].get('update_time', app_dict['settings']['install_time'])
|
|
||||||
|
|
||||||
if file:
|
if file:
|
||||||
manifest, extracted_app_folder = _extract_app_from_file(file)
|
manifest, extracted_app_folder = _extract_app_from_file(file)
|
||||||
elif url:
|
elif url:
|
||||||
manifest, extracted_app_folder = _fetch_app_from_git(url)
|
manifest, extracted_app_folder = _fetch_app_from_git(url)
|
||||||
elif 'lastUpdate' not in app_dict or 'git' not in app_dict:
|
elif app_dict["upgradable"] == "url_required":
|
||||||
logger.warning(m18n.n('custom_app_url_required', app=app_instance_name))
|
logger.warning(m18n.n('custom_app_url_required', app=app_instance_name))
|
||||||
continue
|
continue
|
||||||
elif app_dict['lastUpdate'] > locale_update_time:
|
elif app_dict["upgradable"] == "yes":
|
||||||
manifest, extracted_app_folder = _fetch_app_from_git(app_instance_name)
|
manifest, extracted_app_folder = _fetch_app_from_git(app_instance_name)
|
||||||
else:
|
else:
|
||||||
|
if user_specified_list:
|
||||||
|
logger.success(m18n.n('app_already_up_to_date', app=app_instance_name))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Check requirements
|
# Check requirements
|
||||||
|
@ -516,7 +532,6 @@ def app_upgrade(auth, app=[], url=None, file=None):
|
||||||
|
|
||||||
logger.success(m18n.n('upgrade_complete'))
|
logger.success(m18n.n('upgrade_complete'))
|
||||||
|
|
||||||
|
|
||||||
def app_install(auth, app, label=None, args=None, no_remove_on_failure=False):
|
def app_install(auth, app, label=None, args=None, no_remove_on_failure=False):
|
||||||
"""
|
"""
|
||||||
Install apps
|
Install apps
|
||||||
|
|
|
@ -356,6 +356,7 @@ def tools_update(ignore_apps=False, ignore_packages=False):
|
||||||
ignore_packages -- Ignore apt cache update and changelog
|
ignore_packages -- Ignore apt cache update and changelog
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
# "packages" will list upgradable packages
|
||||||
packages = []
|
packages = []
|
||||||
if not ignore_packages:
|
if not ignore_packages:
|
||||||
cache = apt.Cache()
|
cache = apt.Cache()
|
||||||
|
@ -365,8 +366,6 @@ def tools_update(ignore_apps=False, ignore_packages=False):
|
||||||
if not cache.update():
|
if not cache.update():
|
||||||
raise MoulinetteError(errno.EPERM, m18n.n('update_cache_failed'))
|
raise MoulinetteError(errno.EPERM, m18n.n('update_cache_failed'))
|
||||||
|
|
||||||
logger.info(m18n.n('done'))
|
|
||||||
|
|
||||||
cache.open(None)
|
cache.open(None)
|
||||||
cache.upgrade(True)
|
cache.upgrade(True)
|
||||||
|
|
||||||
|
@ -377,36 +376,26 @@ def tools_update(ignore_apps=False, ignore_packages=False):
|
||||||
'fullname': pkg.fullname,
|
'fullname': pkg.fullname,
|
||||||
'changelog': pkg.get_changelog()
|
'changelog': pkg.get_changelog()
|
||||||
})
|
})
|
||||||
|
logger.info(m18n.n('done'))
|
||||||
|
|
||||||
|
# "apps" will list upgradable packages
|
||||||
apps = []
|
apps = []
|
||||||
if not ignore_apps:
|
if not ignore_apps:
|
||||||
try:
|
try:
|
||||||
app_fetchlist()
|
app_fetchlist()
|
||||||
except MoulinetteError:
|
except MoulinetteError:
|
||||||
|
# FIXME : silent exception !?
|
||||||
pass
|
pass
|
||||||
app_list = os.listdir(APPS_SETTING_PATH)
|
|
||||||
if len(app_list) > 0:
|
|
||||||
for app_id in app_list:
|
|
||||||
if '__' in app_id:
|
|
||||||
original_app_id = app_id[:app_id.index('__')]
|
|
||||||
else:
|
|
||||||
original_app_id = app_id
|
|
||||||
|
|
||||||
current_app_dict = app_info(app_id, raw=True)
|
app_list_installed = os.listdir(APPS_SETTING_PATH)
|
||||||
new_app_dict = app_info(original_app_id, raw=True)
|
for app_id in app_list_installed:
|
||||||
|
|
||||||
# Custom app
|
app_dict = app_info(app_id, raw=True)
|
||||||
if new_app_dict is None or 'lastUpdate' not in new_app_dict or 'git' not in new_app_dict:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if (new_app_dict['lastUpdate'] > current_app_dict['lastUpdate']) \
|
if app_dict["upgradable"] == "yes":
|
||||||
or ('update_time' not in current_app_dict['settings'] \
|
|
||||||
and (new_app_dict['lastUpdate'] > current_app_dict['settings']['install_time'])) \
|
|
||||||
or ('update_time' in current_app_dict['settings'] \
|
|
||||||
and (new_app_dict['lastUpdate'] > current_app_dict['settings']['update_time'])):
|
|
||||||
apps.append({
|
apps.append({
|
||||||
'id': app_id,
|
'id': app_id,
|
||||||
'label': current_app_dict['settings']['label']
|
'label': app_dict['settings']['label']
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(apps) == 0 and len(packages) == 0:
|
if len(apps) == 0 and len(packages) == 0:
|
||||||
|
|
Loading…
Add table
Reference in a new issue