forked from FlexibleSUSY/FlexibleSUSY
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install-sarah
executable file
·274 lines (228 loc) · 8.55 KB
/
install-sarah
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#!/bin/sh
# SARAH installation script
# Author: Alexander Voigt
# directory of this script
BASEDIR=$(dirname $0)
# absolute path to this script
ABSBASEDIR=$(cd $BASEDIR; pwd)
# operating system
operating_system="`(uname -s) 2>/dev/null || echo unknown`"
# default SARAH version
sarah_version="4.14.3"
# determine Mathematica user directory
case "$operating_system" in
Darwin) mathematica_dir="${HOME}/Library/Mathematica" ;;
CYGWIN_NT*) mathematica_dir="${USERPROFILE}/AppData/Roaming/Mathematica" ;;
# Linux, *BSD
*) mathematica_dir="${HOME}/.Mathematica" ;;
esac
mathematica_kernel="math"
mathematica_kernel_dir="${mathematica_dir}/Kernel"
mathematica_applications_dir="${mathematica_dir}/Applications"
mathematica_init="${mathematica_kernel_dir}/init.m"
install_path="${mathematica_applications_dir}"
sarah_link="${install_path}/SARAH"
sarah_link_for_math="$sarah_link"
case "$operating_system" in CYGWIN_NT*)
mathematica_kernel_dir=$(cygpath -u "$mathematica_kernel_dir")
mathematica_applications_dir=$(cygpath -u "$mathematica_applications_dir")
mathematica_init=$(cygpath -u "$mathematica_init")
install_path=$(cygpath -u "$install_path")
sarah_link=$(cygpath -u "$sarah_link")
sarah_link_for_math=$(cygpath -w "$sarah_link_for_math")
esac
escaped_sarah_link_for_math=$(echo "$sarah_link_for_math" | sed 's,\\,\\\\,g')
# installation flags
overwrite="no"
#_____________________________________________________________________
create_symlink() {
# This function tries to create a symlink [$2] pointing to target [$1]
case "$operating_system" in
CYGWIN_NT*)
exists_in_path "cygstart" || {
echo "Error: cygstart not found!"
echo " Please install Cygwin package cygutils."
exit 1
}
# creates an NTFS symbolic link supported by Windows Vista or newer
# see http://stackoverflow.com/questions/18654162/enable-ntfs-symbolic-links-for-cygwin
# and http://stackoverflow.com/questions/4090301/root-user-sudo-equivalent-in-cygwin
cygstart --action=runas env CYGWIN=winsymlinks:nativestrict \
/usr/bin/ln -s "$@" ;;
# *nix
*) ln -s "$@" ;;
esac
}
#_____________________________________________________________________
exists_in_path () {
# This function will try to locate an executable [$1] in $PATH.
#
# The result of the search is stored in cmd, which should be
# immediately copied, since the variables value will be
# overwritten at next invocation of this function.
# Assert that we got enough arguments
if test $# -ne 1 ; then
echo "exists_in_path: Exactly one argument required"
return 1
fi
cmd=$(command -v -- "$1")
case "$cmd" in
/*) return 0 ;;
alias\ *) return 1 ;; # alias
*) return 1 ;; # built-in or function
esac
}
#_____________________________________________________________________
help() {
cat <<EOF
Usage: ./`basename $0` [options]
Options:
--force,-f Overwrite an already existing SARAH link.
--version= SARAH version (default: ${sarah_version}).
Example: --version=${sarah_version}
--with-math-cmd= Mathematica kernel (default: ${mathematica_kernel})
Example: --with-math-cmd=${mathematica_kernel}
--help,-h Print this help message.
This script downloads and installs SARAH.
At first the SARAH tarball is downloaded from the URL
https://sarah.hepforge.org/downloads/
and is stored in
${install_path}/
Afterwards, the tarball is extracted and a static link with the name
\`SARAH' is created, which points to the SARAH directory. The path to
this link is then appended to the \$Path variable inside
${mathematica_init}
This allows one to load SARAH with the Needs["SARAH\`"] command, as
for example required by FlexibleSUSY.
Example:
$ ls ${mathematica_applications_dir}
$ cat ${mathematica_init}
(** User Mathematica initialization file **)
$ ./install-sarah --version=${sarah_version}
[...]
$ ls --classify ${mathematica_applications_dir}
SARAH@ SARAH-${sarah_version}/ SARAH-${sarah_version}.tar.gz
$ cat ${mathematica_init}
(** User Mathematica initialization file **)
AppendTo[\$Path, "${escaped_sarah_link_for_math}"];
$ math
$ Mathematica 7.0 for Linux x86 (64-bit)
Copyright 1988-2008 Wolfram Research, Inc.
In[1]:= Needs["SARAH\`"]
SARAH ${sarah_version}
by Florian Staub, 2014
References:
Comput.Phys.Commun.181 (2010) 1077-1086. (arXiv:0909.2863[hep-ph])
Comput.Phys.Commun.182 (2011) 808-833. (arXiv:1002.0840[hep-ph])
Comput.Phys.Commun.184 (2013) 1792-1809. (arXiv:1207.0906[hep-ph])
Comput.Phys.Commun.185 (2014) 1773-1790. (arXiv:1309.7223[hep-ph])
Download and Documentation:
http://sarah.hepforge.org
Begin evaluation of Model with: Start["Name of Model"]
e.g. Start["MSSM"] or Start["NMSSM","CKM"]
To get a list with all installed models, use ShowModels
In[2]:= Quit[]
EOF
}
# parse command line arguments
if test $# -gt 0 ; then
while test ! "x$1" = "x" ; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case $1 in
--force|-f) overwrite="yes" ;;
--with-math-cmd=*) mathematica_kernel="$optarg" ;;
--help|-h) help; exit ${exit_ok} ;;
--version=*) sarah_version="$optarg" ;;
*) echo "Invalid option '$1'. Try $0 --help" ; exit ${exit_syntax_error} ;;
esac
shift
done
fi
sarah_tarball="SARAH-${sarah_version}.tar.gz"
sarah_dir="SARAH-${sarah_version}"
sarah_download_area="https://sarah.hepforge.org/downloads/"
sarah_download_url="https://sarah.hepforge.org/downloads/${sarah_tarball}"
# check SARAH version string
if echo "${sarah_version}" | grep -v '[0-9]\+.[0-9]\+.[0-9]\+' > /dev/null 2>&1 ; then
echo "Error: incorrect SARAH version pattern"
echo " The SARAH version must be of the form x.y.z , where"
echo " x, y and z are integer numbers."
exit 1
fi
exists_in_path "${mathematica_kernel}" || {
echo "Error: ${mathematica_kernel} not found!"
echo " Please install Mathematica and put its location into PATH."
exit 1
}
printf "Checking for SARAH installation ... "
printf "%s" "If[Needs[\"SARAH\`\"] === \$Failed || Not[StringQ[\$sarahDir]], Quit[1]]; Quit[0]" | ${mathematica_kernel} > /dev/null 2>&1
sarah_is_installed="$?"
if test "x${sarah_is_installed}" = "x0" ; then
printf "installed\n"
echo "Error: SARAH is already installed!"
exit 1
else
printf "not installed\n"
fi
# download SARAH
echo "Downloading ${sarah_tarball} to ${install_path} ..."
if exists_in_path "wget"; then
if test -d ${install_path} ; then
wget ${sarah_download_url} --directory-prefix=${install_path}
if test "x$?" != "x0" ; then
echo "Error: Downloading ${sarah_tarball} failed!"
echo " Please check the available SARAH versions under"
echo " ${sarah_download_area}"
exit 1
fi
else
echo "Error: download destination directory does not exist:"
echo " ${install_path}"
exit 1
fi
else
echo "Error: wget not found!"
echo " Please install wget."
exit 1
fi
# extract SARAH
echo "Extracting ${sarah_tarball} ..."
if exists_in_path "tar"; then
tar -xf ${install_path}/${sarah_tarball} --directory ${install_path}
if test "x$?" != "x0" ; then
echo "Error: extracting tarball ${install_path}/${sarah_tarball} failed!"
exit 1
fi
else
echo "Error: tar not found!"
echo " Please install tar to extract the SARAH package."
exit 1
fi
# create SARAH link
echo "Creating link ${sarah_link} -> ${install_path}/${sarah_dir} ..."
if exists_in_path "ln"; then
if test "${overwrite}" = "yes" -o \( ! -e ${sarah_link} \) ; then
rm -rf ${sarah_link}
create_symlink ${install_path}/${sarah_dir} ${sarah_link}
else
echo "Error: file ${sarah_link} already exists!"
echo " Use the --force option to overwrite it."
exit 1
fi
else
echo "Error: ln not found!"
echo " Please install ln to create a symbolic link."
exit 1
fi
# append path to SARAH link to Mathematica's init.m
echo "Appending link path ${sarah_link_for_math} to \$Path in ${mathematica_init} ..."
if [ -d "${mathematica_kernel_dir}" ] ; then
echo "AppendTo[\$Path, \"${escaped_sarah_link_for_math}\"];" >> "${mathematica_init}"
else
echo "Error: Mathematica kernel directory not found:"
echo " ${mathematica_kernel_dir}"
exit 1
fi