From ee67bddd97c04bbb43dca6578655e674a3af6ba3 Mon Sep 17 00:00:00 2001 From: Dennis Terhorst Date: Tue, 5 Sep 2023 17:42:38 +0200 Subject: [PATCH 1/5] add BUILDER_CONFIG environment variable --- build.sh | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/build.sh b/build.sh index 18b567e..ad43848 100755 --- a/build.sh +++ b/build.sh @@ -22,6 +22,9 @@ set -euo pipefail if [ -z "${BUILDER_PATH+x}" ]; then BUILDER_PATH="$(dirname "$(realpath "$0")")" fi +# Use ~/.buildrc as default config, unless specified explicitly in an +# environment variable. +BUILDER_CONFIG="${BUILDER_CONFIG:-${HOME}/.buildrc}" # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # @@ -49,7 +52,7 @@ Usage: build -h|--help Options: -h or --help this text is printed - configure installs ~/.buildrc and exits + configure installs ~/.buildrc or the file pointed to by BUILDER_CONFIG and exits --dry-run skip build -s or --silent skip build if installation folder exists -f or --force rebuild even if installation folder exists, delete source folder if it exits @@ -104,18 +107,18 @@ esac # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Setup Builder configuration -if [ "${PACKAGE}" == "configure" -a -e "${HOME}/.buildrc" ]; then +if [ "${PACKAGE}" == "configure" -a -e "${BUILDER_CONFIG}" ]; then cat <>> installing default configuration '${HOME}/.buildrc'..." - cat >"${HOME}/.buildrc" <>> installing default configuration '${BUILDER_CONFIG}'..." + cat >"${BUILDER_CONFIG}" <>> default configuration has been written to" - echo -e " ${HOME}/.buildrc\n" + echo -e " ${BUILDER_CONFIG}\n" if [ "$PACKAGE" != "configure" ]; then echo "!!! Please check that the guessed paths are correct and" echo "!!! rerun the build command." @@ -172,10 +175,10 @@ ENDNOTE fi # load configuration -if [ -r "${HOME}/.buildrc" ]; then - . "${HOME}/.buildrc" +if [ -r "${BUILDER_CONFIG}" ]; then + . "${BUILDER_CONFIG}" else - echo "ERROR: Could not read ~/.buildrc" + echo "ERROR: Could not read ${BUILDER_CONFIG}" exit 1 fi From a293d3d55f78df17954f74655748993d5b9b54ac Mon Sep 17 00:00:00 2001 From: Dennis Terhorst Date: Tue, 5 Sep 2023 17:54:29 +0200 Subject: [PATCH 2/5] add BUILDER_CONFIG documentation --- doc/Configuration.md | 13 +++++++------ doc/Install.md | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/doc/Configuration.md b/doc/Configuration.md index 9db38a3..46f3606 100644 --- a/doc/Configuration.md +++ b/doc/Configuration.md @@ -22,12 +22,13 @@ ## `.buildrc` variables - Builder configuriation is automatically loaded from `$HOME/.buildrc`. If this - file does not exist, it will be created and the build will abort for you to - check the settings. The variables expected to be available after sourcing - `.buildrc` are described in the following table. The variables marked - "optional", if undefined, will be filled with appropriate default values by - builder for each build. + Builder configuriation is automatically loaded from `$HOME/.buildrc` (or the + file pointed to by the `$BUILDER_CONFIG` variable). If this file does not + exist, it will be created and the build will abort for you to check the + settings. The variables expected to be available after sourcing `.buildrc` + are described in the following table. The variables marked "optional", if + undefined, will be filled with appropriate default values by builder for each + build. Note that the expressions need not be constants, but are evaluated according to normal bash expansion rules (see man bash(1)). By this, you can diff --git a/doc/Install.md b/doc/Install.md index c029d87..b1a4286 100644 --- a/doc/Install.md +++ b/doc/Install.md @@ -71,3 +71,20 @@ still available. After this you can install or load Builder and go on extending your deployment. + +### Multi-configuration Environments + +When using Builder in a multi-user or CI setup it is inconvenient to have the +`.buildrc` loaded from the user-account home directory. To circumvent this the +variable `$BUILDER_CONFIG` can be defined to override the default path. For +example, suppose you keep your configuration in a repository +`repo/builder.conf`. You can use any Builder installation available and point +it to your current setup: + +```bash +#cd repo # wherever this is +export BUILDER_CONFIG="${PWD}/builder.conf" +``` + +With this, `build` can be called from any location and will find the right +config file. From 0d04413c6b80111068949a37e19ebf484a29e34f Mon Sep 17 00:00:00 2001 From: Dennis Terhorst Date: Tue, 5 Sep 2023 17:58:13 +0200 Subject: [PATCH 3/5] fix code quality --- plans/nest-simulator/3.1/default | 1 + plans/nest-simulator/common | 2 +- plans/nest-simulator/master/default | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/plans/nest-simulator/3.1/default b/plans/nest-simulator/3.1/default index 0d9edd3..64ad1c1 100644 --- a/plans/nest-simulator/3.1/default +++ b/plans/nest-simulator/3.1/default @@ -25,4 +25,5 @@ SHA256SUM=5c11dd6b451c4c6bf93037bf29d5231c6c75a0e1a8863344f6fb9bb225f279ca CMAKEFLAGS+=" -Dwith-boost=ON -Dwith-python=ON -Dwith-mpi=ON -Dwith-detailed-timers=ON -Dwith-ltdl=OFF" +# shellcheck source=../common source "$(dirname "${PLAN}")/../common" diff --git a/plans/nest-simulator/common b/plans/nest-simulator/common index d7eb5d0..a1b1d25 100755 --- a/plans/nest-simulator/common +++ b/plans/nest-simulator/common @@ -62,7 +62,7 @@ module_install () { log_status ">>> installing module file to ${module_path}" mkdir -pv "$(dirname "${module_path}")" module="$(cat "${PLAN}.module")" - if version_gt $BASH_VERSION 4.4; then + if version_gt "${BASH_VERSION}" "4.4"; then echo -e "${module@P}" >"${module_path}" else # this is a bad substitute for the power of the bash>4.4 notation. diff --git a/plans/nest-simulator/master/default b/plans/nest-simulator/master/default index a91d7e6..d92f510 100644 --- a/plans/nest-simulator/master/default +++ b/plans/nest-simulator/master/default @@ -23,4 +23,5 @@ URL="https://github.com/nest/nest-simulator/archive/${VERSION}.tar.gz" CMAKEFLAGS+=" -Dwith-boost=ON -Dwith-python=ON -Dwith-mpi=ON -Dwith-detailed-timers=ON -Dwith-ltdl=OFF" +# shellcheck source=../common source "$(dirname "${PLAN}")/../common" From 4f671883434bfbbb2ca85b8d56f7c35ae7b69a8d Mon Sep 17 00:00:00 2001 From: Dennis Terhorst Date: Tue, 5 Sep 2023 18:00:45 +0200 Subject: [PATCH 4/5] fix relative paths --- plans/nest-simulator/3.1/default | 2 +- plans/nest-simulator/master/default | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plans/nest-simulator/3.1/default b/plans/nest-simulator/3.1/default index 64ad1c1..195de0c 100644 --- a/plans/nest-simulator/3.1/default +++ b/plans/nest-simulator/3.1/default @@ -25,5 +25,5 @@ SHA256SUM=5c11dd6b451c4c6bf93037bf29d5231c6c75a0e1a8863344f6fb9bb225f279ca CMAKEFLAGS+=" -Dwith-boost=ON -Dwith-python=ON -Dwith-mpi=ON -Dwith-detailed-timers=ON -Dwith-ltdl=OFF" -# shellcheck source=../common +# shellcheck source=plans/nest-simulator/common source "$(dirname "${PLAN}")/../common" diff --git a/plans/nest-simulator/master/default b/plans/nest-simulator/master/default index d92f510..936b8cf 100644 --- a/plans/nest-simulator/master/default +++ b/plans/nest-simulator/master/default @@ -23,5 +23,5 @@ URL="https://github.com/nest/nest-simulator/archive/${VERSION}.tar.gz" CMAKEFLAGS+=" -Dwith-boost=ON -Dwith-python=ON -Dwith-mpi=ON -Dwith-detailed-timers=ON -Dwith-ltdl=OFF" -# shellcheck source=../common +# shellcheck source=plans/nest-simulator/common source "$(dirname "${PLAN}")/../common" From c953f9cd07e2e0c7f89ad718b68d371f578aa9ce Mon Sep 17 00:00:00 2001 From: Dennis Terhorst Date: Wed, 6 Sep 2023 09:35:22 +0200 Subject: [PATCH 5/5] minor changes --- README.md | 6 +++--- doc/Configuration.md | 12 ++++++------ doc/Install.md | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 25a0018..755d58f 100644 --- a/README.md +++ b/README.md @@ -50,9 +50,9 @@ Optional Dependencies: You can install any software with Builder if a plan file is available. The default location where Builder looks for plan files is configured as -`PLANFILE_PATH` in `~/.buildrc`. You will find many files in the scheme -`//`, where the `` uses `default` as its -default value. +`PLANFILE_PATH` in the [configuration](doc/Configuration.md). You will find +many files in the scheme `//`, where the `` +uses `default` as its default value. To install a package replace `` and `` with an available build plan: diff --git a/doc/Configuration.md b/doc/Configuration.md index 46f3606..a012e2d 100644 --- a/doc/Configuration.md +++ b/doc/Configuration.md @@ -2,12 +2,12 @@ Builder is designed to require only very minimal configuration. Upon its first build or when explicitly called with `build configure` a file - `.buildrc` is created if it does not exist yet. This file contains variables - that define various locations used in the build and install process. When - the file is generated automatically Builder pre-fills some guessed defaults - that point to your home directory. While this quickly gets you started, - installing a lot of software into your `$HOME` is usually not a good idea and - you should set `$TARGET_PATH` to a better location. + `~/.buildrc` is created if it does not exist yet. This file contains + variables that define various locations used in the build and install + process. When the file is generated automatically Builder pre-fills some + guessed defaults that point to your home directory. While this quickly gets + you started, installing a lot of software into your `$HOME` is usually not a + good idea and you should set `$TARGET_PATH` to a better location. The builder configuration defines variables of the build system itself. Mostly paths where Builder can put its work-space and where to put the diff --git a/doc/Install.md b/doc/Install.md index b1a4286..7fcf337 100644 --- a/doc/Install.md +++ b/doc/Install.md @@ -48,10 +48,10 @@ We can however call Builder directly and start building env modules ./build.sh environment-modules This will build environment-modules as a normal package into your set install -path (see `~/.buildrc`). Alternative implementations like 'lmod' may be built -in a similar manner. Since many things depend on your choice here, you may want -to look into the install instructions and probably manually change things here -and there. +path (see [configuration](Configuration.md)). Alternative implementations like +'lmod' may be built in a similar manner. Since many things depend on your +choice here, you may want to look into the install instructions and probably +manually change things here and there. less ~/install/environment-modules/4.7.1/default/share/doc/INSTALL.txt