author Andreas Tolfsen <>
Fri, 03 Nov 2017 13:39:05 +0000
changeset 443335 257f99d6b09d6d9e3669c9472df3b4838fb906e7
permissions -rw-r--r--
Bug 1414254 - Vendor Rust dependencies r=jgraham MozReview-Commit-ID: CnT3DLl2KBR

# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
#> or the MIT license
# <LICENSE-MIT or>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.

set -ex


main() {
    local arch=$1
    local name=$2
    local dest=/system
    local td=$(mktemp -d)

    apt-get install --no-install-recommends e2tools

    pushd $td
    curl -O $URL/$name
    unzip -q $name

    local system=$(find . -name system.img)
    mkdir -p $dest/{bin,lib,lib64}

    # Extract android linker and libraries to /system
    # This allows android executables to be run directly (or with qemu)
    if [ $arch = "x86_64" -o $arch = "arm64" ]; then
        e2cp -p $system:/bin/linker64 $dest/bin/
        e2cp -p $system:/lib64/ $dest/lib64/
        e2cp -p $system:/lib64/ $dest/lib64/
        e2cp -p $system:/lib64/ $dest/lib64/
        e2cp -p $system:/bin/linker $dest/bin/
        e2cp -p $system:/lib/ $dest/lib/
        e2cp -p $system:/lib/ $dest/lib/
        e2cp -p $system:/lib/ $dest/lib/

    # clean up
    apt-get purge --auto-remove -y e2tools


    rm -rf $td

main "${@}"