diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2023-08-29 14:24:26 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2023-08-29 15:49:42 +0300 |
commit | 803059b346f8bccc9b4c4579119a5966b67da993 (patch) | |
tree | 858c464bf0e2b392e1c3c5b9809f7792da85c811 | |
parent | 9d47b6eeba8038978f860fbdb9370b081bd9bb40 (diff) |
Run `sudo mkdir -p` at bbot.sys.install.tar.extract step in worker
-rw-r--r-- | bbot/worker/worker.cxx | 39 | ||||
-rw-r--r-- | tests/integration/testscript | 4 |
2 files changed, 30 insertions, 13 deletions
diff --git a/bbot/worker/worker.cxx b/bbot/worker/worker.cxx index b759760..8c22796 100644 --- a/bbot/worker/worker.cxx +++ b/bbot/worker/worker.cxx @@ -96,20 +96,35 @@ catch (const system_error& e) } static void -mk_p (tracer& t, string* log, const dir_path& d) -try +#ifndef _WIN32 +mk_p (tracer& t, string* log, const dir_path& d, bool sudo = false) { - if (verb >= 3) - t << "mkdir -p " << d; - - if (log != nullptr) - *log += "mkdir -p " + d.representation () + '\n'; + if (sudo) + { + if (log != nullptr) + *log += "sudo mkdir -p " + d.representation () + '\n'; - try_mkdir_p (d); -} -catch (const system_error& e) + run_io (t, 0, 1, 2, "sudo", "mkdir", "-p", d); + } + else +#else +mk_p (tracer& t, string* log, const dir_path& d, bool = false) { - fail << "unable to create directory " << d << ": " << e << endf; +#endif + try + { + if (verb >= 3) + t << "mkdir -p " << d; + + if (log != nullptr) + *log += "mkdir -p " + d.representation () + '\n'; + + try_mkdir_p (d); + } + catch (const system_error& e) + { + fail << "unable to create directory " << d << ": " << e << endf; + } } static void @@ -4405,7 +4420,7 @@ build (size_t argc, const char* argv[]) config_install_root (step_id::bbot_sys_install)); if (ir) - mk_p (trace, &r.log, *ir); + mk_p (trace, &r.log, *ir, true /* sudo */); if (!module_pkg) { diff --git a/tests/integration/testscript b/tests/integration/testscript index 1e78dfe..a8932ec 100644 --- a/tests/integration/testscript +++ b/tests/integration/testscript @@ -476,5 +476,7 @@ a = $0 &?dist-installed/*** &?redist-installed/*** \ &?../usr/*** &?upload/*** &?upload.tar \ &?../sys-install/*** \ - &task.manifest <| 2>| + &task.manifest <| 2>|; + + sudo rm -rf ../sys-install/ } |