aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-05-22 15:26:09 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-05-22 16:29:43 +0300
commitbc970e792159c6b03febb978fc8c9f09dc91e602 (patch)
tree0e1b7174da6fa040703ca9fb10314b27c6118648
parent0575ec4e2084c553fa56e3d645233b118936a2d5 (diff)
Add support for package manifest upstream-version value
-rw-r--r--libbpkg/manifest.cxx34
-rw-r--r--libbpkg/manifest.hxx1
-rw-r--r--tests/manifest/testscript151
3 files changed, 98 insertions, 88 deletions
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<name_value> 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<std::string> upstream_version;
butl::optional<package_name> project;
butl::optional<priority_type> priority;
std::string summary;
diff --git a/tests/manifest/testscript b/tests/manifest/testscript
index acf9d3b..96f8f31 100644
--- a/tests/manifest/testscript
+++ b/tests/manifest/testscript
@@ -231,21 +231,14 @@
{
: absent
:
- $* <<EOI >>EOO
+ $* <<EOF >>EOF
: 1
name: libfoo
version: 2.0.0
summary: Modern C++ parser
license: LGPLv2
description: libfoo is a very modern C++ XML parser.
- EOI
- : 1
- name: libfoo
- version: 2.0.0
- summary: Modern C++ parser
- license: LGPLv2
- description: libfoo is a very modern C++ XML parser.
- EOO
+ EOF
: not-text
:
@@ -279,21 +272,14 @@
: ignore-unknown
:
- $* -i <<EOI >>EOO
- : 1
- name: libfoo
- version: 2.0.0
- summary: Modern C++ parser
- license: LGPLv2
- description-file: README.rtf
- EOI
+ $* -i <<EOF >>EOF
: 1
name: libfoo
version: 2.0.0
summary: Modern C++ parser
license: LGPLv2
description-file: README.rtf
- EOO
+ EOF
}
: unknown
@@ -315,7 +301,7 @@
: ignore
:
- $* -i <<EOI >>EOO
+ $* -i <<EOF >>EOF
: 1
name: libfoo
version: 2.0.0
@@ -323,15 +309,7 @@
license: LGPLv2
description: libfoo is a very modern C++ XML parser.
description-type: text/markdowns
- EOI
- : 1
- name: libfoo
- version: 2.0.0
- summary: Modern C++ parser
- license: LGPLv2
- description: libfoo is a very modern C++ XML parser.
- description-type: text/markdowns
- EOO
+ EOF
}
: plain
@@ -339,15 +317,7 @@
{
: valid
:
- $* <<EOI >>EOO
- : 1
- name: libfoo
- version: 2.0.0
- summary: Modern C++ parser
- license: LGPLv2
- description: libfoo is a very modern C++ XML parser.
- description-type: text/plain
- EOI
+ $* <<EOF >>EOF
: 1
name: libfoo
version: 2.0.0
@@ -355,7 +325,7 @@
license: LGPLv2
description: libfoo is a very modern C++ XML parser.
description-type: text/plain
- EOO
+ EOF
: invalid
:
@@ -377,15 +347,7 @@
{
: default
:
- $* <<EOI >>EOO
- : 1
- name: libfoo
- version: 2.0.0
- summary: Modern C++ parser
- license: LGPLv2
- description: libfoo is a very modern C++ XML parser.
- description-type: text/markdown
- EOI
+ $* <<EOF >>EOF
: 1
name: libfoo
version: 2.0.0
@@ -393,11 +355,11 @@
license: LGPLv2
description: libfoo is a very modern C++ XML parser.
description-type: text/markdown
- EOO
+ EOF
: gfm
:
- $* <<EOI >>EOO
+ $* <<EOF >>EOF
: 1
name: libfoo
version: 2.0.0
@@ -405,27 +367,11 @@
license: LGPLv2
description: libfoo is a very modern C++ XML parser.
description-type: text/markdown; variant=GFM
- EOI
- : 1
- name: libfoo
- version: 2.0.0
- summary: Modern C++ parser
- license: LGPLv2
- description: libfoo is a very modern C++ XML parser.
- description-type: text/markdown; variant=GFM
- EOO
+ EOF
: common-mark
:
- $* <<EOI >>EOO
- : 1
- name: libfoo
- version: 2.0.0
- summary: Modern C++ parser
- license: LGPLv2
- description: libfoo is a very modern C++ XML parser.
- description-type: text/markdown; variant=CommonMark
- EOI
+ $* <<EOF >>EOF
: 1
name: libfoo
version: 2.0.0
@@ -433,7 +379,7 @@
license: LGPLv2
description: libfoo is a very modern C++ XML parser.
description-type: text/markdown; variant=CommonMark
- EOO
+ EOF
: invalid-variant
:
@@ -454,7 +400,7 @@
: ignore
:
- $* -i <<EOI >>EOO
+ $* -i <<EOF >>EOF
: 1
name: libfoo
version: 2.0.0
@@ -462,15 +408,7 @@
license: LGPLv2
description: libfoo is a very modern C++ XML parser.
description-type: text/markdown; variant=Original
- EOI
- : 1
- name: libfoo
- version: 2.0.0
- summary: Modern C++ parser
- license: LGPLv2
- description: libfoo is a very modern C++ XML parser.
- description-type: text/markdown; variant=Original
- EOO
+ EOF
}
: invalid-parameter
@@ -492,15 +430,7 @@
: ignore
:
- $* -i <<EOI >>EOO
- : 1
- name: libfoo
- version: 2.0.0
- summary: Modern C++ parser
- license: LGPLv2
- description: libfoo is a very modern C++ XML parser.
- description-type: text/markdown; variants=GFM
- EOI
+ $* -i <<EOF >>EOF
: 1
name: libfoo
version: 2.0.0
@@ -508,7 +438,7 @@
license: LGPLv2
description: libfoo is a very modern C++ XML parser.
description-type: text/markdown; variants=GFM
- EOO
+ EOF
}
}
}
@@ -527,6 +457,51 @@
EOI
}
}
+
+ : upstream-version
+ :
+ {
+ : valid
+ :
+ $* <<EOF >>EOF
+ : 1
+ name: libfoo
+ version: 2.0.0
+ upstream-version: 0.28.0.abc.15
+ summary: Modern C++ parser
+ license: LGPLv2
+ description: libfoo is a very modern C++ XML parser.
+ EOF
+
+ : duplicate
+ :
+ $* <<EOI 2>>EOE != 0
+ : 1
+ name: libfoo
+ version: 2.0.0
+ upstream-version: 0.28.0.abc.15
+ summary: Modern C++ parser
+ license: LGPLv2
+ description: libfoo is a very modern C++ XML parser.
+ upstream-version: 0.28.0.abc.15
+ EOI
+ stdin:8:1: error: upstream package version redefinition
+ EOE
+
+ : stub
+ :
+ $* <<EOI 2>>EOE != 0
+ : 1
+ name: libfoo
+ version: 0+1
+ upstream-version: 0.28.0.abc.15
+ summary: Modern C++ parser
+ license: LGPLv2
+ description: libfoo is a very modern C++ XML parser.
+ EOI
+ stdin:4:1: error: upstream package version specified for a stub
+ EOE
+ }
}
: manifest-list