diff options
Diffstat (limited to 'bpkg/rep-create.cxx')
-rw-r--r-- | bpkg/rep-create.cxx | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/bpkg/rep-create.cxx b/bpkg/rep-create.cxx index f47bc09..9b9bdeb 100644 --- a/bpkg/rep-create.cxx +++ b/bpkg/rep-create.cxx @@ -5,8 +5,8 @@ #include <map> -#include <libbutl/filesystem.mxx> // dir_iterator -#include <libbutl/manifest-serializer.mxx> +#include <libbutl/filesystem.hxx> // dir_iterator +#include <libbutl/manifest-serializer.hxx> #include <libbpkg/manifest.hxx> #include <libbpkg/package-name.hxx> @@ -24,7 +24,7 @@ using namespace butl; namespace bpkg { - struct package_key + struct package_name_version { package_name name; bpkg::version version; @@ -34,7 +34,7 @@ namespace bpkg // revision. // bool - operator< (const package_key& y) const + operator< (const package_name_version& y) const { int r (name.compare (y.name)); return r < 0 || (r == 0 && version.compare (y.version, true) < 0); @@ -47,7 +47,7 @@ namespace bpkg package_manifest manifest; }; - using package_map = map<package_key, package_data>; + using package_map = map<package_name_version, package_data>; static void collect (const rep_create_options& o, @@ -58,7 +58,7 @@ namespace bpkg { tracer trace ("collect"); - for (const dir_entry& de: dir_iterator (d, false /* ignore_dangling */)) + for (const dir_entry& de: dir_iterator (d, dir_iterator::no_follow)) { path p (de.path ()); @@ -98,11 +98,16 @@ namespace bpkg path a (d / p); package_manifest m ( - pkg_verify (o, a, o.ignore_unknown (), true /* expand_values */)); + pkg_verify (o, + a, + o.ignore_unknown (), + o.ignore_unknown () /* ignore_toolchain */, + true /* expand_values */, + true /* load_buildfiles */)); // Calculate its checksum. // - m.sha256sum = sha256 (o, a); + m.sha256sum = sha256sum (o, a); l4 ([&]{trace << m.name << " " << m.version << " in " << a << " sha256sum " << *m.sha256sum;}); @@ -111,7 +116,7 @@ namespace bpkg // m.location = a.leaf (root); - package_key k {m.name, m.version}; // Argument evaluation order. + package_name_version k {m.name, m.version}; // Argument evaluation order. auto r (map.emplace (move (k), package_data {a, move (m)})); // Diagnose duplicates. @@ -162,6 +167,15 @@ namespace bpkg }) << " prerequisite repository(s)";}); + optional<standard_version> rmv ( + rms.header && rms.header->min_bpkg_version + ? rms.header->min_bpkg_version + : nullopt); + + optional<standard_version> opv (o.min_bpkg_version_specified () + ? o.min_bpkg_version () + : optional<standard_version> ()); + // While we could have serialized as we go along, the order of // packages will be pretty much random and not reproducible. By // collecting all the manifests in a map we get a sorted list. @@ -170,7 +184,7 @@ namespace bpkg collect (o, pm, d, d); pkg_package_manifests manifests; - manifests.sha256sum = sha256 (o, path (d / repositories_file)); + manifests.sha256sum = sha256sum (o, path (d / repositories_file)); for (auto& p: pm) { @@ -182,6 +196,16 @@ namespace bpkg manifests.emplace_back (move (m)); } + // Issue a warning if --min-bpkg-version option and the repositories + // manifest's min-bpkg-version value are both specified and don't match. + // Let's issue it after the added repositories are printed to stdout, so + // that it doesn't go unnoticed. + // + if (opv && rmv && *opv != *rmv) + warn << "--min-bpkg-version option value " << *opv << " differs from " + << "minimum bpkg version " << *rmv << " specified in " + << d / repositories_file; + // Serialize packages manifest, optionally generate the signature manifest. // path p (d / packages_file); @@ -197,7 +221,7 @@ namespace bpkg ofdstream ofs (p, fdopen_mode::binary); manifest_serializer s (ofs, p.string ()); - manifests.serialize (s); + manifests.serialize (s, opv ? opv : rmv); ofs.close (); } @@ -212,7 +236,7 @@ namespace bpkg info << "run 'bpkg help rep-create' for more information"; signature_manifest m; - m.sha256sum = sha256 (o, p); + m.sha256sum = sha256sum (o, p); m.signature = sign_repository (o, m.sha256sum, key, *cert, d); p = path (d / signature_file); |