aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bpkg/pkg-clean.hxx1
-rw-r--r--bpkg/pkg-command.cxx36
-rw-r--r--bpkg/pkg-command.hxx5
-rw-r--r--bpkg/pkg-install.hxx5
-rw-r--r--bpkg/pkg-test.hxx1
-rw-r--r--bpkg/pkg-uninstall.hxx4
-rw-r--r--bpkg/pkg-update.hxx1
7 files changed, 49 insertions, 4 deletions
diff --git a/bpkg/pkg-clean.hxx b/bpkg/pkg-clean.hxx
index 07dced9..e6dfcbe 100644
--- a/bpkg/pkg-clean.hxx
+++ b/bpkg/pkg-clean.hxx
@@ -23,6 +23,7 @@ namespace bpkg
o.all (),
o.all_pattern (),
false /* package_cwd */,
+ true /* allow_host_type */,
args);
}
}
diff --git a/bpkg/pkg-command.cxx b/bpkg/pkg-command.cxx
index 668aca1..0ff6a0d 100644
--- a/bpkg/pkg-command.cxx
+++ b/bpkg/pkg-command.cxx
@@ -114,10 +114,19 @@ namespace bpkg
collect_dependencies (const shared_ptr<selected_package>& p,
bool recursive,
bool package_cwd,
- vector<pkg_command_vars>& ps)
+ vector<pkg_command_vars>& ps,
+ bool allow_host_type)
{
for (const auto& pr: p->prerequisites)
{
+ if (!allow_host_type)
+ {
+ database& db (pr.first.database ());
+
+ if (db.type == host_config_type || db.type == build2_config_type)
+ continue;
+ }
+
shared_ptr<selected_package> d (pr.first.load ());
// The selected package can only be configured if all its dependencies
@@ -145,7 +154,11 @@ namespace bpkg
package_cwd});
if (recursive)
- collect_dependencies (d, recursive, package_cwd, ps);
+ collect_dependencies (d,
+ recursive,
+ package_cwd,
+ ps,
+ allow_host_type);
}
}
}
@@ -159,6 +172,7 @@ namespace bpkg
bool all,
const strings& all_patterns,
bool package_cwd,
+ bool allow_host_type,
cli::group_scanner& args)
{
tracer trace ("pkg_command");
@@ -254,6 +268,15 @@ namespace bpkg
vector<pkg_command_vars> ps;
{
database db (c, trace, true /* pre_attach */);
+
+ if (!allow_host_type && (db.type == host_config_type ||
+ db.type == build2_config_type))
+ {
+ fail << "unable to " << cmd << " from " << db.type
+ << " configuration" <<
+ info << "use target configuration instead";
+ }
+
transaction t (db);
// We need to suppress duplicate dependencies for the recursive command
@@ -261,7 +284,8 @@ namespace bpkg
//
session ses;
- auto add = [&db, &ps, recursive, immediate, package_cwd] (
+ auto add =
+ [&db, &ps, allow_host_type, recursive, immediate, package_cwd] (
const shared_ptr<selected_package>& p,
strings vars)
{
@@ -275,7 +299,11 @@ namespace bpkg
// Note that it can only be recursive or immediate but not both.
//
if (recursive || immediate)
- collect_dependencies (p, recursive, package_cwd, ps);
+ collect_dependencies (p,
+ recursive,
+ package_cwd,
+ ps,
+ allow_host_type);
};
if (all || !all_patterns.empty ())
diff --git a/bpkg/pkg-command.hxx b/bpkg/pkg-command.hxx
index 0ed7072..2de9b73 100644
--- a/bpkg/pkg-command.hxx
+++ b/bpkg/pkg-command.hxx
@@ -20,6 +20,10 @@ namespace bpkg
// The command can also be performed recursively for all or immediate
// dependencies of the specified or all the held packages.
//
+ // If allow_host_type is false, then fail if the current configuration is of
+ // the host or build2 type. Also skip the build-time dependencies in the
+ // recursive mode in this case.
+ //
// Note: loads selected packages.
//
int
@@ -31,6 +35,7 @@ namespace bpkg
bool all,
const strings& all_patterns,
bool package_cwd,
+ bool allow_host_type,
cli::group_scanner& args);
struct pkg_command_vars
diff --git a/bpkg/pkg-install.hxx b/bpkg/pkg-install.hxx
index 120576a..3898c1a 100644
--- a/bpkg/pkg-install.hxx
+++ b/bpkg/pkg-install.hxx
@@ -13,6 +13,10 @@
namespace bpkg
{
+ // Note that we disallow installing packages from the host/build2
+ // configurations. The reason for that is that otherwise we can fail, trying
+ // to build a package both for install and normally (as a dependency).
+ //
inline int
pkg_install (const pkg_install_options& o, cli::group_scanner& args)
{
@@ -24,6 +28,7 @@ namespace bpkg
o.all (),
o.all_pattern (),
false /* package_cwd */,
+ false /* allow_host_type */,
args);
}
}
diff --git a/bpkg/pkg-test.hxx b/bpkg/pkg-test.hxx
index 0cadabe..26c7b18 100644
--- a/bpkg/pkg-test.hxx
+++ b/bpkg/pkg-test.hxx
@@ -23,6 +23,7 @@ namespace bpkg
o.all (),
o.all_pattern (),
o.package_cwd (),
+ true /* allow_host_type */,
args);
}
}
diff --git a/bpkg/pkg-uninstall.hxx b/bpkg/pkg-uninstall.hxx
index 94a8390..c3df29a 100644
--- a/bpkg/pkg-uninstall.hxx
+++ b/bpkg/pkg-uninstall.hxx
@@ -13,6 +13,9 @@
namespace bpkg
{
+ // Note that we disallow uninstalling packages from the host/build2
+ // configurations (see pkg_install() for details).
+ //
inline int
pkg_uninstall (const pkg_uninstall_options& o, cli::group_scanner& args)
{
@@ -23,6 +26,7 @@ namespace bpkg
o.all (),
o.all_pattern (),
false /* package_cwd */,
+ false /* allow_host_type */,
args);
}
}
diff --git a/bpkg/pkg-update.hxx b/bpkg/pkg-update.hxx
index 41fead0..3a2df8c 100644
--- a/bpkg/pkg-update.hxx
+++ b/bpkg/pkg-update.hxx
@@ -24,6 +24,7 @@ namespace bpkg
o.all (),
o.all_pattern (),
false /* package_cwd */,
+ true /* allow_host_type */,
args);
}