aboutsummaryrefslogtreecommitdiff
path: root/devel/cmake
diff options
context:
space:
mode:
authorAdriaan de Groot <adridg@FreeBSD.org>2021-02-23 23:24:26 +0000
committerAdriaan de Groot <adridg@FreeBSD.org>2021-02-23 23:24:26 +0000
commitab3e646b5ccbfc35aeaa3b5767595ebcb3d73575 (patch)
tree86c56c300f3034f47cae8fe05aac2b43e9bbd389 /devel/cmake
parent43fea2c6267d0b8222d44ea36f2989c77cee231e (diff)
downloadports-ab3e646b5ccbfc35aeaa3b5767595ebcb3d73575.tar.gz
ports-ab3e646b5ccbfc35aeaa3b5767595ebcb3d73575.zip
Update CMake's FreeBSD pkg(8) generator
There is an OPTION CPACK for CMake that enables a FreeBSD pkg(8) generator: after building anything CMake-based, `cpack -G FREEBSD` gives you a a ready-to-go installable package. Well, assuming you turn the option on, and the bugs in the generator are fixed. Which this patch does. I've tried it with supertux2 and some other bits and pieces and the patch is in a MR upstream.
Notes
Notes: svn path=/head/; revision=566434
Diffstat (limited to 'devel/cmake')
-rw-r--r--devel/cmake/Makefile1
-rw-r--r--devel/cmake/files/patch-cmake-issue-18031100
2 files changed, 101 insertions, 0 deletions
diff --git a/devel/cmake/Makefile b/devel/cmake/Makefile
index 7d712365a365..ba695932ebc2 100644
--- a/devel/cmake/Makefile
+++ b/devel/cmake/Makefile
@@ -4,6 +4,7 @@
PORTNAME= cmake
# Remember to update devel/cmake-doc and devel/cmake-gui as well.
DISTVERSION= 3.19.5
+PORTREVISION= 1
CATEGORIES= devel
MASTER_SITES= https://github.com/Kitware/CMake/releases/download/v${DISTVERSION}/ \
https://www.cmake.org/files/v${PORTVERSION}/
diff --git a/devel/cmake/files/patch-cmake-issue-18031 b/devel/cmake/files/patch-cmake-issue-18031
new file mode 100644
index 000000000000..38097b66e0f1
--- /dev/null
+++ b/devel/cmake/files/patch-cmake-issue-18031
@@ -0,0 +1,100 @@
+Use newer pkg_create() API
+
+diff --git Source/CPack/cmCPackFreeBSDGenerator.cxx Source/CPack/cmCPackFreeBSDGenerator.cxx
+index b673006f25..63c7810b15 100644
+--- Source/CPack/cmCPackFreeBSDGenerator.cxx
++++ Source/CPack/cmCPackFreeBSDGenerator.cxx
+@@ -35,6 +35,56 @@ int cmCPackFreeBSDGenerator::InitializeInternal()
+
+ cmCPackFreeBSDGenerator::~cmCPackFreeBSDGenerator() = default;
+
++// This is a wrapper for struct pkg_create and pkg_create()
++//
++// Instantiate this class with suitable parameters, then
++// check isValid() to check if it's ok. Afterwards, call
++// Create() to do the actual work. This will leave a package
++// in the given `output_dir`.
++//
++// This wrapper cleans up the struct pkg_create.
++class PkgCreate
++{
++public:
++ PkgCreate()
++ : d(nullptr)
++ {
++ }
++ PkgCreate(const std::string& output_dir, const std::string& toplevel_dir,
++ const std::string& manifest_name)
++ : d(pkg_create_new())
++ , manifest(manifest_name)
++
++ {
++ if (d) {
++ pkg_create_set_format(d, "txz");
++ pkg_create_set_compression_level(d, 0); // Explicitly set default
++ pkg_create_set_overwrite(d, false);
++ pkg_create_set_rootdir(d, toplevel_dir.c_str());
++ pkg_create_set_output_dir(d, output_dir.c_str());
++ }
++ }
++ ~PkgCreate()
++ {
++ if (d)
++ pkg_create_free(d);
++ }
++
++ bool isValid() const { return d; }
++
++ bool Create()
++ {
++ if (!isValid())
++ return false;
++ int r = pkg_create(d, manifest.c_str(), nullptr, false);
++ return r == 0;
++ }
++
++private:
++ struct pkg_create* d;
++ std::string manifest;
++};
++
+ // This is a wrapper, for use only in stream-based output,
+ // that will output a string in UCL escaped fashion (in particular,
+ // quotes and backslashes are escaped). The list of characters
+@@ -281,7 +331,7 @@ int cmCPackFreeBSDGenerator::PackageFiles()
+ {
+ if (!this->ReadListFile("Internal/CPack/CPackFreeBSD.cmake")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+- "Error while execution CPackFreeBSD.cmake" << std::endl);
++ "Error while executing CPackFreeBSD.cmake" << std::endl);
+ return 0;
+ }
+
+@@ -317,9 +367,25 @@ int cmCPackFreeBSDGenerator::PackageFiles()
+ ONE_PACKAGE_PER_COMPONENT);
+ }
+
++ if (!pkg_initialized() && pkg_init(NULL, NULL) != EPKG_OK) {
++ cmCPackLogger(cmCPackLog::LOG_ERROR,
++ "Can not initialize FreeBSD libpkg." << std::endl);
++ return 0;
++ }
++
+ std::string output_dir = cmSystemTools::CollapseFullPath("../", toplevel);
+- pkg_create_from_manifest(output_dir.c_str(), ::TXZ, toplevel.c_str(),
+- manifestname.c_str(), nullptr);
++ PkgCreate package(output_dir, toplevel, manifestname);
++ if (package.isValid()) {
++ if (!package.Create()) {
++ cmCPackLogger(cmCPackLog::LOG_ERROR,
++ "Error during pkg_create()" << std::endl);
++ return 0;
++ }
++ } else {
++ cmCPackLogger(cmCPackLog::LOG_ERROR,
++ "Error before pkg_create()" << std::endl);
++ return 0;
++ }
+
+ std::string broken_suffix =
+ cmStrCat('-', var_lookup("CPACK_TOPLEVEL_TAG"), ".txz");