Search code examples
rpm-spec

Can anyone advise on variable syntax in RPM patch?


I have the following patch referenced in my spec file. It works with proxy hardcoded but I need to use a variable, which fails. Can anyone please advise on the correct syntax?

diff --git .yarnrc.yml .yarnrc.yml
index 6cc7483..b560e95 100644
--- .yarnrc.yml
+++ .yarnrc.yml
@@ -1,4 +1,8 @@
 enableTelemetry: false
+enableStrictSsl: false
+networkConcurrency: 1
+httpProxy: %{http_proxy}
+httpsProxy: %{https_proxy}

 nodeLinker: pnp

UPDATE:

Comments don't seem to format well so throwing latest incarnation taking onboard reply from Aaron here, which also fails to build (in jenkins). Edited patch verified in jenkins console.

From spec file

%prep
%setup -n %{name}-%{version}
sed -i 's|httpProxy:.*|httpProxy: "'$http_proxy'"|g' %{PATCH0}
sed -i 's|httpsProxy:.*|httpsProxy: "'$https_proxy'"|g' %{PATCH0}
%patch0

Revised patch

diff --git .yarnrc.yml .yarnrc.yml
index 6cc7483..7c3f6df 100644
--- .yarnrc.yml
+++ .yarnrc.yml
@@ -1,4 +1,9 @@
enableTelemetry: false
+enableStrictSsl: false
+networkConcurrency: 1
+httpProxy: ******
+httpsProxy: ******

 nodeLinker: pnp

Solution

  • RPM isn't going to replace those lines in the diff file; you will need some script or something to do that for you before the build. Or you can put it in as part of your %build macro like sed -i -e "s/_HTTP_PROXY_/%{http_proxy}/g" .yarnrc.yml where the yml file you have in your source has a placeholder _HTTP_PROXY_ ...