Re: escaping '%' in a file name.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/29/2012 04:30 AM, Jordan Sissel wrote:
On Mon, May 28, 2012 at 6:29 PM, Jordan Sissel<jls@xxxxxxxxxxxxxxxx>  wrote:

Howdy folks!

I'm mostly noting this here for posterity.

I'm trying to package software that has files with '%' in the names. I
tried a few things, but nothing worked. Googling found only this thread
from 2003 which indicated that "%%" "should" work but it does not (thread;
://tech.groups.yahoo.com/group/rpm-list/message/21824<http://tech.groups.yahoo.com/group/rpm-list/message/21824>
)

If my %files section is follows, for testing all possible permutations ;)

%files
/example/%name
/example/%%name
/example/%%%name
/example/%%%%name
/example/%{%}name
/example/\%name

The error with rpmbuild is:

RPM build errors:
     File not found:
/tmp/package-rpm-build20120528-31204-qsgxuu/BUILD/example/helloworld
     File not found:
/tmp/package-rpm-build20120528-31204-qsgxuu/BUILD/example/helloworld
     File not found:
/tmp/package-rpm-build20120528-31204-qsgxuu/BUILD/example/%helloworld
     File not found:
/tmp/package-rpm-build20120528-31204-qsgxuu/BUILD/example/helloworld
     File not found:
/tmp/package-rpm-build20120528-31204-qsgxuu/BUILD/example/%{%}name
     File not found:
/tmp/package-rpm-build20120528-31204-qsgxuu/BUILD/example/\helloworld

Judging from the above, it appears the correct way to escape a single % in
a filename is to use '%%%'

-Jordan


Replying to my own nonsense.

I misread the output. None of my attempted escapes actually worked.

Any ideas?

The answer is that it depends. Double-escape, eg '%%foo' works... except when %foo is actually a defined macro. And when such a macro is defined, no amount of extra %'s appears to help as items in the %files list gets macro-expanded more than once and escapes get lost somewhere in the process (and yeah it does smell like a bug someplace)

So eg this works for packaging file named '/%fame':

%install
touch ${RPM_BUILD_ROOT}/%%fame
%files
/%%fame

...but for packaging a file named '/%name' this doesn't:

%install
touch ${RPM_BUILD_ROOT}/%%name
%files
/%%name

A simple way around it is using '?' wildcard in place of '%', eg this works for packaging that pesky '/%name' file, is probably more readable than some magic incantation of exactly 7 and half %'s and three \ escapes :) and should work for pretty much any rpm version out there:

%install
touch ${RPM_BUILD_ROOT}/%%name
%files
/?name

	- Panu -
_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list


[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux