svn commit: r566712 - in head/devel/cmake: . files
Adriaan de Groot
adridg at FreeBSD.org
Sat Feb 27 16:52:21 UTC 2021
Author: adridg
Date: Sat Feb 27 16:52:20 2021
New Revision: 566712
URL: https://svnweb.freebsd.org/changeset/ports/566712
Log:
Improve FreeBSD packaging in devel/cmake
The OPTION CPACK in CMake enables building FreeBSD packages directly
from cmake / cpack. This can be useful, for instance, with not-yet-
packaged software, or building packages for proprietary software.
This patch has been submitted upstream; it resolves a disagreement
between cmake and libpkg about the name of the resulting package.
Modified:
head/devel/cmake/Makefile
head/devel/cmake/files/patch-cmake-issue-18031
Modified: head/devel/cmake/Makefile
==============================================================================
--- head/devel/cmake/Makefile Sat Feb 27 16:50:21 2021 (r566711)
+++ head/devel/cmake/Makefile Sat Feb 27 16:52:20 2021 (r566712)
@@ -4,7 +4,7 @@
PORTNAME= cmake
# Remember to update devel/cmake-doc and devel/cmake-gui as well.
DISTVERSION= 3.19.5
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= devel
MASTER_SITES= https://github.com/Kitware/CMake/releases/download/v${DISTVERSION}/ \
https://www.cmake.org/files/v${PORTVERSION}/
Modified: head/devel/cmake/files/patch-cmake-issue-18031
==============================================================================
--- head/devel/cmake/files/patch-cmake-issue-18031 Sat Feb 27 16:50:21 2021 (r566711)
+++ head/devel/cmake/files/patch-cmake-issue-18031 Sat Feb 27 16:52:20 2021 (r566712)
@@ -1,11 +1,36 @@
-Use newer pkg_create() API
-
+diff --git Modules/Internal/CPack/CPackFreeBSD.cmake Modules/Internal/CPack/CPackFreeBSD.cmake
+index ae40532017..c35089cbcf 100644
+--- Modules/Internal/CPack/CPackFreeBSD.cmake
++++ Modules/Internal/CPack/CPackFreeBSD.cmake
+@@ -34,7 +34,7 @@ function(_cpack_freebsd_fallback_var OUTPUT_VAR_NAME)
+ endif()
+ endforeach()
+ if(NOT VALUE)
+- message(WARNING "Variable ${OUTPUT_VAR_NAME} could not be given a fallback value from any variable ${FALLBACK_VAR_NAMES}.")
++ message(WARNING "Variable ${OUTPUT_VAR_NAME} could not be given a fallback value from (any of) ${FALLBACK_VAR_NAMES}.")
+ endif()
+ endfunction()
+
diff --git Source/CPack/cmCPackFreeBSDGenerator.cxx Source/CPack/cmCPackFreeBSDGenerator.cxx
-index b673006f25..63c7810b15 100644
+index b673006f25..9bafc792db 100644
--- Source/CPack/cmCPackFreeBSDGenerator.cxx
+++ Source/CPack/cmCPackFreeBSDGenerator.cxx
-@@ -35,6 +35,56 @@ int cmCPackFreeBSDGenerator::InitializeInternal()
+@@ -21,8 +21,12 @@
+ #include <sys/stat.h>
+
++// Suffix including the '.', used to tell libpkg what compression to use
++static const char FreeBSDPackageSuffix[] = ".txz";
++
+ cmCPackFreeBSDGenerator::cmCPackFreeBSDGenerator()
+- : cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr", ".txz")
++ : cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr",
++ FreeBSDPackageSuffix)
+ {
+ }
+
+@@ -35,6 +39,56 @@ int cmCPackFreeBSDGenerator::InitializeInternal()
+
cmCPackFreeBSDGenerator::~cmCPackFreeBSDGenerator() = default;
+// This is a wrapper for struct pkg_create and pkg_create()
@@ -30,7 +55,7 @@ index b673006f25..63c7810b15 100644
+
+ {
+ if (d) {
-+ pkg_create_set_format(d, "txz");
++ pkg_create_set_format(d, FreeBSDPackageSuffix + 1); // Skip over the '.'
+ 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());
@@ -61,7 +86,16 @@ index b673006f25..63c7810b15 100644
// 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()
+@@ -271,7 +325,7 @@ void write_manifest_files(cmGeneratedFileStream& s,
+ s << "\"files\": {\n";
+ for (std::string const& file : files) {
+ s << " \"/" << cmSystemTools::RelativePath(toplevel, file) << "\": \""
+- << "<sha256>"
++ << "<sha256>" // this gets replaced by libpkg by the actual SHA256
+ << "\",\n";
+ }
+ s << " },\n";
+@@ -281,11 +335,10 @@ int cmCPackFreeBSDGenerator::PackageFiles()
{
if (!this->ReadListFile("Internal/CPack/CPackFreeBSD.cmake")) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
@@ -70,10 +104,40 @@ index b673006f25..63c7810b15 100644
return 0;
}
-@@ -317,9 +367,25 @@ int cmCPackFreeBSDGenerator::PackageFiles()
+- std::vector<std::string>::const_iterator fileIt;
+ cmWorkingDirectory wd(toplevel);
+
+ files.erase(std::remove_if(files.begin(), files.end(), ignore_file),
+@@ -317,17 +370,59 @@ int cmCPackFreeBSDGenerator::PackageFiles()
ONE_PACKAGE_PER_COMPONENT);
}
++ // There should be one name in the packageFileNames (already, see comment
++ // in cmCPackGenerator::DoPackage(), which holds what CPack guesses
++ // will be the package filename. libpkg does something else, though,
++ // so update the single filename to what we know will be right.
++ if (this->packageFileNames.size() == 1) {
++ std::string currentPackage = this->packageFileNames[0];
++ int lastSlash = currentPackage.rfind('/');
++
++ // If there is a pathname, preserve that; libpkg will write out
++ // a file with the package name and version as specified in the
++ // manifest, so we look those up (again). lastSlash is the slash
++ // itself, we need that as path separator to the calculated package name.
++ std::string actualPackage =
++ ((lastSlash != std::string::npos)
++ ? std::string(currentPackage, 0, lastSlash + 1)
++ : std::string()) +
++ var_lookup("CPACK_FREEBSD_PACKAGE_NAME") + '-' +
++ var_lookup("CPACK_FREEBSD_PACKAGE_VERSION") + FreeBSDPackageSuffix;
++
++ this->packageFileNames.clear();
++ this->packageFileNames.emplace_back(actualPackage);
++
++ cmCPackLogger(cmCPackLog::LOG_DEBUG,
++ "Real filename:" << this->packageFileNames[0] << std::endl);
++ }
++
+ if (!pkg_initialized() && pkg_init(NULL, NULL) != EPKG_OK) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Can not initialize FreeBSD libpkg." << std::endl);
@@ -97,4 +161,14 @@ index b673006f25..63c7810b15 100644
+ }
std::string broken_suffix =
- cmStrCat('-', var_lookup("CPACK_TOPLEVEL_TAG"), ".txz");
+- cmStrCat('-', var_lookup("CPACK_TOPLEVEL_TAG"), ".txz");
++ cmStrCat('-', var_lookup("CPACK_TOPLEVEL_TAG"), FreeBSDPackageSuffix);
+ for (std::string& name : packageFileNames) {
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Packagefile " << name << std::endl);
+ if (cmHasSuffix(name, broken_suffix)) {
+ name.replace(name.size() - broken_suffix.size(), std::string::npos,
+- ".txz");
++ FreeBSDPackageSuffix);
+ break;
+ }
+ }
More information about the svn-ports-head
mailing list