aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2021-07-29 13:32:33 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2021-07-29 13:34:24 +0300
commitaaf8e696886f443cd095ca7a5f37fc5b1ce0e207 (patch)
tree1aeae6b2e1cce3373d3a8e0e07d691648e51f2f6
parent74628852308bfa52946d3609f1730691d9a961d5 (diff)
Fix selection between two equal build entries in pkg-build
Wrong selection was causing redundant prerequisites recollection.
-rw-r--r--bpkg/pkg-build.cxx31
1 files changed, 13 insertions, 18 deletions
diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx
index cc90c29..f2af79a 100644
--- a/bpkg/pkg-build.cxx
+++ b/bpkg/pkg-build.cxx
@@ -705,16 +705,12 @@ namespace bpkg
build_package* p1 (&bp);
build_package* p2 (&pkg);
- if (p1->available_version () != p2->available_version ())
+ // Pick with the following preference order: user selection over
+ // implicit one, source package over a system one, newer version
+ // over an older one. So get the preferred into p1 and the other
+ // into p2.
+ //
{
- using constraint_type = build_package::constraint_type;
-
- // If the versions differ, we have to pick one. Pick with the
- // following preference order: user selection over implicit one,
- // source package over a system one, newer version over an older
- // one. So get the preferred to try into p1 and the other to try
- // -- into p2.
- //
int us (p1->user_selection () - p2->user_selection ());
int sf (p1->system - p2->system);
@@ -724,6 +720,14 @@ namespace bpkg
sf == 0 &&
p2->available_version () > p1->available_version ()))
swap (p1, p2);
+ }
+
+ // If the versions differ, pick the satisfactory one and if both are
+ // satisfactory, then keep the preferred.
+ //
+ if (p1->available_version () != p2->available_version ())
+ {
+ using constraint_type = build_package::constraint_type;
// See if pv's version satisfies pc's constraints. Return the
// pointer to the unsatisfied constraint or NULL if all are
@@ -770,15 +774,6 @@ namespace bpkg
l4 ([&]{trace << "pick " << p1->available_name_version_db ()
<< " over " << p2->available_name_version_db ();});
}
- // If versions are the same, then we still need to pick the entry as
- // one of them can build a package from source while another
- // configure a system package. We prefer a user-selected entry (if
- // there is one). If none of them is user-selected we prefer a
- // source package over a system one.
- //
- else if (p2->user_selection () ||
- (!p1->user_selection () && !p2->system))
- swap (p1, p2);
// See if we are replacing the object. If not, then we don't
// need to collect its prerequisites since that should have