6

I have a tar.gz that I am wanting to create a RPM out of and am currently working on the spec file. I couldn't seem to understand what the rule for including files in the %files section of the .spec was. My tar.gz consists of two python packages and is installed via a makefile that simply calls setup.py which uses distutils setup() to install them.

I currently have my documentation included but wasn't sure how to select what else to include:

%files
%doc README changelog
...

Also, my makefile generates a man page for the application; where/how should this be included in the .spec file?

I'm doing this on redhat.

alh
  • 2,569
  • 6
  • 29
  • 42
  • 2
    If the two packages are already packaged with distutils, why don't use `setup.py bdist_rpm` to build an RPM out of each one? – Alastair McCormack Dec 09 '12 at 12:10
  • 1
    The [Fedora packaging guidelines](http://fedoraproject.org/wiki/Packaging:Guidelines) are a good reference on how to write spec files. – jbowes Dec 09 '12 at 12:11
  • @Fuzzyfelt is it possible to package them together with that method, also how would the man page fit into things? – alh Dec 09 '12 at 22:20

1 Answers1

8

The %files section must list every file which will be included in the binary package, and therefore installed on target machines.

If you're making the RPM by the book, then the spec files serves two somewhat separate purposes. It's a build script, detailing how to convert the source code into build artifacts, and a packaging script, detailing what build products should be installed on the destination machines. In your case, the build aspect is very lightweight.

In this traditional approach, the makefile is run during the build phase, and the %files directive lists which of the resulting build artifacts should be installed. To be clear, you would either not use make install with the traditional approach, or you would use it with DESTDIR to install into the RPM build directory (ie not into /usr/lib/python/foo but into ~/rpmbuild/BUILD/usr/lib/python/foo or something), from where you would then select files with %files.

So, what you should do is to have some prior section (probably %install) run the makefile to install into the build area, and then use the %files section to pick out the results. Remember that you can use wildcards in the %files section, so you don't have to explicitly name every individual file.

Does that make sense? Have i misunderstood your question?

Tom Anderson
  • 46,189
  • 17
  • 92
  • 133
  • OK, so it should be safe to use `DESTDIR` and include all the output files from the `%install` that appear in `DESTDIR`? Also, do you know how to incorporate the `man` file created by `make`? Would I just output it to the same `DESTDIR` and list it in `%files`? – alh Dec 09 '12 at 22:24
  • I have no idea what your build is going to put in `DESTDIR`, but hopefully, yes, you can just stick all the output in one place and then include it all. And yes, you can put the man page in the same build directory as the other files - indeed, you have to. Remember to flag it with `%doc`, though. I don't think that's absolutely necessary, but it's good form. – Tom Anderson Dec 10 '12 at 00:13