summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-07-12 16:59:27 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-07-12 19:55:03 +0300
commitfa9017f87197565b970d22d2d51241fdfa55c916 (patch)
tree14e0e4e14465a1b81614400077112a35de92ef65
parent6fc547881a3cce4c9a96d371a2b168d68159eb5d (diff)
downloadbpkg-fa9017f87197565b970d22d2d51241fdfa55c916.tar.gz
bpkg-fa9017f87197565b970d22d2d51241fdfa55c916.tar.xz
bpkg-fa9017f87197565b970d22d2d51241fdfa55c916.zip
Add --manifest option to pkg-verify
-rw-r--r--bpkg/pkg-verify.cli6
-rw-r--r--bpkg/pkg-verify.cxx21
-rw-r--r--bpkg/rep-info.cli2
-rw-r--r--tests/pkg-verify.test12
-rw-r--r--tests/rep-create.test6
-rw-r--r--tests/rep-info.test2
6 files changed, 43 insertions, 6 deletions
diff --git a/bpkg/pkg-verify.cli b/bpkg/pkg-verify.cli
index f4f3214..5432743 100644
--- a/bpkg/pkg-verify.cli
+++ b/bpkg/pkg-verify.cli
@@ -42,5 +42,11 @@ namespace bpkg
declare such a package valid since it cannot be sure the unknown entries
are valid."
}
+
+ bool --manifest
+ {
+ "Instead of printing the successful verification result in the
+ human-readable form, dump the package manifest to \cb{stdout}."
+ }
};
}
diff --git a/bpkg/pkg-verify.cxx b/bpkg/pkg-verify.cxx
index 2711394..69014ac 100644
--- a/bpkg/pkg-verify.cxx
+++ b/bpkg/pkg-verify.cxx
@@ -4,8 +4,11 @@
#include <bpkg/pkg-verify.hxx>
+#include <iostream> // cout
+
#include <libbutl/process.mxx>
#include <libbutl/manifest-parser.mxx>
+#include <libbutl/manifest-serializer.mxx>
#include <bpkg/archive.hxx>
#include <bpkg/diagnostics.hxx>
@@ -189,7 +192,23 @@ namespace bpkg
package_manifest m (
pkg_verify (o, a, o.ignore_unknown (), !o.silent ()));
- if (verb && !o.silent () && !o.no_result ())
+ if (o.manifest ())
+ {
+ try
+ {
+ manifest_serializer s (cout, "STDOUT");
+ m.serialize (s);
+ }
+ catch (const manifest_serialization& e)
+ {
+ fail << "unable to serialize manifest: " << e.description;
+ }
+ catch (const io_error&)
+ {
+ fail << "unable to write to STDOUT";
+ }
+ }
+ else if (verb && !o.silent () && !o.no_result ())
text << "valid package " << m.name << " " << m.version;
return 0;
diff --git a/bpkg/rep-info.cli b/bpkg/rep-info.cli
index 17bf499..35afd55 100644
--- a/bpkg/rep-info.cli
+++ b/bpkg/rep-info.cli
@@ -85,7 +85,7 @@ namespace bpkg
"Print the list of available packages."
}
- bool --manifest|-m
+ bool --manifest
{
"Instead of printing the information in the human-readable form, dump it
as manifest(s). Normally you would use this option in combination with
diff --git a/tests/pkg-verify.test b/tests/pkg-verify.test
index d40b525..d438524 100644
--- a/tests/pkg-verify.test
+++ b/tests/pkg-verify.test
@@ -15,6 +15,18 @@
:
$* $src/foo-1.tar.gz 2>'valid package foo 1'
+: manifest
+:
+$* --manifest $src/foo-1.tar.gz >>EOO
+ : 1
+ name: foo
+ version: 1
+ summary: The "Foo" utility
+ license: MIT
+ url: http://www.example.org/foo
+ email: foo-users@example.org
+ EOO
+
: no-package
:
$* 2>>EOE != 0
diff --git a/tests/rep-create.test b/tests/rep-create.test
index 1fa236f..09aeb7f 100644
--- a/tests/rep-create.test
+++ b/tests/rep-create.test
@@ -32,7 +32,7 @@
%1 package\(s\) in .+/stable/%
EOE
- $rep_info -p -m 1/stable/ >>EOO
+ $rep_info -p --manifest 1/stable/ >>EOO
: 1
name: foo
version: 1
@@ -58,7 +58,7 @@
%1 package\(s\) in .+/stable/%
EOE
- $rep_info -p -m 1/stable/ >>EOO
+ $rep_info -p --manifest 1/stable/ >>EOO
: 1
name: foo
version: 1
@@ -100,7 +100,7 @@
%1 package\(s\) in .+/stable/%
EOE
- $rep_info --cert-fingerprint -p -m 1/stable/ >>~"%EOO%"
+ $rep_info --cert-fingerprint -p --manifest 1/stable/ >>~"%EOO%"
$cert_fp
: 1
name: foo
diff --git a/tests/rep-info.test b/tests/rep-info.test
index 46c91c5..60dd96e 100644
--- a/tests/rep-info.test
+++ b/tests/rep-info.test
@@ -180,7 +180,7 @@ else
: branch is printed because the stable head commit is newer that of the
: master branch.
:
- $* -r -m "$rep/style-basic.git#stable,master" >>~%EOO%
+ $* -r --manifest "$rep/style-basic.git#stable,master" >>~%EOO%
: 1
email: user@example.com
EOO