summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdriaan de Groot <groot@kde.org>2021-12-21 13:26:45 (GMT)
committerAdriaan de Groot <groot@kde.org>2021-12-21 13:29:59 (GMT)
commitc3715e08e44ea42a8d823b909dcd849051eacc63 (patch)
treea928cb2ae5539e0a4c2da2f65c029a38a5e0abe2
parenta76f19d5e836aa271b4e8161497112d79572642c (diff)
downloadCMake-c3715e08e44ea42a8d823b909dcd849051eacc63.zip
CMake-c3715e08e44ea42a8d823b909dcd849051eacc63.tar.gz
CMake-c3715e08e44ea42a8d823b909dcd849051eacc63.tar.bz2
FreeBSD: tidy up
- mismatched comments and code, - remove superfluous log of the "Real package" (which can still change! log the changed filename if it does), - the "fix up the package name" code was replacing the pkg 1.17 suffix by the pkg 1.17 suffix, so it wasn't really being useful. Whether **any** of the backwards- compatibility packaging code is useful is another thing.
-rw-r--r--Source/CPack/cmCPackFreeBSDGenerator.cxx22
1 files changed, 14 insertions, 8 deletions
diff --git a/Source/CPack/cmCPackFreeBSDGenerator.cxx b/Source/CPack/cmCPackFreeBSDGenerator.cxx
index bacb451..b5d41fc 100644
--- a/Source/CPack/cmCPackFreeBSDGenerator.cxx
+++ b/Source/CPack/cmCPackFreeBSDGenerator.cxx
@@ -28,7 +28,8 @@ static const char FreeBSDPackageSuffix_10[] = ".txz";
static const char FreeBSDPackageSuffix_17[] = ".pkg";
cmCPackFreeBSDGenerator::cmCPackFreeBSDGenerator()
- : cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr", FreeBSDPackageSuffix_17 /* old-style, updated if an old-style package is created */)
+ : cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr",
+ FreeBSDPackageSuffix_17)
{
}
@@ -63,7 +64,7 @@ public:
{
if (d) {
- pkg_create_set_format(d, FreeBSDPackageCompression); // Skip over the '.'
+ pkg_create_set_format(d, FreeBSDPackageCompression);
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());
@@ -378,7 +379,7 @@ int cmCPackFreeBSDGenerator::PackageFiles()
// 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('/');
+ auto 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
@@ -393,9 +394,6 @@ int cmCPackFreeBSDGenerator::PackageFiles()
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) {
@@ -442,8 +440,16 @@ int cmCPackFreeBSDGenerator::PackageFiles()
for (std::string& name : packageFileNames) {
if (cmHasSuffix(name, FreeBSDPackageSuffix_17) &&
!cmSystemTools::FileExists(name)) {
- const std::string suffix(FreeBSDPackageSuffix_17);
- name.replace(name.size() - suffix.size(), std::string::npos, suffix);
+ 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);
+ }
}
}