summaryrefslogtreecommitdiffstats
path: root/Source/CPack/cmCPackDebGenerator.cxx
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2007-07-25 17:08:17 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2007-07-25 17:08:17 (GMT)
commit9c2d6f98d7e0fd42bcf2ec78fbd66190c6dc439e (patch)
tree286cffdeddefbcce8421eccb171d84140574b412 /Source/CPack/cmCPackDebGenerator.cxx
parent8796bfcbaf35d9de8320ce625dcaf0a59aab81a6 (diff)
downloadCMake-9c2d6f98d7e0fd42bcf2ec78fbd66190c6dc439e.zip
CMake-9c2d6f98d7e0fd42bcf2ec78fbd66190c6dc439e.tar.gz
CMake-9c2d6f98d7e0fd42bcf2ec78fbd66190c6dc439e.tar.bz2
ENH: apply patch from Mathieu which creates a deb file (not finishsed yet)
Alex
Diffstat (limited to 'Source/CPack/cmCPackDebGenerator.cxx')
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx115
1 files changed, 110 insertions, 5 deletions
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx
index 6354d4c..c4c4750 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -41,11 +41,116 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName,
{
const char* arExecutable = this->GetOption("AR_EXECUTABLE");
const char* cmakeExecutable = this->GetOption("CMAKE_COMMAND");
- (void) outFileName;
- (void) toplevel;
- (void) files;
- (void) arExecutable;
- (void) cmakeExecutable;
+
+ // debian-binary file
+ std::string dbfilename;
+ dbfilename = toplevel;
+ dbfilename += "/debian-binary";
+ { // the scope is needed for cmGeneratedFileStream
+ cmGeneratedFileStream out(dbfilename.c_str());
+ out << "2.0";
+ out << std::endl; // required for valid debian package
+ }
+
+ // debian policy enforce lower case for package name
+ // IF(NOT DEBIAN_PACKAGE_NAME)
+ // STRING(TOLOWER
+ // ${CPACK_PACKAGE_NAME}
+ // DEBIAN_PACKAGE_NAME
+ // )
+
+ // control file
+ std::string ctlfilename;
+ ctlfilename = toplevel;
+ ctlfilename += "/control";
+ { // the scope is needed for cmGeneratedFileStream
+ cmGeneratedFileStream out(ctlfilename.c_str());
+ out << "Package: ${DEBIAN_PACKAGE_NAME}\n";
+ out << "Version: ${CPACK_PACKAGE_VERSION}\n";
+ out << "Section: devel\n";
+ out << "Priority: optional\n";
+ out << "Architecture: ${DEBIAN_ARCHITECTURE}\n";
+ out << "Depends: ${DEBIAN_PACKAGE_DEPENDS}\n";
+ out << "Maintainer: ${CPACK_NSIS_CONTACT}\n";
+ out << "Description: ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}\n";
+ out << "${DEBIAN_PACKAGE_NAME} was packaged by UseDebian and CMake.\n";
+ out << std::endl;
+ }
+
+ std::string output;
+ std::string cmd;
+// cmd = this->GetOption("CPACK_DEB_COMMAND");
+// cmsys::SystemTools::ReplaceString(cmd, "<ARCHIVE>", outFileName);
+// cmsys::SystemTools::ReplaceString(cmd, "<FILELIST>", "deb.filelist");
+
+ cmd = cmakeExecutable;
+ cmd += " -E tar cfz data.tar.gz ./usr";
+ int retVal = -1;
+ int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
+ &retVal, toplevel, this->GeneratorVerbose, 0);
+
+ if ( !res || retVal )
+ {
+ std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
+ tmpFile += "/Deb.log";
+ cmGeneratedFileStream ofs(tmpFile.c_str());
+ ofs << "# Run command: " << cmd.c_str() << std::endl
+ << "# Output:" << std::endl
+ << output.c_str() << std::endl;
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running tar command: "
+ << cmd.c_str() << std::endl
+ << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
+ return 0;
+ }
+
+ std::string md5filename;
+ md5filename = toplevel;
+ md5filename += "/md5sums";
+
+ { // the scope is needed for cmGeneratedFileStream
+ cmGeneratedFileStream out(md5filename.c_str());
+ std::vector<std::string>::const_iterator fileIt;
+ for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt )
+ {
+ cmd = cmakeExecutable;
+ cmd += " -E md5sum ";
+ cmd += *fileIt;
+ //std::string output;
+ //int retVal = -1;
+ res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
+ &retVal, toplevel, this->GeneratorVerbose, 0);
+ out << output;
+ }
+ out << std::endl;
+ }
+
+
+ cmd = cmakeExecutable;
+ cmd += " -E tar cfz control.tar.gz ./control ./md5sums";
+ res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
+ &retVal, toplevel, this->GeneratorVerbose, 0);
+
+ if ( !res || retVal )
+ {
+ std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
+ tmpFile += "/Deb.log";
+ cmGeneratedFileStream ofs(tmpFile.c_str());
+ ofs << "# Run command: " << cmd.c_str() << std::endl
+ << "# Output:" << std::endl
+ << output.c_str() << std::endl;
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running tar command: "
+ << cmd.c_str() << std::endl
+ << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
+ return 0;
+ }
+
+ // ar -r your-package-name.deb debian-binary control.tar.gz data.tar.gz
+ cmd = arExecutable;
+ cmd += " -r \"";
+ cmd += outFileName;
+ cmd += "\" debian-binary control.tar.gz data.tar.gz";
+ res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
+ &retVal, toplevel, this->GeneratorVerbose, 0);
return 1;
}