3

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?

1
  • 1
    As far as I know you can use X/* patterns to mean, everything inside X
    – geckos
    Aug 7, 2019 at 2:22

1 Answer 1

7

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.

4
  • So I should've tested before asking. :-) Thanks! Aug 7, 2019 at 13:16
  • 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". Aug 7, 2019 at 13:17
  • Yes, that is indeed the case.
    – Chris Maes
    Aug 7, 2019 at 13:33
  • If your question is answered, consider accepting the answer.
    – Chris Maes
    Aug 7, 2019 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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