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

Commit

Permalink
fix(snap): installation issue
Browse files Browse the repository at this point in the history
"The SUID sandbox helper binary was found, but is not configured correctly."
electron/electron#17972
  • Loading branch information
kontrollanten committed Jun 1, 2019
1 parent 94960ca commit 39fa8d6
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"main": "app/background.js",
"build": {
"appId": "com.beatplus.pronmail-desktop",
"afterPack": "scripts/after-pack.js",
"publish": [
"github"
],
Expand Down
55 changes: 55 additions & 0 deletions scripts/after-pack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// https://github.com/patrikx3/redis-ui/blob/b772176fc71f5cccbe1dbe31c8f7bd0fdb75f52e/src/build/after-pack.js

const fs = require('fs-extra');
const pkg = require('../package');
const { spawn } = require('child_process');
const { chdir } = require('process');

const exec = async function exec(cmd, args = []) {
const child = spawn(cmd, args, { shell: true });
redirectOutputFor(child);
await waitFor(child);
};

const redirectOutputFor = (child) => {
const printStdout = (data) => {
process.stdout.write(data.toString());
};
const printStderr = (data) => {
process.stderr.write(data.toString());
};
child.stdout.on('data', printStdout);
child.stderr.on('data', printStderr);

child.once('close', () => {
child.stdout.off('data', printStdout);
child.stderr.off('data', printStderr);
});
};

const waitFor = async function(child) {
return new Promise((resolve) => {
child.once('close', () => resolve());
});
};

module.exports = async function(context) {
// eslint-disable-next-line no-console
console.warn('after build; disable sandbox');
const isLinux = context.targets.find(target => target.name === 'appImage' || target.name === 'snap');
if (!isLinux) {
return;
}
const originalDir = process.cwd();
const dirname = context.appOutDir;
chdir(dirname);

await exec('mv', [pkg.name, pkg.name + '.bin']);
const wrapperScript = `#!/bin/bash
"\${BASH_SOURCE%/*}"/${pkg.name}.bin "$@" --no-sandbox
`;
fs.writeFileSync(pkg.name, wrapperScript);
await exec('chmod', ['+x', pkg.name]);

chdir(originalDir);
};

0 comments on commit 39fa8d6

Please sign in to comment.