|
2 | 2 | # Copyright 2013 The Flutter Authors. All rights reserved. |
3 | 3 | # Use of this source code is governed by a BSD-style license that can be |
4 | 4 | # found in the LICENSE file. |
| 5 | + |
| 6 | +# This script may be run as: |
| 7 | +# $ CHROME_DOWNLOAD_DIR=./whatever script/install_chromium.sh |
5 | 8 | set -e |
6 | 9 | set -x |
7 | 10 |
|
8 | | -readonly TARGET_DIR=$1 |
| 11 | +# The target directory where chromium is going to be downloaded |
| 12 | +: "${CHROME_DOWNLOAD_DIR:=/tmp/chromium}" # Default value for the CHROME_DOWNLOAD_DIR env. |
9 | 13 |
|
10 | 14 | # The build of Chromium used to test web functionality. |
11 | 15 | # |
12 | 16 | # Chromium builds can be located here: https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Linux_x64/ |
13 | 17 | # |
14 | | -# Check: https://github.com/flutter/engine/blob/main/lib/web_ui/dev/browser_lock.yaml |
15 | | -readonly CHROMIUM_BUILD=929514 |
| 18 | +# Check: https://github.com/flutter/engine/blob/master/lib/web_ui/dev/browser_lock.yaml |
| 19 | +: "${CHROMIUM_BUILD:=950363}" # Default value for the CHROMIUM_BUILD env. |
| 20 | + |
| 21 | +# Convenience defaults for CHROME_EXECUTABLE and CHROMEDRIVER_EXECUTABLE. These |
| 22 | +# two values should be set in the environment from CI, so this script can validate |
| 23 | +# that it has completed downloading chrome and driver successfully (and the expected |
| 24 | +# files are executable) |
| 25 | +: "${CHROME_EXECUTABLE:=$CHROME_DOWNLOAD_DIR/chrome-linux/chrome}" |
| 26 | +: "${CHROMEDRIVER_EXECUTABLE:=$CHROME_DOWNLOAD_DIR/chromedriver/chromedriver}" |
16 | 27 |
|
17 | 28 | # The correct ChromeDriver is distributed alongside the chromium build above, as |
18 | 29 | # `chromedriver_linux64.zip`, so no need to hardcode any extra info about it. |
19 | 30 | readonly DOWNLOAD_ROOT="https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F${CHROMIUM_BUILD}%2F" |
20 | 31 |
|
21 | 32 | # Install Chromium. |
22 | | -mkdir "$TARGET_DIR" |
23 | | -readonly CHROMIUM_ZIP_FILE="$TARGET_DIR/chromium.zip" |
| 33 | +mkdir "$CHROME_DOWNLOAD_DIR" |
| 34 | +readonly CHROMIUM_ZIP_FILE="$CHROME_DOWNLOAD_DIR/chromium.zip" |
24 | 35 | wget --no-verbose "${DOWNLOAD_ROOT}chrome-linux.zip?alt=media" -O "$CHROMIUM_ZIP_FILE" |
25 | | -unzip -q "$CHROMIUM_ZIP_FILE" -d "$TARGET_DIR/" |
| 36 | +unzip -q "$CHROMIUM_ZIP_FILE" -d "$CHROME_DOWNLOAD_DIR/" |
26 | 37 |
|
27 | 38 | # Install ChromeDriver. |
28 | | -readonly DRIVER_ZIP_FILE="$TARGET_DIR/chromedriver.zip" |
| 39 | +readonly DRIVER_ZIP_FILE="$CHROME_DOWNLOAD_DIR/chromedriver.zip" |
29 | 40 | wget --no-verbose "${DOWNLOAD_ROOT}chromedriver_linux64.zip?alt=media" -O "$DRIVER_ZIP_FILE" |
30 | | -unzip -q "$DRIVER_ZIP_FILE" -d "$TARGET_DIR/" |
31 | | -# Rename TARGET_DIR/chromedriver_linux64 to the expected TARGET_DIR/chromedriver |
32 | | -mv -T "$TARGET_DIR/chromedriver_linux64" "$TARGET_DIR/chromedriver" |
33 | | - |
34 | | -export CHROME_EXECUTABLE="$TARGET_DIR/chrome-linux/chrome" |
| 41 | +unzip -q "$DRIVER_ZIP_FILE" -d "$CHROME_DOWNLOAD_DIR/" |
| 42 | +# Rename CHROME_DOWNLOAD_DIR/chromedriver_linux64 to the expected CHROME_DOWNLOAD_DIR/chromedriver |
| 43 | +mv -T "$CHROME_DOWNLOAD_DIR/chromedriver_linux64" "$CHROME_DOWNLOAD_DIR/chromedriver" |
35 | 44 |
|
36 | 45 | # Echo info at the end for ease of debugging. |
| 46 | +# |
| 47 | +# exports from this script cannot be used elsewhere in the .cirrus.yml file. |
37 | 48 | set +x |
38 | 49 | echo |
39 | | -readonly CHROMEDRIVER_EXECUTABLE="$TARGET_DIR/chromedriver/chromedriver" |
40 | 50 | echo "$CHROME_EXECUTABLE" |
41 | 51 | "$CHROME_EXECUTABLE" --version |
42 | 52 | echo "$CHROMEDRIVER_EXECUTABLE" |
|
0 commit comments