From d681335bc7650cea9fb04653893a9deb9e479af7 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-checkout.cxx | 5 ++++- bpkg/pkg-fetch.cxx | 5 ++++- bpkg/pkg-unpack.cxx | 5 ++++- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx index de8d3ec..ca982a1 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,17 +1210,22 @@ namespace bpkg if (ignore_unsatisfiable) { l5 ([&]{trace << package_string (nm, dvc, dsys) << ddb - << (unsatisfiable.empty () + << (!unsatisfiable ? ": no source" : ": unsatisfiable");}); return no_change (); } + // If not in the ignore-unsatisfiable mode the unsatisfiable list is + // either absent or non-empty. + // + assert (!unsatisfiable || !unsatisfiable->empty ()); + // 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); @@ -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-checkout.cxx b/bpkg/pkg-checkout.cxx index 81efdc2..6bf9443 100644 --- a/bpkg/pkg-checkout.cxx +++ b/bpkg/pkg-checkout.cxx @@ -167,9 +167,12 @@ namespace bpkg fail << "package " << n << " " << v << " is not available from a version control-based repository"; - if (verb > 1) + if (verb > 1 && !simulate) text << "checking out " << pl->location.leaf () << " " << "from " << pl->repository_fragment->name; + else + l4 ([&]{trace << pl->location.leaf () << " from " + << pl->repository_fragment->name << pdb;}); const repository_location& rl (pl->repository_fragment->location); diff --git a/bpkg/pkg-fetch.cxx b/bpkg/pkg-fetch.cxx index 837c968..8126e69 100644 --- a/bpkg/pkg-fetch.cxx +++ b/bpkg/pkg-fetch.cxx @@ -252,9 +252,12 @@ namespace bpkg fail << "package " << n << " " << v << " is not available from an archive-based repository"; - if (verb > 1) + 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 ()); diff --git a/bpkg/pkg-unpack.cxx b/bpkg/pkg-unpack.cxx index 22ff02f..8437ea6 100644 --- a/bpkg/pkg-unpack.cxx +++ b/bpkg/pkg-unpack.cxx @@ -317,9 +317,12 @@ namespace bpkg fail << "package " << n << " " << v << " is not available from a directory-based repository"; - if (verb > 1) + if (verb > 1 && !simulate) text << "unpacking " << pl->location.leaf () << " " << "from " << pl->repository_fragment->name; + else + l4 ([&]{trace << pl->location.leaf () << " from " + << pl->repository_fragment->name << pdb;}); const repository_location& rl (pl->repository_fragment->location); -- cgit v1.1