Skip to content

Commit

Permalink
fix: Studio auto-installation issues on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
psyGamer committed Nov 7, 2024
1 parent 1abc9c1 commit 12b33bc
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
54 changes: 47 additions & 7 deletions CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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##";
Expand All @@ -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 {
Expand All @@ -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) {
Expand Down Expand Up @@ -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-install>/Celeste Studio.exe" to it's own directory under "<celeste-install>/CelesteStudio/".
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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);
}
}
}
Expand Down Expand Up @@ -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<bool> ExecuteCommand(string[] parameters, string errorMessage) {
Expand Down Expand Up @@ -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 "<celeste-install>/CelesteStudio/CelesteStudio.zip" (create the "CelesteStudio" directory if it doesn't already exist. The "<celeste-install>" directory is the same as where "Celeste.exe" / "Celeste.dll" is located)
5. Re-open Celeste
3. Place it under "<celeste-install>/CelesteStudio/{FileName}" (create the "CelesteStudio" directory if it doesn't already exist. The "<celeste-install>" 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}")
Expand Down

0 comments on commit 12b33bc

Please sign in to comment.