1#!/usr/bin/env bash 2# The relative paths in this file only become valid at runtime. 3# shellcheck disable=SC1091 4 5set -e 6set -o xtrace 7 8export DEBIAN_FRONTEND=noninteractive 9 10# Ephemeral packages (installed for this script and removed again at the end) 11EPHEMERAL=( 12 build-essential:native 13 ccache 14 cmake 15 config-package-dev 16 debhelper-compat 17 dpkg-dev 18 ninja-build 19 unzip 20) 21 22DEPS=( 23 iproute2 24) 25apt-get install -y --no-remove --no-install-recommends \ 26 "${DEPS[@]}" "${EPHEMERAL[@]}" 27 28############### Building ... 29 30. .gitlab-ci/container/container_pre_build.sh 31 32############### Downloading NDK for native builds for the guest ... 33 34# Fetch the NDK and extract just the toolchain we want. 35ndk=$ANDROID_NDK 36curl -L --retry 4 -f --retry-all-errors --retry-delay 60 \ 37 -o "$ndk.zip" "https://dl.google.com/android/repository/$ndk-linux.zip" 38unzip -d / "$ndk.zip" 39rm "$ndk.zip" 40 41############### Build dEQP runner 42 43export ANDROID_NDK_HOME=/$ndk 44. .gitlab-ci/container/build-rust.sh 45. .gitlab-ci/container/build-deqp-runner.sh 46 47rm -rf /root/.cargo 48rm -rf /root/.rustup 49 50############### Build dEQP GL 51 52DEQP_API=GL \ 53DEQP_TARGET="android" \ 54EXTRA_CMAKE_ARGS="-DDEQP_TARGET_TOOLCHAIN=ndk-modern -DANDROID_NDK_PATH=/$ndk -DANDROID_ABI=x86_64 -DDE_ANDROID_API=28" \ 55. .gitlab-ci/container/build-deqp.sh 56 57############### Downloading Cuttlefish resources ... 58 59CUTTLEFISH_VERSION=9082637 # Chosen from https://ci.android.com/builds/branches/aosp-master/grid? 60 61mkdir /cuttlefish 62pushd /cuttlefish 63 64curl -L --retry 4 -f --retry-all-errors --retry-delay 60 \ 65 -o aosp_cf_x86_64_phone-img-$CUTTLEFISH_VERSION.zip https://ci.android.com/builds/submitted/$CUTTLEFISH_VERSION/aosp_cf_x86_64_phone-userdebug/latest/raw/aosp_cf_x86_64_phone-img-$CUTTLEFISH_VERSION.zip 66unzip aosp_cf_x86_64_phone-img-$CUTTLEFISH_VERSION.zip 67rm aosp_cf_x86_64_phone-img-$CUTTLEFISH_VERSION.zip 68ls -lhS ./* 69 70curl -L --retry 4 -f --retry-all-errors --retry-delay 60 \ 71 https://ci.android.com/builds/submitted/$CUTTLEFISH_VERSION/aosp_cf_x86_64_phone-userdebug/latest/raw/cvd-host_package.tar.gz | tar -xzvf- 72 73popd 74 75############### Building and installing Debian package ... 76 77git clone --depth 1 https://github.com/google/android-cuttlefish.git 78pushd android-cuttlefish 79 80pushd base 81dpkg-buildpackage -uc -us 82popd 83 84apt-get install -y ./cuttlefish-base_*.deb 85 86popd 87rm -rf android-cuttlefish 88 89addgroup --system kvm 90usermod -a -G kvm,cvdnetwork root 91 92############### Uninstall the build software 93 94rm -rf "/${ndk:?}" 95 96apt-get purge -y "${EPHEMERAL[@]}" 97 98. .gitlab-ci/container/container_post_build.sh 99