aboutsummaryrefslogtreecommitdiff
path: root/bbot/worker/worker.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2023-08-28 15:57:14 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2023-08-28 16:19:44 +0300
commit95aa319c1548fc81dfd018adc5ae8ec8db2e2f9c (patch)
tree2e0224f122abe4c8bf9142d169466dcb27adb561 /bbot/worker/worker.cxx
parent2c45274be4be9000c4de6ca5b1b9f0b32d7439cd (diff)
Add support for bbot.sys-install:config.install.root variable
Diffstat (limited to 'bbot/worker/worker.cxx')
-rw-r--r--bbot/worker/worker.cxx94
1 files changed, 71 insertions, 23 deletions
diff --git a/bbot/worker/worker.cxx b/bbot/worker/worker.cxx
index 985d77e..d7222b4 100644
--- a/bbot/worker/worker.cxx
+++ b/bbot/worker/worker.cxx
@@ -505,6 +505,26 @@ log_step_id (tracer& t, string& log, step_id id)
log += '\n';
}
+// Add the specified string to the log as a comment. Unless the string is
+// empty (e.g., a blank line to separate comments), also trace it.
+//
+static void
+log_comment (tracer& t, string& log, const string& s)
+{
+ if (!s.empty ())
+ l3 ([&]{t << s;});
+
+ log += comment_begin;
+
+ if (!s.empty ())
+ {
+ log += ' ';
+ log += s;
+ }
+
+ log += '\n';
+}
+
// Run the worker script command. Name is used for logging and diagnostics
// only. Match lines read from the command's stderr against the regular
// expressions and return the warning result status (instead of success) in
@@ -2104,14 +2124,24 @@ build (size_t argc, const char* argv[])
// first entry in the PATH environment variable, except for build system
// modules which supposedly don't install any executables.
//
+ // Note that normally the config.install.root is expected to be prefixed
+ // with the bpkg.target.create or, as a fallback, b.create or bpkg.create
+ // step ids. However, for testing of the relocatable installations it can
+ // be desirable to extract the archive distribution package content at the
+ // bbot.sys-install.tar.extract step into a different installation
+ // directory. If that's the case, then this directory needs to also be
+ // specified as bbot.sys-install:config.install.root. If specified, this
+ // directory will be preferred as a base for forming the bin/ directory
+ // path.
+ //
optional<dir_path> install_bin;
- auto config_install_root = [&step_args, &tgt_args] () -> optional<dir_path>
+ auto config_install_root = [&step_args, &tgt_args]
+ (step_id s,
+ optional<step_id> f1 = nullopt,
+ optional<step_id> f2 = nullopt)
+ -> optional<dir_path>
{
- step_id s (step_id::bpkg_target_create);
- step_id f1 (step_id::b_create);
- step_id f2 (step_id::bpkg_create);
-
size_t n (19);
auto space = [] (char c) {return c == ' ' || c == '\t';};
@@ -2140,7 +2170,9 @@ build (size_t argc, const char* argv[])
{
if (!module_pkg)
{
- install_root = config_install_root ();
+ install_root = config_install_root (step_id::bpkg_target_create,
+ step_id::b_create,
+ step_id::bpkg_create);
if (install_root)
install_bin = *install_root / dir_path ("bin");
@@ -3261,24 +3293,17 @@ build (size_t argc, const char* argv[])
s += " - ";
s += name;
- l3 ([&]{trace << s;});
-
- r.log += comment_begin;
- r.log += ' ';
- r.log += s;
- r.log += '\n';
+ log_comment (trace, r.log, s);
};
- r.log += comment_begin;
- r.log += '\n';
+ log_comment (trace, r.log, "");
log (target_uuid, "target");
log (host_uuid, "host");
log (module_uuid, "module");
log (install_uuid, "install");
- r.log += comment_begin;
- r.log += '\n';
+ log_comment (trace, r.log, "");
}
});
@@ -4346,6 +4371,30 @@ build (size_t argc, const char* argv[])
//
else if (*bindist == step_id::bpkg_bindist_archive)
{
+ // If the bbot.sys-install:config.install.root variable is
+ // specified, then make sure the directory it refers to exists by
+ // the time we run `tar -xf`, so that this command doesn't fail
+ // trying to extract into a non-existent directory. Note that we do
+ // that regardless whether the package is a build system module or
+ // not.
+ //
+ optional<dir_path> ir (
+ config_install_root (step_id::bbot_sys_install));
+
+ if (ir)
+ mk_p (trace, &r.log, *ir);
+
+ if (!module_pkg)
+ {
+ if (!ir)
+ ir = config_install_root (step_id::bpkg_target_create,
+ step_id::b_create,
+ step_id::bpkg_create);
+
+ if (ir)
+ install_bin = *ir / dir_path ("bin");
+ }
+
for (const char* f: pfs)
{
// [sudo] tar -xf <distribution-package-file> <env-config-args>
@@ -4404,12 +4453,6 @@ build (size_t argc, const char* argv[])
fail_unreached_breakpoint (r);
break;
}
-
- if (!module_pkg)
- {
- if (optional<dir_path> ir = config_install_root ())
- install_bin = *ir / dir_path ("bin");
- }
}
//
// Fail if the breakpoint refers to a
@@ -4509,7 +4552,12 @@ build (size_t argc, const char* argv[])
// beginning of the PATH environment variable value, so the
// installed executables are found first.
//
- string paths ("PATH=" + install_bin->string ());
+ const string& ib (install_bin->string ());
+
+ log_comment (trace, r.log,
+ "add " + ib + " to PATH environment variable");
+
+ string paths ("PATH=" + ib);
if (optional<string> s = getenv ("PATH"))
{