50fc2130bf678d2bb3f3d4d0839b74be35c7f665
[WebKit-https.git] / Tools / wpe / install-dependencies
1 #!/bin/bash
2
3 # This script needs to be run with root rights.
4 if [ $UID -ne 0 ]; then
5     sudo $0
6     exit $?
7 fi
8
9 function printNotSupportedMessageAndExit() {
10     echo
11     echo "Currently this script only works for distributions supporting apt-get, dnf or pacman."
12     echo "Please add support for your distribution and submit the patch at https://bugs.webkit.org"
13     echo
14     exit 1
15 }
16
17 function checkInstaller {
18     # apt-get - Debian based distributions
19     apt-get --version &> /dev/null
20     if [ $? -eq 0 ]; then
21         installDependenciesWithApt
22         exit 0
23     fi
24
25     # dnf - Fedora
26     dnf --version &> /dev/null
27     if [ $? -eq 0 ]; then
28         installDependenciesWithDnf
29         exit 0
30     fi
31
32     # pacman - Arch Linux
33     # pacman --version and pacman --help both return non-0
34     pacman -Ss &> /dev/null
35     if [ $? -eq 0 ]; then
36         installDependenciesWithPacman
37         exit 0
38     fi
39
40     printNotSupportedMessageAndExit
41 }
42
43
44 # If the package $1 is available, prints it. Otherwise prints $2.
45 # Useful for handling when a package is renamed on new versions of Debian/Ubuntu.
46 function aptIfElse {
47     if apt-cache show $1 &>/dev/null; then
48         echo $1
49     else
50         echo $2
51     fi
52 }
53
54 function installDependenciesWithApt {
55     # These are dependencies necessary for building WPE+.
56     packages=" \
57         autoconf \
58         automake \
59         autopoint \
60         autotools-dev \
61         bison \
62         cmake \
63         flex \
64         g++ \
65         gawk \
66         gcc \
67         gperf \
68         intltool \
69         itstool \
70         libgnutls28-dev \
71         libicu-dev \
72         libjpeg-dev \
73         $(aptIfElse libpng-dev libpng12-dev) \
74         libsqlite3-dev \
75         libtool \
76         libwebp-dev \
77         libxml2-dev \
78         libxslt1-dev \
79         ninja-build \
80         patch \
81         pkg-config \
82         ruby \
83         zlib1g-dev"
84
85     # These are dependencies necessary for running tests.
86     packages="$packages \
87         apache2 \
88         curl \
89         gdb \
90         libapache2-mod-bw \
91         $(aptIfElse libapache2-mod-php7.0 libapache2-mod-php5) \
92         libcgi-pm-perl \
93         psmisc \
94         pulseaudio-utils \
95         python-gi \
96         python-psutil \
97         ruby \
98         ruby-highline \
99         ruby-json"
100
101     # These are dependencies necessary for building the jhbuild.
102     packages="$packages \
103         git \
104         gsettings-desktop-schemas-dev \
105         libexpat1-dev \
106         libgbm-dev \
107         libgles2-mesa-dev \
108         libluajit-5.1-dev \
109         libopus-dev \
110         liborc-0.4-dev \
111         libproxy-dev \
112         libpulse-dev \
113         libsrtp0-dev \
114         libtheora-dev \
115         libtool-bin \
116         libvorbis-dev \
117         libvpx-dev \
118         libxcb-xkb-dev \
119         luajit"
120
121     # These are dependencies necessary for using webkit-patch
122     packages="$packages \
123         git-svn \
124         subversion"
125
126     apt-get install $packages
127 }
128
129 function installDependenciesWithPacman {
130     # These are dependencies necessary for building WebKitGTK+.
131     packages=" \
132         autoconf \
133         automake \
134         bison \
135         cmake \
136         file \
137         findutils \
138         flex \
139         gawk \
140         gcc \
141         gnutls \
142         gperf \
143         grep \
144         groff \
145         gzip \
146         icu \
147         intltool \
148         itstool \
149         libjpeg-turbo \
150         libpng \
151         libtool \
152         libwebp \
153         libxml2 \
154         libxslt \
155         m4 \
156         make \
157         ninja \
158         patch \
159         pkg-config \
160         ruby
161         sed \
162         sqlite \
163         texinfo \
164         which \
165         zlib"
166
167     # These are dependencies necessary for running tests.
168     # Note: apache-mod_bw and ruby-json is available in the AUR
169     packages="$packages \
170         apache \
171         curl \
172         gdb \
173         perl-cgi \
174         php-apache \
175         psmisc \
176         pulseaudio \
177         python2 \
178         python2-gobject \
179         python2-lxml \
180         python2-psutil \
181         ruby \
182         ruby-highline"
183
184     # These are dependencies necessary for building the jhbuild.
185     packages="$packages \
186         expat \
187         git \
188         gsettings-desktop-schemas \
189         libproxy \
190         libpulse \
191         libsrtp \
192         libtheora \
193         libv4l-dev \
194         libvorbis \
195         libvpx \
196         libxcb \
197         luajit \
198         mesa \
199         mesa-libgl \
200         opus \
201         orc \
202         v4l-utils"
203
204     # These are dependencies necessary for using webkit-patch
205     packages="$packages \
206         svn"
207     pacman -S --needed $packages
208
209     echo "You will also need to follow the instructions on the Arch Wiki to make"
210     echo "'python' call python2 in the webkit folder"
211     echo "https://wiki.archlinux.org/index.php/Python#Dealing_with_version_problem_in_build_scripts"
212 }
213
214 function installDependenciesWithDnf {
215     # These are dependencies necessary for building WebKitGTK+.
216     packages=" \
217         autoconf \
218         automake \
219         bison \
220         cmake \
221         flex \
222         gcc-c++ \
223         gnutls-devel \
224         gperf \
225         intltool \
226         itstool \
227         libicu-devel \
228         libjpeg-turbo-devel \
229         libpng-devel \
230         libtool \
231         libwebp-devel \
232         libxml2-devel \
233         libxslt-devel \
234         ninja-build \
235         patch \
236         ruby
237         sqlite-devel \
238         zlib-devel"
239
240     # These are dependencies necessary for running tests.
241     packages="$packages \
242         curl \
243         gdb \
244         httpd \
245         mod_bw \
246         mod_ssl \
247         perl-CGI \
248         php \
249         psmisc \
250         pulseaudio-utils \
251         python2-psutil \
252         python-gobject-base
253         ruby \
254         rubygem-highline \
255         rubygem-json"
256
257     # These are dependencies necessary for building the jhbuild.
258     packages="$packages \
259         expat-devel \
260         git \
261         gsettings-desktop-schemas-devel \
262         libproxy-devel \
263         libsrtp-devel \
264         libtheora-devel \
265         libv4l-devel \
266         libvorbis-devel \
267         libvpx-devel \
268         libxcb-devel \
269         luajit \
270         luajit-devel \
271         mesa-libgbm-devel \
272         mesa-libGLES-devel \
273         opus-devel \
274         orc-devel \
275         pulseaudio-libs-devel"
276
277     # These are dependencies necessary for using webkit-patch
278     packages="$packages
279         git-svn \
280         subversion"
281
282     dnf install $packages
283 }
284
285 checkInstaller