From c130e283f389d2218a2ee00a275d66ebfb57632b Mon Sep 17 00:00:00 2001 From: Johnny Shaw Date: Fri, 9 May 2025 00:52:14 -0500 Subject: [PATCH] consolidate build products --- SystemInformer/include/appsup.h | 1 + SystemInformer/include/phapp.h | 2 +- SystemInformer/main.c | 4 +- tools/CustomBuildTool/Build.cs | 225 ++++++++----------------------- tools/CustomBuildTool/Program.cs | 35 +++-- tools/CustomBuildTool/Utils.cs | 13 +- tools/CustomSetupTool/util.c | 4 + tools/CustomSetupTool/version.rc | 12 +- 8 files changed, 87 insertions(+), 209 deletions(-) diff --git a/SystemInformer/include/appsup.h b/SystemInformer/include/appsup.h index c09e21781..6468b8844 100644 --- a/SystemInformer/include/appsup.h +++ b/SystemInformer/include/appsup.h @@ -266,6 +266,7 @@ typedef enum _PH_RELEASE_CHANNEL PhPreviewChannel = 1, // unused, reserved PhCanaryChannel = 2, PhDeveloperChannel = 3, + PhInvalidChannel = ULONG_MAX, } PH_RELEASE_CHANNEL, *PPH_RELEASE_CHANNEL; PHAPPAPI diff --git a/SystemInformer/include/phapp.h b/SystemInformer/include/phapp.h index 173210906..71616af36 100644 --- a/SystemInformer/include/phapp.h +++ b/SystemInformer/include/phapp.h @@ -75,7 +75,7 @@ typedef struct _PH_STARTUP_PARAMETERS PPH_LIST PluginParameters; PPH_STRING SelectTab; PPH_STRING SysInfo; - ULONG UpdateChannel; + PH_RELEASE_CHANNEL UpdateChannel; } PH_STARTUP_PARAMETERS, *PPH_STARTUP_PARAMETERS; extern BOOLEAN PhPluginsEnabled; diff --git a/SystemInformer/main.c b/SystemInformer/main.c index d2125c010..727bda690 100644 --- a/SystemInformer/main.c +++ b/SystemInformer/main.c @@ -89,7 +89,7 @@ BOOLEAN PhInitializeTimerPolicy( BOOLEAN PhPluginsEnabled = FALSE; BOOLEAN PhPortableEnabled = FALSE; PPH_STRING PhSettingsFileName = NULL; -PH_STARTUP_PARAMETERS PhStartupParameters = { 0 }; +PH_STARTUP_PARAMETERS PhStartupParameters = { .UpdateChannel = PhInvalidChannel }; PH_PROVIDER_THREAD PhPrimaryProviderThread; PH_PROVIDER_THREAD PhSecondaryProviderThread; @@ -1202,7 +1202,7 @@ VOID PhpInitializeSettings( PhSetIntegerSetting(L"SampleCount", sampleCount); } - if (PhStartupParameters.UpdateChannel) + if (PhStartupParameters.UpdateChannel != PhInvalidChannel) { PhSetIntegerSetting(L"ReleaseChannel", PhStartupParameters.UpdateChannel); } diff --git a/tools/CustomBuildTool/Build.cs b/tools/CustomBuildTool/Build.cs index 0d80f940d..57edfc9fc 100644 --- a/tools/CustomBuildTool/Build.cs +++ b/tools/CustomBuildTool/Build.cs @@ -199,7 +199,7 @@ namespace CustomBuildTool public static string BuildVersionBuild { - get + get { // Extract the last two digits of the year. For example, if the year is 2023, (Year % 100) will result in 23. var first = (TimeStart.Year % 100).ToString(); @@ -689,87 +689,25 @@ namespace CustomBuildTool return true; } - public static void CreateSettingsFile(string Channel, string Path) - { - StringBuilder stringBuilder = new StringBuilder(0x100); - - stringBuilder.AppendLine(""); - - if (string.Equals(Channel, "release", StringComparison.OrdinalIgnoreCase)) - { - stringBuilder.AppendLine("0"); // PhReleaseChannel - } - else if (string.Equals(Channel, "preview", StringComparison.OrdinalIgnoreCase)) - { - stringBuilder.AppendLine("1"); // PhPreviewChannel - } - else if (string.Equals(Channel, "canary", StringComparison.OrdinalIgnoreCase)) - { - stringBuilder.AppendLine("2"); // PhCanaryChannel - } - else if (string.Equals(Channel, "developer", StringComparison.OrdinalIgnoreCase)) - { - stringBuilder.AppendLine("3"); // PhDeveloperChannel - } - else - { - throw new Exception($"Invalid channel: {Channel}"); - } - - stringBuilder.AppendLine(""); - - if (Directory.Exists(Path)) - { - Win32.CreateEmptyFile($"{Path}\\SystemInformer.exe.settings.xml"); - Utils.WriteAllText($"{Path}\\SystemInformer.exe.settings.xml", stringBuilder.ToString()); - } - } - - public static bool BuildBinZip(string Channel) + public static bool BuildBinZip() { Program.PrintColorMessage(BuildTimeSpan(), ConsoleColor.DarkGray, false); - Program.PrintColorMessage($"Building build-{Channel}-bin.zip... ", ConsoleColor.Cyan, false); - - try - { - CreateSettingsFile(Channel, "bin\\Release32"); - CreateSettingsFile(Channel, "bin\\Release64"); - CreateSettingsFile(Channel, "bin\\ReleaseARM64"); - } - catch (Exception ex) - { - Program.PrintColorMessage($"[WARN] {ex}", ConsoleColor.Yellow); - return false; - } - - //try - //{ - // if (Directory.Exists("bin\\Release32")) - // Win32.CreateEmptyFile("bin\\Release32\\usernotesdb.xml"); - // if (Directory.Exists("bin\\Release64")) - // Win32.CreateEmptyFile("bin\\Release64\\usernotesdb.xml"); - // if (Directory.Exists("bin\\ReleaseARM64")) - // Win32.CreateEmptyFile("bin\\ReleaseARM64\\usernotesdb.xml"); - //} - //catch (Exception ex) - //{ - // Program.PrintColorMessage($"[WARN] {ex}", ConsoleColor.Yellow); - //} + Program.PrintColorMessage($"Building build-bin.zip... ", ConsoleColor.Cyan, false); try { Utils.CreateOutputDirectory(); Win32.DeleteFile( - $"{BuildOutputFolder}\\systeminformer-build-{Channel}-bin.zip" + $"{BuildOutputFolder}\\systeminformer-build-bin.zip" ); Zip.CreateCompressedFolder( "bin", - $"{BuildOutputFolder}\\systeminformer-build-{Channel}-bin.zip" + $"{BuildOutputFolder}\\systeminformer-build-bin.zip" ); - Program.PrintColorMessage(Win32.GetFileSize($"{BuildOutputFolder}\\systeminformer-build-{Channel}-bin.zip").ToPrettySize(), ConsoleColor.Green); + Program.PrintColorMessage(Win32.GetFileSize($"{BuildOutputFolder}\\systeminformer-build-bin.zip").ToPrettySize(), ConsoleColor.Green); } catch (Exception ex) { @@ -979,58 +917,45 @@ namespace CustomBuildTool private struct BuildDeployInfo { - public string BinFilename; - public string BinHash; - public string BinSig; - public ulong BinFileLength; - - public string SetupFilename; - public string SetupHash; - public string SetupSig; - public ulong SetupFileLength; + public string Filename; + public string Hash; + public string Sig; + public ulong FileLength; } private static bool GetBuildDeployInfo(string Channel, out BuildDeployInfo Info) { - Info = new BuildDeployInfo - { - BinFilename = $"{BuildOutputFolder}\\systeminformer-build-{Channel}-bin.zip", - SetupFilename = $"{BuildOutputFolder}\\systeminformer-build-{Channel}-setup.exe" - }; + string channelKey; + Info = new BuildDeployInfo(); - if (!Verify.CreateSigString(Channel, Info.BinFilename, out Info.BinSig)) + if (string.IsNullOrEmpty(Channel)) { - Program.PrintColorMessage("failed to create bin signature string", ConsoleColor.Red); + // N.B. HACK we only produce a "release" (default setting) build for the binary (portable). + // Sign it using the "release" key. (jxy-s) + channelKey = "release"; + Info.Filename = $"{BuildOutputFolder}\\systeminformer-build-bin.zip"; + } + else + { + channelKey = Channel; + Info.Filename = $"{BuildOutputFolder}\\systeminformer-build-{Channel}-setup.exe"; + } + + if (!Verify.CreateSigString(channelKey, Info.Filename, out Info.Sig)) + { + Program.PrintColorMessage("failed to create signature string", ConsoleColor.Red); return false; } - if (!Verify.CreateSigString(Channel, Info.SetupFilename, out Info.SetupSig)) + if (File.Exists(Info.Filename)) { - Program.PrintColorMessage("failed to create setup signature string", ConsoleColor.Red); - return false; + Info.FileLength = Win32.GetFileSize(Info.Filename); + Info.Hash = Verify.HashFile(Info.Filename); } - if (File.Exists(Info.BinFilename)) + if (string.IsNullOrWhiteSpace(Info.Hash)) { - Info.BinFileLength = Win32.GetFileSize(Info.BinFilename); - Info.BinHash = Verify.HashFile(Info.BinFilename); - } - - if (File.Exists(Info.SetupFilename)) - { - Info.SetupFileLength = Win32.GetFileSize(Info.SetupFilename); - Info.SetupHash = Verify.HashFile(Info.SetupFilename); - } - - if (string.IsNullOrWhiteSpace(Info.BinHash)) - { - Program.PrintColorMessage("build-bin hash not found.", ConsoleColor.Red); - return false; - } - - if (string.IsNullOrWhiteSpace(Info.SetupHash)) - { - Program.PrintColorMessage("build-setup hash not found.", ConsoleColor.Red); + Program.PrintColorMessage("hash not found", ConsoleColor.Red); return false; } @@ -1049,16 +974,6 @@ namespace CustomBuildTool Program.PrintColorMessage("BUILD_BUILDID not found.", ConsoleColor.Red); return false; } - if (!Win32.GetEnvironmentVariable("BUILD_SF_API", out string buildPostSfUrl)) - { - Program.PrintColorMessage("BUILD_SF_API not found.", ConsoleColor.Red); - return false; - } - if (!Win32.GetEnvironmentVariable("BUILD_SF_KEY", out string buildPostSfApiKey)) - { - Program.PrintColorMessage("BUILD_SF_KEY not found.", ConsoleColor.Red); - return false; - } if (!Win32.GetEnvironmentVariable("BUILD_CF_API", out string buildPostCfUrl)) { Program.PrintColorMessage("BUILD_CF_API not found.", ConsoleColor.Red); @@ -1070,6 +985,8 @@ namespace CustomBuildTool return false; } + if (!GetBuildDeployInfo(null, out BuildDeployInfo bin)) + return false; if (!GetBuildDeployInfo("release", out BuildDeployInfo release)) return false; //if (!GetBuildDeployInfo("preview", out BuildDeployInfo preview)) @@ -1085,42 +1002,26 @@ namespace CustomBuildTool return false; } - if (!BuildUploadServerConfig( - buildBuildId, - buildPostSfUrl, - buildPostSfApiKey, - BuildUploadInfo.Item1, - BuildUploadInfo.Item2, - BuildUploadInfo.Item3, - BuildUploadInfo.Item4, - release, - canary - )) - { - Program.PrintColorMessage("BuildUploadServerConfig-SF failed.", ConsoleColor.Red); - return false; - } - if (!BuildUploadServerConfig( buildBuildId, buildPostCfUrl, buildPostCfApiKey, - BuildUploadInfo.Item1, - BuildUploadInfo.Item2, - BuildUploadInfo.Item3, - BuildUploadInfo.Item4, + BuildUploadInfo.Item1, // bin link + bin, + BuildUploadInfo.Item2, // canary setup link release, + BuildUploadInfo.Item3, // release setup link canary )) { - Program.PrintColorMessage("BuildUploadServerConfig-CF failed.", ConsoleColor.Red); + Program.PrintColorMessage("BuildUploadServerConfig failed.", ConsoleColor.Red); return false; } return true; } - private static bool BuildUpdateGithubServer(out Tuple BuildUploadInfo) + private static bool BuildUpdateGithubServer(out Tuple BuildUploadInfo) { BuildUploadInfo = null; @@ -1137,24 +1038,21 @@ namespace CustomBuildTool return false; } - string canaryBinlink = githubMirrorUpload.GetFileUrl($"systeminformer-{Build.BuildLongVersion}-canary-bin.zip"); + string binLink = githubMirrorUpload.GetFileUrl($"systeminformer-{Build.BuildLongVersion}-bin.zip"); string canarySetuplink = githubMirrorUpload.GetFileUrl($"systeminformer-{Build.BuildLongVersion}-canary-setup.exe"); - string releaseBinlink = githubMirrorUpload.GetFileUrl($"systeminformer-{Build.BuildLongVersion}-release-bin.zip"); string releaseSetuplink = githubMirrorUpload.GetFileUrl($"systeminformer-{Build.BuildLongVersion}-release-setup.exe"); - if (string.IsNullOrWhiteSpace(canaryBinlink) || + if (string.IsNullOrWhiteSpace(binLink) || string.IsNullOrWhiteSpace(canarySetuplink) || - string.IsNullOrWhiteSpace(releaseBinlink) || string.IsNullOrWhiteSpace(releaseSetuplink)) { Program.PrintColorMessage("build-github downloads not found.", ConsoleColor.Red); return false; } - BuildUploadInfo = new Tuple( - canaryBinlink, + BuildUploadInfo = new Tuple( + binLink, canarySetuplink, - releaseBinlink, releaseSetuplink ); @@ -1246,11 +1144,11 @@ namespace CustomBuildTool string BuildBuildId, string BuildPostUrl, string BuildPostKey, - string CanaryBinLink, + string BinLink, + BuildDeployInfo Bin, string CanarySetupLink, - string ReleaseBinLink, - string ReleaseSetupLink, BuildDeployInfo Release, + string ReleaseSetupLink, BuildDeployInfo Canary ) { @@ -1262,9 +1160,8 @@ namespace CustomBuildTool if (string.IsNullOrWhiteSpace(BuildBuildId) || string.IsNullOrWhiteSpace(BuildPostUrl) || string.IsNullOrWhiteSpace(BuildPostKey) || - string.IsNullOrWhiteSpace(CanaryBinLink) || + string.IsNullOrWhiteSpace(BinLink) || string.IsNullOrWhiteSpace(CanarySetupLink) || - string.IsNullOrWhiteSpace(ReleaseBinLink) || string.IsNullOrWhiteSpace(ReleaseSetupLink)) { Program.PrintColorMessage("BuildUpdateServerConfig invalid args.", ConsoleColor.Red); @@ -1280,22 +1177,18 @@ namespace CustomBuildTool BuildVersion = Build.BuildLongVersion, BuildCommit = Build.BuildCommitHash, BuildId = BuildBuildId, - BinUrl = CanaryBinLink, - BinLength = Canary.BinFileLength.ToString(), - BinHash = Canary.BinHash, - BinSig = Canary.BinSig, - SetupUrl = CanarySetupLink, - SetupLength = Canary.SetupFileLength.ToString(), - SetupHash = Canary.SetupHash, - SetupSig = Canary.SetupSig, - ReleaseBinUrl = ReleaseBinLink, - ReleaseBinLength = Release.BinFileLength.ToString(), - ReleaseBinHash = Release.BinHash, - ReleaseBinSig = Release.BinSig, + BinUrl = BinLink, + BinLength = Bin.FileLength.ToString(), + BinHash = Bin.Hash, + BinSig = Bin.Sig, + CanarySetupUrl = CanarySetupLink, + CanarySetupLength = Canary.FileLength.ToString(), + CanarySetupHash = Canary.Hash, + CanarySetupSig = Canary.Sig, ReleaseSetupUrl = ReleaseSetupLink, - ReleaseSetupLength = Release.SetupFileLength.ToString(), - ReleaseSetupHash = Release.SetupHash, - ReleaseSetupSig = Release.SetupSig, + ReleaseSetupLength = Release.FileLength.ToString(), + ReleaseSetupHash = Release.Hash, + ReleaseSetupSig = Release.Sig, }; byte[] buildPostString = JsonSerializer.SerializeToUtf8Bytes(buildUpdateRequest, BuildUpdateRequestContext.Default.BuildUpdateRequest); diff --git a/tools/CustomBuildTool/Program.cs b/tools/CustomBuildTool/Program.cs index 2770234cc..f88b29364 100644 --- a/tools/CustomBuildTool/Program.cs +++ b/tools/CustomBuildTool/Program.cs @@ -163,12 +163,8 @@ namespace CustomBuildTool Environment.Exit(1); if (!Build.CopyTextFiles(BuildFlags.Release)) Environment.Exit(1); - - foreach (var (channel, _) in BuildConfig.Build_Channels) - { - if (!Build.BuildBinZip(channel)) - Environment.Exit(1); - } + if (!Build.BuildBinZip()) + Environment.Exit(1); Build.ShowBuildStats(); } @@ -211,11 +207,11 @@ namespace CustomBuildTool Environment.Exit(1); if (!Build.CopyTextFiles(BuildFlags.Release)) Environment.Exit(1); + if (!Build.BuildBinZip()) + Environment.Exit(1); foreach (var (channel, _) in BuildConfig.Build_Channels) { - if (!Build.BuildBinZip(channel)) - Environment.Exit(1); if (!Build.BuildSetupExe(channel)) Environment.Exit(1); } @@ -273,11 +269,11 @@ namespace CustomBuildTool Environment.Exit(1); if (!Build.CopyTextFiles(BuildFlags.Release)) Environment.Exit(1); + if (!Build.BuildBinZip()) + Environment.Exit(1); foreach (var (channel, _) in BuildConfig.Build_Channels) { - if (!Build.BuildBinZip(channel)) - Environment.Exit(1); if (!Build.BuildSetupExe(channel)) Environment.Exit(1); } @@ -361,15 +357,10 @@ namespace CustomBuildTool if (!Build.BuildSolution("SystemInformer.sln", BuildFlags.Release) || !Build.BuildSolution("plugins\\Plugins.sln", BuildFlags.Release) || !Build.CopyDebugEngineFiles(BuildFlags.Release) || - !Build.CopyTextFiles(BuildFlags.Release)) + !Build.CopyTextFiles(BuildFlags.Release) || + !Build.BuildBinZip()) Environment.Exit(1); - foreach (var (channel, _) in BuildConfig.Build_Channels) - { - if (!Build.BuildBinZip(channel)) - Environment.Exit(1); - } - Build.ShowBuildStats(); return true; } @@ -399,12 +390,13 @@ namespace CustomBuildTool if (!Build.ResignFiles() || !Build.CopyDebugEngineFiles(BuildFlags.Release) || - !Build.CopyTextFiles(BuildFlags.Release)) + !Build.CopyTextFiles(BuildFlags.Release) || + !Build.BuildBinZip()) Environment.Exit(1); foreach (var (channel, _) in BuildConfig.Build_Channels) { - if (!Build.BuildBinZip(channel) || !Build.BuildSetupExe(channel)) + if (!Build.BuildSetupExe(channel)) Environment.Exit(1); } @@ -450,9 +442,12 @@ namespace CustomBuildTool ExecuteBuildSteps(BuildFlags.Release, Build.CopyDebugEngineFiles, Build.CopyWow64Files, Build.CopyTextFiles); + if (!!Build.BuildBinZip()) + Environment.Exit(1); + foreach (var (channel, _) in BuildConfig.Build_Channels) { - if (!Build.BuildBinZip(channel) || !Build.BuildSetupExe(channel)) + if (!Build.BuildSetupExe(channel)) Environment.Exit(1); } diff --git a/tools/CustomBuildTool/Utils.cs b/tools/CustomBuildTool/Utils.cs index b0c99f10f..3a6c1111c 100644 --- a/tools/CustomBuildTool/Utils.cs +++ b/tools/CustomBuildTool/Utils.cs @@ -763,15 +763,10 @@ namespace CustomBuildTool [JsonPropertyName("bin_hash")] public string BinHash { get; init; } [JsonPropertyName("bin_sig")] public string BinSig { get; init; } - [JsonPropertyName("setup_url")] public string SetupUrl { get; init; } - [JsonPropertyName("setup_length")] public string SetupLength { get; init; } - [JsonPropertyName("setup_hash")] public string SetupHash { get; init; } - [JsonPropertyName("setup_sig")] public string SetupSig { get; init; } - - [JsonPropertyName("release_bin_url")] public string ReleaseBinUrl { get; init; } - [JsonPropertyName("release_bin_length")] public string ReleaseBinLength { get; init; } - [JsonPropertyName("release_bin_hash")] public string ReleaseBinHash { get; init; } - [JsonPropertyName("release_bin_sig")] public string ReleaseBinSig { get; init; } + [JsonPropertyName("canary_setup_url")] public string CanarySetupUrl { get; init; } + [JsonPropertyName("canary_setup_length")] public string CanarySetupLength { get; init; } + [JsonPropertyName("canary_setup_hash")] public string CanarySetupHash { get; init; } + [JsonPropertyName("canary_setup_sig")] public string CanarySetupSig { get; init; } [JsonPropertyName("release_setup_url")] public string ReleaseSetupUrl { get; init; } [JsonPropertyName("release_setup_length")] public string ReleaseSetupLength { get; init; } diff --git a/tools/CustomSetupTool/util.c b/tools/CustomSetupTool/util.c index 66a8679bb..e1dae4852 100644 --- a/tools/CustomSetupTool/util.c +++ b/tools/CustomSetupTool/util.c @@ -11,6 +11,10 @@ #include "setup.h" +#if defined(_DEBUG) && !defined(PH_RELEASE_CHANNEL_ID) +#define PH_RELEASE_CHANNEL_ID 2 +#endif + #ifdef PH_RELEASE_CHANNEL_ID #if PH_RELEASE_CHANNEL_ID == 0 #define SETUP_APP_PARAMETERS L"-channel release" diff --git a/tools/CustomSetupTool/version.rc b/tools/CustomSetupTool/version.rc index a305bc4c1..e4c0199c6 100644 --- a/tools/CustomSetupTool/version.rc +++ b/tools/CustomSetupTool/version.rc @@ -51,17 +51,7 @@ END // // RCDATA // -#ifdef PH_RELEASE_CHANNEL_ID -#if PH_RELEASE_CHANNEL_ID == 0 -IDR_BIN_DATA RCDATA "../../build/output/systeminformer-build-release-bin.zip" -#elif PH_RELEASE_CHANNEL_ID == 1 -IDR_BIN_DATA RCDATA "../../build/output/systeminformer-build-preview-bin.zip" -#elif PH_RELEASE_CHANNEL_ID == 2 -IDR_BIN_DATA RCDATA "../../build/output/systeminformer-build-canary-bin.zip" -#elif PH_RELEASE_CHANNEL_ID == 3 -IDR_BIN_DATA RCDATA "../../build/output/systeminformer-build-developer-bin.zip" -#endif -#endif +IDR_BIN_DATA RCDATA "../../build/output/systeminformer-build-bin.zip" ///////////////////////////////////////////////////////////////////////////// //