aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-03-28 09:46:20 +0200
committerKaren Arutyunov <karen@codesynthesis.com>2018-04-19 19:39:55 +0300
commit541b40803751d4dc6b6575e3f80de89b04b71bc6 (patch)
treec98616d5f8a5620329339bf4a86e886b1cebfa6c
parent93d95938306e76a0f8b9422ea6b3cb4695610f73 (diff)
Replace --{drop,keep}-prerequisites with --keep-unused
-rw-r--r--bpkg/package.hxx8
-rw-r--r--bpkg/pkg-build.cli22
-rw-r--r--bpkg/pkg-build.cxx16
-rw-r--r--bpkg/pkg-drop.cli31
-rw-r--r--bpkg/pkg-drop.cxx20
-rw-r--r--tests/pkg-build.test42
-rw-r--r--tests/pkg-drop.test33
-rw-r--r--tests/pkg-system.test14
8 files changed, 89 insertions, 97 deletions
diff --git a/bpkg/package.hxx b/bpkg/package.hxx
index c14f7fc..38aa3ee 100644
--- a/bpkg/package.hxx
+++ b/bpkg/package.hxx
@@ -312,6 +312,14 @@ namespace bpkg
// dependencies
//
+ // Note on the terminology: we use the term "dependency" or "dependency
+ // package" to refer to a general concept of package dependency. This would
+ // include dependency alternatives, optional/conditional dependencies, etc.
+ //
+ // In contrast, below we use (mostly internally) the term "prerequisite
+ // package" to refer to the "effective" dependency that has been resolved to
+ // the actual package object.
+ //
#pragma db value(dependency_constraint) definition
#pragma db value(dependency) definition
#pragma db member(dependency::constraint) column("")
diff --git a/bpkg/pkg-build.cli b/bpkg/pkg-build.cli
index b7a75dc..8312450 100644
--- a/bpkg/pkg-build.cli
+++ b/bpkg/pkg-build.cli
@@ -32,9 +32,11 @@ namespace bpkg
\h|DESCRIPTION|
The \cb{pkg-build} command builds one or more packages including all
- their prerequisites. Besides building new packages, this command is also
+ their dependencies. Besides building new packages, this command is also
used to upgrade or downgrade packages that are already present in the
- configuration.
+ configuration. And unless the \c{\b{--keep-unused}|\b{-K}} option is
+ specified, \cb{pkg-build} will also drop dependency packages that would
+ otherwise no longer be used.
The first form (one or more packages are specified) builds new or
upgrades (by default or if \cb{--upgrade} is specified) or patches (if
@@ -200,28 +202,22 @@ namespace bpkg
\cb{install} or \cb{test}."
}
- bool --drop-prerequisite|-D
+ bool --keep-unused|-K
{
- "Drop without confirmation prerequsite packages that were automatically
- built and will no longer be necessary."
- }
-
- bool --keep-prerequisite|-K
- {
- "Don't offer to drop prerequsite packages that were automatically built
- and will no longer be necessary."
+ "Don't drop dependency packages that were automatically built but will no
+ longer be used."
}
bool --update-dependent|-U
{
"Update without confirmation dependent packages that are reconfigured
- due to their prerequisites being upgraded or downgraded."
+ due to their dependencies being upgraded or downgraded."
}
bool --leave-dependent|-L
{
"Don't offer to update dependent packages that are reconfigured due to
- their prerequisites being upgraded or downgraded."
+ their dependencies being upgraded or downgraded."
}
bool --configure-only|-c
diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx
index 4ba838c..b24ac70 100644
--- a/bpkg/pkg-build.cxx
+++ b/bpkg/pkg-build.cxx
@@ -702,7 +702,7 @@ namespace bpkg
if (dap == nullptr)
{
diag_record dr (fail);
- dr << "unknown prerequisite " << d << " of package " << name;
+ dr << "unknown dependency " << d << " of package " << name;
if (!ar->location.empty ())
dr << info << "repository " << ar->location << " appears to "
@@ -724,14 +724,14 @@ namespace bpkg
if (dap->stub ())
{
if (dap->system_version () == nullptr)
- fail << "prerequisite " << d << " of package " << name << " is "
+ fail << "dependency " << d << " of package " << name << " is "
<< "not available in source" <<
info << "specify ?sys:" << dn << " if it is available from "
<< "the system";
if (!satisfies (*dap->system_version (), d.constraint))
{
- fail << "prerequisite " << d << " of package " << name << " is "
+ fail << "dependency " << d << " of package " << name << " is "
<< "not available in source" <<
info << "sys:" << dn << "/" << *dap->system_version ()
<< " does not satisfy the constrains";
@@ -1483,11 +1483,6 @@ namespace bpkg
fail << n << " requires explicit --upgrade|-u or --patch|-p";
}
- if (o.drop_prerequisite () && o.keep_prerequisite ())
- fail << "both --drop-prerequisite|-D and --keep-prerequisite|-K "
- << "specified" <<
- info << "run 'bpkg help pkg-build' for more information";
-
if (o.update_dependent () && o.leave_dependent ())
fail << "both --update-dependent|-U and --leave-dependent|-L "
<< "specified" <<
@@ -2379,6 +2374,11 @@ namespace bpkg
{
if (optional<version> v = evaluate_dependency (db, sp))
{
+ // Skip unused if we were instructed to keep them.
+ //
+ if (o.keep_unused () && v->empty ())
+ continue;
+
dep_pkgs.push_back (dep_pkg {sp->name, *v});
refine = true;
}
diff --git a/bpkg/pkg-drop.cli b/bpkg/pkg-drop.cli
index 7f9dc19..cbf2279 100644
--- a/bpkg/pkg-drop.cli
+++ b/bpkg/pkg-drop.cli
@@ -21,10 +21,11 @@ namespace bpkg
The \cb{pkg-drop} command drops one or more packages from the
configuration. If the packages being dropped still have dependent
- packages, then those will have to be drop as well and you will be prompted
- to confirm. Similarly, if the packages being dropped have prerequisite
- packages that would otherwise no longer be needed, you will be offered to
- drop those as well.
+ packages, then those will have to be drop as well and you will be
+ prompted to confirm. And if the packages being dropped have dependency
+ packages that would otherwise no longer be used, then they will be
+ dropped as well unless the \c{\b{--keep-unused}|\b{-K}} option is
+ specified.
The \cb{pkg-drop} command also supports several options (described below)
that allow you to control the amount of work that will be done."
@@ -47,27 +48,21 @@ namespace bpkg
with \cb{--print-only|-p}."
}
- bool --drop-dependent
+ bool --keep-unused|-K
{
- "Don't warn about or ask for confirmation if dropping dependent
- packages."
+ "Don't drop dependency packages that were automatically built but will no
+ longer be used."
}
- bool --keep-dependent|-K
+ bool --drop-dependent|-D
{
- "Issue an error if attempting to drop dependent packages."
- }
-
- bool --drop-prerequisite|-D
- {
- "Drop without confirmation prerequsite packages that were automatically
- built and will no longer be necessary."
+ "Don't warn about or ask for confirmation if dropping dependent
+ packages."
}
- bool --keep-prerequisite
+ bool --keep-dependent
{
- "Don't offer to drop prerequsite packages that were automatically built
- and will no longer be necessary."
+ "Issue an error if attempting to drop dependent packages."
}
bool --print-only|-p
diff --git a/bpkg/pkg-drop.cxx b/bpkg/pkg-drop.cxx
index 0127fb6..2ba4b72 100644
--- a/bpkg/pkg-drop.cxx
+++ b/bpkg/pkg-drop.cxx
@@ -417,11 +417,6 @@ namespace bpkg
<< "specified" <<
info << "run 'bpkg help pkg-drop' for more information";
- if (o.drop_prerequisite () && o.keep_prerequisite ())
- fail << "both --drop-prerequisite|-D and --keep-prerequisite "
- << "specified" <<
- info << "run 'bpkg help pkg-drop' for more information";
-
if (!args.more ())
fail << "package name argument expected" <<
info << "run 'bpkg help pkg-drop' for more information";
@@ -537,15 +532,14 @@ namespace bpkg
// some that we can drop, ask the user for confirmation.
//
if (pkgs.filter_prerequisites (db) &&
- !o.keep_prerequisite () &&
- !(drop_prq = o.drop_prerequisite ()) &&
+ !o.keep_unused () &&
!(drop_prq = o.yes ()) && !o.no ())
{
{
diag_record dr (text);
- dr << "following prerequisite packages were automatically "
- << "built and will no longer be necessary:";
+ dr << "following dependencies were automatically built but will "
+ << "no longer be used:";
for (const drop_package& dp: pkgs)
{
@@ -555,7 +549,7 @@ namespace bpkg
}
}
- drop_prq = yn_prompt ("drop prerequisite packages? [Y/n]", 'y');
+ drop_prq = yn_prompt ("drop unused packages? [Y/n]", 'y');
if (drop_prq)
print_plan = true;
@@ -623,14 +617,14 @@ namespace bpkg
{
diag_record dr (text);
- dr << "following prerequisite packages were automatically "
- << "built and will no longer be necessary:";
+ dr << "following dependencies were automatically built but will "
+ << "no longer be used:";
for (const drop_package& dp: pkgs)
dr << text << dp.package->name;
}
- if (!yn_prompt ("drop prerequisite packages? [Y/n]", 'y'))
+ if (!yn_prompt ("drop unused packages? [Y/n]", 'y'))
return {};
}
diff --git a/tests/pkg-build.test b/tests/pkg-build.test
index 4df4499..4b0c57b 100644
--- a/tests/pkg-build.test
+++ b/tests/pkg-build.test
@@ -30,7 +30,7 @@
# | |-- libfoo-1.0.0.tar.gz
# | `-- repositories.manifest
# |
-# |-- t3 -> t2 (prerequisite)
+# |-- t3 -> t2 (prerequisite repository)
# | |-- libbaz-1.0.0.tar.gz -> libbar
# | |-- libfox-1.0.0.tar.gz
# | `-- repositories.manifest
@@ -39,16 +39,16 @@
# | |-- libfoo-1.1.0.tar.gz
# | `-- repositories.manifest
# |
-# |-- t4b -> t4a (prerequisite)
+# |-- t4b -> t4a (prerequisite repository)
# | |-- libbar-1.1.0.tar.gz -> libfoo == 1.1.0
# | `-- repositories.manifest
# |
-# |-- t4c -> t4b (prerequisite)
+# |-- t4c -> t4b (prerequisite repository)
# | |-- libbaz-1.1.0.tar.gz -> libfoo, libbar
# | |-- libfoo-1.0.0.tar.gz
# | `-- repositories.manifest
# |
-# |-- t4d -> t4c (complement)
+# |-- t4d -> t4c (complement repository)
# | |-- libbiz-1.0.0.tar.gz -> libfox, libfoo, libbaz
# | |-- libfox-1.0.0.tar.gz
# | `-- repositories.manifest
@@ -65,7 +65,7 @@
# | `-- *
# |
# `-- git
-# |-- libbar.git -> style-basic.git (prerequisite)
+# |-- libbar.git -> style-basic.git (prerequisite repository)
# |-- libbaz.git
# `-- style-basic.git
@@ -92,7 +92,7 @@ end
pkg_configure += -d cfg "config.cxx=$config.cxx" 2>!
pkg_disfigure += -d cfg
-pkg_drop += -d cfg --drop-prerequisite 2>!
+pkg_drop += -d cfg 2>!
pkg_fetch += -d cfg 2>!
pkg_purge += -d cfg
pkg_status += -d cfg
@@ -237,11 +237,11 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
{
test.arguments += --print-only
- : unknown-prerequisite
+ : unknown-dependency
:
$clone_root_cfg;
$* $src/libbar-1.0.0.tar.gz 2>>EOE != 0
- error: unknown prerequisite libfoo of package libbar
+ error: unknown dependency libfoo of package libbar
info: while satisfying libbar/1.0.0
EOE
@@ -250,7 +250,7 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
{
+$clone_root_cfg && $rep_add $rep/t2 && $rep_fetch
- : build-prerequisite
+ : build-dependency
:
{
$clone_cfg;
@@ -282,7 +282,7 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
EOE
}
- : upgrade-prerequisite
+ : upgrade-dependency
:
{
$clone_cfg;
@@ -306,7 +306,7 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
$pkg_purge libfoo 2>'purged libfoo/0.0.1'
}
- : downgrade-prerequisite
+ : downgrade-dependency
:
{
$clone_cfg && $pkg_unpack -e $src/libfoo-1.1.0;
@@ -732,7 +732,7 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
{
test.arguments += --yes
- : wth-prerequisites
+ : with-dependencies
:
{
$clone_root_cfg && $rep_add $rep/t4c && $rep_fetch;
@@ -983,7 +983,7 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
}
}
- : drop-prerequisites
+ : drop-dependencies
:
{
$clone_root_cfg && $rep_add $rep/t2 && $rep_fetch;
@@ -1060,9 +1060,9 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
$pkg_purge libfoo 2>'purged libfoo/1.0.0'
}
- : local-prerequisite
+ : local-dependency
:
- : Test that the local package can be built against the local prerequisite
+ : Test that the local package can be built against the local dependency
: package.
:
{
@@ -1107,7 +1107,7 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
}
}
-: prerequisite
+: dependency
:
{
+$clone_cfg
@@ -1115,7 +1115,7 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
: drop
:
- : Test --drop-prerequisite option.
+ : Test dropping of unused dependencies (default behavior).
:
{
$clone_cfg;
@@ -1133,7 +1133,7 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
updated libbar/1.0.0
EOE
- $* --drop-prerequisite libbar/1.2.0 <'y' 2>>~%EOE%;
+ $* libbar/1.2.0 <'y' 2>>~%EOE%;
upgrade libbar/1.2.0
continue? [Y/n] disfigured libbar/1.0.0
%.*
@@ -1154,7 +1154,7 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
: keep
:
- : Test --keep-prerequisite option.
+ : Test keeping of unused dependencies (--keep-unused option).
:
{
$clone_cfg;
@@ -1172,7 +1172,7 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
updated libbar/1.0.0
EOE
- $* --keep-prerequisite libbar/1.2.0 <'y' 2>>~%EOE%;
+ $* --keep-unused libbar/1.2.0 <'y' 2>>~%EOE%;
upgrade libbar/1.2.0
continue? [Y/n] disfigured libbar/1.0.0
%.*
@@ -1849,7 +1849,7 @@ else
: prerequisite-repo
:
- : Prerequisite package of the dependent being built is in the prerequisite
+ : Dependency package of the dependent being built is in the prerequisite
: repository.
:
{
diff --git a/tests/pkg-drop.test b/tests/pkg-drop.test
index f7666b5..e10bbe2 100644
--- a/tests/pkg-drop.test
+++ b/tests/pkg-drop.test
@@ -10,10 +10,10 @@
# |-- t4a
# | |-- libfoo-1.1.0.tar.gz
# | `-- repositories.manifest
-# |-- t4b -> t4a (prerequisite)
+# |-- t4b -> t4a (prerequisite repository)
# | |-- libbar-1.1.0.tar.gz -> libfoo == 1.1.0
# | `-- repositories.manifest
-# |-- t4c -> t4b (prerequisite)
+# |-- t4c -> t4b (prerequisite repository)
# | |-- libbaz-1.1.0.tar.gz -> libfoo, libbar
# | |-- libfoo-1.0.0.tar.gz
# | `-- repositories.manifest
@@ -60,7 +60,7 @@ $* libfoo/1.0.0 2>>~%EOE% != 0
%error: package libfoo/1.0.0 does not exist in configuration cfg[/\\]%
EOE
-: prerequisites-or-dependents
+: dependencies-or-dependents
:
{
+$clone_cfg && $rep_add $rep/t4c && $rep_fetch
@@ -81,7 +81,7 @@ $* libfoo/1.0.0 2>>~%EOE% != 0
:
{
# Prepare the nested tests to use configuration from the enclosing
- # 'prerequisites-or-dependents' group scope.
+ # 'dependencies-or-dependents' group scope.
#
clone_cfg = cp -r $~/../cfg ./
@@ -156,11 +156,11 @@ $* libfoo/1.0.0 2>>~%EOE% != 0
}
}
- : prerequisites
+ : dependencies
:
{
# Prepare the nested tests to use configuration from the enclosing
- # 'prerequisites-or-dependents' group scope.
+ # 'dependencies-or-dependents' group scope.
#
clone_cfg = cp -r $~/../cfg ./
@@ -198,7 +198,7 @@ $* libfoo/1.0.0 2>>~%EOE% != 0
: dependencies
:
- : Note that we do not move this test to the prerequisites-and-dependents
+ : Note that we do not move this test to the dependencies-and-dependents
: group as the configuration repository set would be different.
:
$clone_cfg;
@@ -225,7 +225,7 @@ $* libfoo/1.0.0 2>>~%EOE% != 0
-$pkg_status libfoo/1.1.0 >'libfoo available [1.1.0]'
}
-: prerequisites-and-dependents
+: dependencies-and-dependents
:
{
+$clone_cfg && $rep_add $rep/t4d && $rep_fetch
@@ -234,7 +234,7 @@ $* libfoo/1.0.0 2>>~%EOE% != 0
clone_cfg = cp -r ../../cfg ./
test.arguments += --print-only
- : drop-prerequisites-no-dependents
+ : drop-dependencies-no-dependents
:
{
test.arguments += --yes
@@ -262,7 +262,7 @@ $* libfoo/1.0.0 2>>~%EOE% != 0
EOO
}
- : drop-prerequisites
+ : drop-dependencies
:
{
test.arguments += --yes --drop-dependent
@@ -312,7 +312,7 @@ $* libfoo/1.0.0 2>>~%EOE% != 0
EOO
}
- : keep-prerequisites
+ : keep-dependencies
{
test.arguments += --no --drop-dependent
@@ -377,8 +377,7 @@ $* libfoo/1.0.0 2>>~%EOE% != 0
: keep-drop-options
:
-: Test --drop-dependent, --keep-dependent, --drop-prerequisite,
-: --keep-prerequisite option.
+: Test --drop-dependent, --keep-dependent, --keep-unused, option.
:
{
+$clone_cfg && $rep_add $rep/t4b && $rep_fetch
@@ -401,12 +400,12 @@ $* libfoo/1.0.0 2>>~%EOE% != 0
EOE
}
- : drop-prerequisite
+ : drop-dependency
:
{
$clone_cfg && $pkg_build libbar;
- $* --drop-prerequisite libbar 2>>EOE
+ $* libbar 2>>EOE
disfigured libbar
disfigured libfoo
purged libbar
@@ -414,12 +413,12 @@ $* libfoo/1.0.0 2>>~%EOE% != 0
EOE
}
- : keep-prerequisite
+ : keep-dependency
:
{
$clone_cfg && $pkg_build libbar;
- $* --keep-prerequisite libbar 2>>EOE;
+ $* --keep-unused libbar 2>>EOE;
disfigured libbar
purged libbar
EOE
diff --git a/tests/pkg-system.test b/tests/pkg-system.test
index b0878e2..ced16f0 100644
--- a/tests/pkg-system.test
+++ b/tests/pkg-system.test
@@ -563,7 +563,7 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
$clone_cfg;
$pkg_build foo 2>>EOE != 0;
- error: prerequisite libbar >= 2 of package foo is not available in source
+ error: dependency libbar >= 2 of package foo is not available in source
info: specify ?sys:libbar if it is available from the system
info: while satisfying foo/2
EOE
@@ -616,7 +616,7 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
# Fail to build foo.
#
$pkg_build foo 2>>EOE != 0;
- error: prerequisite libbar >= 2 of package foo is not available in source
+ error: dependency libbar >= 2 of package foo is not available in source
info: sys:libbar/1 does not satisfy the constrains
info: while satisfying foo/2
EOE
@@ -651,7 +651,7 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
# Fail to build foo and sys:libbar/1.
#
$pkg_build foo 'sys:libbar/1' 2>>EOE != 0;
- error: prerequisite libbar >= 2 of package foo is not available in source
+ error: dependency libbar >= 2 of package foo is not available in source
info: sys:libbar/1 does not satisfy the constrains
info: while satisfying foo/2
EOE
@@ -692,7 +692,7 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
# Fail to build sys:libbar/1.1 and foo.
#
$pkg_build 'sys:libbar/1.1' foo 2>>EOE != 0;
- error: prerequisite libbar >= 2 of package foo is not available in source
+ error: dependency libbar >= 2 of package foo is not available in source
info: sys:libbar/1.1 does not satisfy the constrains
info: while satisfying foo/2
EOE
@@ -751,7 +751,7 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
# Fail to build foo.
#
$pkg_build foo 2>>EOE != 0;
- error: prerequisite libbar >= 2 of package foo is not available in source
+ error: dependency libbar >= 2 of package foo is not available in source
info: sys:libbar/1 does not satisfy the constrains
info: while satisfying foo/2
EOE
@@ -799,7 +799,7 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
$clone_cfg;
$pkg_build foo 2>>EOE != 0;
- error: prerequisite libbar >= 2 of package foo is not available in source
+ error: dependency libbar >= 2 of package foo is not available in source
info: specify ?sys:libbar if it is available from the system
info: while satisfying foo/2
EOE
@@ -813,7 +813,7 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
EOE
$pkg_build foo '?sys:libbar/1' 2>>EOE != 0;
- error: prerequisite libbar >= 2 of package foo is not available in source
+ error: dependency libbar >= 2 of package foo is not available in source
info: sys:libbar/1 does not satisfy the constrains
info: while satisfying foo/2
EOE