From 12b33bcdbaae61a8baac78250008f82eca617322 Mon Sep 17 00:00:00 2001 From: psyGamer Date: Thu, 7 Nov 2024 16:56:39 +0100 Subject: [PATCH] fix: Studio auto-installation issues on macOS --- .github/workflows/Build.yml | 4 ++ .github/workflows/Release.yml | 4 ++ .../Source/EverestInterop/StudioHelper.cs | 54 ++++++++++++++++--- 3 files changed, 55 insertions(+), 7 deletions(-) diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index 7d29b182..eae4fa26 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -60,6 +60,10 @@ jobs: sed -i "s\\##URL_LINUX_x64##\\https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/CelesteStudio-linux-x64.zip\\" CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs sed -i "s\\##URL_MACOS_x64##\\https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/CelesteStudio-macos-x64.zip\\" CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs sed -i "s\\##URL_MACOS_ARM64##\\https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/CelesteStudio-macos-arm64.zip\\" CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs + sed -i "s\\##FILENAME_WINDOWS_x64##\\CelesteStudio-windows-x64.zip\\" CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs + sed -i "s\\##FILENAME_LINUX_x64##\\CelesteStudio-linux-x64.zip\\" CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs + sed -i "s\\##FILENAME_MACOS_x64##\\CelesteStudio-macos-x64.zip\\" CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs + sed -i "s\\##FILENAME_MACOS_ARM64##\\CelesteStudio-macos-arm64.zip\\" CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs sed -i "s\\##CHECKSUM_WINDOWS_x64##\\$(md5sum CelesteStudio-windows-x64.zip | head -c 32)\\" CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs sed -i "s\\##CHECKSUM_LINUX_x64##\\$(md5sum CelesteStudio-linux-x64.zip | head -c 32)\\" CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs sed -i "s\\##CHECKSUM_MACOS_x64##\\$(md5sum CelesteStudio-macos-x64.zip | head -c 32)\\" CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 382b807c..01ea7103 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -101,6 +101,10 @@ jobs: sed -i "s\\##URL_LINUX_x64##\\https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/CelesteStudio-linux-x64.zip\\" CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs sed -i "s\\##URL_MACOS_x64##\\https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/CelesteStudio-macos-x64.zip\\" CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs sed -i "s\\##URL_MACOS_ARM64##\\https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/CelesteStudio-macos-arm64.zip\\" CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs + sed -i "s\\##FILENAME_WINDOWS_x64##\\CelesteStudio-windows-x64.zip\\" CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs + sed -i "s\\##FILENAME_LINUX_x64##\\CelesteStudio-linux-x64.zip\\" CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs + sed -i "s\\##FILENAME_MACOS_x64##\\CelesteStudio-macos-x64.zip\\" CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs + sed -i "s\\##FILENAME_MACOS_ARM64##\\CelesteStudio-macos-arm64.zip\\" CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs sed -i "s\\##CHECKSUM_WINDOWS_x64##\\$(md5sum CelesteStudio-windows-x64.zip | head -c 32)\\" CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs sed -i "s\\##CHECKSUM_LINUX_x64##\\$(md5sum CelesteStudio-linux-x64.zip | head -c 32)\\" CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs sed -i "s\\##CHECKSUM_MACOS_x64##\\$(md5sum CelesteStudio-macos-x64.zip | head -c 32)\\" CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs diff --git a/CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs b/CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs index 90176326..9978bf05 100644 --- a/CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs +++ b/CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs @@ -32,6 +32,11 @@ public static class StudioHelper { private const string DownloadURL_MacOS_x64 = "##URL_MACOS_x64##"; private const string DownloadURL_MacOS_ARM64 = "##URL_MACOS_ARM64##"; + private const string FileName_Windows_x64 = "##FILENAME_WINDOWS_x64##"; + private const string FileName_Linux_x64 = "##FILENAME_LINUX_x64##"; + private const string FileName_MacOS_x64 = "##FILENAME_MACOS_x64##"; + private const string FileName_MacOS_ARM64 = "##FILENAME_MACOS_ARM64##"; + private const string Checksum_Windows_x64 = "##CHECKSUM_WINDOWS_x64##"; private const string Checksum_Linux_x64 = "##CHECKSUM_LINUX_x64##"; private const string Checksum_MacOS_x64 = "##CHECKSUM_MACOS_x64##"; @@ -44,7 +49,7 @@ public static class StudioHelper { private static string StudioDirectory => Path.Combine(Everest.PathGame, "CelesteStudio"); private static string TempStudioInstallDirectory => Path.Combine(StudioDirectory, ".temp_install"); private static string VersionFile => Path.Combine(StudioDirectory, ".version"); - private static string DownloadPath => Path.Combine(StudioDirectory, "CelesteStudio.zip"); + private static string DownloadPath => Path.Combine(StudioDirectory, FileName); private static string DownloadURL { get { @@ -64,6 +69,24 @@ private static string DownloadURL { throw new PlatformNotSupportedException($"Unsupported platform: {RuntimeInformation.OSDescription} with {RuntimeInformation.OSArchitecture}"); } } + private static string FileName { + get { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && RuntimeInformation.OSArchitecture == Architecture.X64) { + return FileName_Windows_x64; + } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && RuntimeInformation.OSArchitecture == Architecture.X64) { + return FileName_Linux_x64; + } + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && RuntimeInformation.OSArchitecture == Architecture.X64) { + return FileName_MacOS_x64; + } + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && RuntimeInformation.OSArchitecture == Architecture.Arm64) { + return FileName_MacOS_ARM64; + } + + throw new PlatformNotSupportedException($"Unsupported platform: {RuntimeInformation.OSDescription} with {RuntimeInformation.OSArchitecture}"); + } + } private static string Checksum { get { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && RuntimeInformation.OSArchitecture == Architecture.X64) { @@ -170,7 +193,7 @@ private static void Load() { string path = Path.GetTempFileName(); string text = """ - === Celeste Studio v3 - Migration notice === + === Celeste TAS Studio v3 - Migration notice === Celeste Studio was recently fully rewritten, bringing lots of new features and proper cross-platform compatibility for Windows, Linux and macOS. With this change, the executable also moved slightly from "/Celeste Studio.exe" to it's own directory under "/CelesteStudio/". @@ -211,6 +234,8 @@ private static async Task DownloadStudio() { string hash = BitConverter.ToString(await md5.ComputeHashAsync(fs)).Replace("-", ""); if (Checksum.Equals(hash, StringComparison.OrdinalIgnoreCase)) { skipDownload = true; + } else { + $"Checksum for {FileName} doesn't match. Expected {Checksum}, found {hash}".Log(LogLevel.Verbose); } } @@ -233,6 +258,8 @@ private static async Task DownloadStudio() { string hash = BitConverter.ToString(await md5.ComputeHashAsync(fs)).Replace("-", ""); if (Checksum.Equals(hash, StringComparison.OrdinalIgnoreCase)) { skipDownload = true; + } else { + $"Checksum for inner archive of {FileName} doesn't match. Expected {Checksum}, found {hash}".Log(LogLevel.Verbose); } } } @@ -341,15 +368,27 @@ private static async Task DownloadStudio() { File.Delete(file); } + foreach (string file in Directory.GetDirectories(StudioDirectory)) { + if (file == DownloadPath || file == TempStudioInstallDirectory) { + continue; + } + + File.Delete(file); + } // Setup new install foreach (string file in Directory.GetFiles(TempStudioInstallDirectory)) { File.Move(file, Path.Combine(StudioDirectory, Path.GetFileName(file))); } + foreach (string file in Directory.GetDirectories(TempStudioInstallDirectory)) { + Directory.Move(file, Path.Combine(StudioDirectory, Path.GetFileName(file))); + } Directory.Delete(TempStudioInstallDirectory, recursive: true); StudioUpdateBanner.CurrentState = StudioUpdateBanner.State.Success; StudioUpdateBanner.FadeoutTimer = 5.0f; + + "Successfully installed Studio".Log(); } private static async Task ExecuteCommand(string[] parameters, string errorMessage) { @@ -445,18 +484,19 @@ private static void ReportError(string error, string? additionalInfo = null) { string path = Path.Combine(StudioDirectory, "error_report.txt"); string text = $""" - === Celeste Studio v{CurrentStudioVersion} - Installation failed === + === Celeste TAS Studio v{CurrentStudioVersion} - Installation failed === {DateTime.Now.ToString(CultureInfo.InvariantCulture)} - The following error occured while trying to install Celeste Studio: + NOTE: If you're using CelesteTAS just for the in-game utilities and not for actual TASing with Celeste Studio, you can ignore this error. + + The following error occured while trying to install Celeste TAS Studio: {error} This may be caused by a bad internet connection. You can manually download Celeste Studio by following these steps: 1. Close Celeste 2. Manually download this file: {DownloadURL} - 3. Rename it to be called "CelesteStudio.zip" (ensure you have file extensions enabled!) - 4. Place it under "/CelesteStudio/CelesteStudio.zip" (create the "CelesteStudio" directory if it doesn't already exist. The "" directory is the same as where "Celeste.exe" / "Celeste.dll" is located) - 5. Re-open Celeste + 3. Place it under "/CelesteStudio/{FileName}" (create the "CelesteStudio" directory if it doesn't already exist. The "" directory is the same as where "Celeste.exe" / "Celeste.dll" is located) + 4. Re-open Celeste If the error persists, please report this issue. And send this ENTIRE file along with it. (This file is located under "{path}")