Skip to content

Commit

Permalink
chore(dev): preparation for ElectronBuilder v26 built-in support for …
Browse files Browse the repository at this point in the history
…Fuses flipping
  • Loading branch information
danielweck committed Feb 2, 2025
1 parent ef8dfd7 commit c41172e
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions scripts/afterPack.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,15 @@ module.exports = async function afterPack(context) {
console.log("context.packager.appInfo.productFilename: " + context.packager.appInfo.productFilename);
console.log("context.appOutDir: " + context.appOutDir);

const ext = {
darwin: ".app",
win32: ".exe",
linux: [""],
}[context.electronPlatformName];
console.log("context.packager instanceof builder.LinuxPackager: " + (context.packager instanceof builder.LinuxPackager));
console.log("context.packager.executableName: " + context.packager.executableName);

const executableName =
context.electronPlatformName === "linux"
? context.packager.appInfo.productFilename.toLowerCase() // context.packager.executableName
: context.packager.appInfo.productFilename;
console.log("context.packager.addElectronFuses(): " + !!context.packager.addElectronFuses);

const electronBinaryPath = path.join(context.appOutDir, `${executableName}${ext}`);

await flipFuses(electronBinaryPath, {
/* @type require("@electron/fuses").FuseConfig */
const fuseConfig = {
version: FuseVersion.V1,
strictlyRequireAllFuses: true,

// https://github.com/electron/fuses?tab=readme-ov-file#apple-silicon
resetAdHocDarwinSignature: context.electronPlatformName === "darwin" && context.arch === builder.Arch.arm64,
Expand Down Expand Up @@ -81,7 +75,30 @@ module.exports = async function afterPack(context) {

// GrantFileProtocolExtraPrivileges = 7,
[FuseV1Options.GrantFileProtocolExtraPrivileges]: false,
});
};

// Electron Builder v26
// https://github.com/electron-userland/electron-builder/pull/8588
if (context.packager.addElectronFuses) {
await context.packager.addElectronFuses(context, fuseConfig);
} else {

const ext = {
darwin: ".app",
win32: ".exe",
linux: [""],
}[context.electronPlatformName];

const executableName = (context.packager instanceof builder.LinuxPackager) ? context.packager.executableName : context.packager.appInfo.productFilename;
// const executableName =
// context.electronPlatformName === "linux"
// ? context.packager.appInfo.productFilename.toLowerCase() // context.packager.executableName
// : context.packager.appInfo.productFilename;

const electronBinaryPath = path.join(context.appOutDir, `${executableName}${ext}`);

await flipFuses(electronBinaryPath, fuseConfig);
}

// if (context.electronPlatformName === 'linux') {
// context.targets.forEach(fixSetuid(context));
Expand Down

0 comments on commit c41172e

Please sign in to comment.