aboutsummaryrefslogtreecommitdiff
path: root/bpkg
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 /bpkg
parent93d95938306e76a0f8b9422ea6b3cb4695610f73 (diff)
Replace --{drop,keep}-prerequisites with --keep-unused
Diffstat (limited to 'bpkg')
-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
5 files changed, 45 insertions, 52 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 {};
}