From 05f25fa85fa8495f97a81927991c1af9de6b1723 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 10 Nov 2021 18:25:37 +0100 Subject: [PATCH] Propagate dir structure change to scripts etc --- .coveragerc | 2 +- .gitignore | 4 +- .gitlab/ci/test.gitlab-ci.yml | 76 ++++++++++++++++----------------- conf/dovecot/dovecot.conf | 2 +- conf/nginx/security.conf.inc | 2 +- conf/postfix/main.cf | 2 +- debian/install | 9 ++-- debian/rules | 2 +- doc/generate_bash_completion.py | 5 +-- doc/generate_helper_doc.py | 2 +- doc/generate_manpages.py | 2 +- doc/helper_doc_template.md | 2 +- hooks/conf_regen/01-yunohost | 4 +- hooks/conf_regen/02-ssl | 8 ++-- hooks/conf_regen/03-ssh | 2 +- hooks/conf_regen/06-slapd | 6 +-- hooks/conf_regen/09-nslcd | 2 +- hooks/conf_regen/12-metronome | 2 +- hooks/conf_regen/15-nginx | 4 +- hooks/conf_regen/19-postfix | 2 +- hooks/conf_regen/25-dovecot | 2 +- hooks/conf_regen/31-rspamd | 2 +- hooks/conf_regen/34-mysql | 2 +- hooks/conf_regen/37-mdns | 2 +- hooks/conf_regen/43-dnsmasq | 2 +- hooks/conf_regen/46-nsswitch | 2 +- hooks/conf_regen/52-fail2ban | 2 +- src/diagnosis/10-ip.py | 2 +- src/diagnosis/24-mail.py | 2 +- src/dns.py | 2 +- src/domain.py | 2 +- src/service.py | 2 +- src/utils/config.py | 2 +- src/utils/password.py | 2 +- tests/add_missing_keys.py | 22 +++++----- tests/test_actionmap.py | 2 +- tests/test_i18n_keys.py | 26 +++++------ tox.ini | 6 +-- 38 files changed, 113 insertions(+), 111 deletions(-) diff --git a/.coveragerc b/.coveragerc index ed13dfa68..fe22c8381 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,2 +1,2 @@ [report] -omit=src/yunohost/tests/*,src/yunohost/vendor/*,/usr/lib/moulinette/yunohost/* +omit=src/tests/*,src/vendor/*,/usr/lib/moulinette/yunohost/* diff --git a/.gitignore b/.gitignore index 75f4ae6ea..eae46b4c5 100644 --- a/.gitignore +++ b/.gitignore @@ -31,7 +31,7 @@ pip-log.txt .mr.developer.cfg # moulinette lib -src/yunohost/locales +src/locales # Test -src/yunohost/tests/apps +src/tests/apps diff --git a/.gitlab/ci/test.gitlab-ci.yml b/.gitlab/ci/test.gitlab-ci.yml index 1aad46fbe..49c07e4b6 100644 --- a/.gitlab/ci/test.gitlab-ci.yml +++ b/.gitlab/ci/test.gitlab-ci.yml @@ -11,7 +11,7 @@ - *install_debs cache: paths: - - src/yunohost/tests/apps + - src/tests/apps key: "$CI_JOB_STAGE-$CI_COMMIT_REF_SLUG" needs: - job: build-yunohost @@ -36,7 +36,7 @@ full-tests: - *install_debs - yunohost tools postinstall -d domain.tld -p the_password --ignore-dyndns --force-diskspace script: - - python3 -m pytest --cov=yunohost tests/ src/yunohost/tests/ data/hooks/diagnosis/ --junitxml=report.xml + - python3 -m pytest --cov=yunohost tests/ src/tests/ src/diagnosis/ --junitxml=report.xml - cd tests - bash test_helpers.sh needs: @@ -57,8 +57,8 @@ test-i18n-keys: only: changes: - locales/en.json - - src/yunohost/*.py - - data/hooks/diagnosis/*.py + - src/*.py + - src/diagnosis/*.py test-translation-format-consistency: extends: .test-stage @@ -74,7 +74,7 @@ test-actionmap: - python3 -m pytest tests/test_actionmap.py only: changes: - - data/actionsmap/*.yml + - share/actionsmap.yml test-helpers: extends: .test-stage @@ -83,126 +83,126 @@ test-helpers: - bash test_helpers.sh only: changes: - - data/helpers.d/* + - helpers/* test-domains: extends: .test-stage script: - - python3 -m pytest src/yunohost/tests/test_domains.py + - python3 -m pytest src/tests/test_domains.py only: changes: - - src/yunohost/domain.py + - src/domain.py test-dns: extends: .test-stage script: - - python3 -m pytest src/yunohost/tests/test_dns.py + - python3 -m pytest src/tests/test_dns.py only: changes: - - src/yunohost/dns.py - - src/yunohost/utils/dns.py + - src/dns.py + - src/utils/dns.py test-apps: extends: .test-stage script: - - python3 -m pytest src/yunohost/tests/test_apps.py + - python3 -m pytest src/tests/test_apps.py only: changes: - - src/yunohost/app.py + - src/app.py test-appscatalog: extends: .test-stage script: - - python3 -m pytest src/yunohost/tests/test_app_catalog.py + - python3 -m pytest src/tests/test_app_catalog.py only: changes: - - src/yunohost/app_calalog.py + - src/app_calalog.py test-appurl: extends: .test-stage script: - - python3 -m pytest src/yunohost/tests/test_appurl.py + - python3 -m pytest src/tests/test_appurl.py only: changes: - - src/yunohost/app.py + - src/app.py test-questions: extends: .test-stage script: - - python3 -m pytest src/yunohost/tests/test_questions.py + - python3 -m pytest src/tests/test_questions.py only: changes: - - src/yunohost/utils/config.py + - src/utils/config.py test-app-config: extends: .test-stage script: - - python3 -m pytest src/yunohost/tests/test_app_config.py + - python3 -m pytest src/tests/test_app_config.py only: changes: - - src/yunohost/app.py - - src/yunohost/utils/config.py + - src/app.py + - src/utils/config.py test-changeurl: extends: .test-stage script: - - python3 -m pytest src/yunohost/tests/test_changeurl.py + - python3 -m pytest src/tests/test_changeurl.py only: changes: - - src/yunohost/app.py + - src/app.py test-backuprestore: extends: .test-stage script: - - python3 -m pytest src/yunohost/tests/test_backuprestore.py + - python3 -m pytest src/tests/test_backuprestore.py only: changes: - - src/yunohost/backup.py + - src/backup.py test-permission: extends: .test-stage script: - - python3 -m pytest src/yunohost/tests/test_permission.py + - python3 -m pytest src/tests/test_permission.py only: changes: - - src/yunohost/permission.py + - src/permission.py test-settings: extends: .test-stage script: - - python3 -m pytest src/yunohost/tests/test_settings.py + - python3 -m pytest src/tests/test_settings.py only: changes: - - src/yunohost/settings.py + - src/settings.py test-user-group: extends: .test-stage script: - - python3 -m pytest src/yunohost/tests/test_user-group.py + - python3 -m pytest src/tests/test_user-group.py only: changes: - - src/yunohost/user.py + - src/user.py test-regenconf: extends: .test-stage script: - - python3 -m pytest src/yunohost/tests/test_regenconf.py + - python3 -m pytest src/tests/test_regenconf.py only: changes: - - src/yunohost/regenconf.py + - src/regenconf.py test-service: extends: .test-stage script: - - python3 -m pytest src/yunohost/tests/test_service.py + - python3 -m pytest src/tests/test_service.py only: changes: - - src/yunohost/service.py + - src/service.py test-ldapauth: extends: .test-stage script: - - python3 -m pytest src/yunohost/tests/test_ldapauth.py + - python3 -m pytest src/tests/test_ldapauth.py only: changes: - - src/yunohost/authenticators/*.py + - src/authenticators/*.py diff --git a/conf/dovecot/dovecot.conf b/conf/dovecot/dovecot.conf index c7e937979..273bd45dc 100644 --- a/conf/dovecot/dovecot.conf +++ b/conf/dovecot/dovecot.conf @@ -23,7 +23,7 @@ ssl_cert = /path/to/dhparam -ssl_dh = /path/to/dhparam.pem # not actually 1024 bits, this applies to all DHE >= 1024 bits -smtpd_tls_dh1024_param_file = /usr/share/yunohost/other/ffdhe2048.pem +smtpd_tls_dh1024_param_file = /usr/share/yunohost/ffdhe2048.pem tls_medium_cipherlist = ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384 {% else %} diff --git a/debian/install b/debian/install index 4680bc6be..55c535ae8 100644 --- a/debian/install +++ b/debian/install @@ -1,7 +1,10 @@ bin/* /usr/bin/ -data/* /usr/share/yunohost/ -data/bash-completion.d/yunohost /etc/bash_completion.d/ +share/* /usr/share/yunohost/ +hooks/* /usr/share/yunohost/hooks/ +helpers/* /usr/share/yunohost/helpers.d/ +conf/* /usr/share/yunohost/conf/ doc/yunohost.8.gz /usr/share/man/man8/ +doc/bash-completion.sh /etc/bash_completion.d/yunohost lib/metronome/modules/* /usr/lib/metronome/modules/ locales/* /usr/lib/moulinette/yunohost/locales/ -src/yunohost /usr/lib/moulinette +src/ /usr/lib/moulinette/yunohost diff --git a/debian/rules b/debian/rules index 341ba2b01..d0cbd5138 100755 --- a/debian/rules +++ b/debian/rules @@ -6,7 +6,7 @@ override_dh_auto_build: # Generate bash completion file - python3 data/actionsmap/yunohost_completion.py + python3 doc/generate_bash_completion.py python3 doc/generate_manpages.py --gzip --output doc/yunohost.8.gz override_dh_installinit: diff --git a/doc/generate_bash_completion.py b/doc/generate_bash_completion.py index c801e2f3c..72a524210 100644 --- a/doc/generate_bash_completion.py +++ b/doc/generate_bash_completion.py @@ -12,9 +12,8 @@ import os import yaml THIS_SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -ACTIONSMAP_FILE = THIS_SCRIPT_DIR + "/yunohost.yml" -os.system(f"mkdir {THIS_SCRIPT_DIR}/../bash-completion.d") -BASH_COMPLETION_FILE = THIS_SCRIPT_DIR + "/../bash-completion.d/yunohost" +ACTIONSMAP_FILE = THIS_SCRIPT_DIR + "/../share/actionsmap.yml" +BASH_COMPLETION_FILE = THIS_SCRIPT_DIR + "/bash-completion.sh" def get_dict_actions(OPTION_SUBTREE, category): diff --git a/doc/generate_helper_doc.py b/doc/generate_helper_doc.py index f2d5bf444..189a445d4 100644 --- a/doc/generate_helper_doc.py +++ b/doc/generate_helper_doc.py @@ -217,7 +217,7 @@ def malformed_error(line_number): def main(): - helper_files = sorted(glob.glob("../data/helpers.d/*")) + helper_files = sorted(glob.glob("../helpers/*")) helpers = [] for helper_file in helper_files: diff --git a/doc/generate_manpages.py b/doc/generate_manpages.py index fa042fb17..bdb1fcaee 100644 --- a/doc/generate_manpages.py +++ b/doc/generate_manpages.py @@ -22,7 +22,7 @@ template = Template(open(os.path.join(base_path, "manpage.template")).read()) THIS_SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -ACTIONSMAP_FILE = os.path.join(THIS_SCRIPT_DIR, "../data/actionsmap/yunohost.yml") +ACTIONSMAP_FILE = os.path.join(THIS_SCRIPT_DIR, "../share/actionsmap.yml") def ordered_yaml_load(stream): diff --git a/doc/helper_doc_template.md b/doc/helper_doc_template.md index d41c0b6e9..ac5d455fb 100644 --- a/doc/helper_doc_template.md +++ b/doc/helper_doc_template.md @@ -52,7 +52,7 @@ Doc auto-generated by [this script](https://github.com/YunoHost/yunohost/blob/{{ {{ h.details }} {%- endif %} -[Dude, show me the code!](https://github.com/YunoHost/yunohost/blob/{{ current_commit }}/data/helpers.d/{{ category }}#L{{ h.line + 1 }}) +[Dude, show me the code!](https://github.com/YunoHost/yunohost/blob/{{ current_commit }}/helpers/{{ category }}#L{{ h.line + 1 }}) [/details] ---------------- {% endfor %} diff --git a/hooks/conf_regen/01-yunohost b/hooks/conf_regen/01-yunohost index 963bd49d3..027be8020 100755 --- a/hooks/conf_regen/01-yunohost +++ b/hooks/conf_regen/01-yunohost @@ -8,7 +8,7 @@ do_init_regen() { exit 1 fi - cd /usr/share/yunohost/templates/yunohost + cd /usr/share/yunohost/conf/yunohost [[ -d /etc/yunohost ]] || mkdir -p /etc/yunohost @@ -71,7 +71,7 @@ do_init_regen() { do_pre_regen() { pending_dir=$1 - cd /usr/share/yunohost/templates/yunohost + cd /usr/share/yunohost/conf/yunohost mkdir -p $pending_dir/etc/systemd/system mkdir -p $pending_dir/etc/cron.d/ diff --git a/hooks/conf_regen/02-ssl b/hooks/conf_regen/02-ssl index 03478552c..f27a23cf8 100755 --- a/hooks/conf_regen/02-ssl +++ b/hooks/conf_regen/02-ssl @@ -6,7 +6,7 @@ ssl_dir="/usr/share/yunohost/yunohost-config/ssl/yunoCA" ynh_ca="/etc/yunohost/certs/yunohost.org/ca.pem" ynh_crt="/etc/yunohost/certs/yunohost.org/crt.pem" ynh_key="/etc/yunohost/certs/yunohost.org/key.pem" -openssl_conf="/usr/share/yunohost/templates/ssl/openssl.cnf" +openssl_conf="/usr/share/yunohost/conf/ssl/openssl.cnf" regen_local_ca() { @@ -26,7 +26,7 @@ regen_local_ca() { RANDFILE=.rnd openssl rand -hex 19 >serial rm -f index.txt touch index.txt - cp /usr/share/yunohost/templates/ssl/openssl.cnf openssl.ca.cnf + cp /usr/share/yunohost/conf/ssl/openssl.cnf openssl.ca.cnf sed -i "s/yunohost.org/${domain}/g" openssl.ca.cnf openssl req -x509 \ -new \ @@ -57,7 +57,7 @@ do_init_regen() { # Make sure this conf exists mkdir -p ${ssl_dir} - cp /usr/share/yunohost/templates/ssl/openssl.cnf ${ssl_dir}/openssl.ca.cnf + cp /usr/share/yunohost/conf/ssl/openssl.cnf ${ssl_dir}/openssl.ca.cnf # create default certificates if [[ ! -f "$ynh_ca" ]]; then @@ -99,7 +99,7 @@ do_init_regen() { do_pre_regen() { pending_dir=$1 - cd /usr/share/yunohost/templates/ssl + cd /usr/share/yunohost/conf/ssl install -D -m 644 openssl.cnf "${pending_dir}/${ssl_dir}/openssl.cnf" } diff --git a/hooks/conf_regen/03-ssh b/hooks/conf_regen/03-ssh index dd1589204..0c700c01f 100755 --- a/hooks/conf_regen/03-ssh +++ b/hooks/conf_regen/03-ssh @@ -7,7 +7,7 @@ set -e do_pre_regen() { pending_dir=$1 - cd /usr/share/yunohost/templates/ssh + cd /usr/share/yunohost/conf/ssh # do not listen to IPv6 if unavailable [[ -f /proc/net/if_inet6 ]] && ipv6_enabled=true || ipv6_enabled=false diff --git a/hooks/conf_regen/06-slapd b/hooks/conf_regen/06-slapd index 0c52e4998..616b383ec 100755 --- a/hooks/conf_regen/06-slapd +++ b/hooks/conf_regen/06-slapd @@ -4,8 +4,8 @@ set -e tmp_backup_dir_file="/root/slapd-backup-dir.txt" -config="/usr/share/yunohost/templates/slapd/config.ldif" -db_init="/usr/share/yunohost/templates/slapd/db_init.ldif" +config="/usr/share/yunohost/conf/slapd/config.ldif" +db_init="/usr/share/yunohost/conf/slapd/db_init.ldif" do_init_regen() { if [[ $EUID -ne 0 ]]; then @@ -109,7 +109,7 @@ do_pre_regen() { schema_dir="${ldap_dir}/schema" mkdir -p "$ldap_dir" "$schema_dir" - cd /usr/share/yunohost/templates/slapd + cd /usr/share/yunohost/conf/slapd # copy configuration files cp -a ldap.conf "$ldap_dir" diff --git a/hooks/conf_regen/09-nslcd b/hooks/conf_regen/09-nslcd index ff1c05433..9d5e5e538 100755 --- a/hooks/conf_regen/09-nslcd +++ b/hooks/conf_regen/09-nslcd @@ -10,7 +10,7 @@ do_init_regen() { do_pre_regen() { pending_dir=$1 - cd /usr/share/yunohost/templates/nslcd + cd /usr/share/yunohost/conf/nslcd install -D -m 644 nslcd.conf "${pending_dir}/etc/nslcd.conf" } diff --git a/hooks/conf_regen/12-metronome b/hooks/conf_regen/12-metronome index 5dfa7b5dc..4802b750e 100755 --- a/hooks/conf_regen/12-metronome +++ b/hooks/conf_regen/12-metronome @@ -5,7 +5,7 @@ set -e do_pre_regen() { pending_dir=$1 - cd /usr/share/yunohost/templates/metronome + cd /usr/share/yunohost/conf/metronome # create directories for pending conf metronome_dir="${pending_dir}/etc/metronome" diff --git a/hooks/conf_regen/15-nginx b/hooks/conf_regen/15-nginx index b585e3cb5..c1d943681 100755 --- a/hooks/conf_regen/15-nginx +++ b/hooks/conf_regen/15-nginx @@ -10,7 +10,7 @@ do_init_regen() { exit 1 fi - cd /usr/share/yunohost/templates/nginx + cd /usr/share/yunohost/conf/nginx nginx_dir="/etc/nginx" nginx_conf_dir="${nginx_dir}/conf.d" @@ -47,7 +47,7 @@ do_init_regen() { do_pre_regen() { pending_dir=$1 - cd /usr/share/yunohost/templates/nginx + cd /usr/share/yunohost/conf/nginx nginx_dir="${pending_dir}/etc/nginx" nginx_conf_dir="${nginx_dir}/conf.d" diff --git a/hooks/conf_regen/19-postfix b/hooks/conf_regen/19-postfix index 7865cd312..4a7325c41 100755 --- a/hooks/conf_regen/19-postfix +++ b/hooks/conf_regen/19-postfix @@ -7,7 +7,7 @@ set -e do_pre_regen() { pending_dir=$1 - cd /usr/share/yunohost/templates/postfix + cd /usr/share/yunohost/conf/postfix postfix_dir="${pending_dir}/etc/postfix" mkdir -p "$postfix_dir" diff --git a/hooks/conf_regen/25-dovecot b/hooks/conf_regen/25-dovecot index e95816604..9a51d0363 100755 --- a/hooks/conf_regen/25-dovecot +++ b/hooks/conf_regen/25-dovecot @@ -7,7 +7,7 @@ set -e do_pre_regen() { pending_dir=$1 - cd /usr/share/yunohost/templates/dovecot + cd /usr/share/yunohost/conf/dovecot dovecot_dir="${pending_dir}/etc/dovecot" mkdir -p "${dovecot_dir}/global_script" diff --git a/hooks/conf_regen/31-rspamd b/hooks/conf_regen/31-rspamd index 72a35fdcc..536aec7c2 100755 --- a/hooks/conf_regen/31-rspamd +++ b/hooks/conf_regen/31-rspamd @@ -5,7 +5,7 @@ set -e do_pre_regen() { pending_dir=$1 - cd /usr/share/yunohost/templates/rspamd + cd /usr/share/yunohost/conf/rspamd install -D -m 644 metrics.local.conf \ "${pending_dir}/etc/rspamd/local.d/metrics.conf" diff --git a/hooks/conf_regen/34-mysql b/hooks/conf_regen/34-mysql index 13730e0bb..d7ddf1a90 100755 --- a/hooks/conf_regen/34-mysql +++ b/hooks/conf_regen/34-mysql @@ -6,7 +6,7 @@ set -e do_pre_regen() { pending_dir=$1 - cd /usr/share/yunohost/templates/mysql + cd /usr/share/yunohost/conf/mysql # Nothing to do } diff --git a/hooks/conf_regen/37-mdns b/hooks/conf_regen/37-mdns index faa581efa..ff674c391 100755 --- a/hooks/conf_regen/37-mdns +++ b/hooks/conf_regen/37-mdns @@ -29,7 +29,7 @@ do_init_regen() { do_pre_regen() { pending_dir="$1" - cd /usr/share/yunohost/templates/mdns + cd /usr/share/yunohost/conf/mdns mkdir -p ${pending_dir}/etc/systemd/system/ cp yunomdns.service ${pending_dir}/etc/systemd/system/ diff --git a/hooks/conf_regen/43-dnsmasq b/hooks/conf_regen/43-dnsmasq index 13c442158..406762ecb 100755 --- a/hooks/conf_regen/43-dnsmasq +++ b/hooks/conf_regen/43-dnsmasq @@ -6,7 +6,7 @@ set -e do_pre_regen() { pending_dir=$1 - cd /usr/share/yunohost/templates/dnsmasq + cd /usr/share/yunohost/conf/dnsmasq # create directory for pending conf dnsmasq_dir="${pending_dir}/etc/dnsmasq.d" diff --git a/hooks/conf_regen/46-nsswitch b/hooks/conf_regen/46-nsswitch index 2c984a905..cc34d0277 100755 --- a/hooks/conf_regen/46-nsswitch +++ b/hooks/conf_regen/46-nsswitch @@ -10,7 +10,7 @@ do_init_regen() { do_pre_regen() { pending_dir=$1 - cd /usr/share/yunohost/templates/nsswitch + cd /usr/share/yunohost/conf/nsswitch install -D -m 644 nsswitch.conf "${pending_dir}/etc/nsswitch.conf" } diff --git a/hooks/conf_regen/52-fail2ban b/hooks/conf_regen/52-fail2ban index 6cbebbfb1..8129e977d 100755 --- a/hooks/conf_regen/52-fail2ban +++ b/hooks/conf_regen/52-fail2ban @@ -7,7 +7,7 @@ set -e do_pre_regen() { pending_dir=$1 - cd /usr/share/yunohost/templates/fail2ban + cd /usr/share/yunohost/conf/fail2ban fail2ban_dir="${pending_dir}/etc/fail2ban" mkdir -p "${fail2ban_dir}/filter.d" diff --git a/src/diagnosis/10-ip.py b/src/diagnosis/10-ip.py index 408019668..bc00fe25c 100644 --- a/src/diagnosis/10-ip.py +++ b/src/diagnosis/10-ip.py @@ -152,7 +152,7 @@ class IPDiagnoser(Diagnoser): # We use the resolver file as a list of well-known, trustable (ie not google ;)) IPs that we can ping resolver_file = ( - "/usr/share/yunohost/templates/dnsmasq/plain/resolv.dnsmasq.conf" + "/usr/share/yunohost/conf/dnsmasq/plain/resolv.dnsmasq.conf" ) resolvers = [ r.split(" ")[1] diff --git a/src/diagnosis/24-mail.py b/src/diagnosis/24-mail.py index c5af4bbc6..f29b2786d 100644 --- a/src/diagnosis/24-mail.py +++ b/src/diagnosis/24-mail.py @@ -14,7 +14,7 @@ from yunohost.domain import _get_maindomain, domain_list from yunohost.settings import settings_get from yunohost.utils.dns import dig -DEFAULT_DNS_BLACKLIST = "/usr/share/yunohost/other/dnsbl_list.yml" +DEFAULT_DNS_BLACKLIST = "/usr/share/yunohost/dnsbl_list.yml" class MailDiagnoser(Diagnoser): diff --git a/src/dns.py b/src/dns.py index 534ade918..cad0ff2f5 100644 --- a/src/dns.py +++ b/src/dns.py @@ -50,7 +50,7 @@ from yunohost.hook import hook_callback logger = getActionLogger("yunohost.domain") -DOMAIN_REGISTRAR_LIST_PATH = "/usr/share/yunohost/other/registrar_list.toml" +DOMAIN_REGISTRAR_LIST_PATH = "/usr/share/yunohost/registrar_list.toml" def domain_dns_suggest(domain): diff --git a/src/domain.py b/src/domain.py index 0bd84ea82..3c244f9cf 100644 --- a/src/domain.py +++ b/src/domain.py @@ -44,7 +44,7 @@ from yunohost.log import is_unit_operation logger = getActionLogger("yunohost.domain") -DOMAIN_CONFIG_PATH = "/usr/share/yunohost/other/config_domain.toml" +DOMAIN_CONFIG_PATH = "/usr/share/yunohost/config_domain.toml" DOMAIN_SETTINGS_DIR = "/etc/yunohost/domains" # Lazy dev caching to avoid re-query ldap every time we need the domain list diff --git a/src/service.py b/src/service.py index 73534e2e3..527ca5813 100644 --- a/src/service.py +++ b/src/service.py @@ -48,7 +48,7 @@ from moulinette.utils.filesystem import ( MOULINETTE_LOCK = "/var/run/moulinette_yunohost.lock" SERVICES_CONF = "/etc/yunohost/services.yml" -SERVICES_CONF_BASE = "/usr/share/yunohost/templates/yunohost/services.yml" +SERVICES_CONF_BASE = "/usr/share/yunohost/conf/yunohost/services.yml" logger = getActionLogger("yunohost.service") diff --git a/src/utils/config.py b/src/utils/config.py index 5d1d1f9d2..352e25be6 100644 --- a/src/utils/config.py +++ b/src/utils/config.py @@ -192,7 +192,7 @@ def evaluate_simple_js_expression(expr, context={}): class ConfigPanel: entity_type = "config" save_path_tpl: Union[str, None] = None - config_path_tpl = "/usr/share/yunohost/other/config_{entity_type}.toml" + config_path_tpl = "/usr/share/yunohost/config_{entity_type}.toml" save_mode = "full" @classmethod diff --git a/src/utils/password.py b/src/utils/password.py index 188850183..04a1ed272 100644 --- a/src/utils/password.py +++ b/src/utils/password.py @@ -36,7 +36,7 @@ SMALL_PWD_LIST = [ "rpi", ] -MOST_USED_PASSWORDS = "/usr/share/yunohost/other/password/100000-most-used.txt" +MOST_USED_PASSWORDS = "/usr/share/yunohost/password/100000-most-used-passwords.txt" # Length, digits, lowers, uppers, others STRENGTH_LEVELS = [ diff --git a/tests/add_missing_keys.py b/tests/add_missing_keys.py index 30c6c6640..1bf335418 100644 --- a/tests/add_missing_keys.py +++ b/tests/add_missing_keys.py @@ -24,11 +24,11 @@ def find_expected_string_keys(): p3 = re.compile(r"YunohostValidationError\(\n*\s*[\'\"](\w+)[\'\"]") p4 = re.compile(r"# i18n: [\'\"]?(\w+)[\'\"]?") - python_files = glob.glob("src/yunohost/*.py") - python_files.extend(glob.glob("src/yunohost/utils/*.py")) - python_files.extend(glob.glob("src/yunohost/data_migrations/*.py")) - python_files.extend(glob.glob("src/yunohost/authenticators/*.py")) - python_files.extend(glob.glob("data/hooks/diagnosis/*.py")) + python_files = glob.glob("src/*.py") + python_files.extend(glob.glob("src/utils/*.py")) + python_files.extend(glob.glob("src/data_migrations/*.py")) + python_files.extend(glob.glob("src/authenticators/*.py")) + python_files.extend(glob.glob("src/diagnosis/*.py")) python_files.append("bin/yunohost") for python_file in python_files: @@ -51,7 +51,7 @@ def find_expected_string_keys(): # For each diagnosis, try to find strings like "diagnosis_stuff_foo" (c.f. diagnosis summaries) # Also we expect to have "diagnosis_description_" for each diagnosis p3 = re.compile(r"[\"\'](diagnosis_[a-z]+_\w+)[\"\']") - for python_file in glob.glob("data/hooks/diagnosis/*.py"): + for python_file in glob.glob("src/diagnosis/*.py"): content = open(python_file).read() for m in p3.findall(content): if m.endswith("_"): @@ -63,14 +63,14 @@ def find_expected_string_keys(): ] # For each migration, expect to find "migration_description_" - for path in glob.glob("src/yunohost/data_migrations/*.py"): + for path in glob.glob("src/data_migrations/*.py"): if "__init__" in path: continue yield "migration_description_" + os.path.basename(path)[:-3] # For each default service, expect to find "service_description_" for service, info in yaml.safe_load( - open("data/templates/yunohost/services.yml") + open("conf/yunohost/services.yml") ).items(): if info is None: continue @@ -79,7 +79,7 @@ def find_expected_string_keys(): # For all unit operations, expect to find "log_" # A unit operation is created either using the @is_unit_operation decorator # or using OperationLogger( - cmd = "grep -hr '@is_unit_operation' src/yunohost/ -A3 2>/dev/null | grep '^def' | sed -E 's@^def (\\w+)\\(.*@\\1@g'" + cmd = "grep -hr '@is_unit_operation' src/ -A3 2>/dev/null | grep '^def' | sed -E 's@^def (\\w+)\\(.*@\\1@g'" for funcname in ( subprocess.check_output(cmd, shell=True).decode("utf-8").strip().split("\n") ): @@ -94,14 +94,14 @@ def find_expected_string_keys(): # Global settings descriptions # Will be on a line like : ("service.ssh.allow_deprecated_dsa_hostkey", {"type": "bool", ... p5 = re.compile(r" \(\n*\s*[\"\'](\w[\w\.]+)[\"\'],") - content = open("src/yunohost/settings.py").read() + content = open("src/settings.py").read() for m in ( "global_settings_setting_" + s.replace(".", "_") for s in p5.findall(content) ): yield m # Keys for the actionmap ... - for category in yaml.safe_load(open("data/actionsmap/yunohost.yml")).values(): + for category in yaml.safe_load(open("share/actionsmap.yml")).values(): if "actions" not in category.keys(): continue for action in category["actions"].values(): diff --git a/tests/test_actionmap.py b/tests/test_actionmap.py index 0b8abb152..e482bdfe1 100644 --- a/tests/test_actionmap.py +++ b/tests/test_actionmap.py @@ -2,4 +2,4 @@ import yaml def test_yaml_syntax(): - yaml.safe_load(open("data/actionsmap/yunohost.yml")) + yaml.safe_load(open("share/actionsmap.yml")) diff --git a/tests/test_i18n_keys.py b/tests/test_i18n_keys.py index 103241085..d0ae75bfc 100644 --- a/tests/test_i18n_keys.py +++ b/tests/test_i18n_keys.py @@ -25,11 +25,11 @@ def find_expected_string_keys(): p3 = re.compile(r"YunohostValidationError\(\n*\s*[\'\"](\w+)[\'\"]") p4 = re.compile(r"# i18n: [\'\"]?(\w+)[\'\"]?") - python_files = glob.glob("src/yunohost/*.py") - python_files.extend(glob.glob("src/yunohost/utils/*.py")) - python_files.extend(glob.glob("src/yunohost/data_migrations/*.py")) - python_files.extend(glob.glob("src/yunohost/authenticators/*.py")) - python_files.extend(glob.glob("data/hooks/diagnosis/*.py")) + python_files = glob.glob("src/*.py") + python_files.extend(glob.glob("src/utils/*.py")) + python_files.extend(glob.glob("src/data_migrations/*.py")) + python_files.extend(glob.glob("src/authenticators/*.py")) + python_files.extend(glob.glob("src/diagnosis/*.py")) python_files.append("bin/yunohost") for python_file in python_files: @@ -52,7 +52,7 @@ def find_expected_string_keys(): # For each diagnosis, try to find strings like "diagnosis_stuff_foo" (c.f. diagnosis summaries) # Also we expect to have "diagnosis_description_" for each diagnosis p3 = re.compile(r"[\"\'](diagnosis_[a-z]+_\w+)[\"\']") - for python_file in glob.glob("data/hooks/diagnosis/*.py"): + for python_file in glob.glob("src/diagnosis/*.py"): content = open(python_file).read() for m in p3.findall(content): if m.endswith("_"): @@ -64,14 +64,14 @@ def find_expected_string_keys(): ] # For each migration, expect to find "migration_description_" - for path in glob.glob("src/yunohost/data_migrations/*.py"): + for path in glob.glob("src/data_migrations/*.py"): if "__init__" in path: continue yield "migration_description_" + os.path.basename(path)[:-3] # For each default service, expect to find "service_description_" for service, info in yaml.safe_load( - open("data/templates/yunohost/services.yml") + open("conf/yunohost/services.yml") ).items(): if info is None: continue @@ -80,7 +80,7 @@ def find_expected_string_keys(): # For all unit operations, expect to find "log_" # A unit operation is created either using the @is_unit_operation decorator # or using OperationLogger( - cmd = "grep -hr '@is_unit_operation' src/yunohost/ -A3 2>/dev/null | grep '^def' | sed -E 's@^def (\\w+)\\(.*@\\1@g'" + cmd = "grep -hr '@is_unit_operation' src/ -A3 2>/dev/null | grep '^def' | sed -E 's@^def (\\w+)\\(.*@\\1@g'" for funcname in ( subprocess.check_output(cmd, shell=True).decode("utf-8").strip().split("\n") ): @@ -95,14 +95,14 @@ def find_expected_string_keys(): # Global settings descriptions # Will be on a line like : ("service.ssh.allow_deprecated_dsa_hostkey", {"type": "bool", ... p5 = re.compile(r" \(\n*\s*[\"\'](\w[\w\.]+)[\"\'],") - content = open("src/yunohost/settings.py").read() + content = open("src/settings.py").read() for m in ( "global_settings_setting_" + s.replace(".", "_") for s in p5.findall(content) ): yield m # Keys for the actionmap ... - for category in yaml.safe_load(open("data/actionsmap/yunohost.yml")).values(): + for category in yaml.safe_load(open("src/actionsmap.yml")).values(): if "actions" not in category.keys(): continue for action in category["actions"].values(): @@ -130,13 +130,13 @@ def find_expected_string_keys(): yield "backup_applying_method_%s" % method yield "backup_method_%s_finished" % method - registrars = toml.load(open("data/other/registrar_list.toml")) + registrars = toml.load(open("share/registrar_list.toml")) supported_registrars = ["ovh", "gandi", "godaddy"] for registrar in supported_registrars: for key in registrars[registrar].keys(): yield f"domain_config_{key}" - domain_config = toml.load(open("data/other/config_domain.toml")) + domain_config = toml.load(open("share/config_domain.toml")) for panel in domain_config.values(): if not isinstance(panel, dict): continue diff --git a/tox.ini b/tox.ini index f00cc7fb8..e5cffb696 100644 --- a/tox.ini +++ b/tox.ini @@ -8,8 +8,8 @@ deps = py39-black-{run,check}: black py39-mypy: mypy >= 0.900 commands = - py39-lint: flake8 src doc data tests --ignore E402,E501,E203,W503 --exclude src/yunohost/vendor - py39-invalidcode: flake8 src data --exclude src/yunohost/tests,src/yunohost/vendor --select F,E722,W605 + py39-lint: flake8 src doc data tests --ignore E402,E501,E203,W503 --exclude src/vendor + py39-invalidcode: flake8 src data --exclude src/tests,src/vendor --select F,E722,W605 py39-black-check: black --check --diff src doc data tests py39-black-run: black src doc data tests - py39-mypy: mypy --ignore-missing-import --install-types --non-interactive --follow-imports silent src/yunohost/ --exclude (acme_tiny|data_migrations) + py39-mypy: mypy --ignore-missing-import --install-types --non-interactive --follow-imports silent src/ --exclude (acme_tiny|data_migrations)