Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 18, 2021. It is now read-only.

Commit 39fa8d6

Browse files
committed
fix(snap): installation issue
"The SUID sandbox helper binary was found, but is not configured correctly." electron/electron#17972
1 parent 94960ca commit 39fa8d6

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"main": "app/background.js",
1818
"build": {
1919
"appId": "com.beatplus.pronmail-desktop",
20+
"afterPack": "scripts/after-pack.js",
2021
"publish": [
2122
"github"
2223
],

scripts/after-pack.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// https://github.com/patrikx3/redis-ui/blob/b772176fc71f5cccbe1dbe31c8f7bd0fdb75f52e/src/build/after-pack.js
2+
3+
const fs = require('fs-extra');
4+
const pkg = require('../package');
5+
const { spawn } = require('child_process');
6+
const { chdir } = require('process');
7+
8+
const exec = async function exec(cmd, args = []) {
9+
const child = spawn(cmd, args, { shell: true });
10+
redirectOutputFor(child);
11+
await waitFor(child);
12+
};
13+
14+
const redirectOutputFor = (child) => {
15+
const printStdout = (data) => {
16+
process.stdout.write(data.toString());
17+
};
18+
const printStderr = (data) => {
19+
process.stderr.write(data.toString());
20+
};
21+
child.stdout.on('data', printStdout);
22+
child.stderr.on('data', printStderr);
23+
24+
child.once('close', () => {
25+
child.stdout.off('data', printStdout);
26+
child.stderr.off('data', printStderr);
27+
});
28+
};
29+
30+
const waitFor = async function(child) {
31+
return new Promise((resolve) => {
32+
child.once('close', () => resolve());
33+
});
34+
};
35+
36+
module.exports = async function(context) {
37+
// eslint-disable-next-line no-console
38+
console.warn('after build; disable sandbox');
39+
const isLinux = context.targets.find(target => target.name === 'appImage' || target.name === 'snap');
40+
if (!isLinux) {
41+
return;
42+
}
43+
const originalDir = process.cwd();
44+
const dirname = context.appOutDir;
45+
chdir(dirname);
46+
47+
await exec('mv', [pkg.name, pkg.name + '.bin']);
48+
const wrapperScript = `#!/bin/bash
49+
"\${BASH_SOURCE%/*}"/${pkg.name}.bin "$@" --no-sandbox
50+
`;
51+
fs.writeFileSync(pkg.name, wrapperScript);
52+
await exec('chmod', ['+x', pkg.name]);
53+
54+
chdir(originalDir);
55+
};

0 commit comments

Comments
 (0)