[CMake] Relocatable RPM

Eric Noulard eric.noulard at gmail.com
Tue Aug 17 11:03:10 EDT 2010


2010/8/17 Gerald Hofmann <gerald.hofmann at cosin.eu>:
> Hi Will,
>
> I found a way to make the RPM relocatable.
>
> This brings some light into rpm relocation: http://www.rpm.org/max-rpm/ch-rpm-reloc.html
>
> The Prefix: tag gives the part of the file names which is replaced when another prefix is specified. You can divert CPACK_RPM_SPEC_MORE_DEFINE from its intended use to add this tag to the spec file.
>
> set( CPACK_RPM_SPEC_MORE_DEFINE "Prefix: /usr" )
>
> The rpm now is relocatable. :-)

I did add [preliminary] built-in support for relocatable RPM:
http://public.kitware.com/Bug/view.php?id=10935

This has been merged to master and should be in next CMake release.
The usage is

set(CPACK_RPM_PACKAGE_RELOCATABLE TRUE)

and CPackRPM will try to build a relocatable package.
This will surely FAIL if:
     - some file are installed with absolute path
     - CPACK_SET_DESTDIR is set to TRUE


> However, I did not yet find a way to set the default prefix from cmake, /usr seems to be hard coded.

You should dig into the ML, there should be some answer about that already :-)
look at this thread:
http://www.cmake.org/pipermail/cmake/2010-August/038820.html

The short answer is many CPack generatorhave builtin prefix (not only CPackRPM)
but those can be overriden by the user if he sets
"CPACK_PACKAGING_INSTALL_PREFIX".
Dave explained how to do it on a per-generator basis:
http://www.cmake.org/pipermail/cmake/2010-August/038831.html

>  Would be nice if someone feels to add another setting to the generator letting the user set the default
> prefix and setting the Prefix: tag at the same time to allow relocation.

Since
http://public.kitware.com/Bug/view.php?id=10935
is fixed this should already be possible.

One last note is as soon as your package is relocatable you can
install it using the
prefix you want with:

rpm --prefix  blah.rpm
or
rpm --relocate blah.rpm


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


More information about the CMake mailing list