Fix npm hashbang replacement
There is a new (?) script deps/npm/bin/npm-prefix.js with the /usr/bin/env hashbang left intact, which caused npm to always pull in whatever nodejs was currently the default one. Now all the scripts there should have the hashbangs adapted to our naming and no new nodes pulled by installing npm. Signed-off-by: Jan Staněk <jstanek@redhat.com> Related: RHEL-76035
This commit is contained in:
parent
f7b68b0302
commit
6cf6adf09f
@ -643,29 +643,21 @@ chrpath --delete %{buildroot}%{_bindir}/node
|
||||
# Rename the node binary
|
||||
mv %{buildroot}%{_bindir}/node %{buildroot}%{_bindir}/node-%{nodejs_pkg_major}
|
||||
|
||||
# Move the npm binary to npm-NODEJS_MAJOR
|
||||
rm -f %{buildroot}%{_bindir}/npm
|
||||
# Adjust the npm binaries
|
||||
# 1. Replace all hasbangs with versioned ones
|
||||
grep --extended-regexp --files-with-matches --recursive \
|
||||
'^#!/usr/bin/(env )?node($|[[:space:]])+' '%{buildroot}%{nodejs_private_sitelib}/npm/bin' \
|
||||
| xargs sed --in-place --regexp-extended \
|
||||
's;^#!/usr/bin/(env )?node($|[[:space:]])+;#!/usr/bin/node-%{nodejs_pkg_major};'
|
||||
|
||||
# Set the hashbang to use the matching Node.js interpreter
|
||||
sed --in-place --regexp-extended \
|
||||
's;^#!/usr/bin/env node($|\ |\t)+;#!/usr/bin/node-%{nodejs_pkg_major};g' \
|
||||
%{buildroot}%{nodejs_private_sitelib}/npm/bin/npm-cli.js
|
||||
# 2. Replace original links with the adjusted ones
|
||||
for bin in npm npx; do
|
||||
ln -srf "%{buildroot}%{nodejs_private_sitelib}/npm/bin/${bin}-cli.js" \
|
||||
"%{buildroot}%{_bindir}/${bin}-%{nodejs_pkg_major}"
|
||||
rm -f "%{buildroot}%{_bindir}/${bin}"
|
||||
done
|
||||
|
||||
ln -srf %{buildroot}%{nodejs_private_sitelib}/npm/bin/npm-cli.js \
|
||||
%{buildroot}%{_bindir}/npm-%{nodejs_pkg_major}
|
||||
|
||||
# Move the npx binary to npx-NODEJS_MAJOR
|
||||
rm -f %{buildroot}%{_bindir}/npx
|
||||
|
||||
# Set the hashbang to use the matching Node.js interpreter
|
||||
sed --in-place --regexp-extended \
|
||||
's;^#!/usr/bin/env node($|\ |\t)+;#!/usr/bin/node-%{nodejs_pkg_major};g' \
|
||||
%{buildroot}%{nodejs_private_sitelib}/npm/bin/npx-cli.js
|
||||
|
||||
ln -srf %{buildroot}%{nodejs_private_sitelib}/npm/bin/npx-cli.js \
|
||||
%{buildroot}%{_bindir}/npx-%{nodejs_pkg_major}
|
||||
|
||||
# Add the symlinks back for the default version
|
||||
# 3. Add the symlinks back for the default version
|
||||
%if 0%{?nodejs_default}
|
||||
ln -srf %{buildroot}%{_bindir}/node-%{nodejs_pkg_major} \
|
||||
%{buildroot}%{_bindir}/node
|
||||
|
Loading…
Reference in New Issue
Block a user