[CMake] Building source RPMs?

Magnus Therning magnus at therning.org
Thu Aug 5 11:20:10 EDT 2010


On Thu, Aug 5, 2010 at 10:39, Eric Noulard <eric.noulard at gmail.com> wrote:
> 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 ?

To match the behaviour of the current build system :-)
I think that using the VCS archive feature will be as good a replacement
though.

> What is your usage pattern?

We ship most of our sources as source RPMs since most of our changes are added
patches to upstream (CentOS) RPMs.

It is just nice to also ship the source of our own code as RPMs rather than as
tar-ball.  However, I don't see a big problem with simply dropping use of
CPack and writing the SPEC files manually.  It would just be a nice-to-have is
all.

/M

-- 
Magnus Therning                        (OpenPGP: 0xAB4DFBA4)
magnus@therning.org          Jabber: magnus@therning.org
http://therning.org/magnus         identi.ca|twitter: magthe


More information about the CMake mailing list