<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> set(INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/ssp-<wbr>suite)<br>
> install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/<wbr>ssp/" DESTINATION ${INSTALL_DIR})<br></blockquote><div><br></div><div>Eric already covered this part - use relative paths instead ( no / at the beginning).<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
But I also need to execute a post script, which runs after installation. I added<br>
<br>
> set(CPACK_RPM_POST_INSTALL_<wbr>SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/<wbr>postinstall")<br>
<br>
to my CMakeLists.txt and in that script, I am using the RPM variable<br>
$RPM_INSTALL_PREFIX. But during installation, I get this error message<br>
<br>
> chmod: cannot access '/usr/usr/bin/startssp': No such file or directory<br>
> warning: %post(ssp-suite-7.1-1.x86_64) scriptlet failed, exit status 1<br>
> Non-fatal POSTIN scriptlet failure in rpm package ssp-suite-7.1-1.x86_64<br></blockquote><div><br><div><br></div>Pre/postinstall scripts are outside what CPackRPM 
is handling automatically but you can still use the relocation paths as 
supported by RPM.<br><br></div><div>Example for single relocation path:<br>set(CPACK_PACKAGING_INSTALL_PREFIX "/usr") # this will become the relocation path - becomes first relocation path<br></div><div><br>Example for multiple relocation paths:<br>set(CPACK_RPM_RELOCATION_PATHS "etc/foo" "opt/bar") # two paths that will be relocatable - etc will become first relocation path and opt the second one<br>set(CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION ON) # this will remove the default /usr from relocation paths<br>set(CPACK_PACKAGING_INSTALL_PREFIX "/a") # relative paths will be prefixed with /a - there is a bug that prevents you from using "/" only for relocation paths so you might decide to patch CPackRPM.cmake yourself <a href="https://gitlab.kitware.com/cmake/cmake/merge_requests/583/diffs">[1]</a><br><br><br></div><div>Now for the postinstall script each relocation path becomes a variable in RPM (RPM_INSTALL_PREFIX0 for first relocation path, RPM_INSTALL_PREFIX1 for the second and so on) so what you have to do in your script is instead of writing something like this:<br><br></div><div>chown someone:somegroup /etc/some_non_relocatable_path/some_file<br><br></div><div>you should write:<br><br>chown someone:somegroup ${RPM_INSTALL_PREFIX0}/some_non_relocatable_path/some_file</div><div><br></div><div>Regards,<br></div><div>Domen<br></div><div><br>[1] <a href="https://gitlab.kitware.com/cmake/cmake/merge_requests/583/diffs">https://gitlab.kitware.com/cmake/cmake/merge_requests/583/diffs</a><br></div></div></div></div>