1# Copyright 2017 The Rust Project Developers. See the COPYRIGHT 2# file at the top-level directory of this distribution and at 3# http://rust-lang.org/COPYRIGHT. 4# 5# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or 6# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license 7# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your 8# option. This file may not be copied, modified, or distributed 9# except according to those terms. 10 11set -ex 12 13URL=https://dl.google.com/android/repository/sys-img/android 14 15main() { 16 local arch=$1 17 local name=$2 18 local dest=/system 19 local td=$(mktemp -d) 20 21 apt-get install --no-install-recommends e2tools 22 23 pushd $td 24 curl -O $URL/$name 25 unzip -q $name 26 27 local system=$(find . -name system.img) 28 mkdir -p $dest/{bin,lib,lib64} 29 30 # Extract android linker and libraries to /system 31 # 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/ 37 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 fi 43 44 # clean up 45 apt-get purge --auto-remove -y e2tools 46 47 popd 48 49 rm -rf $td 50} 51 52main "${@}" 53