From 9d47b6eeba8038978f860fbdb9370b081bd9bb40 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 29 Aug 2023 13:05:00 +0300 Subject: Fix worker not to pass to tar arguments for less specific step ids --- bbot/worker/worker.cxx | 139 ++++++++++++++++++++++++++++++------------------- 1 file changed, 84 insertions(+), 55 deletions(-) (limited to 'bbot') diff --git a/bbot/worker/worker.cxx b/bbot/worker/worker.cxx index d7222b4..b759760 100644 --- a/bbot/worker/worker.cxx +++ b/bbot/worker/worker.cxx @@ -1810,12 +1810,15 @@ build (size_t argc, const char* argv[]) // Return command arguments for the specified step id, complementing // *.create[_for_*] steps with un-prefixed arguments. If no arguments are // specified for the step then use the specified fallbacks, potentially - // both. Arguments with more specific prefixes come last. + // both. Arguments with more specific prefixes come last. Optionally, + // search for arguments starting from the specified step id rather than + // from the least specific one (tool id). // auto step_args = [] (const multimap& args, step_id step, optional fallback1 = nullopt, - optional fallback2 = nullopt) -> cstrings + optional fallback2 = nullopt, + optional start_step = nullopt) -> cstrings { cstrings r; @@ -1851,11 +1854,27 @@ build (size_t argc, const char* argv[]) default: break; } - auto add_step_args = [&add_args] (step_id step) + auto add_step_args = [&add_args] (step_id step, + optional start_step = nullopt) { const string& s (to_string (step)); - for (size_t n (0);; ++n) + size_t n; + + if (start_step) + { + const string& ss (to_string (*start_step)); + + assert (s.size () >= ss.size () && + s.compare (0, ss.size (), ss) == 0 && + (s.size () == ss.size () || s[ss.size ()] == '.')); + + n = ss.size (); + } + else + n = 0; + + for (;; ++n) { n = s.find ('.', n); @@ -1871,7 +1890,7 @@ build (size_t argc, const char* argv[]) // if (args.find (to_string (step)) != args.end ()) { - add_step_args (step); + add_step_args (step, start_step); } else { @@ -3809,16 +3828,17 @@ build (size_t argc, const char* argv[]) { // sudo ldconfig // - step_id b (step_id::bbot_install_ldconfig); - step_id s (step_id::bbot_install_ldconfig); + step_id b (step_id::bbot_install_ldconfig); + step_id s (step_id::bbot_install_ldconfig); + step_id ss (step_id::bbot_install_ldconfig); r.status |= run_ldconfig ( b, trace, r.log, wre, bkp_step, bkp_status, last_cmd, - step_args (env_args, s), - step_args (tgt_args, s), - step_args (pkg_args, s)); + step_args (env_args, s, nullopt, nullopt, ss), + step_args (tgt_args, s, nullopt, nullopt, ss), + step_args (pkg_args, s, nullopt, nullopt, ss)); if (!r.status) break; @@ -4262,8 +4282,9 @@ build (size_t argc, const char* argv[]) // // // - step_id b (step_id::bbot_sys_install_apt_get_update); - step_id s (step_id::bbot_sys_install_apt_get_update); + step_id b (step_id::bbot_sys_install_apt_get_update); + step_id s (step_id::bbot_sys_install_apt_get_update); + step_id ss (step_id::bbot_sys_install_apt_get_update); r.status |= run_apt_get ( b, @@ -4271,9 +4292,9 @@ build (size_t argc, const char* argv[]) bkp_step, bkp_status, last_cmd, "update", "--assume-yes", - step_args (env_args, s), - step_args (tgt_args, s), - step_args (pkg_args, s)); + step_args (env_args, s, nullopt, nullopt, ss), + step_args (tgt_args, s, nullopt, nullopt, ss), + step_args (pkg_args, s, nullopt, nullopt, ss)); if (!r.status) break; @@ -4291,8 +4312,9 @@ build (size_t argc, const char* argv[]) // argument to be treated as a file rather than name. The paths we // pass are absolute. // - step_id b (step_id::bbot_sys_install_apt_get_install); - step_id s (step_id::bbot_sys_install_apt_get_install); + step_id b (step_id::bbot_sys_install_apt_get_install); + step_id s (step_id::bbot_sys_install_apt_get_install); + step_id ss (step_id::bbot_sys_install_apt_get_install); r.status |= run_apt_get ( b, @@ -4300,9 +4322,9 @@ build (size_t argc, const char* argv[]) bkp_step, bkp_status, last_cmd, "install", "--assume-yes", - step_args (env_args, s), - step_args (tgt_args, s), - step_args (pkg_args, s), + step_args (env_args, s, nullopt, nullopt, ss), + step_args (tgt_args, s, nullopt, nullopt, ss), + step_args (pkg_args, s, nullopt, nullopt, ss), pfs); if (!r.status) @@ -4330,8 +4352,9 @@ build (size_t argc, const char* argv[]) // // ... // - step_id b (step_id::bbot_sys_install_dnf_install); - step_id s (step_id::bbot_sys_install_dnf_install); + step_id b (step_id::bbot_sys_install_dnf_install); + step_id s (step_id::bbot_sys_install_dnf_install); + step_id ss (step_id::bbot_sys_install_dnf_install); r.status |= run_dnf ( b, @@ -4340,9 +4363,9 @@ build (size_t argc, const char* argv[]) "install", "--refresh", "--assumeyes", - step_args (env_args, s), - step_args (tgt_args, s), - step_args (pkg_args, s), + step_args (env_args, s, nullopt, nullopt, ss), + step_args (tgt_args, s, nullopt, nullopt, ss), + step_args (pkg_args, s, nullopt, nullopt, ss), pfs); if (!r.status) @@ -4401,8 +4424,9 @@ build (size_t argc, const char* argv[]) // // // - step_id b (step_id::bbot_sys_install_tar_extract); - step_id s (step_id::bbot_sys_install_tar_extract); + step_id b (step_id::bbot_sys_install_tar_extract); + step_id s (step_id::bbot_sys_install_tar_extract); + step_id ss (step_id::bbot_sys_install_tar_extract); r.status |= run_tar ( b, @@ -4411,9 +4435,9 @@ build (size_t argc, const char* argv[]) true /* sudo */, "-xf", f, - step_args (env_args, s), - step_args (tgt_args, s), - step_args (pkg_args, s)); + step_args (env_args, s, nullopt, nullopt, ss), + step_args (tgt_args, s, nullopt, nullopt, ss), + step_args (pkg_args, s, nullopt, nullopt, ss)); if (!r.status) break; @@ -4430,16 +4454,17 @@ build (size_t argc, const char* argv[]) // // // - step_id b (step_id::bbot_sys_install_ldconfig); - step_id s (step_id::bbot_sys_install_ldconfig); + step_id b (step_id::bbot_sys_install_ldconfig); + step_id s (step_id::bbot_sys_install_ldconfig); + step_id ss (step_id::bbot_sys_install_ldconfig); r.status |= run_ldconfig ( b, trace, r.log, wre, bkp_step, bkp_status, last_cmd, - step_args (env_args, s), - step_args (tgt_args, s), - step_args (pkg_args, s)); + step_args (env_args, s, nullopt, nullopt, ss), + step_args (tgt_args, s, nullopt, nullopt, ss), + step_args (pkg_args, s, nullopt, nullopt, ss)); if (!r.status) break; @@ -5359,8 +5384,9 @@ build (size_t argc, const char* argv[]) // // ... // - step_id b (step_id::bbot_sys_uninstall_apt_get_remove); - step_id s (step_id::bbot_sys_uninstall_apt_get_remove); + step_id b (step_id::bbot_sys_uninstall_apt_get_remove); + step_id s (step_id::bbot_sys_uninstall_apt_get_remove); + step_id ss (step_id::bbot_sys_uninstall_apt_get_remove); r.status |= run_apt_get ( b, @@ -5368,9 +5394,9 @@ build (size_t argc, const char* argv[]) bkp_step, bkp_status, last_cmd, "remove", "--assume-yes", - step_args (env_args, s), - step_args (tgt_args, s), - step_args (pkg_args, s), + step_args (env_args, s, nullopt, nullopt, ss), + step_args (tgt_args, s, nullopt, nullopt, ss), + step_args (pkg_args, s, nullopt, nullopt, ss), pns); if (!r.status) @@ -5397,8 +5423,9 @@ build (size_t argc, const char* argv[]) // // ... // - step_id b (step_id::bbot_sys_uninstall_dnf_remove); - step_id s (step_id::bbot_sys_uninstall_dnf_remove); + step_id b (step_id::bbot_sys_uninstall_dnf_remove); + step_id s (step_id::bbot_sys_uninstall_dnf_remove); + step_id ss (step_id::bbot_sys_uninstall_dnf_remove); r.status |= run_dnf ( b, @@ -5406,9 +5433,9 @@ build (size_t argc, const char* argv[]) bkp_step, bkp_status, last_cmd, "remove", "--assumeyes", - step_args (env_args, s), - step_args (tgt_args, s), - step_args (pkg_args, s), + step_args (env_args, s, nullopt, nullopt, ss), + step_args (tgt_args, s, nullopt, nullopt, ss), + step_args (pkg_args, s, nullopt, nullopt, ss), pns); if (!r.status) @@ -5648,8 +5675,9 @@ build (size_t argc, const char* argv[]) // // upload/ // - step_id b (step_id::bbot_upload_tar_create); - step_id s (step_id::bbot_upload_tar_create); + step_id b (step_id::bbot_upload_tar_create); + step_id s (step_id::bbot_upload_tar_create); + step_id ss (step_id::bbot_upload_tar_create); // Make sure the archive is portable. // @@ -5667,9 +5695,9 @@ build (size_t argc, const char* argv[]) #endif "-cf", upload_archive, - step_args (env_args, s), - step_args (tgt_args, s), - step_args (pkg_args, s), + step_args (env_args, s, nullopt, nullopt, ss), + step_args (tgt_args, s, nullopt, nullopt, ss), + step_args (pkg_args, s, nullopt, nullopt, ss), upload_dir); if (!r.status) @@ -5683,8 +5711,9 @@ build (size_t argc, const char* argv[]) // // // - step_id b (step_id::bbot_upload_tar_list); - step_id s (step_id::bbot_upload_tar_list); + step_id b (step_id::bbot_upload_tar_list); + step_id s (step_id::bbot_upload_tar_list); + step_id ss (step_id::bbot_upload_tar_list); r.status |= run_tar ( b, @@ -5693,9 +5722,9 @@ build (size_t argc, const char* argv[]) false /* sudo */, "-tf", upload_archive, - step_args (env_args, s), - step_args (tgt_args, s), - step_args (pkg_args, s)); + step_args (env_args, s, nullopt, nullopt, ss), + step_args (tgt_args, s, nullopt, nullopt, ss), + step_args (pkg_args, s, nullopt, nullopt, ss)); if (!r.status) break; -- cgit v1.1