[CMake] RPM package %config noreplace causes conflict
Eric Noulard
eric.noulard at gmail.com
Fri Aug 24 08:33:52 EDT 2012
2012/8/24 hce <jupiter.hce at gmail.com>:
> Hi,
>
> i use install(FILE ..) to install a configuration file config.txt by both
> RPM packages A.rpm and B.rpm, due to the name and version in config.txt, the
> config.txt is not exactly the same in A.rpm and B.rpm. Now I've got an file
> conflict error when A.rpm was installed, B.rpm failed the installation. I
> actually don't mind if the config.txt can be overriten or not as long as it
> is there.
>
> The install(FILE ...) actually generates "%config config.txt" in the spec
> for not overwriting the file if the file exists.
It generates such %config directive because the file is installed with
an absolute
destination like:
install(FILE config.txt DESTINATION /etc/mysoftware)
if it was installed with relative path you don't (automatically) get
the %config,
anyway the %config is not really the issue here.
> I guess because those two config.txt are different which causing conflic error.
Nope, probably not. The conflict is because two differents packages (A and B)
wan't to install a file at the very same place in the filesystem.
RPM don't care about the content.
> But I actually don't
> mind if the config.txt can be overriten or not as long as it is there. I
> know I can use --force in rpm command to force installation, but don't want
> to tell every body to use extra parameter to install packages.
>
> Is there any function in cmake I can use to force overwriting the
> configuration file if it exists?
The problem is not really with CMake but with RPM.
I can see 2 solutions to this problem:
1) Create 3 packages A,B and common-config.
common-config containing the "shared" config file
and make A and B depends on common-config.
see
cpack --help-variable CPACK_RPM_PACKAGE_REQUIRES
for specifying the dependency.
2) Install the config file in a separate location for each package
install(FILE config.txt config/A) for package A
install(FILE config.txt config/B) for package B
then use a post-install script that put the config file at the wanted
"shared" location. The post-install script shall do appropriate
action if another file is already there (replace, do nothing , merge ....)
see: cpack --help-variable CPACK_RPM_POST_INSTALL_SCRIPT_FILE
Hope this helps.
--
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org
More information about the CMake
mailing list