Skip to content

Commit 4d4095c

Browse files
authored
Enhance MariaDB version fallback logic (#9545)
Updated fallback mechanism for MariaDB version retrieval to use mariadb_repo_setup script when the mirror is unreachable.
1 parent 40ccccb commit 4d4095c

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

misc/tools.func

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2940,9 +2940,16 @@ setup_mariadb() {
29402940
# Resolve "latest" to actual version
29412941
if [[ "$MARIADB_VERSION" == "latest" ]]; then
29422942
if ! curl -fsI --max-time 10 http://mirror.mariadb.org/repo/ >/dev/null 2>&1; then
2943-
msg_warn "MariaDB mirror not reachable - trying cached package list fallback"
2944-
# Fallback: try to use a known stable version
2945-
MARIADB_VERSION="12.0"
2943+
msg_warn "MariaDB mirror not reachable - trying mariadb_repo_setup fallback"
2944+
# Try using official mariadb_repo_setup script as fallback
2945+
if curl -fsSL --max-time 15 https://r.mariadb.com/downloads/mariadb_repo_setup 2>/dev/null | bash -s -- --skip-verify >/dev/null 2>&1; then
2946+
msg_ok "MariaDB repository configured via mariadb_repo_setup"
2947+
# Extract version from configured repo
2948+
MARIADB_VERSION=$(grep -oP 'repo/\K[0-9]+\.[0-9]+\.[0-9]+' /etc/apt/sources.list.d/mariadb.list 2>/dev/null | head -n1 || echo "12.2")
2949+
else
2950+
msg_warn "mariadb_repo_setup failed - using hardcoded fallback version"
2951+
MARIADB_VERSION="12.2"
2952+
fi
29462953
else
29472954
MARIADB_VERSION=$(curl -fsSL --max-time 15 http://mirror.mariadb.org/repo/ 2>/dev/null |
29482955
grep -Eo '[0-9]+\.[0-9]+\.[0-9]+/' |
@@ -2952,8 +2959,14 @@ setup_mariadb() {
29522959
head -n1 || echo "")
29532960

29542961
if [[ -z "$MARIADB_VERSION" ]]; then
2955-
msg_warn "Could not parse latest GA MariaDB version from mirror - using fallback"
2956-
MARIADB_VERSION="12.0"
2962+
msg_warn "Could not parse latest GA MariaDB version from mirror - trying mariadb_repo_setup"
2963+
if curl -fsSL --max-time 15 https://r.mariadb.com/downloads/mariadb_repo_setup 2>/dev/null | bash -s -- --skip-verify >/dev/null 2>&1; then
2964+
msg_ok "MariaDB repository configured via mariadb_repo_setup"
2965+
MARIADB_VERSION=$(grep -oP 'repo/\K[0-9]+\.[0-9]+\.[0-9]+' /etc/apt/sources.list.d/mariadb.list 2>/dev/null | head -n1 || echo "12.2")
2966+
else
2967+
msg_warn "mariadb_repo_setup failed - using hardcoded fallback version"
2968+
MARIADB_VERSION="12.2"
2969+
fi
29572970
fi
29582971
fi
29592972
fi

0 commit comments

Comments
 (0)