2017-05-10 13:26 GMT+02:00 Kristian <kristianonlin...@gmail.com>: > Hi, > > I am creating an RPM package, which on a standard installation should > install the file into /opt/ssp-suite directory. But I want to give the > user the opportunity, to install the package into another directory. > > I am doing this with these lines: > > > set(INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/ssp-suite) > > install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/ssp/" DESTINATION > ${INSTALL_DIR}) >
If you want to create relocatable package you should avoid install directive with absolute destination but rather do: install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/ssp" DESTINATION ssp-suite) then in our CMakeLists.txt before including CPack set(CPACK_RPM_PACKAGE_RELOCATABLE True) > > and by running cmake with > > > cmake -DCMAKE_INSTALL_PREFIX=/opt -V --debug . > CMAKE_INSTALL_PREFIX is not the prefix used by CPack. You should use CPACK_PACKAGING_INSTALL_PREFIX: https://cmake.org/cmake/help/v3.7/variable/CPACK_PACKAGING_INSTALL_PREFIX.html#variable:CPACK_PACKAGING_INSTALL_PREFIX Whatever the value you used for CMAKE_INSTALL_PREFIX at CMake runtime you may use another prefix for packaging when invoking CPack: cpack -DCPACK_PACKAGING_INSTALL_PREFIX=/opt -G RPM this will work for all files/target/dir installed with a **RELATIVE** path if you installed with an absolute path then the absolute path will be kept making the package "partially" or "not-at-all" relocatable. Non relocatable file are commonly placed in /etc/... > > But I also need to execute a post script, which runs after installation. I > added > > > set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ > postinstall") > > to my CMakeLists.txt and in that script, I am using the RPM variable > $RPM_INSTALL_PREFIX. But during installation, I get this error message > > > chmod: cannot access '/usr/usr/bin/startssp': No such file or directory > > warning: %post(ssp-suite-7.1-1.x86_64) scriptlet failed, exit status 1 > > Non-fatal POSTIN scriptlet failure in rpm package ssp-suite-7.1-1.x86_64 > I'm not quite up-to-date with CPack RPM and I guess Domen will step in for that but the specified script will be read and put into the RPM itself by CPackRPM. However since you currently have absolute destination file the prefix may well be "/usr" even if you installed somewhere else. Try: rpm -qi -p <your>.rpm | grep Reloca you'll get the relocations list unless the package is not relocatable. If you want to investigate more about what CPack RPM is doing for you you may try: cpack -D CPACK_RPM_PACKAGE_DEBUG=1 -G RPM as indicated here: https://cmake.org/cmake/help/v3.7/module/CPackRPM.html > Can someone give me some hints, how to change / add lines to > CMakeListst.txt and my postinstall script, so that script can be fully > relocatable? > I don't remember what variables may be used in POST/PRE install script files but you may have a look at the generated spec file which may gives you clue about that. The spec file generated by CPackRPM should be in: <buildroot>/_CPack_Packages/<your_system_arch>/RPM/SPECS running CPack RPM with DEBUG var set to 1 will give you all file locaton.
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake