Fix OpenAL Soft building due to missing certs on a website

This commit is contained in:
Wojtek Figat
2025-10-16 10:39:36 +02:00
parent dab44f5ceb
commit c7437ed533
2 changed files with 27 additions and 16 deletions

View File

@@ -51,6 +51,7 @@ namespace Flax.Deps.Dependencies
var root = options.IntermediateFolder;
var version = "1.23.1";
var dstIncludePath = Path.Combine(options.ThirdPartyFolder, "OpenAL");
var noSSL = true; // OpenAL Soft website has broken certs
foreach (var platform in options.Platforms)
{
@@ -88,7 +89,7 @@ namespace Flax.Deps.Dependencies
// Get the binaries
var packagePath = Path.Combine(root, "package.zip");
if (!File.Exists(packagePath))
Downloader.DownloadFileFromUrlToPath("https://openal-soft.org/openal-binaries/openal-soft-" + version + "-bin.zip", packagePath);
Downloader.DownloadFileFromUrlToPath("https://openal-soft.org/openal-binaries/openal-soft-" + version + "-bin.zip", packagePath, noSSL);
using (ZipArchive archive = ZipFile.Open(packagePath, ZipArchiveMode.Read))
{
if (!Directory.Exists(root))
@@ -129,7 +130,7 @@ namespace Flax.Deps.Dependencies
// Get the source
var packagePath = Path.Combine(root, "package.zip");
File.Delete(packagePath);
Downloader.DownloadFileFromUrlToPath("https://openal-soft.org/openal-releases/openal-soft-" + version + ".tar.bz2", packagePath);
Downloader.DownloadFileFromUrlToPath("https://openal-soft.org/openal-releases/openal-soft-" + version + ".tar.bz2", packagePath, noSSL);
Utilities.Run("tar", "xjf " + packagePath.Replace('\\', '/'), null, root, Utilities.RunOptions.ConsoleLogOutput);
// Use separate build directory
@@ -156,7 +157,7 @@ namespace Flax.Deps.Dependencies
// Get the source
var packagePath = Path.Combine(root, "package.zip");
File.Delete(packagePath);
Downloader.DownloadFileFromUrlToPath("https://openal-soft.org/openal-releases/openal-soft-" + version + ".tar.bz2", packagePath);
Downloader.DownloadFileFromUrlToPath("https://openal-soft.org/openal-releases/openal-soft-" + version + ".tar.bz2", packagePath, noSSL);
if (Platform.BuildTargetPlatform == TargetPlatform.Windows)
{
var sevenZip = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "7-Zip", "7z.exe");
@@ -192,7 +193,7 @@ namespace Flax.Deps.Dependencies
// Get the source
var packagePath = Path.Combine(root, "package.zip");
File.Delete(packagePath);
Downloader.DownloadFileFromUrlToPath("https://openal-soft.org/openal-releases/openal-soft-" + version + ".tar.bz2", packagePath);
Downloader.DownloadFileFromUrlToPath("https://openal-soft.org/openal-releases/openal-soft-" + version + ".tar.bz2", packagePath, noSSL);
Utilities.Run("tar", "xjf " + packagePath.Replace('\\', '/'), null, root, Utilities.RunOptions.ConsoleLogOutput);
// Use separate build directory
@@ -223,7 +224,7 @@ namespace Flax.Deps.Dependencies
var packagePath = Path.Combine(root, "package.zip");
if (!File.Exists(packagePath))
{
Downloader.DownloadFileFromUrlToPath("https://openal-soft.org/openal-releases/openal-soft-" + version + ".tar.bz2", packagePath);
Downloader.DownloadFileFromUrlToPath("https://openal-soft.org/openal-releases/openal-soft-" + version + ".tar.bz2", packagePath, noSSL);
Utilities.Run("tar", "xjf " + packagePath.Replace('\\', '/'), null, root, Utilities.RunOptions.ConsoleLogOutput);
}

View File

@@ -19,14 +19,14 @@ namespace Flax.Deps
// Normal example: FileDownloader.DownloadFileFromURLToPath( "http://example.com/file/download/link", @"C:\file.txt" );
// Drive example: FileDownloader.DownloadFileFromURLToPath( "http://drive.google.com/file/d/FILEID/view?usp=sharing", @"C:\file.txt" );
public static FileInfo DownloadFileFromUrlToPath(string url, string path)
public static FileInfo DownloadFileFromUrlToPath(string url, string path, bool noSSL = false)
{
Log.Info(string.Format("Downloading {0} to {1}", url, path));
if (File.Exists(path))
File.Delete(path);
if (url.StartsWith(GoogleDriveDomain) || url.StartsWith(GoogleDriveDomain2))
return DownloadGoogleDriveFileFromUrlToPath(url, path);
return DownloadFileFromUrlToPath(url, path, null);
return DownloadGoogleDriveFileFromUrlToPath(url, path, noSSL);
return DownloadFileFromUrlToPath(url, path, null, noSSL);
}
private static FileInfo DownloadFileFromUrlToPathRaw(string url, string path, HttpClient httpClient)
@@ -48,16 +48,14 @@ namespace Flax.Deps
return new FileInfo(path);
}
private static FileInfo DownloadFileFromUrlToPath(string url, string path, HttpClient httpClient)
private static FileInfo DownloadFileFromUrlToPath(string url, string path, HttpClient httpClient, bool noSSL)
{
try
{
if (httpClient == null)
{
using (httpClient = new HttpClient())
{
using (httpClient = GetHttpClient(noSSL))
return DownloadFileFromUrlToPathRaw(url, path, httpClient);
}
}
return DownloadFileFromUrlToPathRaw(url, path, httpClient);
}
@@ -125,12 +123,12 @@ namespace Flax.Deps
// Downloading large files from Google Drive prompts a warning screen and
// requires manual confirmation. Consider that case and try to confirm the download automatically
// if warning prompt occurs
private static FileInfo DownloadGoogleDriveFileFromUrlToPath(string url, string path)
private static FileInfo DownloadGoogleDriveFileFromUrlToPath(string url, string path, bool noSSL)
{
// You can comment the statement below if the provided url is guaranteed to be in the following format:
// https://drive.google.com/uc?id=FILEID&export=download
url = GetGoogleDriveDownloadLinkFromUrl(url);
using (var httpClient = new HttpClient())
using (var httpClient = GetHttpClient(noSSL))
{
FileInfo downloadedFile;
@@ -138,7 +136,7 @@ namespace Flax.Deps
// but works in the second attempt
for (int i = 0; i < 2; i++)
{
downloadedFile = DownloadFileFromUrlToPath(url, path, httpClient);
downloadedFile = DownloadFileFromUrlToPath(url, path, httpClient, noSSL);
if (downloadedFile == null)
return null;
@@ -171,7 +169,7 @@ namespace Flax.Deps
url = "https://drive.google.com" + content.Substring(linkIndex, linkEnd - linkIndex).Replace("&amp;", "&");
}
downloadedFile = DownloadFileFromUrlToPath(url, path, httpClient);
downloadedFile = DownloadFileFromUrlToPath(url, path, httpClient, noSSL);
return downloadedFile;
}
}
@@ -209,5 +207,17 @@ namespace Flax.Deps
return string.Format("https://drive.google.com/uc?id={0}&export=download", url.Substring(index, closingIndex - index));
}
private static HttpClient GetHttpClient(bool noSSL)
{
if (noSSL)
{
var handler = new HttpClientHandler();
handler.ClientCertificateOptions = ClientCertificateOption.Manual;
handler.ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => true;
return new HttpClient(handler);
}
return new HttpClient();
}
}
}