Search code examples
recursionrpmrpm-spec

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


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?


Solution

  • 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.