From 4e9e142a6564b2a73848e735f9a1b5bb744d6a83 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 18 Aug 2021 08:35:18 +0200 Subject: Also consider subproject directory names when calculating manifest checksums --- bpkg/manifest-utility.cxx | 109 +++++++++++++++++++++++++++++++--------------- 1 file changed, 73 insertions(+), 36 deletions(-) (limited to 'bpkg/manifest-utility.cxx') diff --git a/bpkg/manifest-utility.cxx b/bpkg/manifest-utility.cxx index a4cee94..9b8cbca 100644 --- a/bpkg/manifest-utility.cxx +++ b/bpkg/manifest-utility.cxx @@ -22,6 +22,41 @@ namespace bpkg const path signature_file ("signature.manifest"); const path manifest_file ("manifest"); + vector + package_b_info (const common_options& o, const dir_paths& ds, bool ext_mods) + { + path b (name_b (o)); + + vector r; + try + { + b_info (r, + ds, + ext_mods, + verb, + [] (const char* const args[], size_t n) + { + if (verb >= 2) + print_process (args, n); + }, + b, + exec_dir, + o.build_option ()); + return r; + } + catch (const b_error& e) + { + if (e.normal ()) + throw failed (); // Assume the build2 process issued diagnostics. + + diag_record dr (fail); + dr << "unable to parse project "; + if (r.size () < ds.size ()) dr << ds[r.size ()] << ' '; + dr << "info: " << e << + info << "produced by '" << b << "'; use --build to override" << endf; + } + } + package_scheme parse_package_scheme (const char*& s) { @@ -272,52 +307,54 @@ namespace bpkg } } - vector> + package_version_infos package_versions (const common_options& o, const dir_paths& ds) { - path b (name_b (o)); + vector pis (package_b_info (o, ds, false /* ext_mods */)); + + package_version_infos r; + r.reserve (pis.size ()); + + for (const b_project_info& pi: pis) + { + // An empty version indicates that the version module is not enabled for + // the project. + // + optional v (!pi.version.empty () + ? version (pi.version.string ()) + : optional ()); + + r.push_back (package_version_info {move (v), move (pi)}); + } + + return r; + } + + string + package_checksum (const common_options& o, + const dir_path& d, + const package_info* pi) + { + path f (d / manifest_file); - vector pis; try { - b_info (pis, - ds, - false /* ext_mods */, - verb, - [] (const char* const args[], size_t n) - { - if (verb >= 2) - print_process (args, n); - }, - b, - exec_dir, - o.build_option ()); + ifdstream is (f, fdopen_mode::binary); + sha256 cs (is); - vector> r; - r.reserve (pis.size ()); + const vector& sps ( + pi != nullptr + ? pi->subprojects + : package_b_info (o, d, false /* ext_mods */).subprojects); - for (const b_project_info& pi: pis) - { - // An empty version indicates that the version module is not enabled - // for the project. - // - r.push_back (!pi.version.empty () - ? version (pi.version.string ()) - : optional ()); - } + for (const package_info::subproject& sp: sps) + cs.append (sp.path.string ()); - return r; + return cs.string (); } - catch (const b_error& e) + catch (const io_error& e) { - if (e.normal ()) - throw failed (); // Assume the build2 process issued diagnostics. - - diag_record dr (fail); - dr << "unable to parse project "; - if (pis.size () < ds.size ()) dr << ds[pis.size ()] << ' '; - dr << "info: " << e << - info << "produced by '" << b << "'; use --build to override" << endf; + fail << "unable to read from " << f << ": " << e << endf; } } } -- cgit v1.1