diff --git a/EESSI-install-software.sh b/EESSI-install-software.sh index f546b11f24..c20a69d588 100755 --- a/EESSI-install-software.sh +++ b/EESSI-install-software.sh @@ -152,37 +152,37 @@ else mkdir -p ${EESSI_PREFIX}/software/${EESSI_OS_TYPE}/${EESSI_SOFTWARE_SUBDIR_OVERRIDE} fi -# if we run the script for the first time, e.g., to start building for a new -# stack, we need to ensure certain files are present in +# We need to ensure that certain files are present or updated before we source +# $TOPDIR/init/eessi_environment_variables +# Particularly the files we need to have present/updated in # ${EESSI_PREFIX}/software/${EESSI_OS_TYPE}/${EESSI_SOFTWARE_SUBDIR_OVERRIDE} -# - .lmod/lmodrc.lua -# - .lmod/SitePackage.lua -# assume there's only one diff file that corresponds to the PR patch file -pr_diff=$(ls [0-9]*.diff | head -1) +# are: +# - .lmod/lmodrc.lua +# - .lmod/SitePackage.lua +# We run scripts to create them if they don't exist or if the scripts have been +# changed in the PR. + +# Set base directory for software and for Lmod config files _eessi_software_path=${EESSI_PREFIX}/software/${EESSI_OS_TYPE}/${EESSI_SOFTWARE_SUBDIR_OVERRIDE} _lmod_cfg_dir=${_eessi_software_path}/.lmod -_lmod_rc_file=${_lmod_cfg_dir}/lmodrc.lua -if [ ! -f ${_lmod_rc_file} ]; then - command -V python3 + +# We assume there's only one diff file that corresponds to the PR patch file +pr_diff=$(ls [0-9]*.diff | head -1) + +# Create or update ${_eessi_software_path}/.lmod/lmodrc.lua +_lmodrc_file=${_lmod_cfg_dir}/lmodrc.lua +_lmodrc_changed=$(cat ${pr_diff} | grep '^+++' | cut -f2 -d' ' | sed 's@^[a-z]/@@g' | grep '^create_lmodrc.py$' > /dev/null; echo $?) +if [ ! -f "${_lmodrc_file}" ] || [ "${_lmodrc_changed}" == '0' ]; then python3 ${TOPDIR}/create_lmodrc.py ${_eessi_software_path} + check_exit_code $? "${_lmodrc_file} created/updated" "Failed to create/update ${_lmodrc_file}" fi + +# Create or update ${_eessi_software_path}/.lmod/SitePackage.lua _lmod_sitepackage_file=${_lmod_cfg_dir}/SitePackage.lua -if [ ! -f ${_lmod_sitepackage_file} ]; then - command -V python3 +_sitepackage_changed=$(cat ${pr_diff} | grep '^+++' | cut -f2 -d' ' | sed 's@^[a-z]/@@g' | grep '^create_lmodsitepackage.py$' > /dev/null; echo $?) +if [ ! -f "${_lmod_sitepackage_file}" ] || [ "${_sitepackage_changed}" == '0' ]; then python3 ${TOPDIR}/create_lmodsitepackage.py ${_eessi_software_path} - echo "newly created '${_lmod_sitepackage_file}':" - cat -n ${_lmod_sitepackage_file} -else - echo ">> Updating Lmod SitePackage.lua ..." - export LMOD_PACKAGE_PATH="${_lmod_cfg_dir}" - lmod_sitepackage_file="$LMOD_PACKAGE_PATH/SitePackage.lua" - sitepackage_changed=$(cat ${pr_diff} | grep '^+++' | cut -f2 -d' ' | sed 's@^[a-z]/@@g' | grep '^create_lmodsitepackage.py$' > /dev/null; echo $?) - if [ ! -f "$lmod_sitepackage_file" ] || [ "${sitepackage_changed}" == '0' ]; then - python3 $TOPDIR/create_lmodsitepackage.py ${_eessi_software_path} - check_exit_code $? "$lmod_sitepackage_file created" "Failed to create $lmod_sitepackage_file" - fi - echo "just updated '${lmod_sitepackage_file}':" - cat -n ${lmod_sitepackage_file} + check_exit_code $? "${_lmod_sitepackage_file} created/updated" "Failed to create/update ${_lmod_sitepackage_file}" fi # Set all the EESSI environment variables (respecting $EESSI_SOFTWARE_SUBDIR_OVERRIDE) @@ -319,25 +319,5 @@ else done fi -### add packages here - -echo ">> Creating/updating Lmod RC file..." -export LMOD_CONFIG_DIR="${EASYBUILD_INSTALLPATH}/.lmod" -lmod_rc_file="$LMOD_CONFIG_DIR/lmodrc.lua" -lmodrc_changed=$(cat ${pr_diff} | grep '^+++' | cut -f2 -d' ' | sed 's@^[a-z]/@@g' | grep '^create_lmodrc.py$' > /dev/null; echo $?) -if [ ! -f $lmod_rc_file ] || [ ${lmodrc_changed} == '0' ]; then - python3 $TOPDIR/create_lmodrc.py ${EASYBUILD_INSTALLPATH} - check_exit_code $? "$lmod_rc_file created" "Failed to create $lmod_rc_file" -fi - -echo ">> Creating/updating Lmod SitePackage.lua ..." -export LMOD_PACKAGE_PATH="${EASYBUILD_INSTALLPATH}/.lmod" -lmod_sitepackage_file="$LMOD_PACKAGE_PATH/SitePackage.lua" -sitepackage_changed=$(cat ${pr_diff} | grep '^+++' | cut -f2 -d' ' | sed 's@^[a-z]/@@g' | grep '^create_lmodsitepackage.py$' > /dev/null; echo $?) -if [ ! -f "$lmod_sitepackage_file" ] || [ "${sitepackage_changed}" == '0' ]; then - python3 $TOPDIR/create_lmodsitepackage.py ${EASYBUILD_INSTALLPATH} - check_exit_code $? "$lmod_sitepackage_file created" "Failed to create $lmod_sitepackage_file" -fi - echo ">> Cleaning up ${TMPDIR}..." rm -r ${TMPDIR}