From 6a84fa4bbf08f7af8621e9121b33a6343df5cce9 Mon Sep 17 00:00:00 2001 From: Andrei Radchenko Date: Fri, 8 Aug 2025 12:41:15 +0200 Subject: [PATCH] spec: fix node binary calls to use versioned node-24 binary Resolves: RHEL-111616 Extend existing shebang fixes to cover all npm nested modules and shell scripts that call 'node' as a command. This prevents failures when scripts try to call /usr/bin/node which is not shipped, instead redirecting them to the versioned /usr/bin/node-24 binary. Fixes include: - All JavaScript/TypeScript files with node shebangs in npm nested modules - Shell scripts like node-gyp that call 'node' as a command --- nodejs24.spec | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nodejs24.spec b/nodejs24.spec index c19230e..0ba0fea 100644 --- a/nodejs24.spec +++ b/nodejs24.spec @@ -454,12 +454,19 @@ declare NPM_DIR="${RPM_BUILD_ROOT}%{nodejs_private_sitelib}/npm" # Adjust npm scripts to use the renamed interpreter readonly SHEBANG_ERE='^#!/usr/bin/(env\s+)?node\b' readonly SHEBANG_FIX='#!%{_bindir}/node-%{node_version_major}' -readonly -a npm_bin_dirs=("${NPM_DIR}/bin" "${NPM_DIR}/node_modules/node-gyp/bin") +readonly -a npm_bin_dirs=("${NPM_DIR}/bin" "${NPM_DIR}/node_modules") find "${npm_bin_dirs[@]}" -type f \ | xargs grep --extended-regexp --files-with-matches "${SHEBANG_ERE}" \ | xargs sed --regexp-extended --in-place "s;${SHEBANG_ERE};${SHEBANG_FIX};" +# Fix shell scripts that call 'node' as command +readonly -a known_shell_scripts=( + "${NPM_DIR}/bin/node-gyp-bin/node-gyp" + "${NPM_DIR}/node_modules/@npmcli/run-script/lib/node-gyp-bin/node-gyp" +) +sed --regexp-extended --in-place 's;\bnode(\s);%{_bindir}/node-%{node_version_major}\1;' "${known_shell_scripts[@]}" + # Replace npm %%{_bindir} symlinks with properly versioned ones # usage: relink_bin relink_bin() {