From b548a8ddbd3211d7b32951daf101440b545eff56 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sun, 15 Oct 2023 15:45:35 +0000 Subject: [PATCH] Merge doveauth and filtermail into chatmaild --- {doveauth => chatmaild}/README.md | 0 {filtermail => chatmaild}/pyproject.toml | 4 +- .../src/doveauth/__init__.py | 0 .../src/doveauth/database.py | 0 .../src/doveauth/dictproxy.py | 0 .../src/doveauth/doveauth-dictproxy.service | 0 .../src/doveauth/doveauth.py | 0 .../src/doveauth/test_doveauth.py | 0 .../src/filtermail/__init__.py | 0 .../src/filtermail/filtermail.py | 0 .../src/filtermail}/filtermail.service | 0 .../src/deploy_chatmail/__init__.py | 55 +++++++------------ deploy.py | 2 +- doveauth/pyproject.toml | 31 ----------- scripts/deploy.sh | 3 +- scripts/init.sh | 9 +-- 16 files changed, 29 insertions(+), 75 deletions(-) rename {doveauth => chatmaild}/README.md (100%) rename {filtermail => chatmaild}/pyproject.toml (82%) rename {doveauth => chatmaild}/src/doveauth/__init__.py (100%) rename {doveauth => chatmaild}/src/doveauth/database.py (100%) rename {doveauth => chatmaild}/src/doveauth/dictproxy.py (100%) rename {doveauth => chatmaild}/src/doveauth/doveauth-dictproxy.service (100%) rename {doveauth => chatmaild}/src/doveauth/doveauth.py (100%) rename {doveauth => chatmaild}/src/doveauth/test_doveauth.py (100%) rename {filtermail => chatmaild}/src/filtermail/__init__.py (100%) rename {filtermail => chatmaild}/src/filtermail/filtermail.py (100%) rename {filtermail => chatmaild/src/filtermail}/filtermail.service (100%) delete mode 100644 doveauth/pyproject.toml diff --git a/doveauth/README.md b/chatmaild/README.md similarity index 100% rename from doveauth/README.md rename to chatmaild/README.md diff --git a/filtermail/pyproject.toml b/chatmaild/pyproject.toml similarity index 82% rename from filtermail/pyproject.toml rename to chatmaild/pyproject.toml index 2d3fb4e9..09ffc221 100644 --- a/filtermail/pyproject.toml +++ b/chatmaild/pyproject.toml @@ -3,13 +3,15 @@ requires = ["setuptools>=45"] build-backend = "setuptools.build_meta" [project] -name = "filtermail" +name = "chatmaild" version = "0.1" dependencies = [ "aiosmtpd" ] [project.scripts] +doveauth = "doveauth.doveauth:main" +doveauth-dictproxy = "doveauth.dictproxy:main" filtermail = "filtermail.filtermail:main" [tool.pytest.ini_options] diff --git a/doveauth/src/doveauth/__init__.py b/chatmaild/src/doveauth/__init__.py similarity index 100% rename from doveauth/src/doveauth/__init__.py rename to chatmaild/src/doveauth/__init__.py diff --git a/doveauth/src/doveauth/database.py b/chatmaild/src/doveauth/database.py similarity index 100% rename from doveauth/src/doveauth/database.py rename to chatmaild/src/doveauth/database.py diff --git a/doveauth/src/doveauth/dictproxy.py b/chatmaild/src/doveauth/dictproxy.py similarity index 100% rename from doveauth/src/doveauth/dictproxy.py rename to chatmaild/src/doveauth/dictproxy.py diff --git a/doveauth/src/doveauth/doveauth-dictproxy.service b/chatmaild/src/doveauth/doveauth-dictproxy.service similarity index 100% rename from doveauth/src/doveauth/doveauth-dictproxy.service rename to chatmaild/src/doveauth/doveauth-dictproxy.service diff --git a/doveauth/src/doveauth/doveauth.py b/chatmaild/src/doveauth/doveauth.py similarity index 100% rename from doveauth/src/doveauth/doveauth.py rename to chatmaild/src/doveauth/doveauth.py diff --git a/doveauth/src/doveauth/test_doveauth.py b/chatmaild/src/doveauth/test_doveauth.py similarity index 100% rename from doveauth/src/doveauth/test_doveauth.py rename to chatmaild/src/doveauth/test_doveauth.py diff --git a/filtermail/src/filtermail/__init__.py b/chatmaild/src/filtermail/__init__.py similarity index 100% rename from filtermail/src/filtermail/__init__.py rename to chatmaild/src/filtermail/__init__.py diff --git a/filtermail/src/filtermail/filtermail.py b/chatmaild/src/filtermail/filtermail.py similarity index 100% rename from filtermail/src/filtermail/filtermail.py rename to chatmaild/src/filtermail/filtermail.py diff --git a/filtermail/filtermail.service b/chatmaild/src/filtermail/filtermail.service similarity index 100% rename from filtermail/filtermail.service rename to chatmaild/src/filtermail/filtermail.service diff --git a/deploy-chatmail/src/deploy_chatmail/__init__.py b/deploy-chatmail/src/deploy_chatmail/__init__.py index e7df2c99..05b6df8a 100644 --- a/deploy-chatmail/src/deploy_chatmail/__init__.py +++ b/deploy-chatmail/src/deploy_chatmail/__init__.py @@ -10,23 +10,27 @@ from pyinfra.facts.files import File from .acmetool import deploy_acmetool -def _install_doveauth() -> None: - """Setup chatctl.""" - doveauth_filename = "doveauth-0.2.tar.gz" - doveauth_path = importlib.resources.files(__package__).joinpath( - f"../../../dist/{doveauth_filename}" +def _install_chatmaild() -> None: + chatmaild_filename = "chatmaild-0.1.tar.gz" + chatmaild_path = importlib.resources.files(__package__).joinpath( + f"../../../dist/{chatmaild_filename}" ) - remote_path = f"/tmp/{doveauth_filename}" - if Path(str(doveauth_path)).exists(): + remote_path = f"/tmp/{chatmaild_filename}" + if Path(str(chatmaild_path)).exists(): files.put( - name="upload local doveauth build", - src=doveauth_path.open("rb"), + name="Upload chatmaild source package", + src=chatmaild_path.open("rb"), dest=remote_path, ) - # Maybe if we introduce dependencies to the doveauth package at some point, we should not install doveauth - # system-wide anymore. For now it's fine though. + + apt.packages( + name="apt install python3-aiosmtpd", + packages="python3-aiosmtpd", + ) + + # --no-deps because aiosmtplib is installed with `apt`. server.shell( - name="install local doveauth build with pip", + name="install chatmaild with pip", commands=[f"pip install --break-system-packages {remote_path}"], ) @@ -48,34 +52,14 @@ def _install_doveauth() -> None: daemon_reload=True, ) - -def _install_filtermail() -> None: - """Setup filtermail.""" - filtermail_filename = "filtermail-0.1.tar.gz" - filtermail_path = importlib.resources.files(__package__).joinpath( - f"../../../dist/{filtermail_filename}" - ) - remote_path = f"/tmp/{filtermail_filename}" - if Path(str(filtermail_path)).exists(): - files.put( - name="upload local filtermail build", - src=filtermail_path.open("rb"), - dest=remote_path, - ) - apt.packages( - name="apt install python3-aiosmtpd", - packages="python3-aiosmtpd", - ) - - # --no-deps because aiosmtplib is installed with `apt`. server.shell( name="install local doveauth build with pip", commands=[f"pip install --break-system-packages --no-deps {remote_path}"], ) files.put( - src=importlib.resources.files(__package__) - .joinpath("../../../filtermail/filtermail.service") + src=importlib.resources.files("filtermail") + .joinpath("filtermail.service") .open("rb"), dest="/etc/systemd/system/filtermail.service", user="root", @@ -227,8 +211,7 @@ def deploy_chatmail(mail_domain: str, mail_server: str, dkim_selector: str) -> N name="apt install python3-pip", packages="python3-pip", ) - _install_doveauth() - _install_filtermail() + _install_chatmaild() dovecot_need_restart = _configure_dovecot(mail_server) postfix_need_restart = _configure_postfix(mail_domain) opendkim_need_restart = _configure_opendkim(mail_domain, dkim_selector) diff --git a/deploy.py b/deploy.py index f3698b9d..ab8d4ed9 100644 --- a/deploy.py +++ b/deploy.py @@ -1,6 +1,6 @@ import os import pyinfra -from chatmail import deploy_chatmail +from deploy_chatmail import deploy_chatmail def main(): diff --git a/doveauth/pyproject.toml b/doveauth/pyproject.toml deleted file mode 100644 index 48ff5dd9..00000000 --- a/doveauth/pyproject.toml +++ /dev/null @@ -1,31 +0,0 @@ -[build-system] -requires = ["setuptools>=45"] -build-backend = "setuptools.build_meta" - -[project] -name = "doveauth" -version = "0.2" - -[project.scripts] -doveauth = "doveauth.doveauth:main" -doveauth-dictproxy = "doveauth.dictproxy:main" - -[tool.pytest.ini_options] -addopts = "-v -ra --strict-markers" - -[tool.tox] -legacy_tox_ini = """ -[tox] -isolated_build = true -envlist = lint - -[testenv:lint] -skipdist = True -skip_install = True -deps = - ruff - black -commands = - black --quiet --check --diff src/ - ruff src/ -""" diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 695135cc..f766f814 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -2,8 +2,7 @@ : ${CHATMAIL_DOMAIN:=c1.testrun.org} export CHATMAIL_DOMAIN -venv/bin/python3 -m build -n --sdist doveauth --outdir dist -venv/bin/python3 -m build -n --sdist filtermail --outdir dist +venv/bin/python3 -m build -n --sdist chatmaild --outdir dist deploy-chatmail/venv/bin/pyinfra --ssh-user root "$CHATMAIL_DOMAIN" deploy.py diff --git a/scripts/init.sh b/scripts/init.sh index fe2c1fde..f68e1243 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -1,12 +1,13 @@ #!/bin/sh +set -e python3 -m venv deploy-chatmail/venv deploy-chatmail/venv/bin/pip install pyinfra pytest deploy-chatmail/venv/bin/pip install -e deploy-chatmail -deploy-chatmail/venv/bin/pip install -e doveauth +deploy-chatmail/venv/bin/pip install -e chatmaild -python3 -m venv doveauth/venv -doveauth/venv/bin/pip install pytest -doveauth/venv/bin/pip install -e doveauth +python3 -m venv chatmaild/venv +chatmaild/venv/bin/pip install pytest +chatmaild/venv/bin/pip install -e chatmaild python3 -m venv online-tests/venv online-tests/venv/bin/pip install pytest pytest-timeout pdbpp deltachat