-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbldBench.sh
executable file
·131 lines (117 loc) · 4.53 KB
/
bldBench.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#! /bin/bash
ARCH=$( uname )
if [ "$ARCH" != "Linux" ]; then
printf "\\n\\tAuction currently support Amazon, Centos, Fedora, Mint & Ubuntu Linux only.\\n"
printf "\\tPlease install on the latest version of one of these Linux distributions.\\n"
printf "\\thttps://aws.amazon.com/amazon-linux-ami/\\n"
printf "\\thttps://www.centos.org/\\n"
printf "\\thttps://start.fedoraproject.org/\\n"
printf "\\thttps://linuxmint.com/\\n"
printf "\\thttps://www.ubuntu.com/\\n"
printf "\\tExiting now.\\n"
exit 1
fi
DISK_MIN="5"
OS_VER=$( grep VERSION_ID /etc/os-release | cut -d'=' -f2 | sed 's/[^0-9\.]//gI' )
OS_MAJ=$(echo "${OS_VER}" | cut -d'.' -f1)
OS_MIN=$(echo "${OS_VER}" | cut -d'.' -f2)
MEM_MEG=$( free -m | sed -n 2p | tr -s ' ' | cut -d\ -f2 || cut -d' ' -f2 )
CPU_SPEED=$( lscpu | grep -m1 "MHz" | tr -s ' ' | cut -d\ -f3 || cut -d' ' -f3 | cut -d'.' -f1 )
CPU_CORE=$( lscpu -pCPU | grep -v "#" | wc -l )
MEM_GIG=$(( ((MEM_MEG / 1000) / 2) ))
JOBS=$(( MEM_GIG > CPU_CORE ? CPU_CORE : MEM_GIG ))
DISK_INSTALL=$(df -h . | tail -1 | tr -s ' ' | cut -d\ -f1 || cut -d' ' -f1)
DISK_TOTAL_KB=$(df . | tail -1 | awk '{print $2}')
DISK_AVAIL_KB=$(df . | tail -1 | awk '{print $4}')
DISK_TOTAL=$(( DISK_TOTAL_KB / 1048576 ))
DISK_AVAIL=$(( DISK_AVAIL_KB / 1048576 ))
printf "\\n\\tOS name: %s\\n" "${OS_NAME}"
printf "\\tOS Version: %s\\n" "${OS_VER}"
printf "\\tCPU speed: %sMhz\\n" "${CPU_SPEED}"
printf "\\tCPU cores: %s\\n" "${CPU_CORE}"
printf "\\tPhysical Memory: %s Mgb\\n" "${MEM_MEG}"
printf "\\tDisk install: %s\\n" "${DISK_INSTALL}"
printf "\\tDisk space total: %sG\\n" "${DISK_TOTAL%.*}"
printf "\\tDisk space available: %sG\\n" "${DISK_AVAIL%.*}"
if [ "${MEM_MEG}" -lt 1900 ]; then
printf "\\tYour system must have 2 or more Gigabytes of physical memory installed.\\n"
printf "\\tExiting now.\\n"
exit 1
fi
case "${OS_NAME}" in
"Linux Mint")
if [ "${OS_MAJ}" -lt 18 ]; then
printf "\\tYou must be running Linux Mint 18.x or higher to install Auction.\\n"
printf "\\tExiting now.\\n"
exit 1
fi
;;
"Ubuntu")
if [ "${OS_MAJ}" -lt 16 ]; then
printf "\\tYou must be running Ubuntu 16.04.x or higher to install Auction.\\n"
printf "\\tExiting now.\\n"
exit 1
fi
;;
"Debian")
if [ $OS_MAJ -lt 10 ]; then
printf "\tYou must be running Debian 10 to install Auction, and resolve missing dependencies from unstable (sid).\n"
printf "\tExiting now.\n"
exit 1
fi
;;
esac
if [ "${DISK_AVAIL%.*}" -lt "${DISK_MIN}" ]; then
printf "\\tYou must have at least %sGB of available storage to install Auction.\\n" "${DISK_MIN}"
printf "\\tExiting now.\\n"
exit 1
fi
DEP_ARRAY=(g++ cmake make automake libssl-dev build-essential googletest \
autoconf libtool doxygen libgoogle-perftools-dev libboost-dev)
COUNT=1
DISPLAY=""
DEP=""
printf "\\n\\tChecking for installed dependencies.\\n\\n"
for (( i=0; i<${#DEP_ARRAY[@]}; i++ ));
do
pkg=$( dpkg -s "${DEP_ARRAY[$i]}" 2>/dev/null | grep Status | tr -s ' ' | cut -d\ -f4 )
if [ -z "$pkg" ]; then
DEP=$DEP" ${DEP_ARRAY[$i]} "
DISPLAY="${DISPLAY}${COUNT}. ${DEP_ARRAY[$i]}\\n\\t"
printf "\\tPackage %s ${bldred} NOT ${txtrst} found.\\n" "${DEP_ARRAY[$i]}"
(( COUNT++ ))
else
printf "\\tPackage %s found.\\n" "${DEP_ARRAY[$i]}"
continue
fi
done
if [ "${COUNT}" -gt 1 ]; then
printf "\\n\\tThe following dependencies are required to install Auction.\\n"
printf "\\n\\t${DISPLAY}\\n\\n"
printf "\\tNeed to install these packages\\n"
printf "\\n\\n\\tInstalling dependencies\\n\\n"
sudo apt-get update
if ! sudo apt-get -y install ${DEP}
then
printf "\\n\\tDPKG dependency failed.\\n"
printf "\\n\\tExiting now.\\n"
exit 1
else
printf "\\n\\tDPKG dependencies installed successfully.\\n"
fi
else
printf "\\n\\tNo required dpkg dependencies to install.\\n"
fi
if [ ! -f /usr/local/lib/pkgconfig/benchmark.pc ]; then
# to be install google benchmark
git clone https://github.com/google/benchmark.git
git clone https://github.com/google/googletest.git benchmark/googletest
[ -d benchmark/build.test ] || mkdir benchmark/build.test
(cd benchmark/build.test; \
cmake ../googletest -DCMAKE_BUILD_TYPE=Release; \
make -j"$JOBS"; sudo make install)
[ -d benchmark/build ] || mkdir benchmark/build
(cd benchmark/build; \
cmake .. -DCMAKE_BUILD_TYPE=Release -DBENCHMARK_ENABLE_TESTING=OFF; \
make -j"$JOBS"; sudo make install)
fi