I'm trying to build an RPM, but the source file from the vendor has a space in the filename, and there doesn't seem to be any good way to escape the filename so that it builds.

I've tried putting a \ in front of the spaces. I've tried replacing them with %20. I tried +. I've tried putting "s around it, I've tried ' around it.

For now, I'm working around it by renaming the source file from the vendor to not have spaces, but I really prefer to leave original vendor source filenames intact whenever possible.

With no escaping or quoting, I get:

+ unzip .../Foo Bar.zip
unzip:  cannot find or open .../Foo, .../Foo.zip or .../Foo.ZIP.

With \, the unzip works, but then:

error: Bad file: .../Foo\ Bar.zip: No such file or directory

Here is a fully functional test.spec file (I did zip "Foo Bar.zip" test.spec to get a sample zipfile):

Summary: Test
Name: test
Version: 1
Release: 1
License: Whatever
URL: http://www.example.com/
Source1: Foo Bar.zip

Just a test of escaping stuff...

%{__install} -d -m0755 %{buildroot}/foo
cd %{buildroot}/foo
unzip %SOURCE1

%{__rm} -rf %{buildroot}


* Wed May 8 2013 Example <example@example.org>
- Whatever
  • Yes, this is software that I'm just unzipping into a directory, with no real build process. – freiheit May 8 '13 at 21:11

Turns out, that leaving the Source unescaped, and quoting it in the %install does the trick:

Source1: Foo Bar.zip
unzip "%SOURCE1"
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.