fix(package): never include the archive in itself; extend release-detail tests
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 9s

This commit is contained in:
faumaray committed 2026-12-04 05:04:44 +03:00
1 parent 691560a369
commit 2c4eeba945
7 files changed
+258 -1

No files matched your search

+16
View File
@@ -79,11 +79,27 @@ create_source_package(const std::filesystem::path &project_root,
std::format("create_source_package: '{}' is not a directory", project_root.string()))};
}
// The archive must never contain itself (or its in-progress staging file) when the output
// lives inside the project tree, e.g. a custom build directory that is not named `build`.
std::error_code output_ec;
const auto canonical_output = std::filesystem::weakly_canonical(output_tar, output_ec);
const bool have_output = !output_ec;
const auto is_output_path = [&](const std::filesystem::path &path) {
if (!have_output) {
return false;
}
std::error_code candidate_ec;
return std::filesystem::weakly_canonical(path, candidate_ec) == canonical_output;
};
std::vector<ArchiveEntrySpec> entries;
std::filesystem::recursive_directory_iterator it{
canon, std::filesystem::directory_options::skip_permission_denied, ec};
for (; !ec && it != std::filesystem::recursive_directory_iterator{}; it.increment(ec)) {
const auto rel = it->path().lexically_relative(canon);
if (is_output_path(it->path())) {
continue;
}
if (is_excluded_package_path(rel)) {
if (it->is_directory(ec)) {
it.disable_recursion_pending();