In an RPM %files section is it possible to specify a directory and all of its files and subdirectories recursively?
Asked Answered
W

1

5

I'm working on a packaging system that packages things in RPMs. I have a case where it would be very convenient to specify that I want a directory and every file and subdirectory under it included in the RPM. This of course, would be in the %files section.

Is there a way to do this? I notice that there is a way to specify that your list of files to include comes from a file. Would I have to run find in the %install section to generate that list into a file then use that file in the %files section later?

Walkthrough answered 6/8, 2019 at 23:38 Comment(1)
As far as I know you can use X/* patterns to mean, everything inside XTerritus
H
10

That is default behavior for rpm spec files:

%files
/directory

means: /directory and all files and directories below recursively.

Note: this only includes the files that you put in the %{rpmbuildroot}, not the files that are present on the system where you will install this rpm!

another example

%files
/usr/bin/*

make sure that some "official directories" like /usr/bin don't belong to your package (as rpm does not allow two packages to "own" the same file or directory). This line will package all files and folders you placed under %{rpmbuildroot}/usr/bin/ recursively, but not /usr/bin itself.

Hinckley answered 7/8, 2019 at 6:52 Comment(4)
So I should've tested before asking. :-) Thanks!Walkthrough
Is it considered standard practice to have RPMs who's only job is to create pieces of the top-level directory structure? Given the existence of the filesystem package on my Fedora machine, I would guess "Yes".Walkthrough
Yes, that is indeed the case.Hinckley
If your question is answered, consider accepting the answer.Hinckley

© 2022 - 2024 — McMap. All rights reserved.