I want to build a demo rpm package which copies one file to the target system and executes some pre and post script. I managed to create a package. When I run the package on the target system I got the e warning "warning: package xxx intend for yyy plattform". But no file was copied. Any ideas? After goes my code/project:
Project tree:
myRpm/CMakeLists.txt
myRpm/install.txt
myRpm/post.py
myRpm/post.sh
myRpm/pre.py
myRpm/pre.sh
CMakeLists:
cmake_minimum_required (VERSION 2.8)
if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
INCLUDE(InstallRequiredSystemLibraries)
set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
set(CPACK_PACKAGE_NAME "my test")
set(CPACK_PACKAGE_VENDOR "tets")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "fake rpm")
set(CPACK_PACKAGE_VERSION "6.6.6")
set(CPACK_PACKAGE_VERSION_MAJOR "6")
set(CPACK_PACKAGE_VERSION_MINOR "6")
set(CPACK_PACKAGE_VERSION_PATCH "6")
set(targetDestDir "myDir")
set(CPACK_GENERATOR "RPM")
install(
FILES "${CMAKE_CURRENT_SOURCE_DIR}/install.txt" "${CMAKE_CURRENT_SOURCE_DIR}/pre.py" "${CMAKE_CURRENT_SOURCE_DIR}/post.py"
DESTINATION "${targetDestDir}"
)
set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/pre.sh")
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/post.sh")
include(CPack)
endif()
The value of CPACK_RPM_PACKAGE_ARCHITECTURE is important when building RPMs for other systems/distros. The following code should work:
cmake_minimum_required (VERSION 2.8)
if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
INCLUDE(InstallRequiredSystemLibraries)
set(CMAKE_INSTALL_TMPDIR /tmp CACHE PATH "Output dir for tmp")
set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
set(CPACK_PACKAGE_NAME "mytest")
set(CPACK_PACKAGE_VENDOR "tets")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "fake rpm")
set(CPACK_PACKAGE_VERSION "6.6.6")
set(CPACK_PACKAGE_VERSION_MAJOR "6")
set(CPACK_PACKAGE_VERSION_MINOR "6")
set(CPACK_PACKAGE_VERSION_PATCH "6")
set(CPACK_GENERATOR "RPM")
set(CPACK_RPM_PACKAGE_ARCHITECTURE "noarch")
set(targetDestDir ${CMAKE_INSTALL_TMPDIR})
install(
FILES "${CMAKE_CURRENT_SOURCE_DIR}/install.txt" "${CMAKE_CURRENT_SOURCE_DIR}/post.py"
DESTINATION "${targetDestDir}"
)
set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/pre.sh")
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/post.sh")
include(CPack)
endif()
Note: the pre.sh and post.sh are in the root dir of the sources. In the post.sh the post.py is called.