fixup! spec: fix node binary calls to use versioned node-24 binary
This commit is contained in:
parent
8a289e3b2e
commit
240ffddaff
1 changed files with 6 additions and 15 deletions
|
|
@ -453,27 +453,18 @@ 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 additional node binary calls throughout the source tree
|
||||
|
||||
# Fix all JavaScript/TypeScript files with node shebangs in npm nested modules
|
||||
find "${NPM_DIR}/node_modules" -type f \( -name "*.js" -o -name "*.mjs" -o -name "*.ts" \) 2>/dev/null | while read -r file; do
|
||||
if grep -q "${SHEBANG_ERE}" "$file" 2>/dev/null; then
|
||||
sed --regexp-extended --in-place "s;${SHEBANG_ERE};${SHEBANG_FIX};" "$file"
|
||||
fi
|
||||
done
|
||||
|
||||
# Fix shell scripts that call 'node' as command
|
||||
find "${NPM_DIR}" -type f -executable | while read -r file; do
|
||||
if grep -q '\bnode\s\+["`$]' "$file" 2>/dev/null; then
|
||||
sed --regexp-extended --in-place 's;\bnode\s+;%{_bindir}/node-%{node_version_major} ;g' "$file"
|
||||
fi
|
||||
done
|
||||
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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue