Skip to content

Commit 5f7d31d

Browse files
committed
fix: environment for hpctoolkit container
1 parent 892ee90 commit 5f7d31d

File tree

4 files changed

+47
-12
lines changed

4 files changed

+47
-12
lines changed

basic/hpctoolkit.def

+6-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ From: containers/basic/{{ BASE_CONTAINER }}.sif
5050
mawk \
5151
ninja-build \
5252
pkg-config \
53-
python3 python3-dev python3-myst-parser \
53+
python3 python3-dev python3-myst-parser python3-venv \
5454
sed \
5555
meson \
5656
zlib1g-dev
@@ -63,9 +63,10 @@ From: containers/basic/{{ BASE_CONTAINER }}.sif
6363
cd /opt/hpctoolkit
6464
git checkout {{ FRAMEWORK_VERSION }}
6565
# Create hpctoolkit-ci.ini configuration
66+
mkdir -p /usr/share/meson/native
6667
t=/usr/share/meson/native/hpctoolkit-ci.ini
6768
rm -f "$t"
68-
echo "[built-in options]" >> "$t"
69+
echo "[built-in options]" > "$t"
6970
echo "wrap_mode = 'nofallback'" >> "$t"
7071
echo "force_fallback_for = ['dyninst', 'libunwind', 'xed']" >> "$t"
7172
echo "" >> "$t"
@@ -84,8 +85,9 @@ From: containers/basic/{{ BASE_CONTAINER }}.sif
8485
meson setup build
8586
meson compile -C build
8687
meson install -C build
87-
echo "export JAVA_HOME=${JAVA_HOME} > /opt/hpctoolkit/bashrc"
88-
echo "export PATH=${PATH}:${JAVA_HOME}/bin:/opt/hpcviewer >> /opt/hpctoolkit/bashrc"
88+
echo "export JAVA_HOME=${JAVA_HOME}" > /opt/hpctoolkit/bashrc
89+
echo "export PATH=${PATH}:${JAVA_HOME}/bin:/opt/hpcviewer" >> /opt/hpctoolkit/bashrc
90+
echo "export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib64" >> /opt/hpctoolkit/bashrc
8991
jq --arg app hpctoolkit --arg commit {{ FRAMEWORK_GIT_REF }} \
9092
--arg branch {{ FRAMEWORK_GIT_REF }} \
9193
'.[$app] |= if . == null then

build.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,6 @@
178178
--build-arg BASE_CONTAINER={{ item.base_container }} \
179179
--build-arg OS_VERSION={{ containers.basic[item.base_container].os.version }} \
180180
--build-arg MPI_VERSION={{ containers.basic[item.base_container].mpi.version }} \
181-
--build-arg FRAMEWORK_VERSION={{ containers.basic[item.base_container].framework.version }} \
182-
--build-arg FRAMEWORK_GIT_REF={{ containers.basic[item.base_container].framework.git_ref | default('default') }} \
183181
{{ original_dir }}/containers/projects/{{ item.name }}.sif \
184182
{{ original_dir }}/{{ item.definition }} \
185183
> {{ item.name }}.log 2>&1

projects/extend-test.def

+24-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ From: {{ CONTAINERS_DIR }}/basic/{{ BASE_CONTAINER }}.sif
2323

2424
%post
2525
echo "Testing OpenMPI implementation"
26-
/bin/bash -c "cd /opt/OMPIFoam && mpicc -o ompiTest testOMPI.cpp"
27-
/bin/bash -c "source /opt/foam/foam-extend-{{ OPENFOAM_VERSION }}/etc/bashrc && cd /opt/OMPIFoam && wmake"
26+
source $(jq -r '.openfoam.source_script' /apps.json)
27+
cd /opt/OMPIFoam && mpicc -o ompiTest testOMPI.cpp
28+
cd /opt/OMPIFoam && wmake
2829
jq --arg app extend-test \
2930
'.[$app] |= if . == null then
3031
{
@@ -38,5 +39,26 @@ From: {{ CONTAINERS_DIR }}/basic/{{ BASE_CONTAINER }}.sif
3839
} end' /apps.json > /tmp/apps.json
3940
mv /tmp/apps.json /apps.json
4041

42+
%environment
43+
#!/bin/bash
44+
jq -r '.. | .source_script? // empty' /apps.json | while read -r script; do
45+
if [[ -f "$script" ]]; then
46+
source "$script"
47+
fi
48+
done
49+
jq -r '.. | .python_env? // empty' /apps.json | while read -r script; do
50+
if [[ -f "$script" ]]; then
51+
source "$script/bin/activate"
52+
fi
53+
done
54+
55+
%runscript
56+
#!/bin/bash
57+
if [ $# -eq 0 ]; then
58+
/bin/bash
59+
else
60+
/bin/bash -c "$@"
61+
fi
62+
4163
%labels
4264
Description Test applications for Foam-Extend

projects/test.def

+17-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ From: {{ CONTAINERS_DIR }}/basic/{{ BASE_CONTAINER }}.sif
2626

2727
%post -c /bin/bash
2828
echo "Testing OpenMPI implementation"
29-
source /usr/lib/openfoam/openfoam{{ FRAMEWORK_VERSION }}/etc/bashrc
29+
source $(jq -r '.openfoam.source_script' /apps.json)
3030
export LD_LIBRARY_PATH=/opt/{{ MPI_IMPLEMENTATION }}/lib:$LD_LIBRARY_PATH
3131
cd /opt/OMPIFoam && mpicc -o ompiTest testOMPI.cpp && wmake
3232
jq --arg app test --arg branch {{ BRANCH }} \
@@ -44,12 +44,25 @@ From: {{ CONTAINERS_DIR }}/basic/{{ BASE_CONTAINER }}.sif
4444
} end' /apps.json > /tmp/apps.json
4545
mv /tmp/apps.json /apps.json
4646

47+
%environment
48+
#!/bin/bash
49+
jq -r '.. | .source_script? // empty' /apps.json | while read -r script; do
50+
if [[ -f "$script" ]]; then
51+
source "$script"
52+
fi
53+
done
54+
jq -r '.. | .python_env? // empty' /apps.json | while read -r script; do
55+
if [[ -f "$script" ]]; then
56+
source "$script/bin/activate"
57+
fi
58+
done
59+
4760
%runscript
48-
/bin/bash -c 'cd /usr/lib/openfoam/openfoam{{ FRAMEWORK_VERSION }} && source etc/bashrc && mkdir -p $FOAM_USER_LIBBIN && mkdir -p $FOAM_USER_APPBIN'
61+
#!/bin/bash
4962
if [ $# -eq 0 ]; then
50-
/usr/bin/openfoam{{ FRAMEWORK_VERSION }}
63+
/bin/bash
5164
else
52-
/usr/bin/openfoam{{ FRAMEWORK_VERSION }} $@
65+
/bin/bash -c "$@"
5366
fi
5467

5568
%labels

0 commit comments

Comments
 (0)