aboutsummaryrefslogtreecommitdiff
path: root/bpkg/rep-fetch.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-09-28 09:34:27 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-09-28 09:34:27 +0200
commitbbc1acd6e9e086c5bcfccac971c8ca4edd192765 (patch)
treecafee6b8011ee3e2d72c77e8858473bf425a5e79 /bpkg/rep-fetch.cxx
parent08a439c5d4e4f8c6a448f4f85b60b5fef6d7ca15 (diff)
Handle complement repositories
Diffstat (limited to 'bpkg/rep-fetch.cxx')
-rw-r--r--bpkg/rep-fetch.cxx39
1 files changed, 33 insertions, 6 deletions
diff --git a/bpkg/rep-fetch.cxx b/bpkg/rep-fetch.cxx
index 641efb2..04e09f8 100644
--- a/bpkg/rep-fetch.cxx
+++ b/bpkg/rep-fetch.cxx
@@ -51,7 +51,9 @@ namespace bpkg
for (repository_manifest& rm: rms)
{
- if (rm.location.empty ())
+ repository_role rr (rm.effective_role ());
+
+ if (rr == repository_role::base)
continue; // Entry for this repository.
// If the location is relative, complete it using this repository
@@ -89,12 +91,37 @@ namespace bpkg
if (!pr->fetched)
rep_fetch (co, t, pr);
- level4 ([&]{trace << pr->name () << " prerequisite of " << r->name ();});
-
- if (!r->prerequisites.insert (lazy_weak_ptr<repository> (db, pr)).second)
+ // @@ What if we have duplicated? Ideally, we would like to check
+ // this once and as early as possible. The original idea was to
+ // do it during manifest parsing and serialization. But at that
+ // stage we have no way of completing relative locations (which
+ // is required to calculate canonical names). Current thinking is
+ // that we should have something like rep-verify (similar to
+ // pkg-verify) that performs (potentially expensive) repository
+ // verifications, including making sure prerequisites can be
+ // satisfied from the listed repositories, etc. Perhaps we can
+ // also re-use some of that functionality here. I.e., instead of
+ // calling the "naked" fetch_repositories() above, we will call
+ // a function from rep-verify that will perform extra verifications.
+ //
+ switch (rr)
{
- fail << "duplicate prerequisite repository " << pr->location << " "
- << "in " << r->name ();
+ case repository_role::complement:
+ {
+ level4 ([&]{trace << pr->name () << " complement of "
+ << r->name ();});
+ r->complements.insert (lazy_shared_ptr<repository> (db, pr));
+ break;
+ }
+ case repository_role::prerequisite:
+ {
+ level4 ([&]{trace << pr->name () << " prerequisite of "
+ << r->name ();});
+ r->prerequisites.insert (lazy_weak_ptr<repository> (db, pr));
+ break;
+ }
+ case repository_role::base:
+ assert (false);
}
}