Fix compat removal, shell metachars in call(), upgrade AlmaLinux 9 MariaDB

- install_utils.call: use shell=True for commands with ||, 2>, |, etc.
  Avoids 'No matching repo to modify: 2>/dev/null, true, ||' when
  dnf config-manager '... 2>/dev/null || true' is run via shlex.split.

- Add explicit 'rpm -e --nodeps MariaDB-server-compat-12.1.2-1.el9.noarch'
  before dnf remove in main(), installMySQL, fix_almalinux9_comprehensive.

- upgrade fix_almalinux9_mariadb: add compat removal before MariaDB install;
  use MariaDB 10.11 repo instead of 12.1 to avoid compat conflicts.
This commit is contained in:
master3395
2026-01-27 00:23:56 +01:00
parent de21c03fc7
commit da4c1d9601
3 changed files with 23 additions and 3 deletions

View File

@@ -353,7 +353,7 @@ class preFlightsChecks:
# These packages from MariaDB 12.1 can conflict with MariaDB 10.11
self.stdOut("Removing conflicting MariaDB compat packages...", 1)
try:
# Remove MariaDB-server-compat packages that conflict with MariaDB 10.11
subprocess.run("rpm -e --nodeps MariaDB-server-compat-12.1.2-1.el9.noarch 2>/dev/null; true", shell=True, timeout=30)
subprocess.run("dnf remove -y 'MariaDB-server-compat*' 2>/dev/null || true", shell=True, timeout=60)
r = subprocess.run("rpm -qa 2>/dev/null | grep -i MariaDB-server-compat", shell=True, capture_output=True, text=True, timeout=30)
for line in (r.stdout or "").strip().splitlines():
@@ -1815,6 +1815,7 @@ module cyberpanel_ols {
# These packages from MariaDB 12.1 can conflict with MariaDB 10.11
self.stdOut("Removing conflicting MariaDB compat packages...", 1)
try:
subprocess.run("rpm -e --nodeps MariaDB-server-compat-12.1.2-1.el9.noarch 2>/dev/null; true", shell=True, timeout=30)
subprocess.run("dnf remove -y 'MariaDB-server-compat*' 2>/dev/null || true", shell=True, timeout=60)
r = subprocess.run("rpm -qa 2>/dev/null | grep -i MariaDB-server-compat", shell=True, capture_output=True, text=True, timeout=30)
for line in (r.stdout or "").strip().splitlines():
@@ -6441,6 +6442,7 @@ def main():
# This package conflicts with MariaDB 10.11 and must be removed early
preFlightsChecks.stdOut("Removing conflicting MariaDB-server-compat packages...", 1)
try:
subprocess.run("rpm -e --nodeps MariaDB-server-compat-12.1.2-1.el9.noarch 2>/dev/null; true", shell=True, timeout=30)
subprocess.run("dnf remove -y 'MariaDB-server-compat*' 2>/dev/null || true", shell=True, timeout=60)
r = subprocess.run("rpm -qa 2>/dev/null | grep -i MariaDB-server-compat", shell=True, capture_output=True, text=True, timeout=30)
for line in (r.stdout or "").strip().splitlines():

View File

@@ -556,6 +556,11 @@ def call(command, distro, bracket, message, log=0, do_exit=0, code=os.EX_OK, she
os._exit(code)
return False
# CRITICAL: Use shell=True for commands with shell metacharacters
# Avoids "No matching repo to modify: 2>/dev/null, true, ||" when shlex.split splits them
if not shell and any(x in command for x in (' || ', ' 2>/dev', ' 2>', ' | ', '; true', '|| true')):
shell = True
# CRITICAL: For mysql/mariadb commands, always use shell=True and full binary path
# This fixes "No such file or directory: 'mysql'" when run via shlex.split
if not shell and ('mysql' in command or 'mariadb' in command):

View File

@@ -4299,6 +4299,19 @@ echo $oConfig->Save() ? 'Done' : 'Error';
Upgrade.stdOut("Applying AlmaLinux 9 MariaDB fixes...", 1)
try:
# CRITICAL: Remove MariaDB-server-compat* before any MariaDB install (conflicts with 10.11)
Upgrade.stdOut("Removing conflicting MariaDB-server-compat packages...", 1)
try:
subprocess.run("rpm -e --nodeps MariaDB-server-compat-12.1.2-1.el9.noarch 2>/dev/null; true", shell=True, timeout=30)
subprocess.run("dnf remove -y 'MariaDB-server-compat*' 2>/dev/null || true", shell=True, timeout=60)
r = subprocess.run("rpm -qa 2>/dev/null | grep -i MariaDB-server-compat", shell=True, capture_output=True, text=True, timeout=30)
for line in (r.stdout or "").strip().splitlines():
pkg = (line.strip().split() or [""])[0]
if pkg and "MariaDB-server-compat" in pkg:
subprocess.run(["rpm", "-e", "--nodeps", pkg], timeout=30)
except Exception as e:
Upgrade.stdOut("Warning: compat cleanup: " + str(e), 0)
# Disable problematic MariaDB MaxScale repository
Upgrade.stdOut("Disabling problematic MariaDB MaxScale repository...", 1)
command = "dnf config-manager --disable mariadb-maxscale 2>/dev/null || true"
@@ -4320,9 +4333,9 @@ echo $oConfig->Save() ? 'Done' : 'Error';
command = "dnf clean all"
subprocess.run(command, shell=True, capture_output=True)
# Install MariaDB from official repository
# Install MariaDB 10.11 from official repository (avoid 12.1 compat conflicts)
Upgrade.stdOut("Setting up official MariaDB repository...", 1)
command = "curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash -s -- --mariadb-server-version='12.1'"
command = "curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash -s -- --mariadb-server-version='10.11'"
result = subprocess.run(command, shell=True, capture_output=True, text=True)
if result.returncode != 0:
Upgrade.stdOut(f"Warning: MariaDB repo setup failed: {result.stderr}", 0)