[CMake] Building source RPMs?

Eric Noulard eric.noulard at gmail.com
Thu Aug 5 05:39:32 EDT 2010


2010/8/5 Magnus Therning <magnus at therning.org>:
> I'm currently using CPack to build binary RPMs, is there a way to also
> generate a source RPM?

Not yet...with CPackRPM.

Building  a source RPM with CMake/CPack is not as easy as building a
binary RPM. Because currently the spec file used to build a binary RPM
is a "short-cutted" one:
   - the %prep step is a simple move of directory
   - the %build is void (because CMake BUILDTOOL should have already done
     the build
   - the %install is a simple move too (because CPack did the install
on it's own)

This is due to the fact that when you call CPack,
   - CMake has been called
   - The software has been built
   - CPack will call install for you BEFORE calling the CPackRPM generator
   in the end CPackRPM "just" have to package the "already built and
installed file".

In a source RPM you should specify the steps (%prep, %build, %install)
what CMake/CPack usually do.  So basically the RPM spec file to use
for building a source RPM won't be the same as the one used to build
the current binary RPM.

So implementing a "Source RPM" generator is doable,
and in fact it was done in the UseRPMTools.cmake macro
http://www.cmake.org/Wiki/CMakeUserUseRPMTools
which is the ancestor of CPackRPM.

The drawback of the old UseRPMTools is that even for a binary RPM
it will redo all the steps including calling CMake etc...

Why do you need to build a Source RPM with CPack ?
What is your usage pattern?

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list