aboutsummaryrefslogtreecommitdiff
path: root/bpkg
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2023-07-28 22:04:29 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2023-07-31 19:35:21 +0300
commit67d42b48930f65a7e270e153f1ca627c5241d17b (patch)
tree817d36b4718793b6475cfdf59fd1ffe2d0b9e344 /bpkg
parentda6d239d0771142b795d18105aac8d130e85c5ba (diff)
Fix unexpected 'no package available for dependency' error when building from archives (GH issue #303)
Diffstat (limited to 'bpkg')
-rw-r--r--bpkg/package-query.cxx29
-rw-r--r--bpkg/package-query.hxx19
-rw-r--r--bpkg/pkg-build-collect.cxx7
-rw-r--r--bpkg/pkg-build.cxx4
-rw-r--r--bpkg/pkg-checkout.cxx2
-rw-r--r--bpkg/pkg-unpack.cxx2
6 files changed, 59 insertions, 4 deletions
diff --git a/bpkg/package-query.cxx b/bpkg/package-query.cxx
index 9705579..0c6d459 100644
--- a/bpkg/package-query.cxx
+++ b/bpkg/package-query.cxx
@@ -7,6 +7,7 @@
#include <bpkg/package-odb.hxx>
#include <bpkg/database.hxx>
#include <bpkg/rep-mask.hxx>
+#include <bpkg/satisfaction.hxx>
using namespace std;
@@ -26,6 +27,34 @@ namespace bpkg
return i != imaginary_stubs.end () ? *i : nullptr;
}
+ vector<pair<reference_wrapper<database>,
+ shared_ptr<available_package>>> existing_packages;
+
+ pair<shared_ptr<available_package>, lazy_shared_ptr<repository_fragment>>
+ find_existing (const package_name& name,
+ const optional<version_constraint>& c,
+ const lazy_shared_ptr<repository_fragment>& rf)
+ {
+ database& db (rf.database ());
+
+ pair<shared_ptr<available_package>,
+ lazy_shared_ptr<repository_fragment>> r;
+
+ for (const auto& p: existing_packages)
+ {
+ if (p.first == db &&
+ p.second->id.name == name &&
+ (!c || satisfies (p.second->version, *c)))
+ {
+ r.first = p.second;
+ r.second = lazy_shared_ptr<repository_fragment> (db, empty_string);
+ break;
+ }
+ }
+
+ return r;
+ }
+
linked_databases repo_configs;
linked_databases
diff --git a/bpkg/package-query.hxx b/bpkg/package-query.hxx
index 12456ce..be4e0be 100644
--- a/bpkg/package-query.hxx
+++ b/bpkg/package-query.hxx
@@ -226,6 +226,25 @@ namespace bpkg
shared_ptr<available_package>
find_imaginary_stub (const package_name&);
+ // Try to find an available package in the existing packages registry. Such
+ // a registry is configuration-specific and contains package versions
+ // specified by the user on the command line as archives or directories for
+ // specific configurations (see pkg-build for details on such packages).
+ //
+ // Note that semantically such a registry can be considered as an imaginary
+ // repository which complements all the real repositories fetched in the
+ // respective configuration. Also note that normally this repository is used
+ // first (by calling this function) when trying to resolve a dependency
+ // package, prior to searching in the real repositories.
+ //
+ extern vector<pair<reference_wrapper<database>,
+ shared_ptr<available_package>>> existing_packages;
+
+ pair<shared_ptr<available_package>, lazy_shared_ptr<repository_fragment>>
+ find_existing (const package_name&,
+ const optional<version_constraint>&,
+ const lazy_shared_ptr<repository_fragment>&);
+
// Configurations to use as the repository information sources.
//
// The list normally contains the current configurations and configurations
diff --git a/bpkg/pkg-build-collect.cxx b/bpkg/pkg-build-collect.cxx
index c581f5c..4006caa 100644
--- a/bpkg/pkg-build-collect.cxx
+++ b/bpkg/pkg-build-collect.cxx
@@ -2507,7 +2507,10 @@ namespace bpkg
// recognized. An unrecognized package means the broken/stale
// repository (see below).
//
- rp = find_available_one (dn, d.constraint, af);
+ rp = find_existing (dn, d.constraint, af);
+
+ if (dap == nullptr)
+ rp = find_available_one (dn, d.constraint, af);
if (dap == nullptr && system && d.constraint)
rp = find_available_one (dn, nullopt, af);
@@ -2658,7 +2661,7 @@ namespace bpkg
system,
specified,
force,
- ru});
+ ru});
}
// Now, as we have pre-collected the dependency builds, go through
diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx
index 9a73ea6..46569df 100644
--- a/bpkg/pkg-build.cxx
+++ b/bpkg/pkg-build.cxx
@@ -2946,6 +2946,8 @@ namespace bpkg
af = root;
ap = make_shared<available_package> (move (m));
ap->locations.push_back (package_location {root, move (a)});
+
+ existing_packages.push_back (make_pair (ref (*pdb), ap));
}
}
catch (const invalid_path&)
@@ -3037,6 +3039,8 @@ namespace bpkg
ap = make_shared<available_package> (move (m));
af = root;
ap->locations.push_back (package_location {root, move (d)});
+
+ existing_packages.push_back (make_pair (ref (*pdb), ap));
}
}
catch (const invalid_path&)
diff --git a/bpkg/pkg-checkout.cxx b/bpkg/pkg-checkout.cxx
index d7b36e4..81efdc2 100644
--- a/bpkg/pkg-checkout.cxx
+++ b/bpkg/pkg-checkout.cxx
@@ -133,7 +133,7 @@ namespace bpkg
check_any_available (rdb, t);
- // Note that here we compare including the revision (see pkg-fetch()
+ // Note that here we compare including the revision (see pkg_fetch()
// implementation for more details).
//
shared_ptr<available_package> ap (
diff --git a/bpkg/pkg-unpack.cxx b/bpkg/pkg-unpack.cxx
index 6e99b36..323f296 100644
--- a/bpkg/pkg-unpack.cxx
+++ b/bpkg/pkg-unpack.cxx
@@ -289,7 +289,7 @@ namespace bpkg
check_any_available (rdb, t);
- // Note that here we compare including the revision (see pkg-fetch()
+ // Note that here we compare including the revision (see pkg_fetch()
// implementation for more details).
//
shared_ptr<available_package> ap (