aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bpkg/pkg-clean.cli16
-rw-r--r--bpkg/pkg-clean.hxx1
-rw-r--r--bpkg/pkg-command.cxx100
-rw-r--r--bpkg/pkg-command.hxx3
-rw-r--r--bpkg/pkg-install.cli15
-rw-r--r--bpkg/pkg-install.hxx1
-rw-r--r--bpkg/pkg-test.cli18
-rw-r--r--bpkg/pkg-test.hxx8
-rw-r--r--bpkg/pkg-uninstall.cli23
-rw-r--r--bpkg/pkg-uninstall.hxx1
-rw-r--r--bpkg/pkg-update.cli19
-rw-r--r--bpkg/pkg-update.hxx1
-rw-r--r--tests/pkg-test.test64
13 files changed, 204 insertions, 66 deletions
diff --git a/bpkg/pkg-clean.cli b/bpkg/pkg-clean.cli
index 69a0cc0..aae1b9e 100644
--- a/bpkg/pkg-clean.cli
+++ b/bpkg/pkg-clean.cli
@@ -15,14 +15,17 @@ namespace bpkg
"\h|SYNOPSIS|
- \c{\b{bpkg pkg-clean}|\b{clean} [<options>] [<vars>] (<pkg> [<vars>])...}
+ \c{\b{bpkg pkg-clean}|\b{clean} [<options>] [<vars>] (<pkg> [<vars>])...\n
+ \b{bpkg pkg-clean}|\b{clean} [<options>] [<vars>] \b{--all}|\b{-a}}
\h|DESCRIPTION|
- The \cb{pkg-clean} command cleans the previously configured (via
- \l{bpkg-pkg-build(1)} or \l{bpkg-pkg-configure(1)}) package. Underneath,
- this command doesn't do much more than run \cb{b clean}.
+ The \cb{pkg-clean} command cleans the specified packages (the first form)
+ or all the held packages (the second form, see \l{bpkg-pkg-status(1)}).
+ Underneath, this command doesn't do much more than run \cb{b clean}.
+ In the first form the specified packages must have been previously
+ configured with \l{bpkg-pkg-build(1)} or \l{bpkg-pkg-configure(1)}.
Additional command line variables (<vars>, normally \cb{config.*}) can be
passed to the build system by either specifying them before the packages,
in which case they apply to the whole configuration, or after a specific
@@ -32,5 +35,10 @@ namespace bpkg
class pkg_clean_options: configuration_options
{
"\h|PKG-CLEAN OPTIONS|"
+
+ bool --all|-a
+ {
+ "Clean all held packages."
+ }
};
}
diff --git a/bpkg/pkg-clean.hxx b/bpkg/pkg-clean.hxx
index 363563e..9890a16 100644
--- a/bpkg/pkg-clean.hxx
+++ b/bpkg/pkg-clean.hxx
@@ -21,6 +21,7 @@ namespace bpkg
"" /* cmd_variant */,
false /* recursive */,
false /* immediate */,
+ o.all (),
args);
}
}
diff --git a/bpkg/pkg-command.cxx b/bpkg/pkg-command.cxx
index 93e1779..5b1bb49 100644
--- a/bpkg/pkg-command.cxx
+++ b/bpkg/pkg-command.cxx
@@ -144,15 +144,11 @@ namespace bpkg
const string& cmd_v,
bool recursive,
bool immediate,
+ bool all,
cli::scanner& args)
{
tracer trace ("pkg_command");
- // We can as well count on the immediate/recursive option names.
- //
- if (immediate && recursive)
- fail << "both --immediate|-i and --recursive|-r specified";
-
const dir_path& c (o.directory ());
l4 ([&]{trace << "configuration: " << c;});
@@ -174,9 +170,27 @@ namespace bpkg
strings cvars;
read_vars (cvars);
- if (!args.more ())
- fail << "package name argument expected" <<
- info << "run 'bpkg help pkg-" << cmd << "' for more information";
+ // Check that options and arguments are consistent.
+ //
+ // Note that we can as well count on the option names that correspond to
+ // the immediate, recursive, and all parameters.
+ //
+ {
+ diag_record dr;
+
+ if (immediate && recursive)
+ dr << fail << "both --immediate|-i and --recursive|-r specified";
+ else if (all)
+ {
+ if (args.more ())
+ dr << fail << "both --all|-a and package argument specified";
+ }
+ else if (!args.more ())
+ dr << fail << "package name argument expected";
+
+ if (!dr.empty ())
+ dr << info << "run 'bpkg help pkg-" << cmd << "' for more information";
+ }
vector<pkg_command_vars> ps;
{
@@ -188,34 +202,64 @@ namespace bpkg
//
session ses;
- while (args.more ())
+ auto add = [&ps, recursive, immediate] (
+ const shared_ptr<selected_package>& p,
+ strings vars)
+ {
+ ps.push_back (pkg_command_vars {p, move (vars)});
+
+ // Note that it can only be recursive or immediate but not both.
+ //
+ if (recursive || immediate)
+ collect_dependencies (p, recursive, ps);
+ };
+
+ if (all)
{
- string n (args.next ());
- shared_ptr<selected_package> p (db.find<selected_package> (n));
+ using query = query<selected_package>;
- if (p == nullptr)
- fail << "package " << n << " does not exist in configuration " << c;
+ query q (query::hold_package &&
+ query::state == "configured" &&
+ query::substate != "system");
- if (p->state != package_state::configured)
- fail << "package " << n << " is " << p->state <<
- info << "expected it to be configured";
+ for (shared_ptr<selected_package> p:
+ pointer_result (db.query<selected_package> (q)))
+ {
+ l4 ([&]{trace << *p;});
- if (p->substate == package_substate::system)
- fail << "cannot " << cmd << " system package " << n;
+ add (p, strings ());
+ }
- l4 ([&]{trace << *p;});
+ if (ps.empty ())
+ info << "nothing to " << cmd;
+ }
+ else
+ {
+ while (args.more ())
+ {
+ string n (args.next ());
+ shared_ptr<selected_package> p (db.find<selected_package> (n));
- // Read package-specific variables.
- //
- strings vars;
- read_vars (vars);
+ if (p == nullptr)
+ fail << "package " << n << " does not exist in configuration "
+ << c;
- ps.push_back (pkg_command_vars {p, move (vars)});
+ if (p->state != package_state::configured)
+ fail << "package " << n << " is " << p->state <<
+ info << "expected it to be configured";
- // Note that it can only be recursive or immediate but not both.
- //
- if (recursive || immediate)
- collect_dependencies (p, recursive, ps);
+ if (p->substate == package_substate::system)
+ fail << "cannot " << cmd << " system package " << n;
+
+ l4 ([&]{trace << *p;});
+
+ // Read package-specific variables.
+ //
+ strings vars;
+ read_vars (vars);
+
+ add (p, move (vars));
+ }
}
t.commit ();
diff --git a/bpkg/pkg-command.hxx b/bpkg/pkg-command.hxx
index ea07b09..3f29c56 100644
--- a/bpkg/pkg-command.hxx
+++ b/bpkg/pkg-command.hxx
@@ -19,7 +19,7 @@ namespace bpkg
// instead.
//
// The command can also be performed recursively for all or immediate
- // dependencies of the specified packages.
+ // dependencies of the specified or all the held packages.
//
int
pkg_command (const string& cmd, // Without the 'pkg-' prefix.
@@ -27,6 +27,7 @@ namespace bpkg
const string& cmd_variant,
bool recursive,
bool immediate,
+ bool all,
cli::scanner& args);
struct pkg_command_vars
diff --git a/bpkg/pkg-install.cli b/bpkg/pkg-install.cli
index 95edef3..75d13a0 100644
--- a/bpkg/pkg-install.cli
+++ b/bpkg/pkg-install.cli
@@ -15,16 +15,20 @@ namespace bpkg
"\h|SYNOPSIS|
- \c{\b{bpkg pkg-install}|\b{install} [<options>] [<vars>] (<pkg> [<vars>])...}
+ \c{\b{bpkg pkg-install}|\b{install} [<options>] [<vars>] (<pkg> [<vars>])...\n
+ \b{bpkg pkg-install}|\b{install} [<options>] [<vars>] \b{--all}|\b{-a}}
\h|DESCRIPTION|
- The \cb{pkg-install} command installs one or more packages. Additionally,
- immediate or all dependencies of the specified packages can be also
+ The \cb{pkg-install} command installs the specified packages (the first
+ form) or all held packages (the second form, see \l{bpkg-pkg-status(1)}).
+ Additionally, immediate or all dependencies of these packages can be also
installed by specifying the \c{\b{--immediate}|\b{-i}} or
\c{\b{--recursive}|\b{-r}} options, respectively. Underneath, this
command doesn't do much more than run \cb{b install}.
+ In the first form the specified packages must have been previously
+ configured with \l{bpkg-pkg-build(1)} or \l{bpkg-pkg-configure(1)}.
Additional command line variables (<vars>, normally \cb{config.*}) can be
passed to the build system by either specifying them before the packages,
in which case they apply to the whole configuration, or after a specific
@@ -45,6 +49,11 @@ namespace bpkg
{
"\h|PKG-INSTALL OPTIONS|"
+ bool --all|-a
+ {
+ "Install all held packages."
+ }
+
bool --immediate|-i
{
"Also install immediate dependencies."
diff --git a/bpkg/pkg-install.hxx b/bpkg/pkg-install.hxx
index 8a74384..118b254 100644
--- a/bpkg/pkg-install.hxx
+++ b/bpkg/pkg-install.hxx
@@ -22,6 +22,7 @@ namespace bpkg
"" /* cmd_variant */,
o.recursive (),
o.immediate (),
+ o.all (),
args);
}
}
diff --git a/bpkg/pkg-test.cli b/bpkg/pkg-test.cli
index f8ad332..731c83a 100644
--- a/bpkg/pkg-test.cli
+++ b/bpkg/pkg-test.cli
@@ -15,17 +15,20 @@ namespace bpkg
"\h|SYNOPSIS|
- \c{\b{bpkg pkg-test}|\b{test} [<options>] [<vars>] (<pkg> [<vars>])...}
+ \c{\b{bpkg pkg-test}|\b{test} [<options>] [<vars>] (<pkg> [<vars>])...\n
+ \b{bpkg pkg-test}|\b{test} [<options>] [<vars>] \b{--all}|\b{-a}}
\h|DESCRIPTION|
- The \cb{pkg-test} command tests the previously configured (via
- \l{bpkg-pkg-build(1)} or \l{bpkg-pkg-configure(1)}) packages.
- Additionally, immediate or all dependencies of the specified packages can
- also be tested by specifying the \c{\b{--immediate}|\b{-i}} or
+ The \cb{pkg-test} command tests the specified packages (the first form)
+ or all the held packages (the second form, see \l{bpkg-pkg-status(1)}).
+ Additionally, immediate or all dependencies of these packages can also be
+ tested by specifying the \c{\b{--immediate}|\b{-i}} or
\c{\b{--recursive}|\b{-r}} options, respectively. Underneath, this
command doesn't do much more than run \cb{b test}.
+ In the first form the specified packages must have been previously
+ configured with \l{bpkg-pkg-build(1)} or \l{bpkg-pkg-configure(1)}.
Additional command line variables (<vars>, normally \cb{config.*}) can be
passed to the build system by either specifying them before the packages,
in which case they apply to the whole configuration, or after a specific
@@ -36,6 +39,11 @@ namespace bpkg
{
"\h|PKG-TEST OPTIONS|"
+ bool --all|-a
+ {
+ "Test all held packages."
+ }
+
bool --immediate|-i
{
"Also test immediate dependencies."
diff --git a/bpkg/pkg-test.hxx b/bpkg/pkg-test.hxx
index 460edc0..1fe697f 100644
--- a/bpkg/pkg-test.hxx
+++ b/bpkg/pkg-test.hxx
@@ -16,7 +16,13 @@ namespace bpkg
inline int
pkg_test (const pkg_test_options& o, cli::scanner& args)
{
- return pkg_command ("test", o, "", o.recursive (), o.immediate (), args);
+ return pkg_command ("test",
+ o,
+ "",
+ o.recursive (),
+ o.immediate (),
+ o.all (),
+ args);
}
}
diff --git a/bpkg/pkg-uninstall.cli b/bpkg/pkg-uninstall.cli
index 79ccf39..6770fbc 100644
--- a/bpkg/pkg-uninstall.cli
+++ b/bpkg/pkg-uninstall.cli
@@ -15,17 +15,21 @@ namespace bpkg
"\h|SYNOPSIS|
- \c{\b{bpkg pkg-uninstall}|\b{uninstall} [<options>] [<vars>] (<pkg> [<vars>])...}
+ \c{\b{bpkg pkg-uninstall}|\b{uninstall} [<options>] [<vars>] (<pkg> [<vars>])...\n
+ \b{bpkg pkg-uninstall}|\b{uninstall} [<options>] [<vars>] \b{--all}|\b{-a}}
\h|DESCRIPTION|
- The \cb{pkg-uninstall} command uninstalls one or more packages that were
- previously installed with \l{bpkg-pkg-install(1)}. Additionally,
- immediate or all dependencies of the specified packages can be also
- uninstalled by specifying the \c{\b{--immediate}|\b{-i}} or
- \c{\b{--recursive}|\b{-r}} options, respectively. Underneath, this
- command doesn't do much more than run \cb{b uninstall}.
+ The \cb{pkg-uninstall} command uninstalls the specified packages (the
+ first form) or all held packages (the second form, see
+ \l{bpkg-pkg-status(1)}). Additionally, immediate or all dependencies of
+ these specified packages can be also uninstalled by specifying the
+ \c{\b{--immediate}|\b{-i}} or \c{\b{--recursive}|\b{-r}} options,
+ respectively. Underneath, this command doesn't do much more than run
+ \cb{b uninstall}.
+ In the first form the specified packages must have been previously
+ configured with \l{bpkg-pkg-build(1)} or \l{bpkg-pkg-configure(1)}.
Additional command line variables (<vars>, normally \cb{config.*}) can be
passed to the build system by either specifying them before the packages,
in which case they apply to the whole configuration, or after a specific
@@ -37,6 +41,11 @@ namespace bpkg
{
"\h|PKG-UNINSTALL OPTIONS|"
+ bool --all|-a
+ {
+ "Uninstall all held packages."
+ }
+
bool --immediate|-i
{
"Also uninstall immediate dependencies."
diff --git a/bpkg/pkg-uninstall.hxx b/bpkg/pkg-uninstall.hxx
index 9e4d6a8..ab45918 100644
--- a/bpkg/pkg-uninstall.hxx
+++ b/bpkg/pkg-uninstall.hxx
@@ -21,6 +21,7 @@ namespace bpkg
"" /* cmd_variant */,
o.recursive (),
o.immediate (),
+ o.all (),
args);
}
}
diff --git a/bpkg/pkg-update.cli b/bpkg/pkg-update.cli
index 1478963..2082e07 100644
--- a/bpkg/pkg-update.cli
+++ b/bpkg/pkg-update.cli
@@ -15,15 +15,19 @@ namespace bpkg
"\h|SYNOPSIS|
- \c{\b{bpkg pkg-update}|\b{update} [<options>] [<vars>] (<pkg> [<vars>])...}
+ \c{\b{bpkg pkg-update}|\b{update} [<options>] [<vars>] (<pkg> [<vars>])...\n
+ \b{bpkg pkg-update}|\b{update} [<options>] [<vars>] \b{--all}|\b{-a}}
\h|DESCRIPTION|
- The \cb{pkg-update} command updates the previously configured (via
- \l{bpkg-pkg-build(1)} or \l{bpkg-pkg-configure(1)}) package. Underneath,
- this command doesn't do much more than run \cb{b update} (or one of its
- \c{update-for-*} variants; see \cb{--for|-f}).
+ The \cb{pkg-update} command updates the specified packages (the first
+ form) or all the held packages (the second form, see
+ \l{bpkg-pkg-status(1)}). Underneath, this command doesn't do much more
+ than run \cb{b update} (or one of its \c{update-for-*} variants; see
+ \cb{--for|-f}).
+ In the first form the specified packages must have been previously
+ configured with \l{bpkg-pkg-build(1)} or \l{bpkg-pkg-configure(1)}.
Additional command line variables (<vars>, normally \cb{config.*}) can be
passed to the build system by either specifying them before the packages,
in which case they apply to the whole configuration, or after a specific
@@ -34,6 +38,11 @@ namespace bpkg
{
"\h|PKG-UPDATE OPTIONS|"
+ bool --all|-a
+ {
+ "Update all held packages."
+ }
+
string --for|-f
{
"<operation>",
diff --git a/bpkg/pkg-update.hxx b/bpkg/pkg-update.hxx
index c2fc982..c2fb5ab 100644
--- a/bpkg/pkg-update.hxx
+++ b/bpkg/pkg-update.hxx
@@ -22,6 +22,7 @@ namespace bpkg
o.for_ (),
false /* recursive */,
false /* immediate */,
+ o.all (),
args);
}
diff --git a/tests/pkg-test.test b/tests/pkg-test.test
index 26a3fd6..cfc7eb2 100644
--- a/tests/pkg-test.test
+++ b/tests/pkg-test.test
@@ -26,13 +26,39 @@
cp -r $src/t0a $out/t0a && $rep_create $out/t0a &$out/t0a/packages.manifest
end
-pkg_build += --yes --auth all --trust-yes -d cfg 2>!
+cfg_create += -d cfg 2>! &cfg/***
+pkg_build += -d cfg --yes --auth all --trust-yes 2>!
+$pkg_build "libbaz@$rep/t0a"
test.options += --build-option -s
-: non-recursive
+: args
+:
+{
+ : no-name
+ :
+ $* 2>>EOE != 0
+ error: package name argument expected
+ info: run 'bpkg help pkg-test' for more information
+ EOE
+
+ : all-name
+ :
+ $* --all libbaz 2>>EOE != 0
+ error: both --all|-a and package argument specified
+ info: run 'bpkg help pkg-test' for more information
+ EOE
+
+ : recursive-immediate
+ :
+ $* libbaz --recursive --immediate 2>>~%EOE% != 0
+ error: both --immediate|-i and --recursive|-r specified
+ info: run 'bpkg help pkg-test' for more information
+ EOE
+}
+
+: package
:
{
$clone_cfg;
@@ -43,6 +69,30 @@ test.options += --build-option -s
EOE
}
+: all
+:
+{
+ : src
+ :
+ {
+ $clone_root_cfg;
+
+ $* --all 2>>~%EOE%
+ %info: .+libbaz-0.0.3.+ has nothing to test%
+ tested libbaz/0.0.3
+ EOE
+ }
+
+ : sys
+ :
+ {
+ $cfg_create;
+ $pkg_build "sys:libbaz@$rep/t0a";
+
+ $* --all 2>'info: nothing to test'
+ }
+}
+
: immediate
:
{
@@ -70,13 +120,3 @@ test.options += --build-option -s
tested libfix/0.0.1
EOE
}
-
-: recursive-immediate
-:
-{
- $clone_cfg;
-
- $* libbaz --recursive --immediate 2>>~%EOE% != 0
- error: both --immediate|-i and --recursive|-r specified
- EOE
-}