Skip to content

Commit 4227c31

Browse files
committed
update android scripts
1 parent e5a841e commit 4227c31

File tree

3 files changed

+43
-39
lines changed

3 files changed

+43
-39
lines changed

Diff for: ci/android-install-ndk.sh

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env sh
22
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
33
# file at the top-level directory of this distribution and at
44
# http://rust-lang.org/COPYRIGHT.
@@ -11,27 +11,27 @@
1111

1212
set -ex
1313

14-
curl -O https://dl.google.com/android/repository/android-ndk-r15b-linux-x86_64.zip
14+
curl --retry 5 -O https://dl.google.com/android/repository/android-ndk-r15b-linux-x86_64.zip
1515
unzip -q android-ndk-r15b-linux-x86_64.zip
1616

1717
case "$1" in
18-
aarch64)
19-
arch=arm64
20-
;;
18+
aarch64)
19+
arch=arm64
20+
;;
2121

22-
i686)
23-
arch=x86
24-
;;
22+
i686)
23+
arch=x86
24+
;;
2525

26-
*)
27-
arch=$1
28-
;;
26+
*)
27+
arch=$1
28+
;;
2929
esac;
3030

3131
android-ndk-r15b/build/tools/make_standalone_toolchain.py \
32-
--unified-headers \
33-
--install-dir /android/ndk-$1 \
34-
--arch $arch \
35-
--api 24
32+
--unified-headers \
33+
--install-dir "/android/ndk-${1}" \
34+
--arch "${arch}" \
35+
--api 24
3636

3737
rm -rf ./android-ndk-r15b-linux-x86_64.zip ./android-ndk-r15b

Diff for: ci/android-install-sdk.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env sh
22
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
33
# file at the top-level directory of this distribution and at
44
# http://rust-lang.org/COPYRIGHT.
@@ -19,7 +19,7 @@ set -ex
1919
# which apparently magically accepts the licenses.
2020

2121
mkdir sdk
22-
curl https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip -O
22+
curl --retry 5 https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip -O
2323
unzip -d sdk sdk-tools-linux-3859397.zip
2424

2525
case "$1" in
@@ -46,15 +46,15 @@ case "$1" in
4646
esac;
4747

4848
# --no_https avoids
49-
# javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
50-
echo "yes" | \
51-
./sdk/tools/bin/sdkmanager --no_https \
49+
# javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
50+
yes | ./sdk/tools/bin/sdkmanager --licenses --no_https
51+
yes | ./sdk/tools/bin/sdkmanager --no_https \
5252
"emulator" \
5353
"platform-tools" \
5454
"platforms;android-24" \
5555
"system-images;android-24;default;$abi"
5656

5757
echo "no" |
5858
./sdk/tools/bin/avdmanager create avd \
59-
--name $1 \
59+
--name "${1}" \
6060
--package "system-images;android-24;default;$abi"

Diff for: ci/android-sysimage.sh

+22-18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env bash
2+
13
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
24
# file at the top-level directory of this distribution and at
35
# http://rust-lang.org/COPYRIGHT.
@@ -13,40 +15,42 @@ set -ex
1315
URL=https://dl.google.com/android/repository/sys-img/android
1416

1517
main() {
16-
local arch=$1
17-
local name=$2
18+
local arch="${1}"
19+
local name="${2}"
1820
local dest=/system
19-
local td=$(mktemp -d)
21+
local td
22+
td="$(mktemp -d)"
2023

2124
apt-get install --no-install-recommends e2tools
2225

23-
pushd $td
24-
curl -O $URL/$name
25-
unzip -q $name
26+
pushd "${td}"
27+
curl --retry 5 -O "${URL}/${name}"
28+
unzip -q "${name}"
2629

27-
local system=$(find . -name system.img)
28-
mkdir -p $dest/{bin,lib,lib64}
30+
local system
31+
system="$(find . -name system.img)"
32+
mkdir -p ${dest}/{bin,lib,lib64}
2933

3034
# Extract android linker and libraries to /system
3135
# This allows android executables to be run directly (or with qemu)
32-
if [ $arch = "x86_64" -o $arch = "arm64" ]; then
33-
e2cp -p $system:/bin/linker64 $dest/bin/
34-
e2cp -p $system:/lib64/libdl.so $dest/lib64/
35-
e2cp -p $system:/lib64/libc.so $dest/lib64/
36-
e2cp -p $system:/lib64/libm.so $dest/lib64/
36+
if [ "${arch}" = "x86_64" ] || [ "${arch}" = "arm64" ]; then
37+
e2cp -p "${system}:/bin/linker64" "${dest}/bin/"
38+
e2cp -p "${system}:/lib64/libdl.so" "${dest}/lib64/"
39+
e2cp -p "${system}:/lib64/libc.so" "${dest}/lib64/"
40+
e2cp -p "${system}:/lib64/libm.so" "${dest}/lib64/"
3741
else
38-
e2cp -p $system:/bin/linker $dest/bin/
39-
e2cp -p $system:/lib/libdl.so $dest/lib/
40-
e2cp -p $system:/lib/libc.so $dest/lib/
41-
e2cp -p $system:/lib/libm.so $dest/lib/
42+
e2cp -p "${system}:/bin/linker" "${dest}/bin/"
43+
e2cp -p "${system}:/lib/libdl.so" "${dest}/lib/"
44+
e2cp -p "${system}:/lib/libc.so" "${dest}/lib/"
45+
e2cp -p "${system}:/lib/libm.so" "${dest}/lib/"
4246
fi
4347

4448
# clean up
4549
apt-get purge --auto-remove -y e2tools
4650

4751
popd
4852

49-
rm -rf $td
53+
rm -rf "${td}"
5054
}
5155

5256
main "${@}"

0 commit comments

Comments
 (0)