-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·117 lines (101 loc) · 2.42 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
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
#!/bin/bash
if [[ $# -ne 0 ]] && [[ "$1" != "-u" ]] && [[ "$1" != "--uninstall" ]]; then
echo "Usage ./$(basename $0) [-u|--uninstall]"
exit 0
fi
source=$(dirname $(realpath $0))
target="$HOME/bin/tntbuild.sh"
is_uninstall=false
if [[ "$1" == "-u" ]] || [[ "$1" == "--uninstall" ]]; then
if [[ -f "$target" ]]; then
rm "$target"
else
echo "Installed file '$target' was not found: nothing to uninstall"
fi
exit 0
fi
cat > "$target" << 'EOM'
#!/bin/bash
src="TEMPLATE_SOURCE"
valid="--uninstall\n-u\n--light\n-l\n"
if [[ $# -gt 1 ]] || ! echo -e "$valid" | fgrep -x -- "$1" > /dev/null; then
echo "Usage ./$(basename $0) [-u|--uninstall|-l|--light]"
exit 0
fi
is_uninstall=false
if [[ "$1" == "-u" ]] || [[ "$1" == "--uninstall" ]]; then
is_uninstall=true
fi
is_light=false
if [[ "$1" == "-l" ]] || [[ "$1" == "--light" ]]; then
is_light=true
fi
if [[ $is_uninstall == false ]] && [[ $is_light == false ]]; then
if [ ! -f '../CMakeLists.txt' ]; then
echo 'Should be run from subfolder of tarantool!'
exit 0
fi
if ! grep -i 'project(tarantool' ../CMakeLists.txt > /dev/null; then
echo 'Should be run from subfolder of tarantool!'
exit 0
fi
fi
full_files=(
"so"
"test-run.sh"
"luatest_auto.sh"
"sorebuild.sh"
"cmake_options.txt"
"install_symlinks.sh"
"is_debug.sh"
"sub.sh"
"patch-test-run.sh"
"test-run.patch"
"luatest.patch"
"my.lua"
"test_run.lua"
"txn_proxy.lua"
"luatest.lua"
"run.lua"
"reprun.lua"
"rep.lua"
)
light_files=(
"test-run.sh"
"luatest_auto.sh"
"cmake_options.txt"
"sub.sh"
"patch-test-run.sh"
"test-run.patch"
"luatest.patch"
)
files=("${full_files[@]}")
if [[ $is_light == true ]]; then
files=("${light_files[@]}")
fi
if [[ $is_uninstall == false ]]; then
if ! [[ -d ./vshard ]]; then
mkdir vshard
fi
for f in ${files[@]}; do
ln -s -f "$src/$f"
done
if [[ $is_light == false ]]; then
echo "Also it could be a good idea to run './install_symlinks.sh'"
fi
else
for f in ${files[@]}; do
if [[ -L "./$f" ]]; then
rm "./$f"
fi
done
if [[ -f "./vshard/storage.so" ]]; then
rm "./vshard/storage.so"
fi
if [[ -d "./vshard" ]]; then
rm -d "./vshard"
fi
fi
EOM
sed -i "s+TEMPLATE_SOURCE+$source+g" "$target"
chmod 755 "$target"