Switch MySQL extension to use (latest) MariaDB connector (fixes 2526) (#2548)

* Switch MySQL extension to use (latest) MariaDB connector (fixes 2526)

* Fix release
This commit is contained in:
Nicholas Hastings
2026-08-15 17:11:04 +00:00
committed by GitHub
parent 261dd2c126
commit e4e49e0623
8 changed files with 175 additions and 127 deletions
+68 -8
View File
@@ -6,7 +6,7 @@
#>
[CmdletBinding()]
param(
param(
[string[]]$SDKs = @(
'csgo',
'hl2dm',
@@ -29,9 +29,63 @@ param(
'eye',
'contagion',
'doi',
'pvkii'
)
)
'pvkii'
),
[switch]$NoMariaDB
)
$MARIADB_CONNECTOR_C_VERSION = if ($env:MARIADB_CONNECTOR_C_VERSION) { $env:MARIADB_CONNECTOR_C_VERSION } else { '3.4.9' }
$MARIADB_CONNECTOR_C_RELEASE = if ($env:MARIADB_CONNECTOR_C_RELEASE) { $env:MARIADB_CONNECTOR_C_RELEASE } else { '3.4.9-sm.5' }
$MARIADB_CONNECTOR_C_REPOSITORY = 'alliedmodders/mariadb-connector-c'
Function Get-MariaDBConnectorC
{
param(
[Parameter(Mandatory=$true)][string]$Architecture
)
$folder = "mariadb-connector-c-$MARIADB_CONNECTOR_C_VERSION-$Architecture"
if (Test-Path $folder -PathType Container)
{
return
}
$releaseUrl = "https://github.com/$MARIADB_CONNECTOR_C_REPOSITORY/releases/download/v$MARIADB_CONNECTOR_C_RELEASE"
$archiveName = "mariadb-connector-c-$MARIADB_CONNECTOR_C_VERSION-windows-$Architecture.zip"
$checksumPath = Join-Path (Resolve-Path '.') 'SHA256SUMS'
$archivePath = Join-Path (Resolve-Path '.') $archiveName
Invoke-WebRequest -Uri "$releaseUrl/SHA256SUMS" -OutFile $checksumPath
Invoke-WebRequest -Uri "$releaseUrl/$archiveName" -OutFile $archivePath
$expected = Get-Content -LiteralPath $checksumPath |
ForEach-Object {
$fields = $_ -split '\s+'
if ($fields.Length -ge 2 -and $fields[-1].TrimStart('*') -eq $archiveName)
{
$fields[0]
}
} |
Select-Object -First 1
if (-not $expected)
{
throw "No SHA256 checksum was published for $archiveName."
}
$actual = (Get-FileHash -Algorithm SHA256 -LiteralPath $archivePath).Hash
if ($actual -ne $expected)
{
throw "SHA256 verification failed for $archiveName."
}
Expand-Archive -LiteralPath $archivePath -DestinationPath .
if (-not (Test-Path $folder -PathType Container))
{
throw "MariaDB Connector/C archive did not contain $folder."
}
Remove-Item -LiteralPath $archivePath, $checksumPath
}
Function Get-Repository
{
@@ -69,13 +123,19 @@ Function Get-Repository
}
}
if (-not (Test-Path "sourcemod" -PathType Container))
if (-not (Test-Path "sourcemod" -PathType Container))
{
Write-Error "Could not find a SourceMod repository; make sure you aren't running this script inside it."
Exit 1
}
Get-Repository -Name "mmsource-1.12" -Branch "1.12-dev" -Repo "https://github.com/alliedmodders/metamod-source.git"
}
if (-not $NoMariaDB)
{
Get-MariaDBConnectorC -Architecture 'x86'
Get-MariaDBConnectorC -Architecture 'x86_64'
}
Get-Repository -Name "mmsource-1.12" -Branch "1.12-dev" -Repo "https://github.com/alliedmodders/metamod-source.git"
if (-not (Test-Path "hl2sdk-proxy-repo" -PathType Container))
{
+60 -68
View File
@@ -3,22 +3,21 @@
trap "exit" INT
download_mysql=1
download_mysql_debug=1
download_mariadb=1
mariadb_version=${MARIADB_CONNECTOR_C_VERSION:-3.4.9}
mariadb_release=${MARIADB_CONNECTOR_C_RELEASE:-3.4.9-sm.5}
mariadb_repo=alliedmodders/mariadb-connector-c
# List of HL2SDK branch names to download.
# ./checkout-deps.sh -s tf2,css
# Disable downloading of mysql libraries.
# Disable downloading of MariaDB Connector/C libraries.
# ./checkout-deps.sh -m
# Disable downloading of mysql debug libraries on Windows.
# ./checkout-deps.sh -d
while getopts ":s:m" opt; do
case $opt in
s) IFS=', ' read -r -a sdks <<< "$OPTARG"
;;
m) download_mysql=0
;;
d) download_mysql_debug=0
m) download_mariadb=0
;;
\?) echo "Invalid option -$OPTARG" >&2
;;
@@ -46,73 +45,66 @@ if [ ! -d "sourcemod" ]; then
fi
fi
getmysql ()
download_file ()
{
if [ ! -d $mysqlfolder ]; then
if [ `command -v wget` ]; then
wget -q $mysqlurl -O $mysqlfolder.$archive_ext
elif [ `command -v curl` ]; then
curl -sS -o $mysqlfolder.$archive_ext $mysqlurl
else
echo "Failed to locate wget or curl. Install one of these programs to download MySQL."
exit 1
fi
$decomp $mysqlfolder.$archive_ext
mv $mysqlver $mysqlfolder
rm $mysqlfolder.$archive_ext
if command -v wget >/dev/null; then
wget -q "$1" -O "$2"
elif command -v curl >/dev/null; then
curl -fsSL "$1" -o "$2"
else
echo "Failed to locate wget or curl. Install one of these programs to download MariaDB Connector/C."
exit 1
fi
}
# 32-bit MySQL
mysqlfolder=mysql-5.7
verify_checksum ()
{
local archive=$1
local sums=$2
local entry
entry=$(grep -E "[[:space:]][*]?$archive$" "$sums")
if [ -z "$entry" ]; then
echo "No checksum found for $archive"
exit 1
fi
if command -v sha256sum >/dev/null; then
printf '%s\n' "$entry" | sha256sum -c -
else
printf '%s\n' "$entry" | shasum -a 256 -c -
fi
}
getmariadb ()
{
local arch=$1
local platform=$2
local folder="mariadb-connector-c-$mariadb_version-$arch"
local archive="mariadb-connector-c-$mariadb_version-$platform-$arch.$archive_ext"
local release_url="https://github.com/$mariadb_repo/releases/download/v$mariadb_release"
local sums=SHA256SUMS
if [ ! -d "$folder" ]; then
download_file "$release_url/$sums" "$sums"
download_file "$release_url/$archive" "$archive"
verify_checksum "$archive" "$sums"
$decomp "$archive"
if [ ! -d "$folder" ]; then
echo "MariaDB Connector/C archive did not contain $folder"
exit 1
fi
rm "$archive" "$sums"
fi
}
if [ $download_mariadb -eq 1 ]; then
mariadb_platform=linux
if [ $ismac -eq 1 ]; then
mysqlfolder=mysql-5.5
mysqlver=mysql-5.5.28-osx10.5-x86
mysqlurl=https://cdn.mysql.com/archives/mysql-5.5/$mysqlver.$archive_ext
mariadb_platform=macos
elif [ $iswin -eq 1 ]; then
mysqlver=mysql-5.7.44-win32
mysqlurl=https://cdn.mysql.com/archives/mysql-5.7/$mysqlver.$archive_ext
# The folder in the zip archive does not contain the substring "-noinstall", so strip it
mysqlver=${mysqlver/-noinstall}
else
mysqlver=mysql-5.7.44-linux-glibc2.12-i686
mysqlurl=https://cdn.mysql.com/archives/mysql-5.7/$mysqlver.$archive_ext
mariadb_platform=windows
fi
if [ $download_mysql -eq 1 ]; then
getmysql
fi
# 64-bit MySQL
mysqlfolder=mysql-5.7-x86_64
if [ $ismac -eq 1 ]; then
mysqlfolder=mysql-5.5-x86_64
mysqlver=mysql-5.5.28-osx10.5-x86_64
mysqlurl=https://cdn.mysql.com/archives/mysql-5.5/$mysqlver.$archive_ext
elif [ $iswin -eq 1 ]; then
mysqlver=mysql-5.7.44-winx64
mysqlurl=https://cdn.mysql.com/archives/mysql-5.7/$mysqlver.$archive_ext
else
mysqlver=mysql-5.7.44-linux-glibc2.12-x86_64
mysqlurl=https://cdn.mysql.com/archives/mysql-5.7/$mysqlver.$archive_ext
fi
if [ $download_mysql -eq 1 ]; then
getmysql
fi
if [ $iswin -eq 1 ] && [ $download_mysql_debug -eq 1 ]; then
mysqlfolder=mysql-5.7-debug
mysqlver=mysql-5.7.44-win32
mysqlurl=https://cdn.mysql.com/archives/mysql-5.7/$mysqlver-debug-test.$archive_ext
getmysql
cp -r $mysqlfolder/lib/* mysql-5.7/lib
rm -rf $mysqlfolder
mysqlfolder=mysql-5.7-debug-x86_64
mysqlver=mysql-5.7.44-winx64
mysqlurl=https://cdn.mysql.com/archives/mysql-5.7/$mysqlver-debug-test.$archive_ext
getmysql
cp -r $mysqlfolder/lib/* mysql-5.7-x86_64/lib
rm -rf $mysqlfolder
getmariadb x86 "$mariadb_platform"
getmariadb x86_64 "$mariadb_platform"
fi
checkout ()