cmCPackCygwinBinaryGenerator.cxx 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmCPackCygwinBinaryGenerator.h"
  14. #include "cmake.h"
  15. #include "cmGlobalGenerator.h"
  16. #include "cmLocalGenerator.h"
  17. #include "cmSystemTools.h"
  18. #include "cmMakefile.h"
  19. #include "cmGeneratedFileStream.h"
  20. #include "cmCPackLog.h"
  21. #include <cmsys/SystemTools.hxx>
  22. //----------------------------------------------------------------------
  23. cmCPackCygwinBinaryGenerator::cmCPackCygwinBinaryGenerator()
  24. {
  25. this->Compress = false;
  26. }
  27. //----------------------------------------------------------------------
  28. cmCPackCygwinBinaryGenerator::~cmCPackCygwinBinaryGenerator()
  29. {
  30. }
  31. //----------------------------------------------------------------------
  32. int cmCPackCygwinBinaryGenerator::InitializeInternal()
  33. {
  34. this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "1");
  35. std::vector<std::string> path;
  36. std::string pkgPath = cmSystemTools::FindProgram("bzip2", path, false);
  37. if ( pkgPath.empty() )
  38. {
  39. cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find BZip2" << std::endl);
  40. return 0;
  41. }
  42. this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str());
  43. cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Found Compress program: "
  44. << pkgPath.c_str()
  45. << std::endl);
  46. return this->Superclass::InitializeInternal();
  47. }
  48. //----------------------------------------------------------------------
  49. int cmCPackCygwinBinaryGenerator::CompressFiles(const char* outFileName,
  50. const char* toplevel, const std::vector<std::string>& files)
  51. {
  52. std::string packageName = this->GetOption("CPACK_PACKAGE_NAME");
  53. packageName += this->GetOption("CPACK_PACKAGE_VERSION");
  54. packageName = cmsys::SystemTools::LowerCase(packageName);
  55. std::string manifest = "/share/doc/";
  56. manifest += packageName;
  57. manifest += "/MANIFEST";
  58. std::string manifestFile
  59. = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
  60. std::string tempdir = manifestFile;
  61. manifestFile += manifest;
  62. // create an extra scope to force the stream
  63. // to create the file before the super class is called
  64. {
  65. cmGeneratedFileStream ofs(manifestFile.c_str());
  66. for(std::vector<std::string>::const_iterator i = files.begin();
  67. i != files.end(); ++i)
  68. {
  69. #undef cerr
  70. // remove the temp dir and replace with /usr
  71. ofs << "/usr" << (*i).substr(tempdir.size()) << "\n";
  72. std::cerr << "/usr" << (*i).substr(tempdir.size()) << "\n";
  73. }
  74. ofs << "/usr" << manifest << "\n";
  75. }
  76. // Now compress up everything
  77. std::vector<std::string> filesWithManifest = files;
  78. filesWithManifest.push_back(manifestFile);
  79. return this->Superclass::CompressFiles(outFileName, toplevel,
  80. filesWithManifest);
  81. }