From 57e8cd1a8172f864a9341f5842726f98aef908c2 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 5 Jul 2022 11:42:00 +0200 Subject: FreeBSD: drop support for libpkg before 1.17 All supported FreeBSD versions are now using 1.17 or later --- Source/CPack/cmCPackFreeBSDGenerator.cxx | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/Source/CPack/cmCPackFreeBSDGenerator.cxx b/Source/CPack/cmCPackFreeBSDGenerator.cxx index 607d797..9f04925 100644 --- a/Source/CPack/cmCPackFreeBSDGenerator.cxx +++ b/Source/CPack/cmCPackFreeBSDGenerator.cxx @@ -23,8 +23,6 @@ // Suffix used to tell libpkg what compression to use static const char FreeBSDPackageCompression[] = "txz"; -// Resulting package file-suffix, for < 1.17 and >= 1.17 versions of libpkg -static const char FreeBSDPackageSuffix_10[] = ".txz"; static const char FreeBSDPackageSuffix_17[] = ".pkg"; cmCPackFreeBSDGenerator::cmCPackFreeBSDGenerator() @@ -416,42 +414,17 @@ int cmCPackFreeBSDGenerator::PackageFiles() return 0; } - // Specifically looking for packages suffixed with the TAG, either extension - std::string broken_suffix_10 = - cmStrCat('-', var_lookup("CPACK_TOPLEVEL_TAG"), FreeBSDPackageSuffix_10); + // Specifically looking for packages suffixed with the TAG std::string broken_suffix_17 = cmStrCat('-', var_lookup("CPACK_TOPLEVEL_TAG"), FreeBSDPackageSuffix_17); for (std::string& name : packageFileNames) { cmCPackLogger(cmCPackLog::LOG_DEBUG, "Packagefile " << name << std::endl); - if (cmHasSuffix(name, broken_suffix_10)) { - name.replace(name.size() - broken_suffix_10.size(), std::string::npos, - FreeBSDPackageSuffix_10); - break; - } if (cmHasSuffix(name, broken_suffix_17)) { name.replace(name.size() - broken_suffix_17.size(), std::string::npos, FreeBSDPackageSuffix_17); break; } } - // If the name uses a *new* style name, which doesn't exist, but there - // is an *old* style name, then use that instead. This indicates we used - // an older libpkg, which still creates .txz instead of .pkg files. - for (std::string& name : packageFileNames) { - if (cmHasSuffix(name, FreeBSDPackageSuffix_17) && - !cmSystemTools::FileExists(name)) { - const std::string badSuffix(FreeBSDPackageSuffix_17); - const std::string goodSuffix(FreeBSDPackageSuffix_10); - std::string repairedName(name); - repairedName.replace(repairedName.size() - badSuffix.size(), - std::string::npos, goodSuffix); - if (cmSystemTools::FileExists(repairedName)) { - name = repairedName; - cmCPackLogger(cmCPackLog::LOG_DEBUG, - "Repaired packagefile " << name << std::endl); - } - } - } return 1; } -- cgit v0.12 From 1b61cd1597068dbba2ef1ac6018339cf91c19b70 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 5 Jul 2022 14:24:31 +0200 Subject: FreeBSD: explain the pkg_create() call - the upstream API is undocumented, so dig in the C sources to get parameter names. --- Source/CPack/cmCPackFreeBSDGenerator.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/CPack/cmCPackFreeBSDGenerator.cxx b/Source/CPack/cmCPackFreeBSDGenerator.cxx index 9f04925..4f07ad4 100644 --- a/Source/CPack/cmCPackFreeBSDGenerator.cxx +++ b/Source/CPack/cmCPackFreeBSDGenerator.cxx @@ -81,6 +81,14 @@ public: { if (!isValid()) return false; + // The API in the FreeBSD sources (the header has no documentation), + // is as follows: + // + // int pkg_create(struct pkg_create *pc, const char *metadata, const char + // *plist, bool hash) + // + // We let the plist be determined from what is installed, and all + // the rest comes from the manifest data. int r = pkg_create(d, manifest.c_str(), nullptr, false); return r == 0; } -- cgit v0.12 From 50580af6456ce178fc8ad69ec3aa19371c25be1e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 5 Jul 2022 14:33:59 +0200 Subject: FreeBSD (docs): repair errors in documentation of FreeBSD-cpack --- Help/cpack_gen/freebsd.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Help/cpack_gen/freebsd.rst b/Help/cpack_gen/freebsd.rst index f429bc5..faf8c74 100644 --- a/Help/cpack_gen/freebsd.rst +++ b/Help/cpack_gen/freebsd.rst @@ -62,8 +62,6 @@ the RPM information (e.g. package license). - :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` (this is always set by CPack itself, if nothing else sets it explicitly). - - :variable:`PROJECT_DESCRIPTION` (this can be set with the DESCRIPTION - parameter for :command:`project`). .. variable:: CPACK_FREEBSD_PACKAGE_DESCRIPTION @@ -75,6 +73,10 @@ the RPM information (e.g. package license). - :variable:`CPACK_DEBIAN_PACKAGE_DESCRIPTION` (this may be set already for Debian packaging, so it is used as a fallback). + - :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` (this is always set + by CPack itself, if nothing else sets it explicitly). + - :variable:`PROJECT_DESCRIPTION` (this can be set with the DESCRIPTION + parameter for :command:`project`). .. variable:: CPACK_FREEBSD_PACKAGE_WWW @@ -85,12 +87,12 @@ the RPM information (e.g. package license). * Mandatory: YES * Default: - - :variable:`CMAKE_PROJECT_HOMEPAGE_URL`, or if that is not set, - :variable:`CPACK_DEBIAN_PACKAGE_HOMEPAGE` (this may be set already + - :variable:`CPACK_PACKAGE_HOMEPAGE_URL`, or if that is not set, + - :variable:`CPACK_DEBIAN_PACKAGE_HOMEPAGE` (this may be set already for Debian packaging, so it is used as a fallback). .. versionadded:: 3.12 - The ``CMAKE_PROJECT_HOMEPAGE_URL`` variable. + The ``CPACK_PACKAGE_HOMEPAGE_URL`` variable. .. variable:: CPACK_FREEBSD_PACKAGE_LICENSE -- cgit v0.12 From 2655605261fc3cbf3e951b0f17f137bddf2dcaac Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 5 Jul 2022 16:00:43 +0200 Subject: FreeBSD: follow CPACK_PACKAGE_FILE_NAME, if set The underlying pkg library always produces a -.pkg file, so to follow CPACK_PACKAGE_FILE_NAME we need to detect that and rename appropriately. FIXES #23034 --- Source/CPack/cmCPackFreeBSDGenerator.cxx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Source/CPack/cmCPackFreeBSDGenerator.cxx b/Source/CPack/cmCPackFreeBSDGenerator.cxx index 4f07ad4..162dfc7 100644 --- a/Source/CPack/cmCPackFreeBSDGenerator.cxx +++ b/Source/CPack/cmCPackFreeBSDGenerator.cxx @@ -408,7 +408,8 @@ int cmCPackFreeBSDGenerator::PackageFiles() return 0; } - std::string output_dir = cmSystemTools::CollapseFullPath("../", toplevel); + const std::string output_dir = + cmSystemTools::CollapseFullPath("../", toplevel); PkgCreate package(output_dir, toplevel, manifestname); if (package.isValid()) { if (!package.Create()) { @@ -434,5 +435,23 @@ int cmCPackFreeBSDGenerator::PackageFiles() } } + const std::string packageFileName = + var_lookup("CPACK_PACKAGE_FILE_NAME") + FreeBSDPackageSuffix_17; + if (packageFileNames.size() == 1 && !packageFileName.empty() && + packageFileNames[0] != packageFileName) { + // Since libpkg always writes -., + // if there is a CPACK_PACKAGE_FILE_NAME set, we need to + // rename, and then re-set the name. + const std::string sourceFile = packageFileNames[0]; + const std::string packageSubDirectory = + cmSystemTools::GetParentDirectory(sourceFile); + const std::string targetFileName = + packageSubDirectory + '/' + packageFileName; + if (cmSystemTools::RenameFile(sourceFile, targetFileName)) { + this->packageFileNames.clear(); + this->packageFileNames.emplace_back(targetFileName); + } + } + return 1; } -- cgit v0.12