Skip to content

Commit 10ed730

Browse files
authored
Merge pull request #14 from ocaisa/correct_hooks_replacement
Make sure the full directory name is replaced in `eb_hooks.py`, replace placeholders before comparing what is shipped
2 parents 7e4067b + a8fc637 commit 10ed730

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

bot/test.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,13 @@ EESSI_REPOS_CFG_DIR_OVERRIDE=$(cfg_get_value "repository" "repos_cfg_dir")
151151
export EESSI_REPOS_CFG_DIR_OVERRIDE=${EESSI_REPOS_CFG_DIR_OVERRIDE:-${PWD}/cfg}
152152
echo "bot/test.sh: EESSI_REPOS_CFG_DIR_OVERRIDE='${EESSI_REPOS_CFG_DIR_OVERRIDE}'"
153153

154-
# determine pilot version to be used from .repository.repo_version in ${JOB_CFG_FILE}
155-
# here, just set & export EESSI_PILOT_VERSION_OVERRIDE
154+
# determine EESSI version to be used from .repository.repo_version in ${JOB_CFG_FILE}
155+
# here, just set & export EESSI_VERSION_OVERRIDE
156156
# next script (eessi_container.sh) makes use of it via sourcing init scripts
157157
# (e.g., init/eessi_defaults or init/minimal_eessi_env)
158-
export EESSI_PILOT_VERSION_OVERRIDE=$(cfg_get_value "repository" "repo_version")
159-
echo "bot/test.sh: EESSI_PILOT_VERSION_OVERRIDE='${EESSI_PILOT_VERSION_OVERRIDE}'"
158+
REPOSITORY_VERSION=$(cfg_get_value "repository" "repo_version")
159+
export EESSI_VERSION_OVERRIDE=${REPOSITORY_VERSION}
160+
echo "bot/build.sh: EESSI_VERSION_OVERRIDE='${EESSI_VERSION_OVERRIDE}'"
160161

161162
# determine CVMFS repo to be used from .repository.repo_name in ${JOB_CFG_FILE}
162163
# here, just set EESSI_CVMFS_REPO_OVERRIDE, a bit further down

eb_hooks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ def parse_hook_zen4_module_only(ec, eprefix):
405405
env_varname = EESSI_IGNORE_ZEN4_GCC1220_ENVVAR
406406
# TODO: create a docs page to which we can refer for more info here
407407
# TODO: then update the link to the known issues page to the _specific_ issue
408-
# Need to escape newline character so that the newline character actually ends up in the module file
408+
# Need to escape the newline character so that the newline character actually ends up in the module file
409409
# (otherwise, it splits the string, and a 2-line string ends up in the modulefile, resulting in syntax error)
410410
errmsg = "EasyConfigs using toolchains based on GCCcore-12.2.0 are not supported for the Zen4 architecture.\\n"
411411
errmsg += "See https://www.eessi.io/docs/known_issues/eessi-<EESSI_VERSION>/#gcc-1220-and-foss-2022b-based-modules-cannot-be-loaded-on-zen4-architecture"

install_scripts.sh

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,31 @@ file_changed_in_pr() {
3737
) && return 0 || return 1
3838
}
3939

40+
sed_update_if_changed() {
41+
# Usage: sed_update_if_changed 's/foo/bar/' file.txt
42+
if [ "$#" -ne 2 ]; then
43+
echo "Usage: sed_update_if_changed 'sed_command' file" >&2
44+
return 1
45+
fi
46+
47+
local sed_command="$1"
48+
local file="$2"
49+
local tmp_file="$(mktemp "${file}.XXXXXX")"
50+
51+
sed "$sed_command" "$file" > "$tmp_file" || {
52+
rm -f "$tmp_file"
53+
echo "sed command failed" >&2
54+
return 1
55+
}
56+
57+
if ! diff -q "$file" "$tmp_file" > /dev/null; then
58+
# Use cat to retain existing permissions, set umask to world readable in case the target file does not yet exist.
59+
(umask 022 && cat "$tmp_file" > "$file")
60+
fi
61+
# Remove the temporary file
62+
rm -f "$tmp_file"
63+
}
64+
4065
compare_and_copy() {
4166
if [ "$#" -ne 2 ]; then
4267
echo "Usage of function: compare_and_copy <source_file> <destination_file>"
@@ -193,15 +218,15 @@ copy_files_by_list ${TOPDIR} ${INSTALL_PREFIX}/init/easybuild "${hook_files[@]}"
193218
# but that should be fine (no changes are made if version placeholder is not present anymore)
194219

195220
# make sure that scripts in init/ and scripts/ use correct EESSI version
196-
sed -i "s/__EESSI_VERSION_DEFAULT__/${EESSI_VERSION}/g" ${INSTALL_PREFIX}/init/eessi_defaults
221+
sed_update_if_changed "s/__EESSI_VERSION_DEFAULT__/${EESSI_VERSION}/g" ${INSTALL_PREFIX}/init/eessi_defaults
197222

198223
# replace placeholder for default EESSI version in Lmod init scripts
199224
for shell in $(ls ${INSTALL_PREFIX}/init/lmod); do
200-
sed -i "s/__EESSI_VERSION_DEFAULT__/${EESSI_VERSION}/g" ${INSTALL_PREFIX}/init/lmod/${shell}
225+
sed_update_if_changed "s/__EESSI_VERSION_DEFAULT__/${EESSI_VERSION}/g" ${INSTALL_PREFIX}/init/lmod/${shell}
201226
done
202227

203228
# replace EESSI version used in comments in EESSI module
204-
sed -i "s@/<EESSI_VERSION>/@/${EESSI_VERSION}/@g" ${INSTALL_PREFIX}/init/modules/EESSI/${EESSI_VERSION}.lua
229+
sed_update_if_changed "s@/<EESSI_VERSION>/@/${EESSI_VERSION}/@g" ${INSTALL_PREFIX}/init/modules/EESSI/${EESSI_VERSION}.lua
205230

206231
# replace EESSI version used in EasyBuild hooks
207-
sed -i "s@/<EESSI_VERSION>/@/${EESSI_VERSION}/@g" ${INSTALL_PREFIX}/init/easybuild/eb_hooks.py
232+
sed_update_if_changed "s@/eessi-<EESSI_VERSION>/@/eessi-${EESSI_VERSION}/@g" ${INSTALL_PREFIX}/init/easybuild/eb_hooks.py

0 commit comments

Comments
 (0)