aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-02-01 14:32:04 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-02-01 14:32:04 +0200
commitd956e69e8b55dc2248b902490a138a46f02f9e55 (patch)
tree3b1c0021597c10402d7c89a4f095760f73a54aa0
parent546391dab6173660acceba6404136e9411ce1388 (diff)
Add --sys-no-stub bpkg-pkg-build option to allow sys: packages without stubs
-rw-r--r--bpkg/pkg-build.cli10
-rw-r--r--bpkg/pkg-build.cxx16
-rw-r--r--bpkg/system-package-manager-debian.cxx23
-rw-r--r--bpkg/system-package-manager.cxx2
4 files changed, 37 insertions, 14 deletions
diff --git a/bpkg/pkg-build.cli b/bpkg/pkg-build.cli
index 740764b..41a8432 100644
--- a/bpkg/pkg-build.cli
+++ b/bpkg/pkg-build.cli
@@ -107,7 +107,8 @@ namespace bpkg
manager is supported, then the automatic installation of an available
package can be requested with the \cb{--sys-install} option. Note that if
the version is not explicitly specified, then at least a stub package
- must be available from one of the repositories.
+ must be available from one of the repositories unless the
+ \cb{--sys-no-stub} option is specified.
Finally, a package can be specified as either the path to the package
archive (<file>) or to the package directory (<dir>\cb{/}; note that it
@@ -437,6 +438,13 @@ namespace bpkg
This option only makes sense together with \cb{--sys-install}."
}
+ bool --sys-no-stub
+ {
+ "Do no require a stub for packages specified with the \cb{sys} scheme.
+ Note that this option has effect only if the system package manager
+ interactions are supported and not disabled."
+ }
+
bool --sys-yes
{
"Assume the answer to the system package manager prompts is \cb{yes}.
diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx
index 4d90df2..9e5e1bb 100644
--- a/bpkg/pkg-build.cxx
+++ b/bpkg/pkg-build.cxx
@@ -1714,11 +1714,21 @@ namespace bpkg
aps = find_available_all (current_configs, nm);
// If no source/stub for the package (and thus no mapping), issue
- // diagnostics consistent with other such places.
+ // diagnostics consistent with other such places unless explicitly
+ // allowed by the user.
//
if (aps.empty ())
- fail << "unknown package " << nm <<
- info << "consider specifying " << nm << "/*";
+ {
+ if (!o.sys_no_stub ())
+ fail << "unknown package " << nm <<
+ info << "consider specifying --sys-no-stub or " << nm << "/*";
+
+ // Add the stub package to the imaginary system repository (like
+ // the user-specified case below).
+ //
+ if (stubs != nullptr)
+ stubs->push_back (make_shared<available_package> (nm));
+ }
}
// This covers both our diagnostics below as well as anything that
diff --git a/bpkg/system-package-manager-debian.cxx b/bpkg/system-package-manager-debian.cxx
index 06b5060..998c4f4 100644
--- a/bpkg/system-package-manager-debian.cxx
+++ b/bpkg/system-package-manager-debian.cxx
@@ -891,10 +891,12 @@ namespace bpkg
<< os_release_.name_id << " package name";
});
- strings ns (system_package_names (*aps,
- os_release_.name_id,
- os_release_.version_id,
- os_release_.like_ids));
+ strings ns;
+ if (!aps->empty ())
+ ns = system_package_names (*aps,
+ os_release_.name_id,
+ os_release_.version_id,
+ os_release_.like_ids);
if (ns.empty ())
{
// Attempt to automatically translate our package name (see above for
@@ -1231,12 +1233,13 @@ namespace bpkg
//
string sv (r->system_version, 0, r->system_version.rfind ('-'));
- optional<version> v (
- downstream_package_version (sv,
- *aps,
- os_release_.name_id,
- os_release_.version_id,
- os_release_.like_ids));
+ optional<version> v;
+ if (!aps->empty ())
+ v = downstream_package_version (sv,
+ *aps,
+ os_release_.name_id,
+ os_release_.version_id,
+ os_release_.like_ids);
if (!v)
{
diff --git a/bpkg/system-package-manager.cxx b/bpkg/system-package-manager.cxx
index 9f5dad0..5089db1 100644
--- a/bpkg/system-package-manager.cxx
+++ b/bpkg/system-package-manager.cxx
@@ -280,6 +280,8 @@ namespace bpkg
const string& version_id,
const vector<string>& like_ids)
{
+ assert (!aps.empty ());
+
semantic_version vid (parse_version_id (version_id, name_id));
// Iterate over the passed available packages (in version descending