SHA256
1
0
forked from pool/nodejs22
nodejs22/nodejs-libpath.patch

55 lines
2.1 KiB
Diff

Index: node-v20.12.0/tools/install.py
===================================================================
--- node-v20.12.0.orig/tools/install.py
+++ node-v20.12.0/tools/install.py
@@ -6,6 +6,7 @@ import errno
import os
import shutil
import sys
+from distutils import sysconfig
import re
def abspath(*args):
@@ -66,6 +67,10 @@ def try_copy(options, path, dest):
try_unlink(target_path) # prevent ETXTBSY errors
return shutil.copy2(source_path, target_path)
+def libdir(options):
+ libdir_fq = sysconfig.get_config_var("LIBDIR")
+ return re.sub("^" + re.escape(options.prefix + "/"), "", libdir_fq)
+
def try_remove(options, path, dest):
source_path, target_path = mkpaths(options, path, dest)
if not options.silent:
@@ -82,7 +87,7 @@ def uninstall(options, paths, dest):
try_remove(options, path, dest)
def package_files(options, action, name, bins):
- target_path = os.path.join('lib/node_modules', name)
+ target_path = os.path.join(libdir(options), 'node_modules', name)
# don't install npm if the target path is a symlink, it probably means
# that a dev version of npm is installed there
@@ -103,7 +108,7 @@ def package_files(options, action, name,
if action == uninstall:
action(options, [link_path], os.path.join('bin', bin_name))
elif action == install:
- try_symlink(options, os.path.join('../lib/node_modules', name, bin_target), link_path)
+ try_symlink(options, os.path.join('..', libdir(options), 'node_modules', name, bin_target), link_path)
else:
assert 0 # unhandled action type
Index: node-v20.12.0/lib/internal/modules/cjs/loader.js
===================================================================
--- node-v20.12.0.orig/lib/internal/modules/cjs/loader.js
+++ node-v20.12.0/lib/internal/modules/cjs/loader.js
@@ -1529,7 +1529,7 @@ Module._initPaths = function() {
path.resolve(process.execPath, '..') :
path.resolve(process.execPath, '..', '..');
- const paths = [path.resolve(prefixDir, 'lib', 'node')];
+ const paths = ['/usr/lib/node'];
if (homeDir) {
ArrayPrototypeUnshift(paths, path.resolve(homeDir, '.node_libraries'));