at 16.09-beta 1.5 kB view raw
1diff --git a/tools/cli/main.js b/tools/cli/main.js 2index 84f94bc..4fbda17 100644 3--- a/tools/cli/main.js 4+++ b/tools/cli/main.js 5@@ -484,6 +484,44 @@ var springboard = function (rel, options) { 6 process.exit(ret.wait()); 7 } 8 9+ // BEGIN HACK 10+ // patch shebang: 11+ var fs = require('fs'); 12+ var path = require("path") 13+ var srcOld = fs.readFileSync(executable, 'utf8'); 14+ srcNew = srcOld.replace(/^#!\/bin\/bash/, '#!/bin/sh'); 15+ if (srcOld !== srcNew) { 16+ fs.writeFileSync(executable, srcNew, 'utf8'); 17+ } 18+ // patch elfs: 19+ var dir = path.dirname(executable); 20+ var interpreter = "@INTERPRETER@"; 21+ var rpath = "@RPATH@"; 22+ function spawnSync(/*...*/) { 23+ var args = Array.prototype.slice.call(arguments); 24+ var proc = require("child_process").spawn.apply(null, args); 25+ var future = new Future(); 26+ proc.on('close', function (code) { 27+ future.return(); 28+ }); 29+ return future.wait(); 30+ } 31+ function patchelf(/*...*/) { 32+ var pathParts = Array.prototype.slice.call(arguments); 33+ var p = path.join.apply(null, [dir, "dev_bundle"].concat(pathParts)); 34+ spawnSync('@PATCHELF@', [ 35+ "--set-interpreter", 36+ interpreter, 37+ "--set-rpath", 38+ rpath, 39+ p 40+ ], {stdio: 'inherit'}); 41+ } 42+ patchelf("bin", "node"); 43+ patchelf("mongodb", "bin", "mongo"); 44+ patchelf("mongodb", "bin", "mongod"); 45+ // END HACK 46+ 47 // Now exec; we're not coming back. 48 require('kexec')(executable, newArgv); 49 throw Error('exec failed?');