summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Smorkalov <alexander.smorkalov@itseez.com>2016-05-10 12:25:25 (GMT)
committerBrad King <brad.king@kitware.com>2016-05-13 14:46:03 (GMT)
commitc7f388e723b85b48a1d0d462a8f2f7d962314421 (patch)
treea694efb10eea8f9c572e49c0ce17f16ef225ef1a
parent2d5896530b7353496e728eb7751ef05c305287e7 (diff)
downloadCMake-c7f388e723b85b48a1d0d462a8f2f7d962314421.zip
CMake-c7f388e723b85b48a1d0d462a8f2f7d962314421.tar.gz
CMake-c7f388e723b85b48a1d0d462a8f2f7d962314421.tar.bz2
CPack/Deb generation of postinst and postrm ldconfig files
DEBIAN/postinst and DEBAIN/postrm files generation if the package installs libraries in ldconfig controlled location (/lib/, /usr/lib/)
-rw-r--r--Modules/CPackDeb.cmake29
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx56
2 files changed, 85 insertions, 0 deletions
diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake
index 748bf06..d38751f 100644
--- a/Modules/CPackDeb.cmake
+++ b/Modules/CPackDeb.cmake
@@ -810,6 +810,33 @@ function(cpack_deb_prepare_package_vars)
endif()
endif()
+ # add ldconfig call in default postrm and postint
+ set(CPACK_ADD_LDCONFIG_CALL 0)
+ foreach(_FILE ${CPACK_DEB_SHARED_OBJECT_FILES})
+ get_filename_component(_DIR ${_FILE} DIRECTORY)
+ # all files in CPACK_DEB_SHARED_OBJECT_FILES have dot at the beginning
+ if(_DIR STREQUAL "./lib" OR _DIR STREQUAL "./usr/lib")
+ set(CPACK_ADD_LDCONFIG_CALL 1)
+ endif()
+ endforeach()
+
+ if(CPACK_ADD_LDCONFIG_CALL)
+ set(CPACK_DEBIAN_GENERATE_POSTINST 1)
+ set(CPACK_DEBIAN_GENERATE_POSTRM 1)
+ foreach(f ${PACKAGE_CONTROL_EXTRA})
+ get_filename_component(n "${f}" NAME)
+ if("${n}" STREQUAL "postinst")
+ set(CPACK_DEBIAN_GENERATE_POSTINST 0)
+ endif()
+ if("${n}" STREQUAL "postrm")
+ set(CPACK_DEBIAN_GENERATE_POSTRM 0)
+ endif()
+ endforeach()
+ else()
+ set(CPACK_DEBIAN_GENERATE_POSTINST 0)
+ set(CPACK_DEBIAN_GENERATE_POSTRM 0)
+ endif()
+
# Print out some debug information if we were asked for that
if(CPACK_DEBIAN_PACKAGE_DEBUG)
message("CPackDeb:Debug: CPACK_TOPLEVEL_DIRECTORY = '${CPACK_TOPLEVEL_DIRECTORY}'")
@@ -863,6 +890,8 @@ function(cpack_deb_prepare_package_vars)
"${CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION}" PARENT_SCOPE)
set(GEN_CPACK_DEBIAN_PACKAGE_SOURCE
"${CPACK_DEBIAN_PACKAGE_SOURCE}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_GENERATE_POSTINST "${CPACK_DEBIAN_GENERATE_POSTINST}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_GENERATE_POSTRM "${CPACK_DEBIAN_GENERATE_POSTRM}" PARENT_SCOPE)
set(GEN_WDIR "${WDIR}" PARENT_SCOPE)
endfunction()
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx
index 839115e..a09a7cb 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -416,6 +416,29 @@ int cmCPackDebGenerator::createDeb()
out << std::endl;
}
+ const std::string postinst = strGenWDIR + "/postinst";
+ const std::string postrm = strGenWDIR + "/postrm";
+ if(this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST"))
+ {
+ cmGeneratedFileStream out(postinst.c_str());
+ out <<
+ "#!/bin/sh\n\n"
+ "set -e\n\n"
+ "if [ \"$1\" = \"configure\" ]; then\n"
+ "\tldconfig\n"
+ "fi\n";
+ }
+ if(this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM"))
+ {
+ cmGeneratedFileStream out(postrm.c_str());
+ out <<
+ "#!/bin/sh\n\n"
+ "set -e\n\n"
+ "if [ \"$1\" = \"remove\" ]; then\n"
+ "\tldconfig\n"
+ "fi\n";
+ }
+
cmArchiveWrite::Compress tar_compression_type = cmArchiveWrite::CompressGZip;
const char* debian_compression_type =
this->GetOption("GEN_CPACK_DEBIAN_COMPRESSION_TYPE");
@@ -629,6 +652,39 @@ int cmCPackDebGenerator::createDeb()
}
}
+ // adds LDCONFIG related files
+ if(this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST"))
+ {
+ control_tar.SetPermissions(permission755);
+ if(!control_tar.Add(postinst, strGenWDIR.length(), "."))
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error adding file to tar:" << std::endl
+ << "#top level directory: "
+ << strGenWDIR << std::endl
+ << "#file: \"postinst\"" << std::endl
+ << "#error:" << control_tar.GetError() << std::endl);
+ return 0;
+ }
+ control_tar.SetPermissions(permission644);
+ }
+
+ if(this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM"))
+ {
+ control_tar.SetPermissions(permission755);
+ if(!control_tar.Add(postrm, strGenWDIR.length(), "."))
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error adding file to tar:" << std::endl
+ << "#top level directory: "
+ << strGenWDIR << std::endl
+ << "#file: \"postinst\"" << std::endl
+ << "#error:" << control_tar.GetError() << std::endl);
+ return 0;
+ }
+ control_tar.SetPermissions(permission644);
+ }
+
// for the other files, we use
// -either the original permission on the files
// -either a permission strictly defined by the Debian policies