blob: 8c3e8ffd40134dcb702f0eca84c74468ce2c3eda [file] [log] [blame]
Roland Levillain72f67742019-03-06 15:48:08 +00001#! /bin/bash
Nicolas Geoffrayb745adc2018-10-11 10:30:19 +01002#
3# Copyright (C) 2018 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
Roland Levillain72f67742019-03-06 15:48:08 +000017# Push ART artifacts and its dependencies to a chroot directory for on-device testing.
18
Martin Stjernholmaea51b52021-04-24 17:17:39 +010019set -e
20
Ulya Trafimovich95977482021-11-09 14:05:14 +000021. "$(dirname $0)/buildbot-utils.sh"
Roland Levillain72f67742019-03-06 15:48:08 +000022
Roland Levillain1d852c32020-02-14 16:38:11 +000023# Setup as root, as some actions performed here require it.
24adb root
Nicolas Geoffrayb745adc2018-10-11 10:30:19 +010025adb wait-for-device
26
Roland Levillain72f67742019-03-06 15:48:08 +000027if [[ -z "$ANDROID_BUILD_TOP" ]]; then
Ulya Trafimovich5298bcd2021-11-09 14:46:22 +000028 msgerror 'ANDROID_BUILD_TOP environment variable is empty; did you forget to run `lunch`?'
Roland Levillain72f67742019-03-06 15:48:08 +000029 exit 1
30fi
31
32if [[ -z "$ANDROID_PRODUCT_OUT" ]]; then
Ulya Trafimovich5298bcd2021-11-09 14:46:22 +000033 msgerror 'ANDROID_PRODUCT_OUT environment variable is empty; did you forget to run `lunch`?'
Nicolas Geoffrayb745adc2018-10-11 10:30:19 +010034 exit 1
35fi
36
Roland Levillain72f67742019-03-06 15:48:08 +000037if [[ -z "$ART_TEST_CHROOT" ]]; then
Ulya Trafimovich5298bcd2021-11-09 14:46:22 +000038 msgerror 'ART_TEST_CHROOT environment variable is empty; ' \
39 'please set it before running this script.'
Nicolas Geoffrayb745adc2018-10-11 10:30:19 +010040 exit 1
41fi
42
Roland Levillain5d24c3d2020-02-07 11:57:12 +000043
Martin Stjernholme2f97112020-05-21 14:59:42 +010044# Sync relevant product directories
45# ---------------------------------
Roland Levillain5d24c3d2020-02-07 11:57:12 +000046
Martin Stjernholmaea51b52021-04-24 17:17:39 +010047(
48 cd $ANDROID_PRODUCT_OUT
49 for dir in system/* linkerconfig data; do
50 [ -d $dir ] || continue
51 if [ $dir == system/apex ]; then
52 # We sync the APEXes later.
53 continue
54 fi
Ulya Trafimovich5298bcd2021-11-09 14:46:22 +000055 msginfo "Syncing $dir directory..."
Martin Stjernholmaea51b52021-04-24 17:17:39 +010056 adb shell mkdir -p "$ART_TEST_CHROOT/$dir"
57 adb push $dir "$ART_TEST_CHROOT/$(dirname $dir)"
58 done
59)
Martin Stjernholme2f97112020-05-21 14:59:42 +010060
Roland Levillain5d24c3d2020-02-07 11:57:12 +000061# Overwrite the default public.libraries.txt file with a smaller one that
62# contains only the public libraries pushed to the chroot directory.
63adb push "$ANDROID_BUILD_TOP/art/tools/public.libraries.buildbot.txt" \
64 "$ART_TEST_CHROOT/system/etc/public.libraries.txt"
65
Martin Stjernholme2f97112020-05-21 14:59:42 +010066# Create the framework directory if it doesn't exist. Some gtests need it.
67adb shell mkdir -p "$ART_TEST_CHROOT/system/framework"
68
Jooyung Han2d348672020-02-12 15:14:15 +090069# APEX packages activation.
70# -------------------------
71
Martin Stjernholmaea51b52021-04-24 17:17:39 +010072adb shell mkdir -p "$ART_TEST_CHROOT/apex"
73
Jooyung Han2d348672020-02-12 15:14:15 +090074# Manually "activate" the flattened APEX $1 by syncing it to /apex/$2 in the
75# chroot. $2 defaults to $1.
Jooyung Han2d348672020-02-12 15:14:15 +090076activate_apex() {
77 local src_apex=${1}
78 local dst_apex=${2:-${src_apex}}
Martin Stjernholmaea51b52021-04-24 17:17:39 +010079
Martin Stjernholmf513a762021-09-13 16:04:52 +010080 # Unpack the .apex or .capex file in the product directory, but if we already
81 # see a directory we assume buildbot-build.sh has already done it for us and
82 # just use it.
Martin Stjernholmaea51b52021-04-24 17:17:39 +010083 src_apex_path=$ANDROID_PRODUCT_OUT/system/apex/${src_apex}
84 if [ ! -d $src_apex_path ]; then
Martin Stjernholmf513a762021-09-13 16:04:52 +010085 unset src_apex_file
86 if [ -f "${src_apex_path}.apex" ]; then
87 src_apex_file="${src_apex_path}.apex"
88 elif [ -f "${src_apex_path}.capex" ]; then
89 src_apex_file="${src_apex_path}.capex"
90 fi
91 if [ -z "${src_apex_file}" ]; then
Ulya Trafimovich5298bcd2021-11-09 14:46:22 +000092 msgerror "Failed to find .apex or .capex file to extract for ${src_apex_path}"
Martin Stjernholmf513a762021-09-13 16:04:52 +010093 exit 1
94 fi
Ulya Trafimovich5298bcd2021-11-09 14:46:22 +000095 msginfo "Extracting APEX ${src_apex_file}..."
Martin Stjernholmaea51b52021-04-24 17:17:39 +010096 mkdir -p $src_apex_path
97 $ANDROID_HOST_OUT/bin/deapexer --debugfs_path $ANDROID_HOST_OUT/bin/debugfs_static \
Martin Stjernholmf513a762021-09-13 16:04:52 +010098 extract ${src_apex_file} $src_apex_path
Martin Stjernholmaea51b52021-04-24 17:17:39 +010099 fi
100
Ulya Trafimovich5298bcd2021-11-09 14:46:22 +0000101 msginfo "Activating APEX ${src_apex} as ${dst_apex}..."
Jooyung Han2d348672020-02-12 15:14:15 +0900102 adb shell rm -rf "$ART_TEST_CHROOT/apex/${dst_apex}"
Martin Stjernholmaea51b52021-04-24 17:17:39 +0100103 adb push $src_apex_path "$ART_TEST_CHROOT/apex/${dst_apex}"
Jooyung Han2d348672020-02-12 15:14:15 +0900104}
105
106# "Activate" the required APEX modules.
107activate_apex com.android.art.testing com.android.art
108activate_apex com.android.i18n
109activate_apex com.android.runtime
110activate_apex com.android.tzdata
111activate_apex com.android.conscrypt
Eric Holk39d529f2021-02-17 12:48:53 -0800112activate_apex com.android.os.statsd