From 6d2be7bed0427b3bd1d251d421d382bfef5acc85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Wed, 26 Apr 2023 15:30:44 +0200 Subject: [PATCH] Replace /usr/etc/npmrc symlink with builtin configuration We want to have the system-level npmrc located at /etc/npmrc. By default, npm looks for it in /usr/etc/npmrc, so we placed a symlink to /etc/npmrc there. However, we are the only known package that has anything in /usr/etc, which confuses and/or breaks various tooling (see related bug). This gets rid of the symlink, and instead uses "builtin"-level configuration of npm to cause it to load the system-level configuration from /etc/npmrc. --- nodejs.spec | 15 +++++++++------ npmrc.builtin.in | 5 +++++ 2 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 npmrc.builtin.in diff --git a/nodejs.spec b/nodejs.spec index ca2b6fb..51d115c 100644 --- a/nodejs.spec +++ b/nodejs.spec @@ -175,6 +175,9 @@ Source100: %{name}-tarball.sh # nodejs-packaging SRPM. Source7: nodejs_native.attr +# Configure npm to look into /etc for configuration +Source8: npmrc.builtin.in + # These are full sources for dependencies included as WASM blobs in the source of Node itself. # Note: These sources would also include pre-compiled WASM blobs… so they are adjusted not to. # Recipes for creating these blobs are included in the sources. @@ -565,15 +568,14 @@ chmod 0755 %{buildroot}%{_prefix}/lib/node_modules/npm/node_modules/node-gyp/bin # automatic dependency on /usr/bin/pwsh that we cannot satisfy. chmod -x %{buildroot}%{_prefix}/lib/node_modules/corepack/shims/*.ps1 +# Drop the NPM builtin configuration in place +sed -e 's#@SYSCONFDIR@#%{_sysconfdir}#g' \ + %{SOURCE8} > %{buildroot}%{_prefix}/lib/node_modules/npm/npmrc + # Drop the NPM default configuration in place mkdir -p %{buildroot}%{_sysconfdir} cp %{SOURCE1} %{buildroot}%{_sysconfdir}/npmrc -# NPM upstream expects it to be in /usr/etc/npmrc, so we'll put a symlink here -# This is done in the interests of keeping /usr read-only. -mkdir -p %{buildroot}%{_prefix}/etc -ln -s %{_sysconfdir}/npmrc %{buildroot}%{_prefix}/etc/npmrc - # Install the full-icu data files install -Dpm0644 -t %{buildroot}%{icudatadir} deps/icu/source/converted/* @@ -700,7 +702,6 @@ end %{_bindir}/npx %{_prefix}/lib/node_modules/npm %config(noreplace) %{_sysconfdir}/npmrc -%{_prefix}/etc/npmrc %ghost %{_sysconfdir}/npmignore %doc %{_mandir}/man1/npm*.1* %doc %{_mandir}/man1/npx.1* @@ -737,6 +738,8 @@ end - Rebase to 18.16.1 Resolves: rhbz#2188290 rhbz#2166926 Resolves: CVE-2023-30581 CVE-2023-30588 CVE-2023-30589 CVE-2023-30590 +- Replace /usr/etc/npmrc symlink with builtin configuration + Resolves: rhbz#2222287 * Tue May 30 2023 Jan Staněk - 1:18.14.2-3 - Update bundled c-ares to 1.19.1 diff --git a/npmrc.builtin.in b/npmrc.builtin.in new file mode 100644 index 0000000..739a57d --- /dev/null +++ b/npmrc.builtin.in @@ -0,0 +1,5 @@ +# This is the distibution-level configuration file for npm. +# To configure NPM on a system level, use the globalconfig below (defaults to @SYSCONFDIR@/npmrc). +# vim:set filetype=dosini: + +globalconfig=@SYSCONFDIR@/npmrc