cmCPackPackageMakerGenerator.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc.
  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. #ifndef cmCPackPackageMakerGenerator_h
  11. #define cmCPackPackageMakerGenerator_h
  12. #include "cmCPackGenerator.h"
  13. class cmCPackComponent;
  14. /** \class cmCPackPackageMakerGenerator
  15. * \brief A generator for PackageMaker files
  16. *
  17. * http://developer.apple.com/documentation/Darwin
  18. * /Reference/ManPages/man1/packagemaker.1.html
  19. */
  20. class cmCPackPackageMakerGenerator : public cmCPackGenerator
  21. {
  22. public:
  23. cmCPackTypeMacro(cmCPackPackageMakerGenerator, cmCPackGenerator);
  24. /**
  25. * Construct generator
  26. */
  27. cmCPackPackageMakerGenerator();
  28. virtual ~cmCPackPackageMakerGenerator();
  29. virtual bool SupportsComponentInstallation() const;
  30. protected:
  31. int CopyInstallScript(const std::string& resdir,
  32. const std::string& script,
  33. const std::string& name);
  34. virtual int InitializeInternal();
  35. int PackageFiles();
  36. virtual const char* GetOutputExtension() { return ".dmg"; }
  37. virtual const char* GetOutputPostfix() { return "darwin"; }
  38. // Copies or creates the resource file with the given name to the
  39. // package or package staging directory dirName. The variable
  40. // CPACK_RESOURCE_FILE_${NAME} (where ${NAME} is the uppercased
  41. // version of name) specifies the input file to use for this file,
  42. // which will be configured via ConfigureFile.
  43. bool CopyCreateResourceFile(const std::string& name,
  44. const std::string& dirName);
  45. bool CopyResourcePlistFile(const std::string& name, const char* outName = 0);
  46. // Run PackageMaker with the given command line, which will (if
  47. // successful) produce the given package file. Returns true if
  48. // PackageMaker succeeds, false otherwise.
  49. bool RunPackageMaker(const char *command, const char *packageFile);
  50. // Retrieve the name of package file that will be generated for this
  51. // component. The name is just the file name with extension, and
  52. // does not include the subdirectory.
  53. std::string GetPackageName(const cmCPackComponent& component);
  54. // Generate a package in the file packageFile for the given
  55. // component. All of the files within this component are stored in
  56. // the directory packageDir. Returns true if successful, false
  57. // otherwise.
  58. bool GenerateComponentPackage(const char *packageFile,
  59. const char *packageDir,
  60. const cmCPackComponent& component);
  61. // Writes a distribution.dist file, which turns a metapackage into a
  62. // full-fledged distribution. This file is used to describe
  63. // inter-component dependencies. metapackageFile is the name of the
  64. // metapackage for the distribution. Only valid for a
  65. // component-based install.
  66. void WriteDistributionFile(const char* metapackageFile);
  67. // Subroutine of WriteDistributionFile that writes out the
  68. // dependency attributes for inter-component dependencies.
  69. void AddDependencyAttributes(const cmCPackComponent& component,
  70. std::set<const cmCPackComponent *>& visited,
  71. cmOStringStream& out);
  72. // Subroutine of WriteDistributionFile that writes out the
  73. // reverse dependency attributes for inter-component dependencies.
  74. void
  75. AddReverseDependencyAttributes(const cmCPackComponent& component,
  76. std::set<const cmCPackComponent *>& visited,
  77. cmOStringStream& out);
  78. // Generates XML that encodes the hierarchy of component groups and
  79. // their components in a form that can be used by distribution
  80. // metapackages.
  81. void CreateChoiceOutline(const cmCPackComponentGroup& group,
  82. cmOStringStream& out);
  83. /// Create the "choice" XML element to describe a component group
  84. /// for the installer GUI.
  85. void CreateChoice(const cmCPackComponentGroup& group,
  86. cmOStringStream& out);
  87. /// Create the "choice" XML element to describe a component for the
  88. /// installer GUI.
  89. void CreateChoice(const cmCPackComponent& component,
  90. cmOStringStream& out);
  91. // Escape the given string to make it usable as an XML attribute
  92. // value.
  93. std::string EscapeForXML(std::string str);
  94. // The PostFlight component when creating a metapackage
  95. cmCPackComponent PostFlightComponent;
  96. double PackageMakerVersion;
  97. unsigned int PackageCompatibilityVersion;
  98. };
  99. #endif