diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-05-14 14:10:56 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-05-14 16:54:16 +0300 |
commit | 2df57d72b65012674e6bc64dec66d9b3fd7f993b (patch) | |
tree | 81c893c0b745145d9a3779b9ce3fb41c57e17956 /bpkg/satisfaction.cxx | |
parent | 1ddbf3409f76f0dd91a9402e602bc1ea1b12f8cd (diff) |
Fallback to output directory removal for --keep-out on disfigure failure
Diffstat (limited to 'bpkg/satisfaction.cxx')
-rw-r--r-- | bpkg/satisfaction.cxx | 63 |
1 files changed, 26 insertions, 37 deletions
diff --git a/bpkg/satisfaction.cxx b/bpkg/satisfaction.cxx index 9211ac0..8a61145 100644 --- a/bpkg/satisfaction.cxx +++ b/bpkg/satisfaction.cxx @@ -6,7 +6,6 @@ #include <libbutl/process.mxx> -#include <bpkg/utility.hxx> #include <bpkg/package-odb.hxx> #include <bpkg/diagnostics.hxx> @@ -100,7 +99,7 @@ namespace bpkg static version build2_version; void - satisfy_build2 (const common_options& co, + satisfy_build2 (const common_options& o, const string& pkg, const dependency& d) { @@ -110,53 +109,43 @@ namespace bpkg // if (build2_version.empty ()) { - const char* args[] = {name_b (co), "--version", nullptr}; + fdpipe pipe (open_pipe ()); - try - { - process_path pp (process::path_search (args[0], exec_dir)); + process pr (start_b (o, + pipe, 2 /* stderr */, + verb_b::quiet, + "--version")); - if (verb >= 3) - print_process (args); + // Shouldn't throw, unless something is severely damaged. + // + pipe.out.close (); - process pr (pp, args, 0, -1); // Redirect STDOUT to pipe. + string l; + try + { + ifdstream is (move (pipe.in), fdstream_mode::skip); + getline (is, l); + is.close (); - string l; - try + if (pr.wait () && l.compare (0, 7, "build2 ") == 0) { - ifdstream is (move (pr.in_ofd), fdstream_mode::skip); - getline (is, l); - is.close (); - - if (pr.wait () && l.compare (0, 7, "build2 ") == 0) + try { - try - { - build2_version = version (string (l, 7)); - } - catch (const invalid_argument&) {} // Fall through. + build2_version = version (string (l, 7)); } - - // Fall through. - } - catch (const io_error&) - { - pr.wait (); - // Fall through. + catch (const invalid_argument&) {} // Fall through. } - if (build2_version.empty ()) - fail << "unable to determine build2 version of " << args[0]; + // Fall through. } - catch (const process_error& e) + catch (const io_error&) { - error << "unable to execute " << args[0] << ": " << e; - - if (e.child) - exit (1); - - throw failed (); + pr.wait (); + // Fall through. } + + if (build2_version.empty ()) + fail << "unable to determine build2 version of " << name_b (o); } if (!satisfies (build2_version, d.constraint)) |