forked from FairRootGroup/FairSoft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththisfairsoft.sh
executable file
·98 lines (88 loc) · 2.55 KB
/
thisfairsoft.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
#!/bin/bash
fairsoft_basedir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
fairsoft_spackdir=spack
fairsoft_configdir=../../../config
if [ "$1" = "--setup" ]
then
fairsoft_do_setup=true
else
fairsoft_do_setup=false
fi
if $fairsoft_do_setup && command -v git >/dev/null 2>&1
then
(cd "$fairsoft_basedir" && git submodule update --init)
fi
. "${fairsoft_basedir}/${fairsoft_spackdir}/share/spack/setup-env.sh"
if $fairsoft_do_setup
then
spack compiler find
fi
(
cd "${fairsoft_basedir}/${fairsoft_spackdir}/etc/spack/${fairsoft_configdir}"
for config_entry in *
do
case "$config_entry" in
*~)
continue
;;
.*)
continue
;;
esac
fairsoft_symlink_from="${fairsoft_basedir}/${fairsoft_spackdir}/etc/spack/${config_entry}"
if [ "!" -e "$fairsoft_symlink_from" ] && [ "!" -L "$fairsoft_symlink_from" ]
then
if $fairsoft_do_setup
then
ln -s "${fairsoft_configdir}/${config_entry}" \
"$fairsoft_symlink_from"
else
echo '!!!' >&2
echo '!!! ========================== /!\ WARNING ==========================' >&2
echo "!!! $fairsoft_symlink_from" >&2
echo "!!! should be a symlink into the FairSoft config directory" >&2
echo "!!! Consider running the setup once:" >&2
echo "!!! --> source ${BASH_SOURCE[0]} --setup" >&2
fi
else
fairsoft_readlink="$(readlink "$fairsoft_symlink_from")"
if [ "$fairsoft_readlink" != "${fairsoft_configdir}/${config_entry}" ]
then
echo '!!!' >&2
echo '!!! ========================== /!\ WARNING ==========================' >&2
echo "!!! $fairsoft_symlink_from" >&2
echo "!!! does not point to the right target" >&2
echo "!!! It should be a symlink to:" >&2
echo "!!! ${fairsoft_configdir}/${config_entry}" >&2
echo "!!! Currently either not a symlink or points to:" >&2
echo "!!! $fairsoft_readlink" >&2
fi
fi
done
)
fairsoft_repo() {
if [ "$(spack repo list | sed -n -e "/^$1 / { s/^[^ ]* *//; p; }")" != "${fairsoft_basedir}/repos/$2" ]
then
if $fairsoft_do_setup
then
spack repo add --scope site "${fairsoft_basedir}/repos/$2"
else
echo '!!!' >&2
echo '!!! ========================== /!\ WARNING ==========================' >&2
echo "!!! spack repo $1 ($2) missing" >&2
echo "!!! Consider running the setup once:" >&2
echo "!!! --> source ${BASH_SOURCE[0]} --setup" >&2
fi
fi
}
fairsoft_repo "fairsoft_backports" "fairsoft-backports"
fairsoft_repo "fairsoft" "fairsoft"
if $fairsoft_do_setup
then
spack clean -ms
fi
unset -f fairsoft_repo
unset fairsoft_basedir
unset fairsoft_spackdir
unset fairsoft_configdir
unset fairsoft_do_setup