[cmake-developers] [PATCH][CPack][RPM] multiple path relocation prefixes

Domen Vrankar domen.vrankar at gmail.com
Mon Jan 12 09:20:19 EST 2015

> I'm not familiar with the corresponding use case.  Please explain
> how "multiple relocation paths" works in general with RPM tools.

In RPM packages you can specify multiple "Prefix:" sections and during
installation you have multiple options:

use "--prefix <new_path>" during installation: this will take the
value of first "Prefix:" path from spec file and relocate all the
paths from old path to provided path (I'd say that this is a back
compatibility feature of RPM) - for this reason I have preserved first
"Prefix:" path in spec file to be the same as in
CPACK_PACKAGING_INSTALL_PREFIX variable (same as before the patch) in
situations where this path is really used (with the patch
CPACK_PACKAGING_INSTALL_PREFIX would probably be set to / in most

use --relocate <path_from_spec_file>=<new_path> (this flag may be
repeated multiple times): "Prefix:" path from spec file that matches
the one provided by relocate flag will be replaced by new path and
this enables us to move for e.g. only documentation or libraries - we
are no longer bound to one root location for all files in a single
relocatable RPM.



spec file:
Prefix: /foo
Prefix: /foo/bin
Prefix: /foo/share/lib


rpm installation:
rpm -i --relocate /foo/bin=/bar/bin --relocate /foo/share/lib=/foo/lib

This will relocate some_program and some_other_lib during install but
will keep some_lib on the same location as defined in spec file.

rpm installation option 2:
rpm -i --prefix /foo/share <rpm_file>

This will relocate all three files to /foo/share/bin/some_program,
/foo/share/lib/some_lib and /foo/share/share/lib/some_other_lib

In both cases not_relocatable file will not be relocated since its
path prefix was not defined in spec file as relocatable.


I've checked and this feature is provided in RPM 3.0.5 on AIX as well
as in 4.12 on latest Fedora (version 21) so the feature is not just
RPM5 fork specific.

I've bound the relocation paths to standard GNU filesystem locations
and since GNUInstallDirs.cmake module already provides this
functionality for install command I extended that module. I don't know
who the maintainer of the module is so I hope that extending it in
such way is OK.


More information about the cmake-developers mailing list