6fd566f0dcf3c5142f690fe2b393a6e03e79e3a3
[WebKit.git] / Tools / gtk / install-dependencies
1 #!/usr/bin/env bash
2
3 # On Linux systems, this script needs to be run with root rights.
4 if [ `uname` != "Darwin" ] && [ $UID -ne 0 ]; then
5     sudo $0
6     exit 0
7 fi
8
9 function printNotSupportedMessageAndExit() {
10     echo
11     echo "Currently this script only works for distributions supporting apt-get and yum."
12     echo "Please add support for your distribution: http://webkit.org/b/110693"
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     if [ `uname` = "Darwin" ]; then
41        installDependenciesWithBrew
42        exit 0
43     fi
44
45     printNotSupportedMessageAndExit
46 }
47
48 function installDependenciesWithBrew {
49     brew &> /dev/null
50     if [ $? -gt 1 ]; then
51         echo "Please install HomeBrew. Instructions on http://brew.sh"
52         exit 1
53     fi
54
55     brew install autoconf \
56          automake \
57          cmake \
58          enchant \
59          gettext \
60          gobject-introspection \
61          intltool \
62          itstool \
63          libcroco \
64          libgcrypt \
65          libgpg-error \
66          libtasn1 \
67          libtiff \
68          libtool \
69          ninja \
70          pango \
71          pkg-config \
72          sqlite \
73          webp \
74          xz
75 }
76
77 # If the package $1 is available, prints it. Otherwise prints $2.
78 # Useful for handling when a package is renamed on new versions of Debian/Ubuntu.
79 function aptIfElse {
80     if apt-cache show $1 &>/dev/null; then
81         echo $1
82     else
83         echo $2
84     fi
85 }
86
87 function installDependenciesWithApt {
88     # These are dependencies necessary for building WebKitGTK.
89     packages=" \
90         autoconf \
91         automake \
92         autopoint \
93         autotools-dev \
94         bubblewrap \
95         cmake \
96         gawk \
97         geoclue-2.0 \
98         gnome-common \
99         gperf \
100         gtk-doc-tools \
101         intltool \
102         itstool \
103         libasound2-dev \
104         libatk1.0-dev \
105         libedit-dev \
106         libenchant-dev \
107         libevent-dev \
108         libfaad-dev \
109         libffi-dev \
110         libfile-copy-recursive-perl \
111         $(aptIfElse libgcrypt20-dev libgcrypt11-dev) \
112         libgirepository1.0-dev \
113         libgl1-mesa-dev \
114         libgl1-mesa-glx \
115         libgtk-3-dev \
116         libgstreamer1.0-dev \
117         libgstreamer-plugins-bad1.0-dev \
118         libgstreamer-plugins-base1.0-dev \
119         libgudev-1.0-dev \
120         libhyphen-dev \
121         libjpeg-dev \
122         libmount-dev \
123         libmpg123-dev \
124         libnotify-dev \
125         libopenjp2-7-dev \
126         libopus-dev \
127         libpango1.0-dev \
128         $(aptIfElse libpng-dev libpng12-dev) \
129         libpulse-dev \
130         librsvg2-dev \
131         libseccomp-dev \
132         libsecret-1-dev \
133         libsoup2.4-dev \
134         libsqlite3-dev \
135         libsrtp2-dev \
136         libtasn1-6-dev \
137         libtheora-dev \
138         libtool \
139         libvorbis-dev \
140         libvpx-dev \
141         libupower-glib-dev \
142         libwebp-dev \
143         libwoff-dev \
144         libxcomposite-dev \
145         libxt-dev \
146         libxtst-dev \
147         libxslt1-dev \
148         libwayland-dev \
149         ninja-build \
150         patch \
151         ruby \
152         xfonts-utils"
153
154     # These are dependencies necessary for running tests.
155     packages="$packages \
156         apache2 \
157         curl \
158         cups-daemon \
159         dbus-x11 \
160         gdb \
161         fonts-liberation \
162         hunspell \
163         hunspell-en-us \
164         hunspell-en-gb \
165         libapache2-mod-bw \
166         libapache2-mod-php \
167         php-json \
168         libcgi-pm-perl \
169         libgpg-error-dev \
170         psmisc \
171         pulseaudio-utils \
172         python-gi \
173         python-psutil \
174         python-yaml \
175         ruby \
176         ruby-json \
177         ruby-highline \
178         weston \
179         xvfb"
180
181     # These are dependencies necessary for building the jhbuild.
182     packages="$packages \
183         bison \
184         flex \
185         git \
186         gobject-introspection \
187         gsettings-desktop-schemas-dev \
188         icon-naming-utils \
189         libcroco3-dev \
190         libcups2-dev \
191         libdrm-dev \
192         libegl1-mesa-dev \
193         libepoxy-dev \
194         libevdev-dev \
195         libexpat1-dev \
196         libfdk-aac-dev \
197         libgbm-dev \
198         libgles2-mesa-dev \
199         libgnutls28-dev \
200         libgpg-error-dev \
201         libjson-glib-dev \
202         libinput-dev \
203         libmtdev-dev \
204         liborc-0.4-dev \
205         libp11-kit-dev \
206         libpciaccess-dev \
207         libproxy-dev \
208         libpsl-dev \
209         libssl-dev \
210         libtiff5-dev \
211         libunistring-dev \
212         libv4l-dev \
213         libxcb-composite0-dev \
214         libxcb-xfixes0-dev \
215         libxfont-dev \
216         libxfont2 \
217         libxkbfile-dev \
218         libxkbcommon-x11-dev \
219         libtool-bin \
220         libudev-dev \
221         libxml-libxml-perl \
222         python-dev \
223         python3-setuptools \
224         ragel \
225         uuid-dev \
226         x11proto-bigreqs-dev \
227         x11proto-composite-dev \
228         x11proto-gl-dev \
229         x11proto-input-dev \
230         x11proto-randr-dev \
231         x11proto-resource-dev \
232         x11proto-scrnsaver-dev \
233         x11proto-video-dev \
234         x11proto-xcmisc-dev \
235         x11proto-xf86dri-dev \
236         xfonts-utils \
237         xtrans-dev \
238         xutils-dev \
239         yasm"
240
241     # These are dependencies necessary for using webkit-patch
242     packages="$packages \
243         git-svn \
244         subversion"
245
246     apt-get install $packages
247 }
248
249 function installDependenciesWithPacman {
250     # These are dependencies necessary for building WebKitGTK.
251     packages=" \
252         alsa-lib \
253         autoconf \
254         automake \
255         bubblewrap \
256         cmake \
257         libedit \
258         libffi \
259         file \
260         findutils \
261         gawk \
262         gcc \
263         gettext \
264         gnome-common \
265         gperf \
266         grep \
267         groff \
268         gstreamer \
269         gst-plugins-bad \
270         gst-plugins-base-libs \
271         gzip \
272         hyphen \
273         libevent \
274         libtool \
275         m4 \
276         make \
277         patch \
278         pkg-config \
279         sed \
280         texinfo \
281         util-linux \
282         which \
283         gtk-doc \
284         intltool \
285         itstool \
286         atk \
287         enchant \
288         faad2 \
289         geoclue2 \
290         gobject-introspection \
291         mesa \
292         mesa-libgl \
293         gtk3 \
294         libsystemd \
295         libjpeg-turbo \
296         mpg123 \
297         openjpeg2 \
298         opus \
299         pango \
300         perl-file-copy-recursive \
301         libgcrypt \
302         libnotify \
303         libpng \
304         libpulse \
305         librsvg \
306         libseccomp \
307         libsecret \
308         libsoup \
309         libsrtp \
310         sqlite \
311         libtasn1 \
312         libtheora \
313         libtool \
314         libvorbis \
315         libvpx \
316         libwebp \
317         libxcomposite \
318         libxt \
319         libxslt \
320         libxtst \
321         upower \
322         ninja \
323         ruby \
324         util-linux \
325         xorg-font-utils \
326         wayland \
327         woff2"
328
329     # These are dependencies necessary for running tests.
330     # Note: apache-mod_bw, ruby-json, and ruby-highline are available in the AUR
331     packages="$packages \
332         apache \
333         curl \
334         cups \
335         gdb \
336         hunspell \
337         hunspell-en \
338         hunspell-en_GB \
339         php-apache \
340         libgpg-error \
341         psmisc \
342         pulseaudio \
343         python-gobject \
344         python2-psutil \
345         python2-yaml \
346         ruby \
347         ttf-liberation \
348         weston \
349         xorg-server-xvfb"
350
351     # These are dependencies necessary for building the jhbuild.
352     # Note: Could not find libegl-mesa
353     packages="$packages \
354         bison \
355         expat \
356         flex \
357         git \
358         gnutls \
359         gobject-introspection \
360         gsettings-desktop-schemas \
361         icon-naming-utils \
362         libcroco \
363         libcups \
364         libdrm \
365         libepoxy \
366         libevdev \
367         libfdk-aac \
368         libgpg-error \
369         libinput \
370         p11-kit \
371         libpciaccess \
372         libproxy \
373         libpsl \
374         libtiff \
375         libunistring-dev \
376         libxfixes \
377         libxfont2 \
378         libxcb \
379         libxkbfile \
380         libxkbcommon-x11 \
381         mtdev \
382         orc \
383         perl-xml-libxml\
384         python2 \
385         python2-lxml \
386         python-setuptools \
387         ragel \
388         bigreqsproto \
389         compositeproto \
390         glproto \
391         inputproto \
392         randrproto \
393         resourceproto \
394         scrnsaverproto \
395         videoproto \
396         xcmiscproto \
397         xf86driproto \
398         xorg-font-utils \
399         xorg-util-macros \
400         xtrans \
401         yasm"
402
403     # These are dependencies necessary for using webkit-patch
404     packages="$packages \
405         svn"
406     pacman -S --needed $packages
407
408         cat <<-EOF
409
410 The following packages are available from AUR, and needed for running tests:
411
412     apache-mod_bw ruby-json ruby-highline
413
414 Instructions on how to use the AUR can be found on the Arch Wiki:
415
416     https://wiki.archlinux.org/index.php/Arch_User_Repository
417
418 You will also need to follow the instructions on the wiki to make 'python'
419 call python2 in the WebKit folder:
420
421     https://wiki.archlinux.org/index.php/Python#Dealing_with_version_problem_in_build_scripts
422
423 Alternatively, you may use a Python 2.x virtualenv while hacking on WebKitGTK:
424
425     https://wiki.archlinux.org/index.php/Python/Virtual_environment
426
427 EOF
428 }
429
430 function installDependenciesWithDnf {
431     # These are dependencies necessary for building WebKitGTK.
432     packages=" \
433         atk-devel \
434         alsa-lib-devel \
435         autoconf \
436         automake \
437         bubblewrap \
438         cairo-devel \
439         cmake \
440         enchant-devel \
441         gcc-c++ \
442         geoclue2-devel \
443         gettext-devel \
444         gobject-introspection-devel \
445         gperf \
446         gstreamer1-devel \
447         gstreamer1-plugins-bad-free-devel \
448         gstreamer1-plugins-base-devel \
449         gtk-doc \
450         gtk3-devel \
451         hyphen-devel \
452         intltool \
453         json-glib-devel \
454         libXt-devel \
455         libXtst-devel \
456         libxslt-devel \
457         libedit-devel \
458         libevent-devel \
459         libffi-devel \
460         libgcrypt-devel \
461         libgudev1-devel \
462         libjpeg-turbo-devel \
463         libmount-devel \
464         libnotify-devel \
465         libpng-devel \
466         libseccomp-devel \
467         libsecret-devel \
468         libsoup-devel \
469         libsrtp-devel \
470         libtasn1-devel \
471         libtheora-devel \
472         libv4l-devel \
473         libvorbis-devel \
474         libvpx-devel \
475         libwebp-devel \
476         libwayland-client-devel \
477         libwayland-server-devel \
478         mesa-libGL-devel \
479         ninja-build \
480         openjpeg2-devel \
481         openssl-devel \
482         opus-devel \
483         patch \
484         pcre-devel \
485         perl-File-Copy-Recursive \
486         perl-JSON-PP \
487         perl-Switch \
488         perl-Time-HiRes \
489         perl-version \
490         pulseaudio-libs-devel \
491         python-devel \
492         redhat-rpm-config \
493         ruby \
494         sqlite-devel \
495         upower-devel \
496         woff2-devel"
497
498     # These are dependencies necessary for running tests.
499     packages="$packages \
500         curl \
501         cups \
502         dbus-x11 \
503         gdb \
504         hunspell-en \
505         hunspell-en-GB \
506         httpd \
507         liberation-fonts \
508         libgpg-error-devel \
509         mod_bw \
510         mod_ssl \
511         perl-CGI \
512         php \
513         php-json \
514         psmisc \
515         pulseaudio-utils \
516         pygobject3-base \
517         python2-psutil \
518         python2-yaml \
519         ruby \
520         rubygem-json \
521         rubygem-highline \
522         weston-devel \
523         xorg-x11-server-Xvfb"
524
525     # These are dependencies necessary for building the jhbuild.
526     packages="$packages \
527         bison \
528         cups-devel \
529         docbook-utils \
530         expat-devel \
531         fdk-aac-devel \
532         flex \
533         git \
534         gnutls-devel \
535         gobject-introspection \
536         gsettings-desktop-schemas-devel \
537         icon-naming-utils \
538         itstool \
539         libXfont2-devel \
540         libcroco-devel \
541         libdrm-devel \
542         libepoxy-devel \
543         libevdev-devel
544         libgpg-error-devel \
545         libinput-devel \
546         libp11-devel \
547         libpciaccess-devel \
548         libproxy-devel \
549         libpsl-devel \
550         libtiff-devel \
551         libunistring-devel \
552         libuuid-devel \
553         libxcb-devel \
554         libxkbfile-devel \
555         libxkbcommon-x11-devel \
556         mesa-libEGL-devel \
557         mtdev-devel \
558         orc-devel \
559         perl-XML-LibXML \
560         python3-setuptools \
561         ragel \
562         systemd-devel \
563         xorg-x11-font-utils \
564         xorg-x11-proto-devel \
565         xorg-x11-util-macros \
566         xorg-x11-xtrans-devel \
567         yasm"
568
569     # These are dependencies necessary for using webkit-patch
570     packages="$packages
571         git-svn \
572         subversion"
573
574     dnf install $packages
575 }
576
577 checkInstaller
578