|
2 | 2 |
|
3 | 3 | # Enforce running from ExaGO root dir
|
4 | 4 | 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 |
7 | 7 | fi
|
8 | 8 |
|
9 | 9 | # Need to know which platform we are configuring for
|
10 | 10 | MY_CLUSTER="${MY_CLUSTER:?MY_CLUSTER is unset. Please set manually.}"
|
11 |
| -[[ -z $MY_CLUSTER ]] && return 1 |
| 11 | +[[ -z $MY_CLUSTER ]] && return 1 |
12 | 12 |
|
13 | 13 | echo "$MY_CLUSTER" | awk '{print tolower($0)}'
|
14 | 14 | # Use ${var,,} to convert to lower case
|
15 | 15 | # 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 |
22 | 21 | fi
|
23 | 22 |
|
24 | 23 | base="./buildsystem/spack/${MY_CLUSTER}"
|
25 | 24 |
|
26 | 25 | # 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 |
31 | 29 | fi
|
32 | 30 |
|
33 | 31 | # 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 |
41 | 38 | fi
|
42 | 39 |
|
43 |
| - |
44 | 40 | # 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 && |
60 | 42 |
|
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}" && |
63 | 46 |
|
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 && |
67 | 49 |
|
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) && |
72 | 56 |
|
| 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 && |
73 | 60 |
|
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 |
76 | 67 |
|
77 | 68 | # Print config if configured successfully
|
78 | 69 | if [ $? -eq 0 ] && [ "$1" = "-v" ]; then
|
79 |
| - spack config get config |
| 70 | + spack config get config |
80 | 71 | fi
|
0 commit comments