From 9c2d6f98d7e0fd42bcf2ec78fbd66190c6dc439e Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Wed, 25 Jul 2007 13:08:17 -0400 Subject: [PATCH] ENH: apply patch from Mathieu which creates a deb file (not finishsed yet) Alex --- Source/CPack/cmCPackDebGenerator.cxx | 115 +++++++++++++++++++++++++-- Source/CPack/cmCPackGenerators.cxx | 4 - 2 files changed, 110 insertions(+), 9 deletions(-) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 6354d4c88..c4c47507f 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, "", outFileName); +// cmsys::SystemTools::ReplaceString(cmd, "", "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::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; } diff --git a/Source/CPack/cmCPackGenerators.cxx b/Source/CPack/cmCPackGenerators.cxx index bccee43f2..49d05a3d4 100644 --- a/Source/CPack/cmCPackGenerators.cxx +++ b/Source/CPack/cmCPackGenerators.cxx @@ -90,7 +90,6 @@ cmCPackGenerators::~cmCPackGenerators() cmCPackGenericGenerator* cmCPackGenerators::NewGenerator(const char* name) { cmCPackGenericGenerator* gen = this->NewGeneratorInternal(name); - fprintf(stderr, "********* NewGen %s\n", name); if ( !gen ) { return 0; @@ -106,15 +105,12 @@ cmCPackGenericGenerator* cmCPackGenerators::NewGeneratorInternal( { if ( !name ) { - fprintf(stderr, "*** 1 name==0\n"); return 0; } - fprintf(stderr, "*** 2 name==%s\n", name); cmCPackGenerators::t_GeneratorCreatorsMap::iterator it = this->GeneratorCreators.find(name); if ( it == this->GeneratorCreators.end() ) { - fprintf(stderr, "*** 2 name==%s not found\n", name); return 0; } return (it->second)();