Skip to content

Commit f49c439

Browse files
author
rcrutherford
committed
Attempt to fix spack environment issue with new syntax and no copy.
1 parent 1c5524a commit f49c439

File tree

1 file changed

+39
-48
lines changed

1 file changed

+39
-48
lines changed

buildsystem/spack/load_spack.sh

+39-48
Original file line numberDiff line numberDiff line change
@@ -2,79 +2,70 @@
22

33
# Enforce running from ExaGO root dir
44
if [[ ! -f $PWD/buildsystem/build.sh ]]; then
5-
echo 'Please run this script from the top-level ExaGO source directory.'
6-
exit 1
5+
echo 'Please run this script from the top-level ExaGO source directory.'
6+
exit 1
77
fi
88

99
# Need to know which platform we are configuring for
1010
MY_CLUSTER="${MY_CLUSTER:?MY_CLUSTER is unset. Please set manually.}"
11-
[[ -z $MY_CLUSTER ]] && return 1
11+
[[ -z $MY_CLUSTER ]] && return 1
1212

1313
echo "$MY_CLUSTER" | awk '{print tolower($0)}'
1414
# Use ${var,,} to convert to lower case
1515
# There must be an existing folder for the cluster
16-
if [ ! -d "./buildsystem/spack/${MY_CLUSTER}" ]
17-
then
18-
echo "${MY_CLUSTER} did not match any directories in /buildsystem/spack/"
19-
echo "Try one of the following platforms: "
20-
echo $(ls -d ./buildsystem/spack/*/ | tr '\n' '\0' | xargs -0 -n 1 basename )
21-
return
16+
if [ ! -d "./buildsystem/spack/${MY_CLUSTER}" ]; then
17+
echo "${MY_CLUSTER} did not match any directories in /buildsystem/spack/"
18+
echo "Try one of the following platforms: "
19+
echo $(ls -d ./buildsystem/spack/*/ | tr '\n' '\0' | xargs -0 -n 1 basename)
20+
return
2221
fi
2322

2423
base="./buildsystem/spack/${MY_CLUSTER}"
2524

2625
# There needs to be an existing spack.yaml
27-
if [ ! -f "$base/spack.yaml" ]
28-
then
29-
echo "No spack.yaml in $base/spack.yaml. Add this and try again."
30-
return
26+
if [ ! -f "$base/spack.yaml" ]; then
27+
echo "No spack.yaml in $base/spack.yaml. Add this and try again."
28+
return
3129
fi
3230

3331
# We must configure with platform specific environment before loading spack
34-
if [ ! -f "$base/env.sh" ]
35-
then
36-
echo "No environment (env.sh) script detected in $base."
37-
echo "Please add a script that creates a compatible shell environment."
38-
echo "You must set the following variables that affect your spack configuration."
39-
echo "TODO - add updated description of all spack platform variables" # TODO
40-
return
32+
if [ ! -f "$base/env.sh" ]; then
33+
echo "No environment (env.sh) script detected in $base."
34+
echo "Please add a script that creates a compatible shell environment."
35+
echo "You must set the following variables that affect your spack configuration."
36+
echo "TODO - add updated description of all spack platform variables" # TODO
37+
return
4138
fi
4239

43-
4440
# Source base platform environment
45-
source $base/env.sh && \
46-
47-
# Make sure SPACK_INSTALL is set, so we aren't installing somewhere undesired
48-
SPACK_INSTALL="${SPACK_INSTALL:?SPACK_INSTALL is unset. $base/env.sh should be edited to configure this}" && \
49-
SPACK_MIRROR="${SPACK_MIRROR:?SPACK_MIRROR is unset. $base/env.sh should be edited to configure this}" && \
50-
51-
# Load spack
52-
source ./tpl/spack/share/spack/setup-env.sh && \
53-
54-
# Create directory for environment
55-
SPACKENV=$(pwd)/spack-env-$MY_CLUSTER && \
56-
mkdir -p $SPACKENV && \
57-
# Remove old config
58-
(rm -f $SPACKENV/spack.yaml || true) && \
59-
(rm -f $SPACKENV/spack.lock || true) && \
41+
source $base/env.sh &&
6042

61-
# Use a directory based environment, and decorate command line
62-
spack env create -d $SPACKENV && \
43+
# Make sure SPACK_INSTALL is set, so we aren't installing somewhere undesired
44+
SPACK_INSTALL="${SPACK_INSTALL:?SPACK_INSTALL is unset. $base/env.sh should be edited to configure this}" &&
45+
SPACK_MIRROR="${SPACK_MIRROR:?SPACK_MIRROR is unset. $base/env.sh should be edited to configure this}" &&
6346

64-
# Use git version of config
65-
cp $base/spack.yaml $SPACKENV && \
66-
spack env activate -p $SPACKENV && \
47+
# Load spack
48+
source ./tpl/spack/share/spack/setup-env.sh &&
6749

68-
# Print relevant spack config for sanity check of environment.
69-
echo "spack configuration will be installed into $SPACK_INSTALL" && \
70-
mkdir -p $SPACK_INSTALL && \
71-
mkdir -p $SPACK_CACHE && \
50+
# Create directory for environment
51+
SPACKENV=$(pwd)/spack-env-$MY_CLUSTER &&
52+
mkdir -p $SPACKENV &&
53+
# Remove old config if present
54+
(rm -f $SPACKENV/spack.yaml || true) &&
55+
(rm -f $SPACKENV/spack.lock || true) &&
7256

57+
# Use a directory based environment, and decorate command line
58+
spack env create -d $SPACKENV $base/spack.yaml &&
59+
spack env activate -p $SPACKENV &&
7360

74-
echo "spack mirror will be in $SPACK_MIRROR" && \
75-
mkdir -p $SPACK_MIRROR
61+
# Print relevant spack config for sanity check of environment.
62+
echo "spack configuration will be installed into $SPACK_INSTALL" &&
63+
mkdir -p $SPACK_INSTALL &&
64+
mkdir -p $SPACK_CACHE &&
65+
echo "spack mirror will be in $SPACK_MIRROR" &&
66+
mkdir -p $SPACK_MIRROR
7667

7768
# Print config if configured successfully
7869
if [ $? -eq 0 ] && [ "$1" = "-v" ]; then
79-
spack config get config
70+
spack config get config
8071
fi

0 commit comments

Comments
 (0)