cmCPackPackageMakerGenerator.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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, const std::string& script,
  32. const std::string& name);
  33. virtual int InitializeInternal();
  34. int PackageFiles();
  35. virtual const char* GetOutputExtension() { return ".dmg"; }
  36. virtual const char* GetOutputPostfix() { return "darwin"; }
  37. // Copies or creates the resource file with the given name to the
  38. // package or package staging directory dirName. The variable
  39. // CPACK_RESOURCE_FILE_${NAME} (where ${NAME} is the uppercased
  40. // version of name) specifies the input file to use for this file,
  41. // which will be configured via ConfigureFile.
  42. bool CopyCreateResourceFile(const std::string& name,
  43. const std::string& dirName);
  44. bool CopyResourcePlistFile(const std::string& name, const char* outName = 0);
  45. // Run PackageMaker with the given command line, which will (if
  46. // successful) produce the given package file. Returns true if
  47. // PackageMaker succeeds, false otherwise.
  48. bool RunPackageMaker(const char* command, const char* packageFile);
  49. // Retrieve the name of package file that will be generated for this
  50. // component. The name is just the file name with extension, and
  51. // does not include the subdirectory.
  52. std::string GetPackageName(const cmCPackComponent& component);
  53. // Generate a package in the file packageFile for the given
  54. // component. All of the files within this component are stored in
  55. // the directory packageDir. Returns true if successful, false
  56. // otherwise.
  57. bool GenerateComponentPackage(const char* packageFile,
  58. const char* packageDir,
  59. const cmCPackComponent& component);
  60. // Writes a distribution.dist file, which turns a metapackage into a
  61. // full-fledged distribution. This file is used to describe
  62. // inter-component dependencies. metapackageFile is the name of the
  63. // metapackage for the distribution. Only valid for a
  64. // component-based install.
  65. void WriteDistributionFile(const char* metapackageFile);
  66. // Subroutine of WriteDistributionFile that writes out the
  67. // dependency attributes for inter-component dependencies.
  68. void AddDependencyAttributes(const cmCPackComponent& component,
  69. std::set<const cmCPackComponent*>& visited,
  70. std::ostringstream& out);
  71. // Subroutine of WriteDistributionFile that writes out the
  72. // reverse dependency attributes for inter-component dependencies.
  73. void AddReverseDependencyAttributes(
  74. const cmCPackComponent& component,
  75. std::set<const cmCPackComponent*>& visited, std::ostringstream& out);
  76. // Generates XML that encodes the hierarchy of component groups and
  77. // their components in a form that can be used by distribution
  78. // metapackages.
  79. void CreateChoiceOutline(const cmCPackComponentGroup& group,
  80. std::ostringstream& out);
  81. /// Create the "choice" XML element to describe a component group
  82. /// for the installer GUI.
  83. void CreateChoice(const cmCPackComponentGroup& group,
  84. std::ostringstream& out);
  85. /// Create the "choice" XML element to describe a component for the
  86. /// installer GUI.
  87. void CreateChoice(const cmCPackComponent& component,
  88. std::ostringstream& out);
  89. // Escape the given string to make it usable as an XML attribute
  90. // value.
  91. std::string EscapeForXML(std::string str);
  92. // The PostFlight component when creating a metapackage
  93. cmCPackComponent PostFlightComponent;
  94. double PackageMakerVersion;
  95. unsigned int PackageCompatibilityVersion;
  96. };
  97. #endif