aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-07-11 13:35:50 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-07-11 13:35:50 +0300
commit7f86ee1fd487cb7fd4a1b76949951ad8e4b8b69d (patch)
tree37b16ec7a392f4ed94d2a9a1aaa63d4214f3b155
parent1b192351dc0ef09423ee9a40d68bacc3137c9aec (diff)
Add support for package project manifest value
-rw-r--r--libbpkg/manifest.cxx17
-rw-r--r--libbpkg/manifest.hxx4
-rw-r--r--tests/manifest/testscript1
3 files changed, 22 insertions, 0 deletions
diff --git a/libbpkg/manifest.cxx b/libbpkg/manifest.cxx
index c2d7eee..b4b1fa5 100644
--- a/libbpkg/manifest.cxx
+++ b/libbpkg/manifest.cxx
@@ -993,6 +993,20 @@ namespace bpkg
if (m.version.release && m.version.release->empty ())
bad_value ("invalid package version release");
}
+ else if (n == "project")
+ {
+ if (m.project)
+ bad_name ("package project redefinition");
+
+ try
+ {
+ m.project = package_name (move (v));
+ }
+ catch (const invalid_argument& e)
+ {
+ bad_value (string ("invalid project name: ") + e.what ());
+ }
+ }
else if (n == "summary")
{
if (!m.summary.empty ())
@@ -1399,6 +1413,9 @@ namespace bpkg
s.next ("name", name.string ());
s.next ("version", version.string ());
+ if (project)
+ s.next ("project", project->string ());
+
if (priority)
{
size_t v (*priority);
diff --git a/libbpkg/manifest.hxx b/libbpkg/manifest.hxx
index 72af14c..cd81d6e 100644
--- a/libbpkg/manifest.hxx
+++ b/libbpkg/manifest.hxx
@@ -388,6 +388,7 @@ namespace bpkg
package_name name;
version_type version;
+ butl::optional<package_name> project;
butl::optional<priority_type> priority;
std::string summary;
std::vector<licenses> license_alternatives;
@@ -412,6 +413,9 @@ namespace bpkg
butl::optional<std::string> sha256sum;
butl::optional<std::string> fragment;
+ const package_name&
+ effective_project () const noexcept {return project ? *project : name;}
+
public:
package_manifest () = default; // VC export.
package_manifest (butl::manifest_parser&, bool ignore_unknown = false);
diff --git a/tests/manifest/testscript b/tests/manifest/testscript
index 77a27ea..f9a42cb 100644
--- a/tests/manifest/testscript
+++ b/tests/manifest/testscript
@@ -97,6 +97,7 @@
:
name: libfoo
version: 1.2.3+2
+ project: foo
priority: high; Due to critical bug fix.
summary: Modern XML parser
license: LGPLv2, MIT; Both required.