summaryrefslogtreecommitdiffstats
path: root/Source/CPack
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 /Source/CPack
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/)
Diffstat (limited to 'Source/CPack')
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx56
1 files changed, 56 insertions, 0 deletions
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