From 95aa319c1548fc81dfd018adc5ae8ec8db2e2f9c Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 28 Aug 2023 15:57:14 +0300 Subject: Add support for bbot.sys-install:config.install.root variable --- bbot/worker/worker.cxx | 94 +++++++++++++++++++++++++++++++++----------- doc/manual.cli | 30 ++++++++------ tests/integration/testscript | 28 +++++++++++-- 3 files changed, 115 insertions(+), 37 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 install_bin; - auto config_install_root = [&step_args, &tgt_args] () -> optional + auto config_install_root = [&step_args, &tgt_args] + (step_id s, + optional f1 = nullopt, + optional f2 = nullopt) + -> optional { - 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 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 @@ -4404,12 +4453,6 @@ build (size_t argc, const char* argv[]) fail_unreached_breakpoint (r); break; } - - if (!module_pkg) - { - if (optional 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 s = getenv ("PATH")) { diff --git a/doc/manual.cli b/doc/manual.cli index e61e6ef..3a00e2d 100644 --- a/doc/manual.cli +++ b/doc/manual.cli @@ -2329,16 +2329,16 @@ linux*-gcc_8 linux-gcc_8 x86_64-linux-gnu \"all gcc-8+:gcc-7+\" \ If the \c{} list contains the \c{config.install.root} variable -that applies to the \c{bpkg.create} step, then in addition to building and -possibly running tests, the \c{bbot} worker will also test installing and -uninstalling each package (unless replaced with the \c{bbot.sys-install} -step). Furthermore, if the package contains subprojects that support the test -operation and/or refers to other packages via the \c{tests}, \c{examples}, or -\c{benchmarks} manifest values which are not excluded by the \c{bbot} -controller, then the worker will additionally build such subprojects/packages -against the installation (created either from source or from the binary -distribution package) and run their tests (test installed and test separate -installed phases). +that applies to the \c{bpkg.target.create} or, as a fallback, \c{b.create} or +\c{bpkg.create} steps, then in addition to building and possibly running +tests, the \c{bbot} worker will also test installing and uninstalling each +package (unless replaced with the \c{bbot.sys-install} step). Furthermore, if +the package contains subprojects that support the test operation and/or refers +to other packages via the \c{tests}, \c{examples}, or \c{benchmarks} manifest +values which are not excluded by the \c{bbot} controller, then the worker will +additionally build such subprojects/packages against the installation (created +either from source or from the binary distribution package) and run their +tests (test installed and test separate installed phases). Two types of installations can be tested: \i{system} and \i{private}. A system installation uses a well-known location, such as \c{/usr} or \c{/usr/local}, @@ -2362,7 +2362,15 @@ Note also that while building and running tests against the installation created either from source or from the archive distribution package the worker makes the \c{bin} subdirectory of \c{config.install.root} the first entry in the \c{PATH} environment variable, except for build system modules which -supposedly don't install any executables. +supposedly don't install any executables. As was mentioned earlier, normally +the \c{config.install.root} variable is expected to be prefixed with the +\c{bpkg.target.create} or, as a fallback, \c{b.create} or \c{bpkg.create} step +ids. However, for testing of the relocatable installations it can be desirable +to extract the archive distribution package content at the +\c{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 \c{bbot.sys-install:config.install.root}. If specified, this directory will +be preferred as a base for forming the \c{bin/} directory path. The \c{bbot} controller normally issues the build task by picking an unbuilt package configuration and one of the produced (via the machine names match) diff --git a/tests/integration/testscript b/tests/integration/testscript index a608bef..060029e 100644 --- a/tests/integration/testscript +++ b/tests/integration/testscript @@ -64,7 +64,7 @@ b.test-installed.configure:\"config.cc.loptions=-L'$~/install/lib'\" \ bpkg.test-separate-installed.create:\"config.cc.loptions=-L'$~/install/lib'\"" pkg = libhello -ver = 1.0.0+10 +ver = 1.0.0+11 #rep_url = "https://git.build2.org/hello/libhello.git#1.0" #rep_type = git rep_url = https://stage.build2.org/1 @@ -96,6 +96,27 @@ config = "$config bpkg.create:config.install.root=\"'$~/usr/local'\"" +export LD_LIBRARY_PATH="$~/usr/local/lib:$getenv('LD_LIBRARY_PATH')" #\ #\ +sys_install_dir = [dir_path] $~/sys-install/ +package_config = "package-config: +\\ ++bpkg.bindist.archive:--archive-build-meta= +bpkg.bindist.archive:config.install.relocatable=true + ++bbot.bindist.upload: + +bbot.sys-install.tar.extract:--directory=$sys_install_dir +bbot.sys-install.tar.extract:--strip-components=3 + +b.test-installed.configure:config.cc.loptions='-L$sys_install_dir/lib' +bpkg.test-separate-installed.create:config.cc.loptions='-L$sys_install_dir/lib' + +bpkg.create:config.bin.rpath=[null] +\\" +config = "$config bpkg.create:config.install.root=\"'$~/usr/local'\" \ +bbot.sys-install:config.install.root=\"'$sys_install_dir'\"" ++export LD_LIBRARY_PATH="$sys_install_dir/lib:$getenv('LD_LIBRARY_PATH')" +#\ +#\ package_config = 'package-config: \ +bpkg.bindist.fedora: @@ -202,7 +223,7 @@ bpkg.module.create:config.bin.rpath=[null] # #\ pkg = libbuild2-autoconf -ver = 0.2.0-a.0.20230323135046.19cd67c1fa85 +ver = 0.2.0 rep_url = "https://github.com/build2/libbuild2-autoconf.git#master" rep_type = git rfp = yes @@ -235,7 +256,7 @@ config.bpkg.tests.remote=true #\ pkg = cli -ver = 1.2.0-b.9.20230320105544.115e8dc4c504 +ver = 1.2.0-b.10.20230822134113.24d21424af96 rep_url = "https://git.codesynthesis.com/cli/cli.git#master" rep_type = git #rep_url = https://stage.build2.org/1 @@ -455,5 +476,6 @@ a = $0 &?dist-install/*** &?redist-install/*** \ &?dist-installed/*** &?redist-installed/*** \ &?../usr/*** &?upload/*** &?upload.tar \ + &?../sys-install/*** \ &task.manifest <| 2>| } -- cgit v1.1