blob: aee133e3a098ec958617356121401f77509ada48 [file] [log] [blame]
Jeff Vander Stoep956d1432020-09-18 13:46:24 +02001#!/usr/bin/env sh
2# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
3# file at the top-level directory of this distribution and at
4# http://rust-lang.org/COPYRIGHT.
5#
6# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9# option. This file may not be copied, modified, or distributed
10# except according to those terms.
11
12set -ex
13
14# Prep the SDK and emulator
15#
16# Note that the update process requires that we accept a bunch of licenses, and
17# we can't just pipe `yes` into it for some reason, so we take the same strategy
18# located in https://github.com/appunite/docker by just wrapping it in a script
19# which apparently magically accepts the licenses.
20
21SDK=4333796
22mkdir sdk
23curl --retry 20 https://dl.google.com/android/repository/sdk-tools-linux-${SDK}.zip -O
24unzip -q -d sdk sdk-tools-linux-${SDK}.zip
25
26case "$1" in
27 arm | armv7)
28 api=24
29 image="system-images;android-${api};google_apis;armeabi-v7a"
30 ;;
31 aarch64)
32 api=24
33 image="system-images;android-${api};google_apis;arm64-v8a"
34 ;;
35 i686)
36 api=28
37 image="system-images;android-${api};default;x86"
38 ;;
39 x86_64)
40 api=28
41 image="system-images;android-${api};default;x86_64"
42 ;;
43 *)
44 echo "invalid arch: $1"
45 exit 1
46 ;;
47esac;
48
49# Try to fix warning about missing file.
50# See https://askubuntu.com/a/1078784
51mkdir -p /root/.android/
52echo '### User Sources for Android SDK Manager' >> /root/.android/repositories.cfg
53echo '#Fri Nov 03 10:11:27 CET 2017 count=0' >> /root/.android/repositories.cfg
54
55# Print all available packages
56# yes | ./sdk/tools/bin/sdkmanager --list --verbose
57
58# --no_https avoids
59# javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
60#
61# | grep -v = || true removes the progress bar output from the sdkmanager
62# which produces an insane amount of output.
63yes | ./sdk/tools/bin/sdkmanager --licenses --no_https | grep -v = || true
64yes | ./sdk/tools/bin/sdkmanager --no_https \
65 "emulator" \
66 "platform-tools" \
67 "platforms;android-${api}" \
68 "${image}" | grep -v = || true
69
70echo "no" |
71 ./sdk/tools/bin/avdmanager create avd \
72 --name "${1}" \
73 --package "${image}" | grep -v = || true
74