mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-30 02:42:59 +00:00
25e582c497
closes #10064
50 lines
1.5 KiB
Diff
50 lines
1.5 KiB
Diff
diff --git a/tools/cli/main.js b/tools/cli/main.js
|
|
index 84f94bc..4fbda17 100644
|
|
--- a/tools/cli/main.js
|
|
+++ b/tools/cli/main.js
|
|
@@ -484,6 +484,44 @@ var springboard = function (rel, options) {
|
|
process.exit(ret.wait());
|
|
}
|
|
|
|
+ // BEGIN HACK
|
|
+ // patch shebang:
|
|
+ var fs = require('fs');
|
|
+ var path = require("path")
|
|
+ var srcOld = fs.readFileSync(executable, 'utf8');
|
|
+ srcNew = srcOld.replace(/^#!\/bin\/bash/, '#!/bin/sh');
|
|
+ if (srcOld !== srcNew) {
|
|
+ fs.writeFileSync(executable, srcNew, 'utf8');
|
|
+ }
|
|
+ // patch elfs:
|
|
+ var dir = path.dirname(executable);
|
|
+ var interpreter = "@INTERPRETER@";
|
|
+ var rpath = "@RPATH@";
|
|
+ function spawnSync(/*...*/) {
|
|
+ var args = Array.prototype.slice.call(arguments);
|
|
+ var proc = require("child_process").spawn.apply(null, args);
|
|
+ var future = new Future();
|
|
+ proc.on('close', function (code) {
|
|
+ future.return();
|
|
+ });
|
|
+ return future.wait();
|
|
+ }
|
|
+ function patchelf(/*...*/) {
|
|
+ var pathParts = Array.prototype.slice.call(arguments);
|
|
+ var p = path.join.apply(null, [dir, "dev_bundle"].concat(pathParts));
|
|
+ spawnSync('@PATCHELF@', [
|
|
+ "--set-interpreter",
|
|
+ interpreter,
|
|
+ "--set-rpath",
|
|
+ rpath,
|
|
+ p
|
|
+ ], {stdio: 'inherit'});
|
|
+ }
|
|
+ patchelf("bin", "node");
|
|
+ patchelf("mongodb", "bin", "mongo");
|
|
+ patchelf("mongodb", "bin", "mongod");
|
|
+ // END HACK
|
|
+
|
|
// Now exec; we're not coming back.
|
|
require('kexec')(executable, newArgv);
|
|
throw Error('exec failed?');
|