|
| 1 | +#!/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 | + |
| 12 | +set -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 | + |
| 21 | +SDK=4333796 |
| 22 | +mkdir sdk |
| 23 | +curl --retry 20 https://dl.google.com/android/repository/sdk-tools-linux-${SDK}.zip -O |
| 24 | +unzip -q -d sdk sdk-tools-linux-${SDK}.zip |
| 25 | + |
| 26 | +case "$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 | + ;; |
| 47 | +esac; |
| 48 | + |
| 49 | +# Try to fix warning about missing file. |
| 50 | +# See https://askubuntu.com/a/1078784 |
| 51 | +mkdir -p /root/.android/ |
| 52 | +echo '### User Sources for Android SDK Manager' >> /root/.android/repositories.cfg |
| 53 | +echo '#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. |
| 63 | +yes | ./sdk/tools/bin/sdkmanager --licenses --no_https | grep -v = || true |
| 64 | +yes | ./sdk/tools/bin/sdkmanager --no_https \ |
| 65 | + "emulator" \ |
| 66 | + "platform-tools" \ |
| 67 | + "platforms;android-${api}" \ |
| 68 | + "${image}" | grep -v = || true |
| 69 | + |
| 70 | +echo "no" | |
| 71 | + ./sdk/tools/bin/avdmanager create avd \ |
| 72 | + --name "${1}" \ |
| 73 | + --package "${image}" | grep -v = || true |
| 74 | + |
0 commit comments