cmCPackDebGenerator.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 cmCPackDebGenerator_h
  11. #define cmCPackDebGenerator_h
  12. #include <cmConfigure.h>
  13. #include "cmCPackGenerator.h"
  14. #include "cmTypeMacro.h"
  15. #include <string>
  16. #include <vector>
  17. /** \class cmCPackDebGenerator
  18. * \brief A generator for Debian packages
  19. *
  20. */
  21. class cmCPackDebGenerator : public cmCPackGenerator
  22. {
  23. public:
  24. cmCPackTypeMacro(cmCPackDebGenerator, cmCPackGenerator);
  25. /**
  26. * Construct generator
  27. */
  28. cmCPackDebGenerator();
  29. ~cmCPackDebGenerator() CM_OVERRIDE;
  30. static bool CanGenerate()
  31. {
  32. #ifdef __APPLE__
  33. // on MacOS enable CPackDeb iff dpkg is found
  34. std::vector<std::string> locations;
  35. locations.push_back("/sw/bin"); // Fink
  36. locations.push_back("/opt/local/bin"); // MacPorts
  37. return cmSystemTools::FindProgram("dpkg", locations) != "" ? true : false;
  38. #else
  39. // legacy behavior on other systems
  40. return true;
  41. #endif
  42. }
  43. protected:
  44. int InitializeInternal() CM_OVERRIDE;
  45. /**
  46. * This method factors out the work done in component packaging case.
  47. */
  48. int PackageOnePack(std::string const& initialToplevel,
  49. std::string const& packageName);
  50. /**
  51. * The method used to package files when component
  52. * install is used. This will create one
  53. * archive for each component group.
  54. */
  55. int PackageComponents(bool ignoreGroup);
  56. /**
  57. * Special case of component install where all
  58. * components will be put in a single installer.
  59. */
  60. int PackageComponentsAllInOne(const std::string& compInstDirName);
  61. int PackageFiles() CM_OVERRIDE;
  62. const char* GetOutputExtension() CM_OVERRIDE { return ".deb"; }
  63. bool SupportsComponentInstallation() const CM_OVERRIDE;
  64. std::string GetComponentInstallDirNameSuffix(
  65. const std::string& componentName) CM_OVERRIDE;
  66. private:
  67. int createDeb();
  68. std::vector<std::string> packageFiles;
  69. };
  70. #endif