[CMake] CPack 2.8.7 RPM: hiding /etc/init.d from %files list

Deborah Pickett Deborah.Pickett at autodesk.com
Sun Jan 8 22:19:35 EST 2012


Hi Eric,

On 06/01/2012, at 7:36 PM, Eric Noulard wrote:

>> From a ton of googling, consensus seems to be that for directories that you "know" are on the target system, you don't have to list them in the %files list.  I'm confident that /etc/init.d is in this category.
> 
> I think you are right for that and we should add a list of "don't"
> include directories,
> or more generally
> We should add
> 
> CPACK_RPM_FILTER_FILELIST
> [...]
> You are welcome to file a bug report on that.

I will, but I think I found an underlying bug too... read on.

> I think there is an unexpected [nasty] workaround...
> [...]
> This should work. At least it works on my small test here.
> Please tell us if it works for you.

Almost.  The RPM compiles with the %ignore'd comment (lovely dirty hack, by the way).  But the resulting RPM still has the offending directory:

$ rpm -q --filesbypkg -p mypackage.rpm
mypackage /etc
mypackage /etc/init.d
mypackage /etc/init.d/mydaemon
[...]

Hand-editing the .spec file and completely removing the %ignore line, and it's still being included.

I think I found out why.  When I pack verbosely, I get these warnings from rpmbuild:

warning: File listed twice: /etc/init.d/mydaemon
warning: File listed twice: /etc/sysconfig
warning: File listed twice: /etc/sysconfig/autodesk
warning: File listed twice: /etc/sysconfig/autodesk
warning: File listed twice: /etc/sysconfig/autodesk/mydaemon
warning: File listed twice: /etc/sysconfig/autodesk/mydaemon
warning: File listed twice: /etc/sysconfig/autodesk/mydaemon
[...]

What's happening is that CPack is putting directories in the %files list (as it should) but it isn't tagging them with the %dir directive, so rpmbuild is doing a little mini "find . -print" on each line in %files, and ends up re-including /etc/init.d when it processes /etc.

About the %dir directive: http://www.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html#S3-RPM-INSIDE-DIR-DIRECTIVE

I confirmed that by %ignore-ing /etc too:
SET(CPACK_RPM_jobmanager_USER_FILELIST "%ignore /etc" "%ignore /etc/init.d")
(%dir would have worked for /etc too) and now the RPM correctly has only mydaemon and not its ancestors:
$ rpm -q --filesbypkg -p /tmp/mypackage.rpm
mypackage /etc/init.d/mydaemon

NOW the workaround succeeds.

So here's my assertion:

CPackRPM should be explicitly marking directories with "%dir" in the %files list, to prevent rpmbuild from recursively including each directory's descendants implicitly.

That's a pretty big change in behaviour, though.  What do other users of CPackRPM think?  Perhaps it's never actually come up because we haven't had CPACK_RPM_USER_FILELIST for long enough for anyone to notice.

> Ok with, but on my side I do happily review clean patches :-]

I'll file a bug report for the %dir "File listed twice" issue as well as a placeholder for your suggested CPACK_RPM_FILTER_FILELIST variable.  Then I'll get to work on some patches.

Thanks for the hack.  I've now got a workaround until 2.8.8. :)



More information about the CMake mailing list