cmCPackPackageMakerGenerator.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 char* resdir,
  32. const char* script,
  33. const char* 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 char* name, const char *dirName);
  44. bool CopyResourcePlistFile(const char* 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. cmOStringStream& out);
  71. // Subroutine of WriteDistributionFile that writes out the
  72. // reverse dependency attributes for inter-component dependencies.
  73. void
  74. AddReverseDependencyAttributes(const cmCPackComponent& component,
  75. std::set<const cmCPackComponent *>& visited,
  76. cmOStringStream& out);
  77. // Generates XML that encodes the hierarchy of component groups and
  78. // their components in a form that can be used by distribution
  79. // metapackages.
  80. void CreateChoiceOutline(const cmCPackComponentGroup& group,
  81. cmOStringStream& out);
  82. /// Create the "choice" XML element to describe a component group
  83. /// for the installer GUI.
  84. void CreateChoice(const cmCPackComponentGroup& group,
  85. cmOStringStream& out);
  86. /// Create the "choice" XML element to describe a component for the
  87. /// installer GUI.
  88. void CreateChoice(const cmCPackComponent& component,
  89. cmOStringStream& out);
  90. // Escape the given string to make it usable as an XML attribute
  91. // value.
  92. std::string EscapeForXML(std::string str);
  93. // The PostFlight component when creating a metapackage
  94. cmCPackComponent PostFlightComponent;
  95. double PackageMakerVersion;
  96. double PackageCompatibilityVersion;
  97. };
  98. #endif