Skip to content

Commit f15c42e

Browse files
committed
chore: add env.sh
1 parent 2f1ab61 commit f15c42e

File tree

1 file changed

+130
-0
lines changed

1 file changed

+130
-0
lines changed

environments/env.sh

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#!/usr/bin/env bash
2+
3+
# To remove a package in order to reinstall it
4+
#
5+
# $ spack uninstall --dependents --all --force -y <package>
6+
#
7+
# e.g.
8+
#
9+
# $ spack env deactivate; spack env rm -y star-x86-root5; spack env create star-x86-root5 environments/star-x86-root-5.34.yaml; spack env activate star-x86-root5; spack install
10+
# $ spack env deactivate; spack env rm -y star-x86_64-root5; spack env create star-x86_64-root5 environments/star-x86_64-root-5.34.yaml; spack env activate star-x86_64-root5; spack install
11+
#
12+
# $ setarch i686 bash
13+
#
14+
# spack install --keep-stage --reuse [email protected]~vc~vmc~python build_type=Debug
15+
16+
set -e
17+
18+
install_envs() {
19+
20+
envs=("$@")
21+
22+
for env in "${envs[@]}"; do
23+
filename=${env%%:*}
24+
spackenv=${env#*:}
25+
echo
26+
27+
if [[ $spackenv == *"debug"* ]]; then
28+
DEBUG_OPTS="--keep-stage"
29+
else
30+
DEBUG_OPTS=""
31+
fi
32+
33+
cmd="spack env rm -y $spackenv"
34+
echo "$cmd"
35+
eval "$cmd"
36+
37+
cmd="spack env create $spackenv $SPACK_ROOT/../environments/$filename.yaml"
38+
echo "$cmd"
39+
eval "$cmd"
40+
41+
cmd="spack env activate $spackenv"
42+
echo "$cmd"
43+
eval "$cmd"
44+
45+
cmd="spack install $DEBUG_OPTS"
46+
echo "$cmd"
47+
eval "$cmd"
48+
49+
cmd="spack module tcl refresh -y"
50+
echo "$cmd"
51+
eval "$cmd"
52+
53+
cmd="spack env deactivate"
54+
echo "$cmd"
55+
eval "$cmd"
56+
done
57+
}
58+
59+
60+
compilers_x86_64=$(cat <<EOF
61+
compilers:
62+
- compiler:
63+
64+
paths:
65+
cc: /usr/bin/gcc
66+
cxx: /usr/bin/g++
67+
f77: /usr/bin/gfortran
68+
fc: /usr/bin/gfortran
69+
flags: {}
70+
operating_system: rhel7
71+
target: x86_64
72+
modules: []
73+
environment: {}
74+
extra_rpaths: []
75+
EOF
76+
)
77+
78+
compilers_x86=$(cat <<EOF
79+
compilers:
80+
- compiler:
81+
82+
paths:
83+
cc: /usr/bin/gcc
84+
cxx: /usr/bin/g++
85+
f77: /usr/bin/gfortran
86+
fc: /usr/bin/gfortran
87+
flags:
88+
cflags: -m32
89+
cxxflags: -m32
90+
fflags: -m32
91+
operating_system: rhel7
92+
target: x86
93+
modules: []
94+
environment: {}
95+
extra_rpaths: []
96+
EOF
97+
)
98+
99+
envs_x86_64=(
100+
"star-x86_64-loose:star-x86_64-loose"
101+
"star-x86_64-root-5.34:star-x86_64-root5"
102+
"star-x86_64-root-6.24:star-x86_64-root6"
103+
"star-geant:star-x86_64-geant"
104+
"star-debug:star-x86_64-debug"
105+
)
106+
107+
envs_x86=(
108+
"star-x86-loose:star-x86-loose"
109+
"star-x86-root-5.34:star-x86-root5"
110+
"star-x86-root-6.24:star-x86-root6"
111+
"star-geant:star-x86-geant"
112+
)
113+
114+
115+
if [ "$1" == 'x86_64' ]; then
116+
echo "==> Install envs for target=x86_64"
117+
echo "$compilers_x86_64" > ~/.spack/linux/compilers.yaml
118+
cat ~/.spack/linux/compilers.yaml
119+
install_envs "${envs_x86_64[@]}"
120+
121+
elif [ "$1" == 'x86' ]; then
122+
echo "==> Install envs for target=x86"
123+
echo "$compilers_x86" > ~/.spack/linux/compilers.yaml
124+
cat ~/.spack/linux/compilers.yaml
125+
install_envs "${envs_x86[@]}"
126+
127+
else
128+
echo "==> Error: Unrecognized target $1"
129+
echo "==> Pick one of [x86, x86_64]"
130+
fi

0 commit comments

Comments
 (0)