diff --git a/scripts/ingest-tarball.sh b/scripts/ingest-tarball.sh index 9a2580d2..952c8629 100755 --- a/scripts/ingest-tarball.sh +++ b/scripts/ingest-tarball.sh @@ -182,7 +182,10 @@ function update_lmod_caches() { error "the script for updating the Lmod caches (${update_caches_script}) does not have execute permissions!" fi ${cvmfs_server} transaction "${cvmfs_repo}" - ${update_caches_script} "${CVMFS_ROOT}/${cvmfs_repo}/${basedir}/${version}" + # Find the oldest version that we have, and use its Lmod to generate the cache to get better backwards compatibilty with old Lmod versions + oldest_stack=$(ls -1 -v "${CVMFS_ROOT}/${cvmfs_repo}/${basedir}" | head -n 1) + oldest_stack_lmod_update_script="${CVMFS_ROOT}/${cvmfs_repo}/${basedir}/${oldest_stack}/compat/linux/$(uname -m)/usr/share/Lmod/libexec/update_lmod_system_cache_files" + ${update_caches_script} "${CVMFS_ROOT}/${cvmfs_repo}/${basedir}/${version}" "${oldest_stack_lmod_update_script}" ec=$? if [ $ec -eq 0 ]; then ${cvmfs_server} publish -m "update Lmod caches after ingesting ${tar_file_basename}" "${cvmfs_repo}" diff --git a/scripts/update_lmod_caches.sh b/scripts/update_lmod_caches.sh index 70737123..79ba632d 100755 --- a/scripts/update_lmod_caches.sh +++ b/scripts/update_lmod_caches.sh @@ -14,11 +14,12 @@ function error() { } # Check if a stack base dir has been specified -if [ "$#" -ne 1 ]; then - error "usage: $0 " +if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then + error "usage: $0 []" fi stack_base_dir="$1" +update_lmod_system_cache_files="$2" # Check if the given stack base dir exists if [ ! -d ${stack_base_dir} ] @@ -26,8 +27,11 @@ 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 no Lmod cache update script was specified, try to find one in the compatibility layer of the given stack +if [ -z ${update_lmod_system_cache_files} ]; then + update_lmod_system_cache_files="${stack_base_dir}/compat/linux/$(uname -m)/usr/share/Lmod/libexec/update_lmod_system_cache_files" +fi +# Make sure that the expected Lmod cache update script exists 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."