Merge pull request #329823 from ExpidusOS/fix/pkgsllvm/elfutils
[NixPkgs.git] / pkgs / servers / meteor / main.patch
blob3282c91abac89023a2e781a5815a3918cdc43f90
1 diff --git a/tools/cli/main.js b/tools/cli/main.js
2 index 84f94bc..4fbda17 100644
3 --- a/tools/cli/main.js
4 +++ b/tools/cli/main.js
5 @@ -554,6 +554,44 @@
6 }).await());
7 } // Now exec; we're not coming back.
9 + // BEGIN HACK
10 + // patch shebang:
11 + var fs = require('fs');
12 + var path = require("path")
13 + var Future = require("fibers/future")
14 + var srcOld = fs.readFileSync(executable, 'utf8');
15 + srcNew = srcOld.replace(/^#!\/bin\/bash/, '#!/bin/sh');
16 + if (srcOld !== srcNew) {
17 + fs.writeFileSync(executable, srcNew, 'utf8');
18 + }
19 + // patch elfs:
20 + var dir = path.dirname(executable);
21 + var interpreter = "@INTERPRETER@";
22 + var rpath = "@RPATH@";
23 + function spawnSync(/*...*/) {
24 + var args = Array.prototype.slice.call(arguments);
25 + var proc = require("child_process").spawn.apply(null, args);
26 + var future = new Future();
27 + proc.on('close', function (code) {
28 + future.return();
29 + });
30 + return future.wait();
31 + }
32 + function patchelf(/*...*/) {
33 + var pathParts = Array.prototype.slice.call(arguments);
34 + var p = path.join.apply(null, [dir, "dev_bundle"].concat(pathParts));
35 + spawnSync('@PATCHELF@', [
36 + "--set-interpreter",
37 + interpreter,
38 + "--set-rpath",
39 + rpath,
40 + p
41 + ], {stdio: 'inherit'});
42 + }
43 + patchelf("bin", "node");
44 + patchelf("mongodb", "bin", "mongo");
45 + patchelf("mongodb", "bin", "mongod");
46 + // END HACK
48 require('kexec')(executable, newArgv);
50 @@ -1485,4 +1523,4 @@
52 process.exit(ret);
53 }).run();
54 -//# sourceMappingURL=main.js.map
55 \ No newline at end of file
56 +//# sourceMappingURL=main.js.map