-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBuildLinux.sh
executable file
·148 lines (135 loc) · 2.92 KB
/
BuildLinux.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/bash
#### Import distro specific variables
source /etc/os-release
case $ID in
suse)
ID_LIKE="suse"
;;
debian)
ID_LIKE="debian"
;;
arch)
ID_LIKE="arch"
;;
rhel)
ID_LIKE="rhel"
;;
esac
#### Variables initialisations
debian_packages=("git" "build-essential" "cmake" "python" "libsdl1.2-dev" "libopenal-dev" "libopenal1" "libsdl1.2debian" "python-ply")
suse_packages=("git" "+pattern:devel_basis" "cmake" "python" "libSDL-devel" "libSDL-1_2-0" "python-ply" "openal-soft" "openal-soft-devel")
rhel_packages=("git" "gcc" "gcc-c++" "make" "cmake" "python" "python-ply" "SDL" "SDL-devel" "openal-soft-devel" "openal-soft")
arch_packages=("git" "base-devel" "cmake" "sdl" "python2" "python2-ply" "openal")
uninstalled=()
SUDO=''
try_install=0
#### Function declaration
function check_for_package {
case $ID_LIKE in
suse)
rpm -q "$@" > /dev/null 2>&1
;;
debian)
dpkg -s "$@" > /dev/null 2>&1
;;
*rhel*)
rpm -q "$@" > /dev/null 2>&1
;;
arch)
pacman -Qs "$@" > /dev/null 2>&1
;;
*)
false
;;
esac
}
function check_for_command {
hash "$1" > /dev/null 2>&1
}
function install_package {
case $ID_LIKE in
suse)
$SUDO zypper --non-interactive in "$@"
;;
debian)
$SUDO apt-get --assume-yes install "$@"
;;
*rhel*)
$SUDO yum -y install "$@"
;;
arch)
$SUDO pacman --noconfirm -S "$@"
;;
esac
}
#### Check and install needed packages
if [ $EUID -ne 0 ]; then
if ! check_for_command sudo; then
try_install=1;
else
SUDO='sudo'
fi
fi
case $ID_LIKE in
suse)
for package in ${suse_packages[@]}; do
if ! check_for_package $package; then
uninstalled+=($package)
fi
done
;;
debian)
for package in ${debian_packages[@]}; do
if ! check_for_package $package; then
uninstalled+=($package)
fi
done
;;
rhel)
for package in ${rhel_packages[@]}; do
if ! check_for_package $package; then
uninstalled+=($package)
fi
done
;;
arch)
for package in ${arch_packages[@]}; do
if ! check_for_package $package; then
uninstalled+=($package)
fi
done
;;
*)
try_install=1
esac
if [ ${#uninstalled[@]} -ne 0 ]; then
if [ $try_install -eq 0 ] ; then
read -p "Do you want this script to try installing missing packages ? [Y/n] " yn
if [[ $yn == N* ]] || [[ $yn == n* ]]; then
try_install=1
fi
fi
if [ $try_install -eq 0 ] ; then
install_package ${uninstalled[@]}
else
echo "You need to install these packages in order to continue ${uninstalled[@]}"
exit 1;
fi
fi
### Uncomment this to make it clone the repository
#if [[ $1 = --no-download ]]; then
#else
#git clone https://github.com/GP-S/HOTS.git
#cd HOTS
#fi
git submodule update --init --recursive
cd Dependencies/Polycode
./BuildLinux.sh
cd ../..
#### Build HOTS
mkdir Build
cd Build
cmake .. -DCMAKE_BUILD_TYPE=Release
make
make install
cd ..