mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
Fix user permissions for wavesrv.arm64 in macOS Universal binary (#333)
Adds an afterPack script in electron-builder to correct permissions for wavesrv.arm64 after it is copied into the universal binary.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
const { Arch } = require("electron-builder");
|
||||
const pkg = require("./package.json");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
@@ -54,15 +55,6 @@ const config = {
|
||||
: false,
|
||||
mergeASARs: true,
|
||||
singleArchFiles: "dist/bin/wavesrv.*",
|
||||
binaries: fs
|
||||
.readdirSync("./dist/bin", { recursive: true, withFileTypes: true })
|
||||
.filter((f) => f.isFile() && (f.name.startsWith("wavesrv") || f.name.includes("darwin")))
|
||||
.map((f) => {
|
||||
const resolvedPath = path.resolve(f.parentPath ?? f.path, f.name);
|
||||
console.log("resolvedPath", resolvedPath);
|
||||
return resolvedPath;
|
||||
})
|
||||
.filter((path) => path),
|
||||
},
|
||||
linux: {
|
||||
artifactName: "${name}-${platform}-${arch}-${version}.${ext}",
|
||||
@@ -93,6 +85,23 @@ const config = {
|
||||
provider: "generic",
|
||||
url: "https://dl.waveterm.dev/releases-w2",
|
||||
},
|
||||
afterPack: (context) => {
|
||||
// This is a workaround to restore file permissions to the wavesrv binaries on macOS after packaging the universal binary.
|
||||
if (context.electronPlatformName === "darwin" && context.arch === Arch.universal) {
|
||||
const packageBinDir = path.join(
|
||||
context.appOutDir,
|
||||
`${pkg.name}.app/Contents/Resources/app.asar.unpacked/dist/bin`
|
||||
);
|
||||
|
||||
// Reapply file permissions to the wavesrv binaries in the final app package
|
||||
fs.readdirSync(packageBinDir, {
|
||||
recursive: true,
|
||||
withFileTypes: true,
|
||||
})
|
||||
.filter((f) => f.isFile() && f.name.startsWith("wavesrv"))
|
||||
.forEach((f) => fs.chmodSync(path.resolve(f.parentPath ?? f.path, f.name), 0o755));
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = config;
|
||||
|
||||
Reference in New Issue
Block a user