From bc970e792159c6b03febb978fc8c9f09dc91e602 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 22 May 2019 15:26:09 +0300 Subject: Add support for package manifest upstream-version value --- libbpkg/manifest.cxx | 34 ++++++++++++++++++++++++++++++++++ libbpkg/manifest.hxx | 1 + 2 files changed, 35 insertions(+) (limited to 'libbpkg') diff --git a/libbpkg/manifest.cxx b/libbpkg/manifest.cxx index dc3ff86..139b7a8 100644 --- a/libbpkg/manifest.cxx +++ b/libbpkg/manifest.cxx @@ -1586,6 +1586,8 @@ namespace bpkg return email (move (v), move (c)); } + const version stub_version (0, "0", nullopt, 0, 0); + static void parse_package_manifest ( parser& p, @@ -1637,6 +1639,11 @@ namespace bpkg return (fl & f) != package_manifest_flags::none; }; + // Cache the upstream version manifest value and validate whether it's + // allowed later, after the version value is parsed. + // + optional upstream_version; + // We will cache the depends manifest values to parse and, if requested, // complete the dependency constraints later, after the version value is // parsed. @@ -1706,6 +1713,16 @@ namespace bpkg m.version.string () + ": earliest release"); } } + else if (n == "upstream-version") + { + if (upstream_version) + bad_name ("upstream package version redefinition"); + + if (v.empty ()) + bad_value ("empty upstream package version"); + + upstream_version = move (nv); + } else if (n == "project") { if (m.project) @@ -2004,6 +2021,20 @@ namespace bpkg else if (m.license_alternatives.empty ()) bad_value ("no project license specified"); + // Verify that the upstream version is not specified for a stub. + // + if (upstream_version) + { + // Restore as bad_name() uses its line/column. + // + nv = move (*upstream_version); + + if (m.version.compare (stub_version, true) == 0) + bad_name ("upstream package version specified for a stub"); + + m.upstream_version = move (nv.value); + } + // Verify that description is specified if the description type is // specified. // @@ -2433,6 +2464,9 @@ namespace bpkg s.next ("name", m.name.string ()); s.next ("version", m.version.string ()); + if (m.upstream_version) + s.next ("upstream-version", *m.upstream_version); + if (m.project) s.next ("project", m.project->string ()); diff --git a/libbpkg/manifest.hxx b/libbpkg/manifest.hxx index 2d1e609..59c0ba0 100644 --- a/libbpkg/manifest.hxx +++ b/libbpkg/manifest.hxx @@ -627,6 +627,7 @@ namespace bpkg package_name name; version_type version; + butl::optional upstream_version; butl::optional project; butl::optional priority; std::string summary; -- cgit v1.1