From 5fb0df6f63e02c141e8a0e5ad4543dea525df3fc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 1 May 2017 11:02:36 +0200 Subject: Reimplement tar invocations to do manual decompression This is needed to prevent tar from forking, which doesn't work reliably on MSYS2. --- bpkg/pkg-verify.cxx | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'bpkg/pkg-verify.cxx') diff --git a/bpkg/pkg-verify.cxx b/bpkg/pkg-verify.cxx index cd51d54..275c710 100644 --- a/bpkg/pkg-verify.cxx +++ b/bpkg/pkg-verify.cxx @@ -23,26 +23,27 @@ namespace bpkg dir_path pd (package_dir (af)); path mf (pd / path ("manifest")); - // If diag is false, we need to make tar not print any diagnostics. - // There doesn't seem to be an option to suppress this and the only - // way is to redirect STDERR to something like /dev/null. To keep - // things simple, we are going to redirect it to STDOUT, which we - // in turn redirect to a pipe and use to parse the manifest data. - // If things go badly for tar and it starts spitting errors instead - // of the manifest, the manifest parser will fail. But that's ok - // since we assume that the child error is always the reason for - // the manifest parsing failure. + // If diag is false, we need to make tar not print any diagnostics. There + // doesn't seem to be an option to suppress this and the only way is to + // redirect STDERR to something like /dev/null. // - process pr (start_extract (co, af, mf, diag)); + // If things go badly for tar and it starts spitting errors instead of the + // manifest, the manifest parser will fail. But that's ok since we assume + // that the child error is always the reason for the manifest parsing + // failure. + // + pair pr (start_extract (co, af, mf, diag)); + + auto wait = [&pr] () {return pr.second.wait () && pr.first.wait ();}; try { - ifdstream is (move (pr.in_ofd), fdstream_mode::skip); + ifdstream is (move (pr.second.in_ofd), fdstream_mode::skip); manifest_parser mp (is, mf.string ()); package_manifest m (mp, iu); is.close (); - if (pr.wait ()) + if (wait ()) { // Verify package archive/directory is -. // @@ -68,7 +69,7 @@ namespace bpkg // catch (const manifest_parsing& e) { - if (pr.wait ()) + if (wait ()) { if (diag) error (e.name, e.line, e.column) << e.description << @@ -79,7 +80,7 @@ namespace bpkg } catch (const io_error&) { - if (pr.wait ()) + if (wait ()) { if (diag) error << "unable to extract " << mf << " from " << af; @@ -91,7 +92,7 @@ namespace bpkg // We should only get here if the child exited with an error // status. // - assert (!pr.wait ()); + assert (!wait ()); // While it is reasonable to assuming the child process issued // diagnostics, tar, specifically, doesn't mention the archive -- cgit v1.1