cmCPackDebGenerator.h 1.9 KB

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