From e37c6b4f00a429693a5568aaca81d65e41b02768 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 1 Jul 2024 16:22:59 +0300 Subject: Some diagnostics/tracing cleanups --- bpkg/pkg-build.cxx | 32 +++++++++++++++++++++++--------- bpkg/pkg-fetch.cxx | 9 ++++++++- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx index de8d3ec..f0f01ad 100644 --- a/bpkg/pkg-build.cxx +++ b/bpkg/pkg-build.cxx @@ -849,7 +849,13 @@ namespace bpkg // using sp_set = set; - vector> unsatisfiable; + // If there are no available package versions which don't satisfy some + // dependents, then it is left absent. Otherwise, it is filled with the + // unsatisfiable versions together with the respective unsatisfied + // dependents, unless we are in the ignore unsatisfiable mode, in which + // case it is empty. + // + optional>> unsatisfiable; bool stub (false); @@ -1023,8 +1029,11 @@ namespace bpkg if (!satisfactory) { + if (!unsatisfiable) + unsatisfiable = vector> (); + if (!ignore_unsatisfiable) - unsatisfiable.emplace_back (av, move (unsatisfied_dependents)); + unsatisfiable->emplace_back (av, move (unsatisfied_dependents)); // If the dependency is expected to be configured as system, then bail // out, as an available package version will always resolve to the @@ -1201,7 +1210,7 @@ namespace bpkg if (ignore_unsatisfiable) { l5 ([&]{trace << package_string (nm, dvc, dsys) << ddb - << (unsatisfiable.empty () + << (!unsatisfiable ? ": no source" : ": unsatisfiable");}); @@ -1211,7 +1220,7 @@ namespace bpkg // If there are no unsatisfiable versions then the package is not present // (or is not available in source) in its dependents' repositories. // - if (unsatisfiable.empty ()) + if (!unsatisfiable) { diag_record dr (fail); @@ -1245,6 +1254,11 @@ namespace bpkg } } + // If not in the ignore-unsatisfiable mode the unsatisfiable list is + // either absent or non-empty. + // + assert (!unsatisfiable->empty ()); + // Issue the diagnostics and fail. // diag_record dr (fail); @@ -1255,9 +1269,9 @@ namespace bpkg // dependents each. // size_t nv (0); - for (const auto& u: unsatisfiable) + for (const auto& u: *unsatisfiable) { - dr << info << package_string (nm, u.first) << " doesn't satisfy"; + dr << info << package_string (nm, u.first, dsys) << " doesn't satisfy"; const sp_set& ps (u.second); @@ -1276,12 +1290,12 @@ namespace bpkg if (i != n) dr << " and " << n - i << " more"; - if (++nv == 3 && unsatisfiable.size () != 4) + if (++nv == 3 && unsatisfiable->size () != 4) break; } - if (nv != unsatisfiable.size ()) - dr << info << "and " << unsatisfiable.size () - nv << " more"; + if (nv != unsatisfiable->size ()) + dr << info << "and " << unsatisfiable->size () - nv << " more"; dr << endf; } diff --git a/bpkg/pkg-fetch.cxx b/bpkg/pkg-fetch.cxx index 837c968..2c36b62 100644 --- a/bpkg/pkg-fetch.cxx +++ b/bpkg/pkg-fetch.cxx @@ -252,9 +252,16 @@ namespace bpkg fail << "package " << n << " " << v << " is not available from an archive-based repository"; - if (verb > 1) + // @@ Shouldn't we do the same (only print progress if verb > 1 && + // !simulate and trace otherwise) also for pkg_checkout() and + // pkg_unpack()? + // + if (verb > 1 && !simulate) text << "fetching " << pl->location.leaf () << " " << "from " << pl->repository_fragment->name; + else + l4 ([&]{trace << pl->location.leaf () << " from " + << pl->repository_fragment->name << pdb;}); auto_rmfile arm; path an (pl->location.leaf ()); -- cgit v1.1