cmCPackCygwinBinaryGenerator.cxx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmCPackCygwinBinaryGenerator.h"
  4. #include "cmCPackLog.h"
  5. #include "cmGeneratedFileStream.h"
  6. #include "cmGlobalGenerator.h"
  7. #include "cmMakefile.h"
  8. #include "cmSystemTools.h"
  9. #include "cmake.h"
  10. #include "cmsys/SystemTools.hxx"
  11. cmCPackCygwinBinaryGenerator::cmCPackCygwinBinaryGenerator()
  12. {
  13. }
  14. cmCPackCygwinBinaryGenerator::~cmCPackCygwinBinaryGenerator()
  15. {
  16. }
  17. int cmCPackCygwinBinaryGenerator::InitializeInternal()
  18. {
  19. this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
  20. this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "0");
  21. return this->Superclass::InitializeInternal();
  22. }
  23. int cmCPackCygwinBinaryGenerator::PackageFiles()
  24. {
  25. std::string packageName = this->GetOption("CPACK_PACKAGE_NAME");
  26. packageName += "-";
  27. packageName += this->GetOption("CPACK_PACKAGE_VERSION");
  28. packageName = cmsys::SystemTools::LowerCase(packageName);
  29. std::string manifest = "/usr/share/doc/";
  30. manifest += packageName;
  31. manifest += "/MANIFEST";
  32. std::string manifestFile = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
  33. // Create a MANIFEST file that contains all of the files in
  34. // the tar file
  35. std::string tempdir = manifestFile;
  36. manifestFile += manifest;
  37. // create an extra scope to force the stream
  38. // to create the file before the super class is called
  39. {
  40. cmGeneratedFileStream ofs(manifestFile.c_str());
  41. for (std::vector<std::string>::const_iterator i = files.begin();
  42. i != files.end(); ++i) {
  43. // remove the temp dir and replace with /usr
  44. ofs << (*i).substr(tempdir.size()) << "\n";
  45. }
  46. ofs << manifest << "\n";
  47. }
  48. // add the manifest file to the list of all files
  49. files.push_back(manifestFile);
  50. // create the bzip2 tar file
  51. return this->Superclass::PackageFiles();
  52. }
  53. const char* cmCPackCygwinBinaryGenerator::GetOutputExtension()
  54. {
  55. this->OutputExtension = "-";
  56. const char* patchNumber = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
  57. if (!patchNumber) {
  58. patchNumber = "1";
  59. cmCPackLogger(cmCPackLog::LOG_WARNING,
  60. "CPACK_CYGWIN_PATCH_NUMBER not specified using 1"
  61. << std::endl);
  62. }
  63. this->OutputExtension += patchNumber;
  64. this->OutputExtension += ".tar.bz2";
  65. return this->OutputExtension.c_str();
  66. }