element-desktop/patches/electron-builder-squirrel-windows+26.0.11.patch
Michael Telatynski c3e7573f03
Update electron-builder-squirrel-windows to patch
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2025-03-17 09:14:28 +00:00

68 lines
4.6 KiB
Diff

diff --git a/node_modules/electron-builder-squirrel-windows/out/SquirrelWindowsTarget.js b/node_modules/electron-builder-squirrel-windows/out/SquirrelWindowsTarget.js
index 0a2c265..a7fe489 100644
--- a/node_modules/electron-builder-squirrel-windows/out/SquirrelWindowsTarget.js
+++ b/node_modules/electron-builder-squirrel-windows/out/SquirrelWindowsTarget.js
@@ -1,6 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const builder_util_1 = require("builder-util");
+const wine_1 = require("app-builder-lib/out/wine");
const filename_1 = require("builder-util/out/filename");
const app_builder_lib_1 = require("app-builder-lib");
const path = require("path");
@@ -16,12 +17,10 @@ class SquirrelWindowsTarget extends app_builder_lib_1.Target {
this.options = { ...this.packager.platformSpecificBuildOptions, ...this.packager.config.squirrelWindows };
}
async prepareSignedVendorDirectory() {
- // If not specified will use the Squirrel.Windows that is shipped with electron-installer(https://github.com/electron/windows-installer/tree/main/vendor)
- // After https://github.com/electron-userland/electron-builder-binaries/pull/56 merged, will add `electron-builder-binaries` to get the latest version of squirrel.
- let vendorDirectory = this.options.customSquirrelVendorDir || path.join(require.resolve("electron-winstaller/package.json"), "..", "vendor");
+ let vendorDirectory = this.options.customSquirrelVendorDir;
if ((0, builder_util_1.isEmptyOrSpaces)(vendorDirectory) || !fs.existsSync(vendorDirectory)) {
- builder_util_1.log.warn({ vendorDirectory }, "unable to access Squirrel.Windows vendor directory, falling back to default electron-winstaller");
- vendorDirectory = path.join(require.resolve("electron-winstaller/package.json"), "..", "vendor");
+ builder_util_1.log.warn({ vendorDirectory }, "unable to access custom Squirrel.Windows vendor directory, falling back to default vendor ");
+ vendorDirectory = path.resolve(__dirname, "..", "vendor");
}
const tmpVendorDirectory = await this.packager.info.tempDirManager.createTempDir({ prefix: "squirrel-windows-vendor" });
// Copy entire vendor directory to temp directory
@@ -29,14 +28,29 @@ class SquirrelWindowsTarget extends app_builder_lib_1.Target {
builder_util_1.log.debug({ from: vendorDirectory, to: tmpVendorDirectory }, "copied vendor directory");
const files = await fs.promises.readdir(tmpVendorDirectory);
for (const file of files) {
- if (["Squirrel.exe", "StubExecutable.exe"].includes(file)) {
+ if (file === "Squirrel.exe") {
const filePath = path.join(tmpVendorDirectory, file);
builder_util_1.log.debug({ file: filePath }, "signing vendor executable");
await this.packager.sign(filePath);
+ break;
}
}
return tmpVendorDirectory;
}
+ async generateStubExecutableExe(appOutDir, vendorDir) {
+ const files = await fs.promises.readdir(appOutDir, { withFileTypes: true });
+ for (const file of files) {
+ if (file.isFile() && file.name.toLocaleLowerCase().endsWith(".exe") && file.name.toLocaleLowerCase() !== "squirrel.exe") {
+ const filePath = path.join(appOutDir, file.name);
+ builder_util_1.log.debug({ file: filePath }, "generating stub executable for exe");
+ const fileNameWithoutExt = file.name.slice(0, -4);
+ const stubExePath = path.join(appOutDir, `${fileNameWithoutExt}_ExecutionStub.exe`);
+ await fs.promises.copyFile(path.join(vendorDir, "StubExecutable.exe"), stubExePath);
+ await (0, wine_1.execWine)(path.join(vendorDir, "WriteZipToSetup.exe"), null, ["--copy-stub-resources", filePath, stubExePath]);
+ await this.packager.sign(stubExePath);
+ }
+ }
+ }
async build(appOutDir, arch) {
const packager = this.packager;
const version = packager.appInfo.version;
@@ -51,6 +65,7 @@ class SquirrelWindowsTarget extends app_builder_lib_1.Target {
arch,
});
const distOptions = await this.computeEffectiveDistOptions(appOutDir, installerOutDir, setupFile);
+ await this.generateStubExecutableExe(appOutDir, distOptions.vendorDirectory);
await (0, electron_winstaller_1.createWindowsInstaller)(distOptions);
await packager.signAndEditResources(artifactPath, arch, installerOutDir);
if (this.options.msi) {