cmCPackCygwinBinaryGenerator.cxx 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmCPackCygwinBinaryGenerator.h"
  11. #include "cmCPackLog.h"
  12. #include "cmGeneratedFileStream.h"
  13. #include "cmGlobalGenerator.h"
  14. #include "cmMakefile.h"
  15. #include "cmSystemTools.h"
  16. #include "cmake.h"
  17. #include <cmsys/SystemTools.hxx>
  18. //----------------------------------------------------------------------
  19. cmCPackCygwinBinaryGenerator::cmCPackCygwinBinaryGenerator()
  20. {
  21. }
  22. //----------------------------------------------------------------------
  23. cmCPackCygwinBinaryGenerator::~cmCPackCygwinBinaryGenerator()
  24. {
  25. }
  26. //----------------------------------------------------------------------
  27. int cmCPackCygwinBinaryGenerator::InitializeInternal()
  28. {
  29. this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
  30. this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "0");
  31. return this->Superclass::InitializeInternal();
  32. }
  33. //----------------------------------------------------------------------
  34. int cmCPackCygwinBinaryGenerator::PackageFiles()
  35. {
  36. std::string packageName = this->GetOption("CPACK_PACKAGE_NAME");
  37. packageName += "-";
  38. packageName += this->GetOption("CPACK_PACKAGE_VERSION");
  39. packageName = cmsys::SystemTools::LowerCase(packageName);
  40. std::string manifest = "/usr/share/doc/";
  41. manifest += packageName;
  42. manifest += "/MANIFEST";
  43. std::string manifestFile
  44. = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
  45. // Create a MANIFEST file that contains all of the files in
  46. // the tar file
  47. std::string tempdir = manifestFile;
  48. manifestFile += manifest;
  49. // create an extra scope to force the stream
  50. // to create the file before the super class is called
  51. {
  52. cmGeneratedFileStream ofs(manifestFile.c_str());
  53. for(std::vector<std::string>::const_iterator i = files.begin();
  54. i != files.end(); ++i)
  55. {
  56. // remove the temp dir and replace with /usr
  57. ofs << (*i).substr(tempdir.size()) << "\n";
  58. }
  59. ofs << manifest << "\n";
  60. }
  61. // add the manifest file to the list of all files
  62. files.push_back(manifestFile);
  63. // create the bzip2 tar file
  64. return this->Superclass::PackageFiles();
  65. }
  66. const char* cmCPackCygwinBinaryGenerator::GetOutputExtension()
  67. {
  68. this->OutputExtension = "-";
  69. const char* patchNumber =this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
  70. if(!patchNumber)
  71. {
  72. patchNumber = "1";
  73. cmCPackLogger(cmCPackLog::LOG_WARNING,
  74. "CPACK_CYGWIN_PATCH_NUMBER not specified using 1"
  75. << std::endl);
  76. }
  77. this->OutputExtension += patchNumber;
  78. this->OutputExtension += ".tar.bz2";
  79. return this->OutputExtension.c_str();
  80. }