Fixed issue with Debian bullseye (11).

This commit is contained in:
Antoine Nguyen
2021-09-22 11:32:55 +02:00
parent 32041a40e2
commit 58f5a8af09
8 changed files with 84 additions and 41 deletions

View File

@@ -48,7 +48,7 @@ class PostgreSQL(Database):
def install_package(self):
"""Install database if required."""
name, version, _id = utils.dist_info()
name, version = utils.dist_info()
if "CentOS" in name:
if version.startswith("7"):
# Install newer version of postgres in this case
@@ -158,31 +158,44 @@ class MySQL(Database):
def install_package(self):
"""Preseed package installation."""
name, version, _id = utils.dist_info()
name, version = utils.dist_info()
name = name.lower()
if name == "debian":
mysql_name = "mysql" if version.startswith("8") else "mariadb"
self.packages["deb"].append("lib{}client-dev".format(mysql_name))
if name.startswith("debian"):
if version.startswith("8"):
self.packages["deb"].append("libmysqlclient-dev")
elif version.startswith("11"):
self.packages["deb"].append("libmariadb-dev")
else:
self.packages["deb"].append("libmariadbclient-dev")
elif name == "ubuntu":
self.packages["deb"].append("libmysqlclient-dev")
super(MySQL, self).install_package()
if name == "debian" and version.startswith("8"):
package.backend.preconfigure(
"mariadb-server", "root_password", "password",
self.dbpassword)
package.backend.preconfigure(
"mariadb-server", "root_password_again", "password",
self.dbpassword)
else:
queries = []
if name.startswith("debian"):
if version.startswith("8"):
package.backend.preconfigure(
"mariadb-server", "root_password", "password",
self.dbpassword)
package.backend.preconfigure(
"mariadb-server", "root_password_again", "password",
self.dbpassword)
return
if version.startswith("11"):
queries = [
"SET PASSWORD FOR 'root'@'localhost' = PASSWORD('{}')"
.format(self.dbpassword),
"flush privileges"
]
if not queries:
queries = [
"UPDATE user SET plugin='' WHERE user='root'",
"UPDATE user SET password=PASSWORD('{}') WHERE USER='root'"
.format(self.dbpassword),
"flush privileges"
]
for query in queries:
utils.exec_cmd(
"mysql -D mysql -e '{}'".format(self._escape(query)))
for query in queries:
utils.exec_cmd(
"mysql -D mysql -e '{}'".format(self._escape(query)))
def _exec_query(self, query, dbname=None, dbuser=None, dbpassword=None):
"""Exec a mysql query."""

View File

@@ -108,7 +108,7 @@ def get_backend():
"""Return the appropriate package backend."""
distname = utils.dist_name()
backend = None
if distname in ["debian", "ubuntu"]:
if distname in ["debian", "debian gnu/linux", "ubuntu"]:
backend = DEBPackage
elif "centos" in distname:
backend = RPMPackage

View File

@@ -24,10 +24,11 @@ def get_pip_path(venv):
def install_package(name, venv=None, upgrade=False, binary=True, **kwargs):
"""Install a Python package using pip."""
cmd = "{} install{}{} {}".format(
cmd = "{} install{}{}{} {}".format(
get_pip_path(venv),
" -U" if upgrade else "",
" --no-binary :all:" if not binary else "",
" --pre" if kwargs.pop("beta", False) else "",
name
)
utils.exec_cmd(cmd, **kwargs)
@@ -35,8 +36,12 @@ def install_package(name, venv=None, upgrade=False, binary=True, **kwargs):
def install_packages(names, venv=None, upgrade=False, **kwargs):
"""Install a Python package using pip."""
cmd = "{} install {}{}".format(
get_pip_path(venv), " -U " if upgrade else "", " ".join(names))
cmd = "{} install{}{} {}".format(
get_pip_path(venv),
" -U " if upgrade else "",
" --pre" if kwargs.pop("beta", False) else "",
" ".join(names)
)
utils.exec_cmd(cmd, **kwargs)

View File

@@ -37,6 +37,17 @@ server {
try_files $uri $uri/ =404;
}
location ^~ /new-admin {
alias %{app_instance_path}/frontend/;
index index.html;
expires -1;
add_header Pragma "no-cache";
add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
try_files $uri $uri/ /index.html = 404;
}
location / {
include uwsgi_params;
uwsgi_param UWSGI_SCRIPT instance.wsgi:application;

View File

@@ -25,7 +25,7 @@ class Modoboa(base.Installer):
"deb": [
"build-essential", "python3-dev", "libxml2-dev", "libxslt-dev",
"libjpeg-dev", "librrd-dev", "rrdtool", "libffi-dev", "cron",
"libssl-dev", "redis-server", "supervisor"
"libssl-dev", "redis-server", "supervisor", "rustc"
],
"rpm": [
"gcc", "gcc-c++", "python3-devel", "libxml2-devel", "libxslt-devel",
@@ -75,11 +75,10 @@ class Modoboa(base.Installer):
packages = ["rrdtool"]
version = self.config.get("modoboa", "version")
if version == "latest":
modoboa_package = "modoboa"
packages += self.extensions
packages += ["modoboa"] + self.extensions
else:
matrix = compatibility_matrix.COMPATIBILITY_MATRIX[version]
modoboa_package = "modoboa=={}".format(version)
packages.append("modoboa=={}".format(version))
for extension in list(self.extensions):
if not self.is_extension_ok_for_version(extension, version):
self.extensions.remove(extension)
@@ -91,12 +90,13 @@ class Modoboa(base.Installer):
packages.append("{}{}".format(extension, req_version))
else:
packages.append(extension)
# Temp fix for https://github.com/modoboa/modoboa-installer/issues/197
# Temp fix for django-braces
python.install_package(
modoboa_package, self.venv_path,
upgrade=self.upgrade, binary=False, sudo_user=self.user)
"django-braces", self.venv_path, upgrade=self.upgrade,
sudo_user=self.user
)
if self.dbengine == "postgres":
packages.append("psycopg2-binary")
packages.append("psycopg2-binary\<2.9")
else:
packages.append("mysqlclient")
if sys.version_info.major == 2 and sys.version_info.micro < 9:
@@ -105,8 +105,10 @@ class Modoboa(base.Installer):
# Temp fix for https://github.com/modoboa/modoboa/issues/2247
packages.append("django-webpack-loader==0.7.0")
python.install_packages(
packages, self.venv_path, upgrade=self.upgrade,
sudo_user=self.user
packages, self.venv_path,
upgrade=self.upgrade,
sudo_user=self.user,
beta=self.config.getboolean("modoboa", "install_beta")
)
if self.devmode:
# FIXME: use dev-requirements instead

View File

@@ -75,14 +75,19 @@ def exec_cmd(cmd, sudo_user=None, pinput=None, login=True, **kwargs):
def dist_info():
"""Try to return information about the system we're running on."""
try:
# Python 3.8 and up way
import distro
return distro.linux_distribution()
except ImportError:
# Python 3.7 and down way
import platform
return platform.linux_distribution()
path = "/etc/os-release"
if os.path.exists(path):
info = {}
with open(path) as fp:
while True:
l = fp.readline()
if not l:
break
key, value = l.split("=")
value = value.rstrip('"\n')
value = value.strip('"')
info[key] = value
return info["NAME"], info["VERSION_ID"]
printcolor(
"Failed to retrieve information about your system, aborting.",
RED)
@@ -91,8 +96,7 @@ def dist_info():
def dist_name():
"""Try to guess the distribution name."""
name, version, _id = dist_info()
return name.lower()
return dist_info()[0].lower()
def mkdir(path, mode, uid, gid):