4646db9e6c48f586f6644801a8bb0a5d02770f0f
[WebKit-https.git] / Tools / wpe / install-dependencies
1 #!/usr/bin/env 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         cmake \
62         g++ \
63         gawk \
64         gcc \
65         gperf \
66         gtk-doc-tools \
67         intltool \
68         itstool \
69         libasound2-dev \
70         libevent-dev \
71         libgbm-dev \
72         libgnutls28-dev \
73         libgstreamer1.0-dev \
74         libgstreamer-plugins-bad1.0-dev \
75         libgstreamer-plugins-base1.0-dev \
76         libicu-dev \
77         libjpeg-dev \
78         libfile-copy-recursive-perl \
79         $(aptIfElse libpng-dev libpng12-dev) \
80         libsqlite3-dev \
81         libtasn1-6-dev \
82         libtool \
83         libwebp-dev \
84         libxml2-dev \
85         libxslt1-dev \
86         ninja-build \
87         patch \
88         pkg-config \
89         ruby \
90         zlib1g-dev"
91
92     # These are dependencies necessary for running tests.
93     packages="$packages \
94         apache2 \
95         curl \
96         gdb \
97         libapache2-mod-bw \
98         libapache2-mod-php \
99         php-json \
100         libcgi-pm-perl \
101         psmisc \
102         pulseaudio-utils \
103         python-gi \
104         python-psutil \
105         ruby \
106         ruby-highline \
107         ruby-json"
108
109     # These are dependencies necessary for building the jhbuild.
110     packages="$packages \
111         git \
112         gsettings-desktop-schemas-dev \
113         libegl1-mesa-dev \
114         libexpat1-dev \
115         libgles2-mesa-dev \
116         libluajit-5.1-dev \
117         libmount-dev \
118         libopus-dev \
119         liborc-0.4-dev \
120         libproxy-dev \
121         libpsl-dev \
122         libpulse-dev \
123         libsrtp0-dev \
124         libtheora-dev \
125         libtool-bin \
126         libvorbis-dev \
127         libvpx-dev \
128         libxcb-xkb-dev \
129         libxkbcommon-dev \
130         libxml-libxml-perl \
131         libxrandr-dev \
132         libwayland-dev \
133         luajit \
134         python3-setuptools \
135         yasm"
136
137     # These are dependencies necessary for using webkit-patch
138     packages="$packages \
139         git-svn \
140         subversion"
141
142     apt-get install $packages
143 }
144
145 function installDependenciesWithPacman {
146     # These are dependencies necessary for building WPE.
147     packages=" \
148         alsa-lib \
149         autoconf \
150         automake \
151         cmake \
152         file \
153         findutils \
154         gawk \
155         gcc \
156         gnutls \
157         gperf \
158         gtk-doc \
159         grep \
160         groff \
161         gstreamer \
162         gst-plugins-bad \
163         gst-plugins-base-libs \
164         gzip \
165         icu \
166         intltool \
167         itstool \
168         libevent \
169         libjpeg-turbo \
170         libpng \
171         libtasn1 \
172         libtool \
173         libwebp \
174         libxml2 \
175         libxslt \
176         m4 \
177         make \
178         ninja \
179         patch \
180         perl-file-copy-recursive \
181         pkg-config \
182         ruby
183         sed \
184         sqlite \
185         texinfo \
186         which \
187         zlib"
188
189     # These are dependencies necessary for running tests.
190     # Note: apache-mod_bw and ruby-json is available in the AUR
191     packages="$packages \
192         apache \
193         curl \
194         gdb \
195         perl-cgi \
196         php-apache \
197         psmisc \
198         pulseaudio \
199         python2 \
200         python2-gobject \
201         python2-lxml \
202         python2-psutil \
203         ruby \
204         ruby-highline"
205
206     # These are dependencies necessary for building the jhbuild.
207     packages="$packages \
208         expat \
209         git \
210         gsettings-desktop-schemas \
211         libproxy \
212         libpsl \
213         libpulse \
214         libsrtp \
215         libtheora \
216         libv4l-dev \
217         libvorbis \
218         libvpx \
219         libxcb \
220         libxkbcommon \
221         luajit \
222         mesa \
223         mesa-libgl \
224         opus \
225         orc \
226         perl-xml-libxml \
227         python3-setuptools \
228         util-linux \
229         v4l-utils \
230         xorg-xrandr \
231         wayland \
232         yasm"
233
234     # These are dependencies necessary for using webkit-patch
235     packages="$packages \
236         svn"
237     pacman -S --needed $packages
238
239     echo "You will also need to follow the instructions on the Arch Wiki to make"
240     echo "'python' call python2 in the webkit folder"
241     echo "https://wiki.archlinux.org/index.php/Python#Dealing_with_version_problem_in_build_scripts"
242 }
243
244 function installDependenciesWithDnf {
245     # These are dependencies necessary for building WebKitWPE.
246     packages=" \
247         autoconf \
248         automake \
249         alsa-lib-devel \
250         cmake \
251         gcc-c++ \
252         gnutls-devel \
253         gperf \
254         gstreamer1-devel \
255         gstreamer1-plugins-bad-free-devel \
256         gstreamer1-plugins-base-devel \
257         gtk-doc \
258         intltool \
259         itstool \
260         libevent-devel \
261         libicu-devel \
262         libjpeg-turbo-devel \
263         libpng-devel \
264         libtasn1-devel \
265         libtool \
266         libwebp-devel \
267         libxml2-devel \
268         libxslt-devel \
269         ninja-build \
270         patch \
271         perl-File-Copy-Recursive \
272         perl-JSON-PP \
273         perl-Time-HiRes \
274         perl-version \
275         ruby \
276         sqlite-devel \
277         zlib-devel"
278
279     # These are dependencies necessary for running tests.
280     packages="$packages \
281         curl \
282         gdb \
283         httpd \
284         mod_bw \
285         mod_ssl \
286         perl-CGI \
287         php \
288         php-json \
289         psmisc \
290         pulseaudio-utils \
291         python2-psutil \
292         python-gobject-base \
293         ruby \
294         rubygem-highline \
295         rubygem-json"
296
297     # These are dependencies necessary for building the jhbuild.
298     packages="$packages \
299         expat-devel \
300         git \
301         gsettings-desktop-schemas-devel \
302         libmount-devel \
303         libproxy-devel \
304         libpsl-devel \
305         libsrtp-devel \
306         libtheora-devel \
307         libv4l-devel \
308         libvorbis-devel \
309         libvpx-devel \
310         libxcb-devel \
311         libxkbcommon-devel \
312         libXrandr-devel \
313         luajit \
314         luajit-devel \
315         mesa-libGLES-devel \
316         mesa-libEGL-devel \
317         opus-devel \
318         orc-devel \
319         perl-XML-LibXML \
320         pulseaudio-libs-devel \
321         python3-setuptools \
322         wayland-devel \
323         yasm"
324
325     # These are dependencies necessary for using webkit-patch
326     packages="$packages
327         git-svn \
328         subversion"
329
330     dnf install $packages
331 }
332
333 checkInstaller