aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bpkg/pkg-build.cxx28
-rw-r--r--tests/pkg-build.testscript115
2 files changed, 118 insertions, 25 deletions
diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx
index 9096026..7002b0f 100644
--- a/bpkg/pkg-build.cxx
+++ b/bpkg/pkg-build.cxx
@@ -975,13 +975,14 @@ namespace bpkg
bp.constraints.emplace_back (name.string (), *dp.constraint);
// Now collect this prerequisite. If it was actually collected
- // (i.e., it wasn't already there) and we are forcing an upgrade
- // and the version is not held, then warn, unless we are running
- // quiet. Downgrade or upgrade of a held version -- refuse.
+ // (i.e., it wasn't already there) and we are forcing a downgrade or
+ // upgrade, then refuse for a held version, warn for a held package,
+ // and print the info message otherwise, unless the verbosity level is
+ // less than two.
//
// Note though that while the prerequisite was collected it could have
// happen because it is an optional package and so not being
- // pre-collected earlier. Meanwhile the package version was specified
+ // pre-collected earlier. Meanwhile the package was specified
// explicitly and we shouldn't consider that as a dependency-driven
// up/down-grade enforcement.
//
@@ -996,19 +997,24 @@ namespace bpkg
if (p != nullptr && force && !dep_optional)
{
- const version& av (p->available_version ());
-
- // Fail if downgrade non-system package or held.
+ // Fail if the version is held. Otherwise, warn if the package is
+ // held.
//
- bool u (av > dsp->version);
- bool f (dsp->hold_version || (!u && !dsp->system ()));
+ bool f (dsp->hold_version);
+ bool w (!f && dsp->hold_package);
- if (verb || f)
+ if (f || w || verb >= 2)
{
+ const version& av (p->available_version ());
+
+ bool u (av > dsp->version);
bool c (d.constraint);
+
diag_record dr;
- (f ? dr << fail : dr << warn)
+ (f ? dr << fail :
+ w ? dr << warn :
+ dr << info)
<< "package " << name << " dependency on "
<< (c ? "(" : "") << d << (c ? ")" : "") << " is forcing "
<< (u ? "up" : "down") << "grade of " << *dsp << " to ";
diff --git a/tests/pkg-build.testscript b/tests/pkg-build.testscript
index 964eee4..d63868b 100644
--- a/tests/pkg-build.testscript
+++ b/tests/pkg-build.testscript
@@ -629,37 +629,34 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
info: specify sys:libfoo/1.1.0 if it is available from the system
EOE
- : upgrade-warning
+ : upgrade
:
{
$clone_cfg;
$pkg_fetch -e $src/libfoo-0.0.1.tar.gz && $pkg_unpack libfoo;
$pkg_fetch -e $src/libfix-0.0.1.tar.gz && $pkg_unpack libfix;
- $* libbaz >>EOO 2>>EOE;
+ $* libbaz >>EOO;
upgrade libfoo/1.1.0 (required by libbar libbaz)
new libbar/1.1.0 (required by libbaz)
new libbaz/1.1.0
EOO
- warning: package libbar dependency on (libfoo == 1.1.0) is forcing upgrade of libfoo/0.0.1 to 1.1.0
- EOE
$pkg_purge libfoo 2>'purged libfoo/0.0.1';
$pkg_purge libfix 2>'purged libfix/0.0.1'
}
- : downgrade-error
+ : downgrade
:
{
$clone_cfg;
$pkg_fetch -e $src/libfoo-1.2.0.tar.gz && $pkg_unpack libfoo;
- $* libbaz 2>>EOE != 0;
- error: package libbar dependency on (libfoo == 1.1.0) is forcing downgrade of libfoo/1.2.0 to 1.1.0
- info: explicitly request version downgrade to continue
- info: while satisfying libbar/1.1.0
- info: while satisfying libbaz/1.1.0
- EOE
+ $* libbaz >>EOO;
+ downgrade libfoo/1.1.0 (required by libbar libbaz)
+ new libbar/1.1.0 (required by libbaz)
+ new libbaz/1.1.0
+ EOO
$rep_add $rep/t4a && $rep_fetch;
@@ -728,13 +725,11 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
: its dependencies.
:
$clone_cfg;
- $* libbar >>EOO 2>>EOE
+ $* libbar >>EOO
upgrade libfoo/1.1.0 (required by libbar)
upgrade libbar/1.1.0
reconfigure libbaz (dependent of libbar libfoo)
EOO
- warning: package libbar dependency on (libfoo == 1.1.0) is forcing upgrade of libfoo/1.0.0 to 1.1.0
- EOE
: foo
:
@@ -1226,6 +1221,98 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
: dependency
:
{
+ : upgrade-diag
+ :
+ {
+ +$clone_root_cfg && $rep_fetch $rep/t1
+
+ : warning
+ :
+ {
+ $clone_cfg;
+
+ $* libfoo 2>!;
+ $rep_fetch $rep/t4b;
+
+ $* libbar --yes 2>>~%EOE%;
+ warning: package libbar dependency on (libfoo == 1.1.0) is forcing upgrade of libfoo/1.0.0 to 1.1.0
+ disfigured libfoo/1.0.0
+ %.*
+ %.*fetched libfoo/1.1.0%
+ unpacked libfoo/1.1.0
+ configured libfoo/1.1.0
+ %.*
+ %.*fetched libbar/1.1.0%
+ unpacked libbar/1.1.0
+ configured libbar/1.1.0
+ %info: .+ is up to date%
+ updated libbar/1.1.0
+ EOE
+
+ $pkg_drop libbar libfoo
+ }
+
+ : error
+ :
+ {
+ $clone_cfg;
+
+ $* libfoo/1.0.0 2>!;
+ $rep_fetch $rep/t4b;
+
+ $* libbar 2>>EOE != 0;
+ error: package libbar dependency on (libfoo == 1.1.0) is forcing upgrade of libfoo/1.0.0 to 1.1.0
+ info: package version libfoo/1.0.0 is held
+ info: explicitly request version upgrade to continue
+ info: while satisfying libbar/1.1.0
+ EOE
+
+ $pkg_drop libfoo
+ }
+
+ : info
+ :
+ {
+ $clone_cfg && $rep_fetch $rep/t2;
+
+ $* libbar --yes 2>!;
+ $rep_fetch $rep/t4b;
+
+ $* -v libbar --yes 2>>~%EOE%;
+ info: package libbar dependency on (libfoo == 1.1.0) is forcing upgrade of libfoo/1.0.0 to 1.1.0
+ %.*
+ EOE
+
+ $pkg_drop libbar
+ }
+
+ : none
+ :
+ {
+ $clone_cfg && $rep_fetch $rep/t2;
+
+ $* libbar --yes 2>!;
+ $rep_fetch $rep/t4b;
+
+ $* libbar --yes 2>>~%EOE%;
+ disfigured libbar/1.0.0
+ disfigured libfoo/1.0.0
+ %.*
+ %.*fetched libfoo/1.1.0%
+ unpacked libfoo/1.1.0
+ configured libfoo/1.1.0
+ %.*
+ %.*fetched libbar/1.1.0%
+ unpacked libbar/1.1.0
+ configured libbar/1.1.0
+ %info: .+ is up to date%
+ updated libbar/1.1.0
+ EOE
+
+ $pkg_drop libbar
+ }
+ }
+
: unknown
:
{