-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·172 lines (130 loc) · 3.59 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/sh
#
# This script links an HPCToolkit satellite repository (this
# directory) with a main spack repository.
#
# The main spack repo contains the build scripts and config files for
# building a few thousand packages with spack. This, the satellite
# repo contains the config files for building the HPCToolkit
# prerequisite packages with options needed for HPCToolkit.
#
# This script links the satellite repo to the main spack repo by
# creating two files in the spack repository in the directory:
# <spack-root>/etc/spack:
#
# config.yaml -- sets install_tree to the root of the install prefix
# for the hpctoolkit packages.
#
# repos.yaml -- sets the location of the satellite repository.
#
# This script also creates the file 'env.sh' in this directory.
# Source this file to put the spack bin directory on your path.
#
# Usage: ./setup.sh spack-root [prefix]
#
# spack-root = path to the main spack repository
# prefix = path to the install prefix (optional)
#
spack_root="$1"
prefix="$2"
prog_name=setup.sh
this_dir=`/bin/pwd`
env=env.sh
die() {
cat <<EOF
error: $@
usage: ./$prog_name spack-root [prefix]
spack-root = path to the main spack repository
prefix = path to the install prefix (optional)
EOF
exit 1
}
#------------------------------------------------------------
# Step 1 -- test if spack_root and prefix exist
#------------------------------------------------------------
test "x$spack_root" != x || die "missing spack-root"
cd "$spack_root" || die "unable to cd: $spack_root"
test -x "bin/spack" || die "not a spack directory: $spack_root"
test -d "etc/spack" || die "not a spack directory: $spack_root"
spack_root=`/bin/pwd`
cd "$this_dir" || die "unable to cd: $this_dir"
if test "x$prefix" != x ; then
#
# if prefix is specified but does not exist, then try to create
#
test -d "$prefix" || mkdir -p "$prefix"
cd "$prefix" || die "unable to cd: $prefix"
prefix=`/bin/pwd`
fi
cd "$this_dir" || die "unable to cd: $this_dir"
test -d "packages" || die "not a valid satellite repository: $this_dir"
#------------------------------------------------------------
# Step 2 -- write config.yaml and repos.yaml to spack tree,
# and env.sh to current dir.
#------------------------------------------------------------
cd "$spack_root" || die "unable to cd: $spack_root"
cd "etc/spack" || die "unable to cd: ${spack_root}/etc/spack"
config=config.yaml
config_bak="${config}.bak"
rm -f "$config_bak"
if test -f "$config" ; then
mv -f "$config" "$config_bak"
fi
cat <<EOF >"$config"
#
# config.yaml
#
# generated by $prog_name from: $this_dir
#
config:
EOF
if test "x$prefix" != x ; then
cat <<EOF >>"$config"
install_tree: $prefix
EOF
fi
cat <<EOF >>"$config"
build_stage:
- \$spack/var/spack/stage
# build_jobs: 8
EOF
repos=repos.yaml
repos_bak="${repos}.bak"
rm -f "$repos_bak"
if test -f "$repos" ; then
mv -f "$repos" "$repos_bak"
fi
cat <<EOF >"$repos"
#
# repos.yaml
#
# generated by $prog_name from: $this_dir
#
repos:
- $this_dir
- \$spack/var/spack/repos/builtin
EOF
#
# Write env.sh
#
cd "$this_dir" || die "unable to cd: $this_dir"
rm -f "$env"
cat <<EOF >"$env"
#
# source me to add spack bin directory to PATH
#
PATH="${spack_root}/bin/:\$PATH"
EOF
#------------------------------------------------------------
# Step 3 -- print the list of known repositories and install prefix
# to see if everything worked.
#------------------------------------------------------------
echo
cd "${spack_root}/bin"
./spack repo list
if test "x$prefix" = x ; then
prefix="${spack_root}/opt/spack"
fi
echo
echo "install prefix: $prefix"
echo