aboutsummaryrefslogtreecommitdiff
path: root/bpkg/rep-fetch.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-02-19 21:47:04 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-02-21 17:42:43 +0300
commit89dd478de7cf075beac69d0145df46f914cf35cf (patch)
treebe960f2406d087135c6456cff654de1f24a91557 /bpkg/rep-fetch.cxx
parentd75d1d9e1c5b03b17fdea1fa3638db2bfe5e8d12 (diff)
Add support for pkg-checkout
Diffstat (limited to 'bpkg/rep-fetch.cxx')
-rw-r--r--bpkg/rep-fetch.cxx36
1 files changed, 30 insertions, 6 deletions
diff --git a/bpkg/rep-fetch.cxx b/bpkg/rep-fetch.cxx
index e78ae064..0458975 100644
--- a/bpkg/rep-fetch.cxx
+++ b/bpkg/rep-fetch.cxx
@@ -74,7 +74,15 @@ namespace bpkg
authenticate_repository (co, conf, cert_pem, *cert, sm, rl);
}
- return rep_fetch_data {move (rms), move (pms), move (cert)};
+ vector<rep_fetch_data::package> fps;
+ fps.reserve (pms.size ());
+
+ for (package_manifest& m: pms)
+ fps.emplace_back (
+ rep_fetch_data::package {move (m),
+ string () /* repository_state */});
+
+ return rep_fetch_data {move (rms), move (fps), move (cert)};
}
template <typename M>
@@ -144,6 +152,9 @@ namespace bpkg
// Clone or fetch the repository.
//
+ // If changing the repository directory naming scheme, then don't forget
+ // to also update pkg_checkout().
+ //
dir_path h (sha256 (rl.canonical_name ()).abbreviated_string (16));
auto_rmdir rm (temp_dir / h);
@@ -209,7 +220,10 @@ namespace bpkg
}
}
- // Fill "skeleton" package manifests.
+ vector<rep_fetch_data::package> fps;
+ fps.reserve (pms.size ());
+
+ // Parse package manifests.
//
for (package_manifest& sm: pms)
{
@@ -246,7 +260,7 @@ namespace bpkg
// Save the package manifest, preserving its location.
//
- m.location = move (sm.location);
+ m.location = move (*sm.location);
sm = move (m);
}
catch (const manifest_parsing& e)
@@ -327,8 +341,15 @@ namespace bpkg
is.close ();
+ // If succeess then save the package manifest together with the
+ // repository state it belongs to and go to the next package.
+ //
if (pr.wait ())
- continue; // Go to the next package.
+ {
+ fps.emplace_back (rep_fetch_data::package {move (sm),
+ nm.string ()});
+ continue;
+ }
// Fall through.
}
@@ -352,7 +373,7 @@ namespace bpkg
}
}
- return rep_fetch_data {move (rms), move (pms), nullptr};
+ return rep_fetch_data {move (rms), move (fps), nullptr};
}
rep_fetch_data
@@ -520,8 +541,10 @@ namespace bpkg
session& s (session::current ());
session::reset_current ();
- for (package_manifest& pm: rfd.packages)
+ for (rep_fetch_data::package& fp: rfd.packages)
{
+ package_manifest& pm (fp.manifest);
+
// We might already have this package in the database.
//
bool persist (false);
@@ -570,6 +593,7 @@ namespace bpkg
//
p->locations.push_back (
package_location {lazy_shared_ptr<repository> (db, r),
+ move (fp.repository_state),
move (*pm.location)});
if (persist)