Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BUILDER_CONFIG environment variable #66

Merged
merged 5 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 <<ENDNOTICE
!!!
!!! ~/.buildrc already exists.
!!! ${BUILDER_CONFIG} already exists.
!!!
!!! Edit manually or delete it to install a new default configuration.
!!!
ENDNOTICE
fi
if [ ! -e "${HOME}/.buildrc" ]; then
echo ">>> installing default configuration '${HOME}/.buildrc'..."
cat >"${HOME}/.buildrc" <<ENDRC
if [ ! -e "${BUILDER_CONFIG}" ]; then
echo ">>> installing default configuration '${BUILDER_CONFIG}'..."
cat >"${BUILDER_CONFIG}" <<ENDRC
#
# This is the configuration file for Builder
# (auto-generated on $(date))
Expand Down Expand Up @@ -154,15 +157,15 @@ LOG_PATH="\\\${BUILD}/logs"
# define the number of cores to use in standard build_package()
#MAKE_THREADS=\$(( \$(nproc) / 4 ))
ENDRC
cat "${HOME}/.buildrc"
cat "${BUILDER_CONFIG}"
cat <<ENDNOTE
!!!
!!! You probably want to modify at least the \$TARGET_PATH in your
!!! configuration in '~/.buildrc'.
!!! configuration in '${BUILDER_CONFIG}'.
!!!
ENDNOTE
echo -e "\n>>> 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."
Expand All @@ -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

Expand Down
13 changes: 7 additions & 6 deletions doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@

finnerty-fzj marked this conversation as resolved.
Show resolved Hide resolved
## `.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
Expand Down
17 changes: 17 additions & 0 deletions doc/Install.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions plans/nest-simulator/3.1/default
Original file line number Diff line number Diff line change
Expand Up @@ -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=plans/nest-simulator/common
finnerty-fzj marked this conversation as resolved.
Show resolved Hide resolved
source "$(dirname "${PLAN}")/../common"
2 changes: 1 addition & 1 deletion plans/nest-simulator/common
Original file line number Diff line number Diff line change
Expand Up @@ -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
terhorstd marked this conversation as resolved.
Show resolved Hide resolved
echo -e "${module@P}" >"${module_path}"
else
# this is a bad substitute for the power of the bash>4.4 notation.
Expand Down
1 change: 1 addition & 0 deletions plans/nest-simulator/master/default
Original file line number Diff line number Diff line change
Expand Up @@ -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=plans/nest-simulator/common
finnerty-fzj marked this conversation as resolved.
Show resolved Hide resolved
source "$(dirname "${PLAN}")/../common"
Loading