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

Capture and automatically load dependencies in modulefiles #5

Merged
merged 14 commits into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
19 changes: 18 additions & 1 deletion build_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,24 @@ build_install () {
make install 2>&1 | tee "${LOG}/make-install.log"
}

module_capture_prereq () {
# This function returns the module system "prereq" lines
# built from the curently loaded modules listed in `$LOADEDMODULES`
MODULES="${LOADEDMODULES:-}"
for dep in ${MODULES//:/ }; do
if echo "$dep" | grep "Builder" >/dev/null; then
# nothing should ever automatically depend on builder
# so we skip this dependency.
continue;
fi
echo -n "prereq $dep\\n"
done
}

module_install () {
AUTOMATIC_BUILD_WARNING=" This file was automatically produced by Builder.\n# Any changes may be overwritten without notice.\n#\n# Please see ${BUILDER_PATH} for details."

PREREQ_DEPENDS="$(module_capture_prereq)"
if [ -r "${PLAN}.module" ]; then
module_path="${MODULE_INSTALL_PATH}/${PACKAGE}/${VERSION}/${VARIANT}"
#PYTHON_SCRIPTS="$(python -c "import sysconfig; print(sysconfig.get_path('scripts'))")"
Expand All @@ -221,7 +237,7 @@ module_install () {
mkdir -pv "$(dirname "${module_path}")"
module="$(cat "${PLAN}.module")"
if version_gt $BASH_VERSION 4.4; then
echo "${module@P}" >"${module_path}"
echo -e "${module@P}" >"${module_path}"
else
# this is a bad substitute for the power of the bash>4.4 notation.
echo "${module}" | sed \
Expand All @@ -243,6 +259,7 @@ module_install () {
-e "s%\${\?TARGET}\?%$TARGET%g" \
-e "s%\${\?BUILD}\?%$BUILD%g" \
-e "s%\${\?LOG}\?%$LOG%g" \
-e "s%\${\?PREREQ_DEPENDS}\?%$PREREQ_DEPENDS%g" \
-e "s%\${\?VIRTUAL_ENV}\?%${VIRTUAL_ENV:-/}%g" \
-e 's%__NOT_BUILDER_DOLLAR__%$%g' \
> "${module_path}"
Expand Down
19 changes: 19 additions & 0 deletions doc/module-dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Module files and Dependencies

Builder does explicitly not track dependencies between packages, but is designed
to work with what is there. This is necessary to be able to integrate well with
different environments on each machine. What builder can do, however, is to track
which modules where loaded during the build time. It is (for now) assumed that

* run-time dependencies are at least a sub-set of the build-time dependencies,
so that requiring build-time deps at run-time provides all package requirements,
and
* build-time loaded modules are also available at run-time (not a given, if
packages are built on a head node, but run on a compute node, for example).

Additional points to note are

* required modules are different on all systems, so module-names can not be
hard-coded in planfiles or modulefile templates.
* Builder is not designed for cross-compiles.

31 changes: 31 additions & 0 deletions plans/bats/1.2.1/default
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# This file is part of Builder.
#
# Builder is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Builder is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Builder. If not, see <https://www.gnu.org/licenses/>.
#
URL="https://github.com/bats-core/bats-core/archive/v${VERSION}.tar.gz"
MD5SUM="e0efccc6345218d40c39678d1c89e67e"
SHA256SUM="91c49b1fe6f0656c46491929ed728f8dfa9a96df0cce294963e8c6082bff87a2"

build_prepare() {
log_status ">>> nothing to prepare"
}
build_package() {
log_status ">>> nothing to build"
}
build_install () {
log_status ">>> installing..."
cd "${SOURCE}"
./install.sh "${TARGET}" 2>&1 | tee "${LOG}/make-install.log"
}
23 changes: 23 additions & 0 deletions plans/bats/1.2.1/default.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#%Module1.0#####################################################################
##
set INSTALLDIR "${TARGET}"

proc ModulesHelp { } {
puts stderr "
Bats is a TAP-compliant testing framework for Bash. It provides a simple way
to verify that the UNIX programs you write behave as expected.

A Bats test file is a Bash script with special syntax for defining test
cases. Under the hood, each test case is just a function with a description.

See https://github.com/bats-core/bats-core#bats-core-bash-automated-testing-system-2018
"
}

module-whatis "Bash testing framework (${VERSION})"

conflict ${PACKAGE}
${PREREQ_DEPENDS}

prepend-path PATH \$INSTALLDIR/bin
prepend-path MANPATH \$INSTALLDIR/share/man
1 change: 1 addition & 0 deletions plans/nest-simulator/2.20.0/default.module
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ INSTALLDIR: \$INSTALLDIR"
module-whatis "NEST spiking neural network simulator, version ${VERSION} (${VARIANT} build)"

conflict ${PACKAGE}
${PREREQ_DEPENDS}

################################################################################
# from \$INSTALLDIR/bin/nest_vars.sh
Expand Down