cmCPackCygwinBinaryGenerator.cxx 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 "cmake.h"
  12. #include "cmGlobalGenerator.h"
  13. #include "cmLocalGenerator.h"
  14. #include "cmSystemTools.h"
  15. #include "cmMakefile.h"
  16. #include "cmGeneratedFileStream.h"
  17. #include "cmCPackLog.h"
  18. #include <cmsys/SystemTools.hxx>
  19. //----------------------------------------------------------------------
  20. cmCPackCygwinBinaryGenerator::cmCPackCygwinBinaryGenerator()
  21. {
  22. }
  23. //----------------------------------------------------------------------
  24. cmCPackCygwinBinaryGenerator::~cmCPackCygwinBinaryGenerator()
  25. {
  26. }
  27. //----------------------------------------------------------------------
  28. int cmCPackCygwinBinaryGenerator::InitializeInternal()
  29. {
  30. this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
  31. this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "0");
  32. return this->Superclass::InitializeInternal();
  33. }
  34. //----------------------------------------------------------------------
  35. int cmCPackCygwinBinaryGenerator::PackageFiles()
  36. {
  37. std::string packageName = this->GetOption("CPACK_PACKAGE_NAME");
  38. packageName += "-";
  39. packageName += this->GetOption("CPACK_PACKAGE_VERSION");
  40. packageName = cmsys::SystemTools::LowerCase(packageName);
  41. std::string manifest = "/usr/share/doc/";
  42. manifest += packageName;
  43. manifest += "/MANIFEST";
  44. std::string manifestFile
  45. = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
  46. // Create a MANIFEST file that contains all of the files in
  47. // the tar file
  48. std::string tempdir = manifestFile;
  49. manifestFile += manifest;
  50. // create an extra scope to force the stream
  51. // to create the file before the super class is called
  52. {
  53. cmGeneratedFileStream ofs(manifestFile.c_str());
  54. for(std::vector<std::string>::const_iterator i = files.begin();
  55. i != files.end(); ++i)
  56. {
  57. // remove the temp dir and replace with /usr
  58. ofs << (*i).substr(tempdir.size()) << "\n";
  59. }
  60. ofs << manifest << "\n";
  61. }
  62. // add the manifest file to the list of all files
  63. files.push_back(manifestFile);
  64. // create the bzip2 tar file
  65. return this->Superclass::PackageFiles();
  66. }
  67. const char* cmCPackCygwinBinaryGenerator::GetOutputExtension()
  68. {
  69. this->OutputExtension = "-";
  70. const char* patchNumber =this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
  71. if(!patchNumber)
  72. {
  73. patchNumber = "1";
  74. cmCPackLogger(cmCPackLog::LOG_WARNING,
  75. "CPACK_CYGWIN_PATCH_NUMBER not specified using 1"
  76. << std::endl);
  77. }
  78. this->OutputExtension += patchNumber;
  79. this->OutputExtension += ".tar.bz2";
  80. return this->OutputExtension.c_str();
  81. }