From aee787bce2b94a057ad8e6fd42e2cd901776e348 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 22 Apr 2021 15:32:09 +0300 Subject: Various cleanups --- bpkg/pkg-build.cxx | 27 +++++++++++++++++---------- bpkg/rep-fetch.cxx | 4 ++++ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx index 082696e..32a680f 100644 --- a/bpkg/pkg-build.cxx +++ b/bpkg/pkg-build.cxx @@ -107,7 +107,7 @@ namespace bpkg return r; } - // As above but only look for packages from the specified list fo repository + // As above but only look for packages from the specified list of repository // fragments, their prerequisite repositories, and their complements, // recursively (note: recursivity applies to complements, not // prerequisites). @@ -284,6 +284,8 @@ namespace bpkg { enum action_type { + // Available package is not NULL. + // build, // Selected package is not NULL, available package is NULL. @@ -1067,9 +1069,9 @@ namespace bpkg // Add our constraint, if we have one. // - // Note that we always add the constraint implied by the dependent. The - // user-implied constraint, if present, will be added when merging from - // the pre-entered entry. So we will have both constraints for + // Note that we always add the constraint implied by the dependent. + // The user-implied constraint, if present, will be added when merging + // from the pre-entered entry. So we will have both constraints for // completeness. // if (dp.constraint) @@ -1549,8 +1551,12 @@ namespace bpkg return p.available_name_version (); }; - for (chain.push_back (name); i != chain.end () - 1; ++i) - dr << info << nv (*i) << " depends on " << nv (*(i + 1)); + // Note: push_back() can invalidate the iterator. + // + size_t j (i - chain.begin ()); + + for (chain.push_back (name); j != chain.size () - 1; ++j) + dr << info << nv (chain[j]) << " depends on " << nv (chain[j + 1]); } } @@ -3180,8 +3186,8 @@ namespace bpkg // map package_map; - auto check_dup = [&package_map, &arg_string, arg_parsed] ( - const pkg_arg& pa) -> bool + auto check_dup = [&package_map, &arg_string, &arg_parsed] + (const pkg_arg& pa) -> bool { assert (arg_parsed (pa)); @@ -3904,7 +3910,6 @@ namespace bpkg if (scratch) { pkgs.clear (); - postponed.clear (); // Pre-enter dependencies to keep track of the desired versions and // options specified on the command line. In particular, if the @@ -4169,7 +4174,7 @@ namespace bpkg // make sure that the unsatisfiable dependency, if left, is // reported. // - auto need_refinement = [&eval_dep, &deps, rec_pkgs, &db, &o] ( + auto need_refinement = [&eval_dep, &deps, &rec_pkgs, &db, &o] ( bool diag = false) -> bool { // Examine the new dependency set for any up/down-grade/drops. @@ -4654,6 +4659,8 @@ namespace bpkg // if (sp != nullptr) { + assert (!sp->system ()); + transaction t (db, !simulate /* start */); pkg_purge (c, t, sp, simulate); // Commits the transaction. diff --git a/bpkg/rep-fetch.cxx b/bpkg/rep-fetch.cxx index 3239421..ef4c110 100644 --- a/bpkg/rep-fetch.cxx +++ b/bpkg/rep-fetch.cxx @@ -1444,6 +1444,10 @@ namespace bpkg // Add the repository, unless it is already a top-level one and has the // same location. // + // Note that on Windows we can overwrite the local repository location + // with the same location but some characters specified in a different + // case, which is ok. + // if (ua.find (r) == ua.end () || r.load ()->location.url () != rl.url ()) rep_add (o, t, rl); -- cgit v1.1