cmCPackCygwinBinaryGenerator.cxx 2.8 KB

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