From 542528ab05716c5335cdc6079e9bb0029292e24d Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 21 Dec 2017 19:19:33 +0100 Subject: [PATCH 01/14] Fix broken ynh_replace_string (#394) * Fix broken ynh_replace_string * Replace name for ynh_replace_special_string --- data/helpers.d/string | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/data/helpers.d/string b/data/helpers.d/string index fbf598738..13399ffe0 100644 --- a/data/helpers.d/string +++ b/data/helpers.d/string @@ -26,6 +26,27 @@ ynh_replace_string () { local replace_string=$2 local workfile=$3 + # Escape the delimiter if it's in the string. + match_string=${match_string//${delimit}/"\\${delimit}"} + replace_string=${replace_string//${delimit}/"\\${delimit}"} + + sudo sed --in-place "s${delimit}${match_string}${delimit}${replace_string}${delimit}g" "$workfile" +} + +# Substitute/replace a special string by another in a file +# +# usage: ynh_replace_special_string match_string replace_string target_file +# | arg: match_string - String to be searched and replaced in the file +# | arg: replace_string - String that will replace matches +# | arg: target_file - File in which the string will be replaced. +# +# This helper will use ynh_replace_string, but as you can use special +# characters, you can't use some regular expressions and sub-expressions. +ynh_replace_special_string () { + local match_string=$1 + local replace_string=$2 + local workfile=$3 + # Escape any backslash to preserve them as simple backslash. match_string=${match_string//\\/"\\\\"} replace_string=${replace_string//\\/"\\\\"} @@ -34,9 +55,5 @@ ynh_replace_string () { match_string=${match_string//&/"\&"} replace_string=${replace_string//&/"\&"} - # Escape the delimiter if it's in the string. - match_string=${match_string//${delimit}/"\\${delimit}"} - replace_string=${replace_string//${delimit}/"\\${delimit}"} - - sudo sed --in-place "s${delimit}${match_string}${delimit}${replace_string}${delimit}g" "$workfile" + ynh_replace_string "$match_string" "$replace_string" "$workfile" } From a079e3f5eef856845e3485312e989bf13eabac38 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Thu, 4 Jan 2018 18:02:58 +0100 Subject: [PATCH 02/14] [enh] display which app is being upgraded --- locales/en.json | 1 + src/yunohost/app.py | 1 + 2 files changed, 2 insertions(+) diff --git a/locales/en.json b/locales/en.json index 8dac6e799..e3bc763bb 100644 --- a/locales/en.json +++ b/locales/en.json @@ -34,6 +34,7 @@ "app_sources_fetch_failed": "Unable to fetch sources files", "app_unknown": "Unknown app", "app_unsupported_remote_type": "Unsupported remote type used for the app", + "app_upgrade_app_name": "Upgrading app {app}...", "app_upgrade_failed": "Unable to upgrade {app:s}", "app_upgrade_some_app_failed": "Unable to upgrade some applications", "app_upgraded": "{app:s} has been upgraded", diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 403e76cc4..e9278855e 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -555,6 +555,7 @@ def app_upgrade(auth, app=[], url=None, file=None): logger.info("Upgrading apps %s", ", ".join(app)) for app_instance_name in apps: + logger.warning(m18n.n('app_upgrade_app_name', app=app_instance_name)) installed = _is_installed(app_instance_name) if not installed: raise MoulinetteError(errno.ENOPKG, From b97675516ee1f9dcc54327a82e87f083f1cc94e5 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Thu, 4 Jan 2018 18:15:10 +0100 Subject: [PATCH 03/14] [enh] display app name everytime possible on requirements testing to improve UX --- locales/en.json | 10 +++++----- src/yunohost/app.py | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/locales/en.json b/locales/en.json index e3bc763bb..11598a473 100644 --- a/locales/en.json +++ b/locales/en.json @@ -16,7 +16,7 @@ "app_change_url_success": "Successfully changed {app:s} url to {domain:s}{path:s}", "app_extraction_failed": "Unable to extract installation files", "app_id_invalid": "Invalid app id", - "app_incompatible": "The app is incompatible with your YunoHost version", + "app_incompatible": "The app {app} is incompatible with your YunoHost version", "app_install_files_invalid": "Invalid installation files", "app_location_already_used": "An app is already installed in this location", "app_location_install_failed": "Unable to install the app in this location", @@ -26,11 +26,11 @@ "app_not_correctly_installed": "{app:s} seems to be incorrectly installed", "app_not_installed": "{app:s} is not installed", "app_not_properly_removed": "{app:s} has not been properly removed", - "app_package_need_update": "The app package needs to be updated to follow YunoHost changes", + "app_package_need_update": "The app {app} package needs to be updated to follow YunoHost changes", "app_removed": "{app:s} has been removed", - "app_requirements_checking": "Checking required packages...", - "app_requirements_failed": "Unable to meet requirements: {error}", - "app_requirements_unmeet": "Requirements are not met, the package {pkgname} ({version}) must be {spec}", + "app_requirements_checking": "Checking required packages for {app}...", + "app_requirements_failed": "Unable to meet requirements for {app}: {error}", + "app_requirements_unmeet": "Requirements are not met for {app}, the package {pkgname} ({version}) must be {spec}", "app_sources_fetch_failed": "Unable to fetch sources files", "app_unknown": "Unknown app", "app_unsupported_remote_type": "Unsupported remote type used for the app", diff --git a/src/yunohost/app.py b/src/yunohost/app.py index e9278855e..3802874b6 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -581,7 +581,7 @@ def app_upgrade(auth, app=[], url=None, file=None): continue # Check requirements - _check_manifest_requirements(manifest) + _check_manifest_requirements(manifest, app_instance_name=app_instance_name) app_setting_path = APPS_SETTING_PATH + '/' + app_instance_name @@ -684,7 +684,7 @@ def app_install(auth, app, label=None, args=None, no_remove_on_failure=False): app_id = manifest['id'] # Check requirements - _check_manifest_requirements(manifest) + _check_manifest_requirements(manifest, app_id) # Check if app can be forked instance_number = _installed_instance_number(app_id, last=True) + 1 @@ -1690,7 +1690,7 @@ def _encode_string(value): return value -def _check_manifest_requirements(manifest): +def _check_manifest_requirements(manifest, app_instance_name): """Check if required packages are met from the manifest""" requirements = manifest.get('requirements', dict()) @@ -1708,12 +1708,12 @@ def _check_manifest_requirements(manifest): 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'))) + m18n.g('colon', m18n.n('app_incompatible'), app=app_instance_name), + m18n.n('app_package_need_update', app=app_instance_name))) elif not requirements: return - logger.info(m18n.n('app_requirements_checking')) + logger.info(m18n.n('app_requirements_checking', app=app_instance_name)) # Retrieve versions of each required package try: @@ -1722,7 +1722,7 @@ def _check_manifest_requirements(manifest): except packages.PackageException as e: raise MoulinetteError(errno.EINVAL, m18n.n('app_requirements_failed', - error=str(e))) + error=str(e), app=app_instance_name)) # Iterate over requirements for pkgname, spec in requirements.items(): @@ -1731,7 +1731,7 @@ def _check_manifest_requirements(manifest): raise MoulinetteError( errno.EINVAL, m18n.n('app_requirements_unmeet', pkgname=pkgname, version=version, - spec=spec)) + spec=spec, app=app_instance_name)) def _parse_args_from_manifest(manifest, action, args={}, auth=None): From a194e1fa1cc655e9076dc99b6caee6d6d9c4b68d Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Thu, 4 Jan 2018 18:44:13 +0100 Subject: [PATCH 04/14] [enh] Maintain ssh client connexion --- data/templates/ssh/sshd_config | 3 +++ 1 file changed, 3 insertions(+) diff --git a/data/templates/ssh/sshd_config b/data/templates/ssh/sshd_config index 695ea0d36..8c5a7fb95 100644 --- a/data/templates/ssh/sshd_config +++ b/data/templates/ssh/sshd_config @@ -66,6 +66,9 @@ PrintLastLog yes TCPKeepAlive yes #UseLogin no +# keep ssh sessions fresh +ClientAliveInterval 60 + #MaxStartups 10:30:60 Banner /etc/issue.net From 13aca112fa74b79f9c8097521f3f19abe24a72e2 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Thu, 4 Jan 2018 20:31:58 +0100 Subject: [PATCH 05/14] [enh] make change_url possibility available on the API for the admin --- src/yunohost/app.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 403e76cc4..7ceb795d7 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -330,6 +330,9 @@ def app_info(app, show_status=False, raw=False): if not _is_installed(app): raise MoulinetteError(errno.EINVAL, m18n.n('app_not_installed', app=app)) + + app_setting_path = APPS_SETTING_PATH + app + if raw: ret = app_list(filter=app, raw=True)[app] ret['settings'] = _get_app_settings(app) @@ -345,11 +348,10 @@ def app_info(app, show_status=False, raw=False): upgradable = "no" ret['upgradable'] = upgradable + ret['change_url'] = os.path.exists(os.path.join(app_setting_path, "scripts", "change_url")) return ret - app_setting_path = APPS_SETTING_PATH + app - # Retrieve manifest and status with open(app_setting_path + '/manifest.json') as f: manifest = json.loads(str(f.read())) From aea13bc3e8816375b37ec33624d2fdcc6c5d1807 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sat, 6 Jan 2018 18:36:29 +0100 Subject: [PATCH 06/14] [enh] save the conf/ directory of app during installation and upgrade --- src/yunohost/app.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 403e76cc4..87178464c 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -621,10 +621,13 @@ def app_upgrade(auth, app=[], url=None, file=None): with open(app_setting_path + '/status.json', 'w+') as f: json.dump(status, f) - # Replace scripts and manifest - os.system('rm -rf "%s/scripts" "%s/manifest.json"' % (app_setting_path, app_setting_path)) + # Replace scripts and manifest and conf (if exists) + os.system('rm -rf "%s/scripts" "%s/manifest.json %/conf"' % (app_setting_path, app_setting_path, app_setting_path)) os.system('mv "%s/manifest.json" "%s/scripts" %s' % (extracted_app_folder, extracted_app_folder, app_setting_path)) + if os.path.exists(os.path.join(extracted_app_folder, "conf")): + os.system('cp -R %s/conf %s' % (extracted_app_folder, app_setting_path)) + # So much win upgraded_apps.append(app_instance_name) logger.success(m18n.n('app_upgraded', app=app_instance_name)) @@ -733,6 +736,9 @@ def app_install(auth, app, label=None, args=None, no_remove_on_failure=False): os.system('cp %s/manifest.json %s' % (extracted_app_folder, app_setting_path)) os.system('cp -R %s/scripts %s' % (extracted_app_folder, app_setting_path)) + if os.path.exists(os.path.join(extracted_app_folder, "conf")): + os.system('cp -R %s/conf %s' % (extracted_app_folder, app_setting_path)) + # Execute the app install script install_retcode = 1 try: From 7d9307c4c60edd2e7001100c86db95882b22ccca Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sat, 6 Jan 2018 18:44:31 +0100 Subject: [PATCH 07/14] [doc$ add PULL_REQUEST_TEMPLATE.md --- src/yunohost/.github/PULL_REQUEST_TEMPLATE.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/yunohost/.github/PULL_REQUEST_TEMPLATE.md diff --git a/src/yunohost/.github/PULL_REQUEST_TEMPLATE.md b/src/yunohost/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..065c2dd90 --- /dev/null +++ b/src/yunohost/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,19 @@ +## The problem + +... + +## Solution + +... + +## PR Status + +... + + +## Validation + +- [ ] Principle agreement 0/2 : +- [ ] Quick review 0/1 : +- [ ] Simple test 0/1 : +- [ ] Deep review 0/1 : From f20ef340dc9aa648b5d9d94629076717a7a7b36e Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sun, 7 Jan 2018 02:04:18 +0100 Subject: [PATCH 08/14] [fix] .github was not in the right folder --- {src/yunohost/.github => .github}/PULL_REQUEST_TEMPLATE.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {src/yunohost/.github => .github}/PULL_REQUEST_TEMPLATE.md (100%) diff --git a/src/yunohost/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from src/yunohost/.github/PULL_REQUEST_TEMPLATE.md rename to .github/PULL_REQUEST_TEMPLATE.md From 297026e6548ef1763f6c5d51bef1c940f02e532d Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sun, 7 Jan 2018 16:43:10 +0100 Subject: [PATCH 09/14] [fix] improve UX, previous message was unclear for users qsd --- locales/en.json | 2 +- src/yunohost/app.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/locales/en.json b/locales/en.json index 8dac6e799..6e6ed6daa 100644 --- a/locales/en.json +++ b/locales/en.json @@ -19,7 +19,7 @@ "app_incompatible": "The app is incompatible with your YunoHost version", "app_install_files_invalid": "Invalid installation files", "app_location_already_used": "An app is already installed in this location", - "app_location_install_failed": "Unable to install the app in this location", + "app_location_install_failed": "Unable to install the app in this location because it conflit with the app '{other_app}' already installed on '{other_path}'", "app_location_unavailable": "This url is not available or conflicts with an already installed app", "app_manifest_invalid": "Invalid app manifest: {error}", "app_no_upgrade": "No app to upgrade", diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 403e76cc4..5599c0d53 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -1169,10 +1169,12 @@ def app_checkurl(auth, url, app=None): continue if path == p: raise MoulinetteError(errno.EINVAL, - m18n.n('app_location_already_used')) + m18n.n('app_location_already_used', + app=a["id"], path=path)) elif path.startswith(p) or p.startswith(path): raise MoulinetteError(errno.EPERM, - m18n.n('app_location_install_failed')) + m18n.n('app_location_install_failed', + other_path=p, other_app=a['id'])) if app is not None and not installed: app_setting(app, 'domain', value=domain) From 9cd760defd74e815408ece4a7960631692681a0d Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sun, 7 Jan 2018 17:04:48 +0100 Subject: [PATCH 10/14] [enh] make exceptions messages more obivous --- locales/en.json | 3 ++- src/yunohost/app.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/locales/en.json b/locales/en.json index 6e6ed6daa..1edf2609c 100644 --- a/locales/en.json +++ b/locales/en.json @@ -18,7 +18,8 @@ "app_id_invalid": "Invalid app id", "app_incompatible": "The app is incompatible with your YunoHost version", "app_install_files_invalid": "Invalid installation files", - "app_location_already_used": "An app is already installed in this location", + "app_location_already_used": "The app '{app}' is already installed on that location ({path})", + "app_make_default_location_already_used": "Can't make the app '{app}' the default on the domain {domain} is already used by the other app '{other_app}'", "app_location_install_failed": "Unable to install the app in this location because it conflit with the app '{other_app}' already installed on '{other_path}'", "app_location_unavailable": "This url is not available or conflicts with an already installed app", "app_manifest_invalid": "Invalid app manifest: {error}", diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 5599c0d53..851fcdaa6 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -1016,7 +1016,9 @@ def app_makedefault(auth, app, domain=None): if '/' in app_map(raw=True)[domain]: raise MoulinetteError(errno.EEXIST, - m18n.n('app_location_already_used')) + m18n.n('app_make_default_location_already_used', + app=app, domain=app_domain, + other_app=app_map(raw=True)[domain]["/"]["id"])) try: with open('/etc/ssowat/conf.json.persistent') as json_conf: From e8196cbc9855ab460ec9cbcb6c3505e70eb46be1 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sun, 7 Jan 2018 17:23:02 +0100 Subject: [PATCH 11/14] [doc] add comment to speak intent --- src/yunohost/app.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 851fcdaa6..d9ca5977f 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -1173,6 +1173,7 @@ def app_checkurl(auth, url, app=None): raise MoulinetteError(errno.EINVAL, m18n.n('app_location_already_used', app=a["id"], path=path)) + # can't install "/a/b/" if "/a/" exists elif path.startswith(p) or p.startswith(path): raise MoulinetteError(errno.EPERM, m18n.n('app_location_install_failed', From d7967f6d5fde81d4537bff8d2de1f723d1fceec4 Mon Sep 17 00:00:00 2001 From: JocelynDelalande Date: Mon, 8 Jan 2018 17:59:53 +0100 Subject: [PATCH 12/14] Fix comment lines in DNS zone example (using ";") If copy-pasted into a registrar zone file, the provided DNS zone sample for a given domain will fail, because comments lines start with "#" However, comments character in DNS zone files is ";" not "#" https://en.wikipedia.org/wiki/Zone_file --- src/yunohost/domain.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/yunohost/domain.py b/src/yunohost/domain.py index f828b0973..727a63df3 100644 --- a/src/yunohost/domain.py +++ b/src/yunohost/domain.py @@ -188,17 +188,17 @@ def domain_dns_conf(domain, ttl=None): result = "" - result += "# Basic ipv4/ipv6 records" + result += "; Basic ipv4/ipv6 records" for record in dns_conf["basic"]: result += "\n{name} {ttl} IN {type} {value}".format(**record) result += "\n\n" - result += "# XMPP" + result += "; XMPP" for record in dns_conf["xmpp"]: result += "\n{name} {ttl} IN {type} {value}".format(**record) result += "\n\n" - result += "# Mail" + result += "; Mail" for record in dns_conf["mail"]: result += "\n{name} {ttl} IN {type} {value}".format(**record) From 20f0e9a40c67fc9b373cd4ae33a982628c816552 Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Tue, 9 Jan 2018 23:01:19 +0100 Subject: [PATCH 13/14] Fix conf dir clean-up --- src/yunohost/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 87178464c..7b6195e60 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -622,7 +622,7 @@ def app_upgrade(auth, app=[], url=None, file=None): json.dump(status, f) # Replace scripts and manifest and conf (if exists) - os.system('rm -rf "%s/scripts" "%s/manifest.json %/conf"' % (app_setting_path, app_setting_path, app_setting_path)) + os.system('rm -rf "%s/scripts" "%s/manifest.json %s/conf"' % (app_setting_path, app_setting_path, app_setting_path)) os.system('mv "%s/manifest.json" "%s/scripts" %s' % (extracted_app_folder, extracted_app_folder, app_setting_path)) if os.path.exists(os.path.join(extracted_app_folder, "conf")): From 9c44878d9203bf174bfc7c9ae164e57d781a5b5e Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Tue, 9 Jan 2018 23:21:33 +0100 Subject: [PATCH 14/14] [mod] add section in PR template to inform on how to test a PR --- .github/PULL_REQUEST_TEMPLATE.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 065c2dd90..9642e92f6 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -10,6 +10,9 @@ ... +## How to test + +... ## Validation