[WPE] Add an install-dependencies script
[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         libopus-dev \
109         liborc-0.4-dev \
110         libproxy-dev \
111         libpulse-dev \
112         libsrtp0-dev \
113         libtheora-dev \
114         libtool-bin \
115         libvorbis-dev \
116         libvpx-dev \
117         libxcb-xkb-dev"
118
119     # These are dependencies necessary for using webkit-patch
120     packages="$packages \
121         git-svn \
122         subversion"
123
124     apt-get install $packages
125 }
126
127 function installDependenciesWithPacman {
128     # These are dependencies necessary for building WebKitGTK+.
129     packages=" \
130         autoconf \
131         automake \
132         bison \
133         cmake \
134         file \
135         findutils \
136         flex \
137         gawk \
138         gcc \
139         gnutls \
140         gperf \
141         grep \
142         groff \
143         gzip \
144         icu \
145         intltool \
146         itstool \
147         libjpeg-turbo \
148         libpng \
149         libtool \
150         libwebp \
151         libxml2 \
152         libxslt \
153         m4 \
154         make \
155         ninja \
156         patch \
157         pkg-config \
158         ruby
159         sed \
160         sqlite \
161         texinfo \
162         which \
163         zlib"
164
165     # These are dependencies necessary for running tests.
166     # Note: apache-mod_bw and ruby-json is available in the AUR
167     packages="$packages \
168         apache \
169         curl \
170         gdb \
171         perl-cgi \
172         php-apache \
173         psmisc \
174         pulseaudio \
175         python2 \
176         python2-gobject \
177         python2-lxml \
178         python2-psutil \
179         ruby \
180         ruby-highline"
181
182     # These are dependencies necessary for building the jhbuild.
183     packages="$packages \
184         expat \
185         git \
186         gsettings-desktop-schemas \
187         libproxy \
188         libpulse \
189         libsrtp \
190         libtheora \
191         libv4l-dev \
192         libvorbis \
193         libvpx \
194         libxcb \
195         mesa \
196         mesa-libgl \
197         opus \
198         orc \
199         v4l-utils"
200
201     # These are dependencies necessary for using webkit-patch
202     packages="$packages \
203         svn"
204     pacman -S --needed $packages
205
206     echo "You will also need to follow the instructions on the Arch Wiki to make"
207     echo "'python' call python2 in the webkit folder"
208     echo "https://wiki.archlinux.org/index.php/Python#Dealing_with_version_problem_in_build_scripts"
209 }
210
211 function installDependenciesWithDnf {
212     # These are dependencies necessary for building WebKitGTK+.
213     packages=" \
214         autoconf \
215         automake \
216         bison \
217         cmake \
218         flex \
219         gcc-c++ \
220         gnutls-devel \
221         gperf \
222         intltool \
223         itstool \
224         libicu-devel \
225         libjpeg-turbo-devel \
226         libpng-devel \
227         libtool \
228         libwebp-devel \
229         libxml2-devel \
230         libxslt-devel \
231         ninja-build \
232         patch \
233         ruby
234         sqlite-devel \
235         zlib-devel"
236
237     # These are dependencies necessary for running tests.
238     packages="$packages \
239         curl \
240         gdb \
241         httpd \
242         mod_bw \
243         mod_ssl \
244         perl-CGI \
245         php \
246         psmisc \
247         pulseaudio-utils \
248         python2-psutil \
249         python-gobject-base
250         ruby \
251         rubygem-highline \
252         rubygem-json"
253
254     # These are dependencies necessary for building the jhbuild.
255     packages="$packages \
256         expat-devel \
257         git \
258         gsettings-desktop-schemas-devel \
259         libproxy-devel \
260         libsrtp-devel \
261         libtheora-devel \
262         libv4l-devel \
263         libvorbis-devel \
264         libvpx-devel \
265         libxcb-devel \
266         mesa-libgbm-devel \
267         mesa-libGLES-devel \
268         opus-devel \
269         orc-devel \
270         pulseaudio-libs-devel"
271
272     # These are dependencies necessary for using webkit-patch
273     packages="$packages
274         git-svn \
275         subversion"
276
277     dnf install $packages
278 }
279
280 checkInstaller