aboutsummaryrefslogtreecommitdiff
path: root/bpkg/pkg-verify.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2022-07-11 14:46:08 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2022-07-13 12:04:48 +0300
commitf253fe820064310eee9aefc793328e84674d5c36 (patch)
tree1f7053ca5f7ac180c8d67abfc99aa142e168f4d4 /bpkg/pkg-verify.cxx
parentd235d58f5521264e27decf416df74fa97f894307 (diff)
Add support for build-file package manifest value
Diffstat (limited to 'bpkg/pkg-verify.cxx')
-rw-r--r--bpkg/pkg-verify.cxx86
1 files changed, 64 insertions, 22 deletions
diff --git a/bpkg/pkg-verify.cxx b/bpkg/pkg-verify.cxx
index 229b73d..26393d6 100644
--- a/bpkg/pkg-verify.cxx
+++ b/bpkg/pkg-verify.cxx
@@ -202,31 +202,41 @@ namespace bpkg
throw failed ();
}
- // Expand the *-file manifest values, if requested.
+ // If requested, expand file-referencing package manifest values.
//
- if (ev)
+ if (ev || lb)
{
m.load_files (
- [&pd, &co, &af, diag_level] (const string& n, const path& p)
+ [ev, &pd, &co, &af, diag_level]
+ (const string& n, const path& p) -> optional<string>
{
- path f (pd / p);
- string s (extract (co, af, f, diag_level != 0));
+ bool bf (n == "build-file");
- if (s.empty ())
+ // Always expand the build-file values.
+ //
+ if (ev || bf)
{
- if (diag_level != 0)
- error << n << " manifest value in package archive "
- << af << " references empty file " << f;
+ path f (pd / p);
+ string s (extract (co, af, f, diag_level != 0));
- throw failed ();
- }
+ if (s.empty () && !bf)
+ {
+ if (diag_level != 0)
+ error << n << " manifest value in package archive "
+ << af << " references empty file " << f;
+
+ throw failed ();
+ }
- return s;
+ return s;
+ }
+ else
+ return nullopt;
},
iu);
}
- // Extract the bootstrap, root, and config/*.build buildfiles into the
+ // Load the bootstrap, root, and config/*.build buildfiles into the
// respective *-build values, if requested and are not already
// specified in the manifest.
//
@@ -433,21 +443,53 @@ namespace bpkg
// Load the bootstrap, root, and config/*.build buildfiles into the
// respective *-build values, if requested and if they are not already
- // specified in the manifest.
+ // specified in the manifest. But first expand the build-file manifest
+ // values into the respective *-build values.
//
// Note that we don't verify that the files are not empty.
//
if (lb)
- try
- {
- load_package_buildfiles (m, d);
- }
- catch (const runtime_error& e)
{
- if (diag_level != 0)
- error << e;
+ m.load_files (
+ [&d, &mf, diag_level]
+ (const string& n, const path& p) -> optional<string>
+ {
+ // Only expand the build-file values.
+ //
+ if (n == "build-file")
+ {
+ path f (d / p);
- throw failed ();
+ try
+ {
+ ifdstream is (f);
+ return is.read_text ();
+ }
+ catch (const io_error& e)
+ {
+ if (diag_level != 0)
+ error << "unable to read from " << f << " referenced by "
+ << n << " manifest value in " << mf << ": " << e;
+
+ throw failed ();
+ }
+ }
+ else
+ return nullopt;
+ },
+ iu);
+
+ try
+ {
+ load_package_buildfiles (m, d);
+ }
+ catch (const runtime_error& e)
+ {
+ if (diag_level != 0)
+ error << e;
+
+ throw failed ();
+ }
}
// We used to verify package directory is <name>-<version> but it is