diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2021-10-09 22:05:40 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2021-10-12 14:20:53 +0300 |
commit | b48fc390bc1c6fa289f821bac0380267762d1238 (patch) | |
tree | 9944de53a4c11a8948e59d5fe5fb44a150a6aed8 /bpkg/pkg-verify.hxx | |
parent | 6beb03862724e444bf24c92031e47814c9949ae2 (diff) |
Verify package manifest compatibility with current toolchain
Diffstat (limited to 'bpkg/pkg-verify.hxx')
-rw-r--r-- | bpkg/pkg-verify.hxx | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/bpkg/pkg-verify.hxx b/bpkg/pkg-verify.hxx index 5643692..ac231ec 100644 --- a/bpkg/pkg-verify.hxx +++ b/bpkg/pkg-verify.hxx @@ -4,6 +4,8 @@ #ifndef BPKG_PKG_VERIFY_HXX #define BPKG_PKG_VERIFY_HXX +#include <libbutl/manifest-forward.hxx> + #include <libbpkg/manifest.hxx> #include <bpkg/types.hxx> @@ -20,17 +22,27 @@ namespace bpkg // expand the file-referencing manifest values (description, changes, etc), // setting them to the contents of files they refer to, set the potentially // absent description-type value to the effective description type (see - // libbpkg/manifest.hxx), and complete the dependency constraints. Throw - // failed if invalid or if something goes wrong. If diag is false, then - // don't issue diagnostics about the reason why the package is invalid. + // libbpkg/manifest.hxx), and complete the dependency constraints. + // + // Throw not_package (derived from failed) if this doesn't look like a + // package. Throw plain failed if this does looks like a package but + // something about it is invalid or if something else goes wrong. + // + // Issue diagnostics according the diag_level as follows: // + // 0 - Suppress all errors messages except for underlying system errors. + // 1 - Suppress error messages about the reason why this is not a package. + // 2 - Suppress no error messages. + // + class not_package: public failed {}; + package_manifest pkg_verify (const common_options&, const path& archive, bool ignore_unknown, bool expand_values, bool complete_depends = true, - bool diag = true); + int diag_level = 2); // Similar to the above but verifies that a source directory is a valid // package. Always translates the package version and completes dependency @@ -39,10 +51,28 @@ namespace bpkg // itself. // package_manifest - pkg_verify (const dir_path& source, + pkg_verify (const common_options&, + const dir_path& source, bool ignore_unknown, const function<package_manifest::translate_function>&, - bool diag = true); + int diag_level = 2); + + // Pre-parse the package manifest and return the name value pairs list, + // stripping the format version and the end-of-manifest/stream pairs. Also + // verify that the package is compatible with the current toolchain and + // issue diagnostics and throw failed if it is not. Pass through the + // manifest_parsing and io_error exceptions, so that the caller can decide + // how to handle them (for example, ignore them if the manifest-printing + // process has failed, etc). + // + // To omit the package location from the diagnostics, pass an empty path as + // the what argument. + // + vector<butl::manifest_name_value> + pkg_verify (const common_options&, + butl::manifest_parser&, + const path& what, + int diag_level = 2); } #endif // BPKG_PKG_VERIFY_HXX |