From 0f9ce1c7022e5fa572886c9a9bda3a7e5c466314 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 21 Aug 2016 13:26:28 +0200 Subject: Implement searching for b in bpkg's exec directory as last resort This way if we run /opt/build2/bin/bpkg it will be able to find b in /opt/build2/bin/ without PATH. --- bpkg/utility.cxx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'bpkg/utility.cxx') diff --git a/bpkg/utility.cxx b/bpkg/utility.cxx index 12ef220..002d316 100644 --- a/bpkg/utility.cxx +++ b/bpkg/utility.cxx @@ -167,15 +167,19 @@ namespace bpkg } } + dir_path exec_dir; + void - run (const char* args[]) + run (const char* args[], const dir_path& fallback) { - if (verb >= 2) - print_process (args); - try { - process pr (args); + process_path pp (process::path_search (args[0], fallback)); + + if (verb >= 2) + print_process (args); + + process pr (pp, args); if (!pr.wait ()) throw failed (); // Assume the child issued diagnostics. @@ -253,7 +257,13 @@ namespace bpkg args.push_back (bspec.c_str ()); args.push_back (nullptr); - run (args); + + // Use our executable directory as a fallback search since normally the + // entire toolchain is installed into one directory. This way, for + // example, if we installed into /opt/build2 and run bpkg with absolute + // path (and without PATH), then bpkg will be able to find "its" b. + // + run (args, exec_dir); } bool exception_unwinding_dtor = false; -- cgit v1.1