File nodejs-libpath.patch of Package nodejs4
Index: node-v4.7.0/lib/module.js
===================================================================
--- node-v4.7.0.orig/lib/module.js
+++ node-v4.7.0/lib/module.js
@@ -453,7 +453,7 @@ Module._initPaths = function() {
homeDir = process.env.HOME;
}
- var paths = [path.resolve(process.execPath, '..', '..', 'lib', 'node')];
+ var paths = ['/usr/lib/node_modules', '/usr/lib/node'];
if (homeDir) {
paths.unshift(path.resolve(homeDir, '.node_libraries'));
Index: node-v4.7.0/tools/install.py
===================================================================
--- node-v4.7.0.orig/tools/install.py
+++ node-v4.7.0/tools/install.py
@@ -6,6 +6,7 @@ import os
import re
import shutil
import sys
+from distutils import sysconfig
# set at init time
node_prefix = '/usr/local' # PREFIX variable from Makefile
@@ -81,7 +82,7 @@ def update_shebang(path, shebang):
open(path, 'w').write(s)
def npm_files(action):
- target_path = 'lib/node_modules/npm/'
+ target_path = sysconfig.get_config_var("LIB") + '/node_modules/npm/'
# don't install npm if the target path is a symlink, it probably means
# that a dev version of npm is installed there
@@ -99,17 +100,7 @@ def npm_files(action):
if action == uninstall:
action([link_path], 'bin/npm')
elif action == install:
- try_symlink('../lib/node_modules/npm/bin/npm-cli.js', link_path)
- if os.environ.get('PORTABLE'):
- # This crazy hack is necessary to make the shebang execute the copy
- # of node relative to the same directory as the npm script. The precompiled
- # binary tarballs use a prefix of "/" which gets translated to "/bin/node"
- # in the regular shebang modifying logic, which is incorrect since the
- # precompiled bundle should be able to be extracted anywhere and "just work"
- shebang = '/bin/sh\n// 2>/dev/null; exec "`dirname "$0"`/node" "$0" "$@"'
- else:
- shebang = os.path.join(node_prefix or '/', 'bin/node')
- update_shebang(link_path, shebang)
+ try_symlink("../" + sysconfig.get_config_var("LIB") + '/node_modules/npm/bin/npm-cli.js',link_path)
else:
assert(0) # unhandled action type
@@ -142,7 +133,7 @@ def files(action):
action([output_prefix + output_file], 'bin/' + output_file)
if 'true' == variables.get('node_use_dtrace'):
- action(['out/Release/node.d'], 'lib/dtrace/node.d')
+ action(['out/Release/node.d'], sysconfig.get_config_var("LIB") + '/dtrace/node.d')
# behave similarly for systemtap
action(['src/node.stp'], 'share/systemtap/tapset/')