aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bpkg/pkg-build.cxx34
-rw-r--r--tests/pkg-build.testscript62
2 files changed, 82 insertions, 14 deletions
diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx
index 46569df..d67de51 100644
--- a/bpkg/pkg-build.cxx
+++ b/bpkg/pkg-build.cxx
@@ -549,6 +549,7 @@ namespace bpkg
database& ddb (i->db != nullptr ? *i->db : db);
const optional<version_constraint>& dvc (i->constraint); // May be nullopt.
bool dsys (i->system);
+ bool deorphan (i->deorphan);
// The selected package in the desired database which we copy over.
//
@@ -560,14 +561,16 @@ namespace bpkg
: ddb.find<selected_package> (nm));
// If a package in the desired database is already selected and matches
- // the user expectations then no package change is required.
+ // the user expectations then no package change is required, unless the
+ // package also needs to be deorphaned.
//
if (dsp != nullptr && dvc)
{
const version& sv (dsp->version);
bool ssys (dsp->system ());
- if (ssys == dsys &&
+ if (!deorphan &&
+ ssys == dsys &&
(ssys ? sv == *dvc->min_version : satisfies (sv, dvc)))
{
l5 ([&]{trace << *dsp << ddb << ": unchanged";});
@@ -604,7 +607,7 @@ namespace bpkg
ddb,
dsp,
i->upgrade,
- i->deorphan,
+ deorphan,
true /* explicitly */,
repo_frags,
dpt_constrs,
@@ -968,29 +971,32 @@ namespace bpkg
}
else
{
- // If the best satisfactory version and the desired system flag
- // perfectly match the ones of the selected package, then no package
- // change is required, unless we are deorphaning. Otherwise, recommend
- // an upgrade/downgrade/deorphaning.
+ // In the up/downgrade+deorphan mode always replace the dependency,
+ // re-fetching it from an existing repository if the version stays the
+ // same.
//
- if (dsp != nullptr &&
- av == dsp->version &&
- dsp->system () == dsys &&
- !deorphan)
+ if (deorphan)
+ return deorphan_result (move (af), "constrained version");
+
+ // For the regular up/downgrade if the best satisfactory version and
+ // the desired system flag perfectly match the ones of the selected
+ // package, then no package change is required. Otherwise, recommend
+ // an upgrade/downgrade.
+ //
+ if (dsp != nullptr && av == dsp->version && dsp->system () == dsys)
{
l5 ([&]{trace << *dsp << ddb << ": unchanged";});
return no_change ();
}
- l5 ([&]{trace << *sp << db << ": update"
- << (deorphan ? "/deorphan" : "") << " to "
+ l5 ([&]{trace << *sp << db << ": update to "
<< package_string (nm, av, dsys) << ddb;});
return evaluate_result {
ddb, move (ap), move (af.second),
false /* unused */,
dsys,
- deorphan ? *dov : optional<version> ()};
+ nullopt /* orphan */};
}
}
diff --git a/tests/pkg-build.testscript b/tests/pkg-build.testscript
index fe7f9e6..370a977 100644
--- a/tests/pkg-build.testscript
+++ b/tests/pkg-build.testscript
@@ -19485,6 +19485,68 @@ else
$pkg_drop libbar
}
}
+
+ : same-version
+ :
+ {
+ : best-match
+ :
+ {
+ $clone_root_cfg;
+
+ $rep_add $rep/t1 && $rep_fetch;
+ $* libfoo 2>!;
+
+ $rep_add $rep/t2 && $rep_fetch;
+ $* libbar ?libfoo 2>!;
+
+ $rep_remove $rep/t1;
+
+ $* --deorphan ?libfoo 2>>~%EOE%;
+ replace/update libfoo/1.0.0
+ reconfigure libbar (dependent of libfoo)
+ disfigured libbar/1.0.0
+ disfigured libfoo/1.0.0
+ fetched libfoo/1.0.0
+ unpacked libfoo/1.0.0
+ configured libfoo/1.0.0
+ configured libbar/1.0.0
+ %info: .+libbar-1.0.0.+ is up to date%
+ updated libbar/1.0.0
+ EOE
+
+ $pkg_drop libbar
+ }
+
+ : constrained
+ :
+ {
+ $clone_root_cfg;
+
+ $rep_add $rep/t1 && $rep_fetch;
+ $* libfoo 2>!;
+
+ $rep_add $rep/t2 && $rep_fetch;
+ $* libbar ?libfoo 2>!;
+
+ $rep_remove $rep/t1;
+
+ $* --deorphan ?libfoo/1.0.0 2>>~%EOE%;
+ replace/update libfoo/1.0.0
+ reconfigure libbar (dependent of libfoo)
+ disfigured libbar/1.0.0
+ disfigured libfoo/1.0.0
+ fetched libfoo/1.0.0
+ unpacked libfoo/1.0.0
+ configured libfoo/1.0.0
+ configured libbar/1.0.0
+ %info: .+libbar-1.0.0.+ is up to date%
+ updated libbar/1.0.0
+ EOE
+
+ $pkg_drop libbar
+ }
+ }
}
: held