-
Notifications
You must be signed in to change notification settings - Fork 12
/
setup.sh
112 lines (100 loc) · 2.75 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
#!/bin/bash
# Copyright © Huawei Technologies Co., Ltd. 2010-2019. All rights reserved.
# @rem Copyright © Huawei Technologies Co., Ltd. 2010-2019. All rights reserved.
# @rem Description: build script
set -e
SRC_PATH=$(pwd)
BUILDVERSION=$(ls "${SRC_PATH}"/open_source | grep libwd | awk '{print substr($0,7,5)}')
function Install_warpdrive()
{
local wd_src_path=$(ls /usr/local/lib | grep libwd.so.${BUILDVERSION})
local wd_rpm_path=$(ls /usr/lib64 | grep libwd.so.${BUILDVERSION})
if [ ! -n "${wd_src_path}" ] && [ ! -n "${wd_rpm_path}" ]; then
cd "${SRC_PATH}"/open_source
rm -rf warpdrive
tar -zxvf libwd-"${BUILDVERSION}".tar.gz
cd warpdrive/
sh autogen.sh
./configure
make clean && make
make install
fi
}
function Target_zlib()
{
cd "${SRC_PATH}"/open_source
rm -rf zlib-1.2.11
tar -zxvf zlib-1.2.11.tar.gz
cd "${SRC_PATH}"/open_source/zlib-1.2.11/
./configure
make
}
function Build_kaezip()
{
Install_warpdrive
Target_zlib
cd "${SRC_PATH}"
make clean && make
make install
cd -
patch -Np1 < ../../patch/kaezip_for_zlib-1.2.11.patch
./configure --prefix=/usr/local/kaezip
make
}
function Install_kaezip()
{
if [ -d "${SRC_PATH}"/open_source/zlib-1.2.11/ ]; then
cd "${SRC_PATH}"/open_source/zlib-1.2.11/
make install
fi
}
function Uninstall_kaezip()
{
local zlib_path=
if [ -d "${SRC_PATH}"/open_source/zlib-1.2.11/ ]; then
zlib_path=$(ls /usr/local/kaezip/lib | grep libz.so.1.2.11)
if [ -n "${zlib_path}" ]; then
cd "${SRC_PATH}"/open_source/zlib-1.2.11/
make uninstall && make clean
rm -rf "${SRC_PATH}"/open_source/zlib-1.2.11
fi
fi
local wd_src_path=$(ls /usr/local/lib | grep libwd.so.${BUILDVERSION})
local wd_rpm_path=$(ls /usr/lib64 | grep libwd.so.${BUILDVERSION})
if [ -n "${wd_src_path}" ] || [ -n "${wd_rpm_path}" ]; then
if [ -d "${SRC_PATH}"/open_source/warpdrive ]; then
cd "${SRC_PATH}"/open_source/warpdrive
make uninstall && make clean
rm -rf "${SRC_PATH}"/open_source/warpdrive
fi
fi
local kaezip_path=$(ls /usr/local/kaezip/lib | grep libkaezip.so.${BUILDVERSION})
if [ -n "${kaezip_path}" ]; then
if [ -d "${SRC_PATH}" ]; then
cd "${SRC_PATH}"
make uninstall && make clean
fi
fi
}
function Operate()
{
cd "${SRC_PATH}"/open_source
case "$1" in
build)
Build_kaezip
;;
install)
Build_kaezip
Install_kaezip
;;
uninstall)
Uninstall_kaezip
;;
esac
}
function main()
{
Operate "$1"
}
main "$@"
exit $?