Merge doveauth and filtermail into chatmaild

This commit is contained in:
link2xt 2023-10-15 15:45:35 +00:00
parent 262eb36a5c
commit b548a8ddbd
16 changed files with 29 additions and 75 deletions

View File

@ -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]

View File

@ -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)

View File

@ -1,6 +1,6 @@
import os
import pyinfra
from chatmail import deploy_chatmail
from deploy_chatmail import deploy_chatmail
def main():

View File

@ -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/
"""

View File

@ -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

View File

@ -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