From bc24eec7208187e171fd61ced7130fd8e2828257 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 14 Mar 2018 00:54:05 +0300 Subject: Add support for version iteration --- bpkg/pkg-unpack.cxx | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'bpkg/pkg-unpack.cxx') diff --git a/bpkg/pkg-unpack.cxx b/bpkg/pkg-unpack.cxx index d9d54ea..41c72f4 100644 --- a/bpkg/pkg-unpack.cxx +++ b/bpkg/pkg-unpack.cxx @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -60,8 +61,11 @@ namespace bpkg } } + // Select the external package in this configuration. + // static shared_ptr - pkg_unpack (dir_path c, + pkg_unpack (const common_options& o, + dir_path c, transaction& t, string n, version v, @@ -74,6 +78,8 @@ namespace bpkg database& db (t.database ()); tracer_guard tg (db, trace); + string mc (sha256 (o, d / manifest_file)); + // Make the package and configuration paths absolute and normalized. // If the package is inside the configuration, use the relative path. // This way we can move the configuration around. @@ -99,6 +105,7 @@ namespace bpkg p->repository = move (rl); p->src_root = move (d); p->purge_src = purge; + p->manifest_checksum = move (mc); db.update (p); } @@ -116,12 +123,15 @@ namespace bpkg false, // Don't purge archive. move (d), purge, + move (mc), nullopt, // No output directory yet. {}}); // No prerequisites captured yet. db.persist (p); } + assert (p->external ()); + t.commit (); return p; } @@ -150,15 +160,18 @@ namespace bpkg // Fix-up the package version. // - optional v (package_version (o, d)); + if (optional v = package_version (o, d)) + m.version = move (*v); - if (v) + if (optional v = package_iteration ( + o, c, t, d, m.name, m.version, true /* check_external */)) m.version = move (*v); // Use the special root repository as the repository of this // package. // - return pkg_unpack (c, + return pkg_unpack (o, + c, t, move (m.name), move (m.version), @@ -168,7 +181,8 @@ namespace bpkg } shared_ptr - pkg_unpack (const dir_path& c, + pkg_unpack (const common_options& o, + const dir_path& c, transaction& t, string n, version v, @@ -224,7 +238,8 @@ namespace bpkg const repository_location& rl (pl->repository->location); - return pkg_unpack (c, + return pkg_unpack (o, + c, t, move (n), move (v), @@ -386,6 +401,8 @@ namespace bpkg p->src_root = d.leaf (); // For now assuming to be in configuration. p->purge_src = true; + p->manifest_checksum = sha256 (co, d / manifest_file); + p->state = package_state::unpacked; db.update (p); @@ -444,7 +461,7 @@ namespace bpkg // p = v.empty () ? pkg_unpack (o, c, t, n) - : pkg_unpack (c, t, move (n), move (v), o.replace ()); + : pkg_unpack (o, c, t, move (n), move (v), o.replace ()); } if (verb && !o.no_result ()) -- cgit v1.1