cmCPackCygwinBinaryGenerator.cxx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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::string const& file : files) {
  42. // remove the temp dir and replace with /usr
  43. ofs << file.substr(tempdir.size()) << "\n";
  44. }
  45. ofs << manifest << "\n";
  46. }
  47. // add the manifest file to the list of all files
  48. files.push_back(manifestFile);
  49. // create the bzip2 tar file
  50. return this->Superclass::PackageFiles();
  51. }
  52. const char* cmCPackCygwinBinaryGenerator::GetOutputExtension()
  53. {
  54. this->OutputExtension = "-";
  55. const char* patchNumber = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
  56. if (!patchNumber) {
  57. patchNumber = "1";
  58. cmCPackLogger(cmCPackLog::LOG_WARNING,
  59. "CPACK_CYGWIN_PATCH_NUMBER not specified using 1"
  60. << std::endl);
  61. }
  62. this->OutputExtension += patchNumber;
  63. this->OutputExtension += ".tar.bz2";
  64. return this->OutputExtension.c_str();
  65. }