Fix support of Anope 2.1.2 (#251)

It is going to change module names:
7ac1fe5847
This commit is contained in:
2024-01-27 10:32:35 +01:00
committed by GitHub
parent 0ebfbdf6ab
commit d75e3fae34

View File

@ -2,7 +2,7 @@ import functools
from pathlib import Path from pathlib import Path
import shutil import shutil
import subprocess import subprocess
from typing import Type from typing import Tuple, Type
from irctest.basecontrollers import BaseServicesController, DirectoryBasedController from irctest.basecontrollers import BaseServicesController, DirectoryBasedController
@ -66,7 +66,7 @@ options {{
warningtimeout = 4h warningtimeout = 4h
}} }}
module {{ name = "m_sasl" }} module {{ name = "{module_prefix}sasl" }}
module {{ name = "enc_sha256" }} module {{ name = "enc_sha256" }}
module {{ name = "ns_cert" }} module {{ name = "ns_cert" }}
@ -74,16 +74,13 @@ module {{ name = "ns_cert" }}
@functools.lru_cache() @functools.lru_cache()
def installed_version() -> int: def installed_version() -> Tuple[int, ...]:
output = subprocess.run( output = subprocess.run(
["anope", "--version"], stdout=subprocess.PIPE, universal_newlines=True ["anope", "--version"], stdout=subprocess.PIPE, universal_newlines=True
).stdout ).stdout
if output.startswith("Anope-2.0"): (anope, version, *trailing) = output.split()[0].split("-")
return 20 assert anope == "Anope"
elif output.startswith("Anope-2.1"): return tuple(map(int, version.split(".")))
return 21
else:
assert False, f"unexpected version: {output}"
class AnopeController(BaseServicesController, DirectoryBasedController): class AnopeController(BaseServicesController, DirectoryBasedController):
@ -112,7 +109,7 @@ class AnopeController(BaseServicesController, DirectoryBasedController):
# Rewrite Anope 2.0 module names for 2.1 # Rewrite Anope 2.0 module names for 2.1
if not self.software_version: if not self.software_version:
self.software_version = installed_version() self.software_version = installed_version()
if self.software_version >= 21: if self.software_version >= (2, 1, 0):
if protocol == "charybdis": if protocol == "charybdis":
protocol = "solanum" protocol = "solanum"
elif protocol == "inspircd3": elif protocol == "inspircd3":
@ -126,6 +123,7 @@ class AnopeController(BaseServicesController, DirectoryBasedController):
protocol=protocol, protocol=protocol,
server_hostname=server_hostname, server_hostname=server_hostname,
server_port=server_port, server_port=server_port,
module_prefix="" if self.software_version >= (2, 1, 2) else "m_",
) )
) )