diff options
-rw-r--r-- | Modules/CPackDeb.cmake | 29 | ||||
-rw-r--r-- | Source/CPack/cmCPackDebGenerator.cxx | 56 |
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 |