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 script for updating Lmod caches #175

Merged
merged 6 commits into from
Mar 26, 2024
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
18 changes: 18 additions & 0 deletions scripts/ingest-tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,23 @@ function check_arch() {
fi
}

function update_lmod_caches() {
# Update the Lmod caches for the stacks of all supported CPUs
script_dir=$(dirname $(realpath $BASH_SOURCE))
update_caches_script=${script_dir}/update_lmod_caches.sh
if [ ! -f ${update_caches_script} ]
then
error "cannot find the script for updating the Lmod caches; it should be placed in the same directory as the ingestion script!"
fi
if [ ! -x ${update_caches_script} ]
then
error "the script for updating the Lmod caches (${update_caches_script}) does not have execute permissions!"
fi
cvmfs_server transaction "${repo}"
${update_caches_script} /cvmfs/${repo}/${basedir}/${version}
cvmfs_server publish -m "update Lmod caches after ingesting ${tar_file_basename}" "${repo}"
}

function ingest_init_tarball() {
# Handle the ingestion of tarballs containing init scripts
cvmfs_ingest_tarball
Expand All @@ -183,6 +200,7 @@ function ingest_software_tarball() {
check_arch
check_os
cvmfs_ingest_tarball
update_lmod_caches
}

function ingest_compat_tarball() {
Expand Down
52 changes: 52 additions & 0 deletions scripts/update_lmod_caches.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

function echo_green() {
echo -e "\e[32m$1\e[0m"
}

function echo_red() {
echo -e "\e[31m$1\e[0m"
}

function error() {
echo_red "ERROR: $1" >&2
exit 1
}

# Check if a stack base dir has been specified
if [ "$#" -ne 1 ]; then
error "usage: $0 <path to main directory of an EESSI stack>"
fi

stack_base_dir="$1"

# Check if the given stack base dir exists
if [ ! -d ${stack_base_dir} ]
then
error "${stack_base_dir} does not point to an existing directory!"
fi

# Check if Lmod's cache update script can be found at the expected location (in the compatibility layer of the given stack)
update_lmod_system_cache_files="${stack_base_dir}/compat/linux/$(uname -m)/usr/share/Lmod/libexec/update_lmod_system_cache_files"
if [ ! -f ${update_lmod_system_cache_files} ]
then
error "expected to find Lmod's cache update script at ${update_lmod_system_cache_files}, but it doesn't exist."
fi

# Find all subtrees of supported CPU targets by looking for "modules" directories, and taking their parent directory
architectures=$(find ${stack_base_dir}/software/ -maxdepth 5 -type d -name modules -exec dirname {} \;)

# Create/update the Lmod cache for all architectures
for archdir in ${architectures}
do
lmod_cache_dir="${archdir}/.lmod/cache"
${update_lmod_system_cache_files} -d ${lmod_cache_dir} -t ${lmod_cache_dir}/timestamp ${archdir}/modules/all
exit_code=$?
if [[ ${exit_code} -eq 0 ]]; then
echo_green "Updated the Lmod cache for ${archdir}."
ls -lrt ${lmod_cache_dir}
else
echo_red "Updating the Lmod cache failed for ${archdir}."
exit ${exit_code}
fi
done
Loading