-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·90 lines (73 loc) · 1.76 KB
/
install.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
#!/bin/bash
PREFIX=/usr/local
for k in "$@"; do
case "$k" in
--prefix=*)
PREFIX=( "${k#*=}" )
shift
;;
*)
echo Uknown options "$k"
exit -1
esac
done;
echo "Installing Alice with PREFIX=$PREFIX"
declare -a rollback
function do_cleanup ()
{
for k in "${rollback[@]}"; do
echo "$k"
eval "$k"
done
}
function uninstall_cmds ()
{
echo "PREFIX="'"'"$PREFIX"'"'
for k in "${rollback[@]}"; do
echo "$k"
done
}
trap '
if [ $? -ne 0 ]; then
echo "Installation to $PREFIX failed"
do_cleanup
fi
' 0
trap 'do_cleanup
exit 1' SIGINT SIGTERM
function transaction ()
{
echo "$1"
eval "$1"
rollback=("$2" "${rollback[@]}")
return 0
}
set -e
transaction 'mkdir -p "$PREFIX"/include/alice' \
'rmdir "$PREFIX"/include/alice && rmdir "$PREFIX"/include && rmdir "$PREFIX"'
transaction 'cp -n __targets/*.hpp "$PREFIX"/include/alice' \
'rm "$PREFIX"/include/alice/*.hpp'
transaction 'mkdir -p "$PREFIX"/lib' \
'rmdir "$PREFIX"/lib'
transaction 'cp -n __targets/libalice.a "$PREFIX/lib"'\
'rm "$PREFIX"/lib/libalice.a'
if [ "$(id -u)" == "0" ]; then
chmod -R o+r "$PREFIX"/include
chmod -R o+r "$PREFIX"/bin
chmod -R o+r "$PREFIX"/lib
chmod -R o+r "$PREFIX"/include/alice
fi
uninstall_cmds > .uninstall.sh
chmod u+x .uninstall.sh
echo "Alice has now been installed"
if ! [[ "$CPATH" == ?(*:)"$PREFIX/include"?(:*) ]];then
echo " * If you wish to use libalice, \
you may need to add $PREFIX/include to the CPATH variable."
fi
if ! [[ "$LIBRARY_PATH" == ?(*:)"$PREFIX/lib"?(:*) ]];then
echo " * If you wish to use libalice, \
you may need to add $PREFIX/lib to the LIBRARY_PATH variable."
fi
if ! [[ "$LD_LIBRARY_PATH" == ?(*:)"$PREFIX/lib"?(:*) ]];then
echo " * If you wish to use libalice you may need to add $PREFIX/lib to the LD_LIBRARY_PATH variable."
fi