ports/devel/cmake/files/patch-Source_CPack_cmCPackFreeBSDGenerator.cxx
Adriaan de Groot 86692a43de ntroduce OPTION for devel/cmake to generate packages
The generator causes segfaults because it doesn't call pkg_init()
(see https://gitlab.kitware.com/cmake/cmake/issues/18031).
This feature was briefly enabled by default for 3.11.0, between
r467437 (added) and r467620 (removed), but causes problems with
stage-qa (PR 227372). Hide it behind an OPTION for people who want
it and don't worry about stage-qa.

The patch to CPack source will be submitted upstream once some
corner cases are ironed out.

Reported by:	upstream
Approved by:	tcberner
Differential Revision:	https://reviews.freebsd.org/D15900
2018-06-20 09:00:53 +00:00

18 lines
698 B
C++

diff --git Source/CPack/cmCPackFreeBSDGenerator.cxx Source/CPack/cmCPackFreeBSDGenerator.cxx
index 91ae1a23f..a676302e7 100644
--- Source/CPack/cmCPackFreeBSDGenerator.cxx
+++ Source/CPack/cmCPackFreeBSDGenerator.cxx
@@ -339,6 +339,13 @@ int cmCPackFreeBSDGenerator::PackageFiles()
std::string output_dir =
cmSystemTools::CollapseCombinedPath(toplevel, "../");
+ if (!pkg_initialized() && pkg_init(NULL, NULL) != EPKG_OK)
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Can not initialize libpkg." << std::endl);
+ return 0;
+ }
+
pkg_create_from_manifest(output_dir.c_str(), ::TXZ, toplevel.c_str(),
manifestname.c_str(), NULL);