1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-19 19:43:23 +08:00

FreeBSD: follow CPACK_PACKAGE_FILE_NAME, if set

The underlying pkg library always produces a <name>-<version>.pkg
file, so to follow CPACK_PACKAGE_FILE_NAME we need to detect
that and rename appropriately.

FIXES #23034
This commit is contained in:
Adriaan de Groot
2022-07-05 16:00:43 +02:00
parent 50580af645
commit 2655605261

View File

@@ -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 <name>-<version>.<suffix>,
// 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;
}