nodejs22/nodejs-libpath.patch

55 lines
2.1 KiB
Diff

Index: node-v22.12.0/tools/install.py
===================================================================
--- node-v22.12.0.orig/tools/install.py
+++ node-v22.12.0/tools/install.py
@@ -7,6 +7,7 @@ import os
import platform
import shutil
import sys
+from distutils import sysconfig
import re
current_system = platform.system()
@@ -72,6 +73,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:
@@ -88,7 +93,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
@@ -109,7 +114,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-v22.12.0/lib/internal/modules/cjs/loader.js
===================================================================
--- node-v22.12.0.orig/lib/internal/modules/cjs/loader.js
+++ node-v22.12.0/lib/internal/modules/cjs/loader.js
@@ -1798,7 +1798,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'));