Compare commits

...
Sign in to create a new pull request.

2 commits

Author SHA1 Message Date
Jan Staněk
240ffddaff
fixup! spec: fix node binary calls to use versioned node-24 binary 2025-08-11 16:22:11 +02:00
Andrei Radchenko
8a289e3b2e spec: fix node binary calls to use versioned node-24 binary
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

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-08 12:46:55 +02:00

View file

@ -453,12 +453,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 <basename> <source>
relink_bin() {