Bug 5397

Summary: Issue with package_rpm : can't install files named "%name..."
Product: [Runtime] Package Management Issues Reporter: Sébastien MENNETRIER <s.mennetrier>
Component: RPMAssignee: Ross Burton - Disabled <ross>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: Medium CC: bluelightning, mburtin, n3npq, richard.purdie, ross.burton, sgw
Version: unspecified   
Target Milestone: 1.9 M3   
Hardware: All   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Sébastien MENNETRIER 2013-10-28 15:36:14 UTC
The rpm process replace all the "%name" in the spec file by the name of the package. So, if the package is composed of some files or directories named "%name...", the rpm package process failed.

More details :
http://lists.openembedded.org/pipermail/openembedded-core/2013-October/085602.html
Comment 1 Sébastien MENNETRIER 2013-10-31 08:34:33 UTC
I tried to create a patch to fix this issue : http://lists.openembedded.org/pipermail/openembedded-core/2013-October/085689.html
Comment 2 Mark Hatle 2013-10-31 13:42:49 UTC
The correct fix should be to replace "%" with "%%" in a name.  The later is a literal, the former indicates part of a variable will be coming next.

[%] might work, but it invokes the globbing mechanism which is not necessary.
Comment 3 Sébastien MENNETRIER 2013-10-31 13:57:41 UTC
I tried to replace "%" with "%%" and with "\%" but it doesn't work. I also tried to replace "%name" by "%%name" and it doesn't work.

"[%]" is the only solution that I found that fix the issue...
Comment 4 Sébastien MENNETRIER 2013-12-03 13:53:06 UTC
Have you an other suggestion Mark to fix this issues ?
Comment 5 Mark Hatle 2013-12-03 16:29:38 UTC
any filename that includes a '%', should be automatically turned into '%%'

%%name is valid RPM syntax and should result in finding the file name literal '%name'.

If that isn't working, then the globbing mechanism may be the only other approach that can be used.  It should be fairly easy to add a routine that does a search/replace of '%' in the contents of:

            file_list = []
            walk_files(root, file_list, conffiles)
            if not file_list and localdata.getVar('ALLOW_EMPTY') != "1":
                bb.note("Not creating empty RPM package for %s" % splitname)
            else:
                bb.note("Creating RPM package for %s" % splitname)
                spec_files_top.append('%files')
                spec_files_top.append('%defattr(-,-,-,-)')
                if file_list:
                    bb.note("Creating RPM package for %s" % splitname)
                    spec_files_top.extend(file_list)
                else:
                    bb.note("Creating EMPTY RPM Package for %s" % splitname)
                spec_files_top.append('')

iterate file_list, and replace with either the '%%' or '[%]' as necessary.
Comment 6 Sébastien MENNETRIER 2013-12-04 09:43:04 UTC
I think that you cannot modify 'file_list'. This list contains items that begin by "%dir" or by "%config" and these "%" must not be replaced.

I created a patch that escapes "%" in "walk_files" function (http://lists.openembedded.org/pipermail/openembedded-core/2013-October/085689.html)

I use the globbing mechanism because I tried with '%%' and this didn't work. Maybe is an issue with rpm5 (used by yocto)... (http://rpm5.org/)
Comment 7 Jeff Johnson 2014-11-24 22:46:20 UTC
rpm5 expands file paths twice, once while building,
another time while installing.

So %%%%name (i.e. four % characters) is needed for a literal "%name"

Meanwhile you almost certainly going to be happier patching
to remove the need for escaping '%' ... dunno if this is possible.
Comment 8 Michaël Burtin 2015-05-20 14:50:13 UTC
New patch submitted, replacing "%" in file/dir with "%%%%%%%%": http://lists.openembedded.org/pipermail/openembedded-core/2015-May/105143.html