forked from chromium/dom-distiller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-build-deps.sh
executable file
·88 lines (75 loc) · 2.58 KB
/
install-build-deps.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
#!/bin/bash
# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Installs required build dependencies (to buildtools/ and the local system).
# If Chrome is older than CHROME_MIN_VERSION, force update.
[ -z "$CHROME_MIN_VERSION" ] && CHROME_MIN_VERSION=49
(
set -e
if [ "$(id -u)" != "0" ]; then
echo "Please run this as root."
exit 1
fi
apt-get update
apt-get install -y \
ant \
openjdk-8-jdk \
protobuf-compiler \
python \
python-setuptools \
python-protobuf \
unzip \
wget \
xdotool \
xvfb
# Specify JDK version in case there are other versions installed.
update-alternatives --set java $(sudo update-alternatives --list java | grep java-8)
if ! command -v google-chrome >/dev/null 2>&1; then
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
apt-get update
apt-get install google-chrome-stable
fi
# Update chrome if it is too old, and keep the default channel.
CHROME_VERSION=$(google-chrome --version | tr " " "\n" | awk '/[0-9.]/{print ($1+0)}')
if (( $CHROME_VERSION < $CHROME_MIN_VERSION )); then
echo "Current Chrome version is $CHROME_VERSION. Updating to latest."
case "$(google-chrome --version)" in
*dev*)
apt-get install google-chrome-unstable
;;
*beta*)
apt-get install google-chrome-beta
;;
*)
apt-get install google-chrome-stable
;;
esac
fi
user=$SUDO_USER
bit=$(getconf LONG_BIT)
domdistiller=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
pkg=selenium-3.141.0
tar=${pkg}.tar.gz
zip=chromedriver_linux${bit}.zip
tmp=/tmp/domdistiller-$$
tools=$domdistiller/buildtools
set -e
mkdir $tmp
cd $tmp
# The version scheme changed after 2.46. See http://chromedriver.chromium.org/downloads/version-selection
CHROME_VERSION=$(google-chrome --version | tr " " "\n" | awk '/[0-9.]/{print ($1+0)}')
VERSION=$(wget -q --output-document - https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION} | cat)
[ -z "${VERSION}" ] && VERSION=2.24
wget https://chromedriver.storage.googleapis.com/${VERSION}/$zip
chmod a+r $zip
sudo -u $user mkdir -p $tools
sudo -u $user unzip -o -d $tools $zip
chmod u+x $tools/chromedriver
wget https://pypi.python.org/packages/source/s/selenium/$tar
tar -xf $tar
cd $pkg
python setup.py install
rm -rf $tmp
)