Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 1 | #! /bin/bash |
Nicolas Geoffray | b745adc | 2018-10-11 10:30:19 +0100 | [diff] [blame] | 2 | # |
| 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 Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 17 | # Push ART artifacts and its dependencies to a chroot directory for on-device testing. |
| 18 | |
Martin Stjernholm | aea51b5 | 2021-04-24 17:17:39 +0100 | [diff] [blame] | 19 | set -e |
| 20 | |
Ulya Trafimovich | 9597748 | 2021-11-09 14:05:14 +0000 | [diff] [blame] | 21 | . "$(dirname $0)/buildbot-utils.sh" |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 22 | |
Roland Levillain | 1d852c3 | 2020-02-14 16:38:11 +0000 | [diff] [blame] | 23 | # Setup as root, as some actions performed here require it. |
| 24 | adb root |
Nicolas Geoffray | b745adc | 2018-10-11 10:30:19 +0100 | [diff] [blame] | 25 | adb wait-for-device |
| 26 | |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 27 | if [[ -z "$ANDROID_BUILD_TOP" ]]; then |
Ulya Trafimovich | 5298bcd | 2021-11-09 14:46:22 +0000 | [diff] [blame] | 28 | msgerror 'ANDROID_BUILD_TOP environment variable is empty; did you forget to run `lunch`?' |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 29 | exit 1 |
| 30 | fi |
| 31 | |
| 32 | if [[ -z "$ANDROID_PRODUCT_OUT" ]]; then |
Ulya Trafimovich | 5298bcd | 2021-11-09 14:46:22 +0000 | [diff] [blame] | 33 | msgerror 'ANDROID_PRODUCT_OUT environment variable is empty; did you forget to run `lunch`?' |
Nicolas Geoffray | b745adc | 2018-10-11 10:30:19 +0100 | [diff] [blame] | 34 | exit 1 |
| 35 | fi |
| 36 | |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 37 | if [[ -z "$ART_TEST_CHROOT" ]]; then |
Ulya Trafimovich | 5298bcd | 2021-11-09 14:46:22 +0000 | [diff] [blame] | 38 | msgerror 'ART_TEST_CHROOT environment variable is empty; ' \ |
| 39 | 'please set it before running this script.' |
Nicolas Geoffray | b745adc | 2018-10-11 10:30:19 +0100 | [diff] [blame] | 40 | exit 1 |
| 41 | fi |
| 42 | |
Roland Levillain | 5d24c3d | 2020-02-07 11:57:12 +0000 | [diff] [blame] | 43 | |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 44 | # Sync relevant product directories |
| 45 | # --------------------------------- |
Roland Levillain | 5d24c3d | 2020-02-07 11:57:12 +0000 | [diff] [blame] | 46 | |
Martin Stjernholm | aea51b5 | 2021-04-24 17:17:39 +0100 | [diff] [blame] | 47 | ( |
| 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 Trafimovich | 5298bcd | 2021-11-09 14:46:22 +0000 | [diff] [blame] | 55 | msginfo "Syncing $dir directory..." |
Martin Stjernholm | aea51b5 | 2021-04-24 17:17:39 +0100 | [diff] [blame] | 56 | adb shell mkdir -p "$ART_TEST_CHROOT/$dir" |
| 57 | adb push $dir "$ART_TEST_CHROOT/$(dirname $dir)" |
| 58 | done |
| 59 | ) |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 60 | |
Roland Levillain | 5d24c3d | 2020-02-07 11:57:12 +0000 | [diff] [blame] | 61 | # Overwrite the default public.libraries.txt file with a smaller one that |
| 62 | # contains only the public libraries pushed to the chroot directory. |
| 63 | adb push "$ANDROID_BUILD_TOP/art/tools/public.libraries.buildbot.txt" \ |
| 64 | "$ART_TEST_CHROOT/system/etc/public.libraries.txt" |
| 65 | |
Martin Stjernholm | e2f9711 | 2020-05-21 14:59:42 +0100 | [diff] [blame] | 66 | # Create the framework directory if it doesn't exist. Some gtests need it. |
| 67 | adb shell mkdir -p "$ART_TEST_CHROOT/system/framework" |
| 68 | |
Jooyung Han | 2d34867 | 2020-02-12 15:14:15 +0900 | [diff] [blame] | 69 | # APEX packages activation. |
| 70 | # ------------------------- |
| 71 | |
Martin Stjernholm | aea51b5 | 2021-04-24 17:17:39 +0100 | [diff] [blame] | 72 | adb shell mkdir -p "$ART_TEST_CHROOT/apex" |
| 73 | |
Jooyung Han | 2d34867 | 2020-02-12 15:14:15 +0900 | [diff] [blame] | 74 | # Manually "activate" the flattened APEX $1 by syncing it to /apex/$2 in the |
| 75 | # chroot. $2 defaults to $1. |
Jooyung Han | 2d34867 | 2020-02-12 15:14:15 +0900 | [diff] [blame] | 76 | activate_apex() { |
| 77 | local src_apex=${1} |
| 78 | local dst_apex=${2:-${src_apex}} |
Martin Stjernholm | aea51b5 | 2021-04-24 17:17:39 +0100 | [diff] [blame] | 79 | |
Martin Stjernholm | f513a76 | 2021-09-13 16:04:52 +0100 | [diff] [blame] | 80 | # 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 Stjernholm | aea51b5 | 2021-04-24 17:17:39 +0100 | [diff] [blame] | 83 | src_apex_path=$ANDROID_PRODUCT_OUT/system/apex/${src_apex} |
| 84 | if [ ! -d $src_apex_path ]; then |
Martin Stjernholm | f513a76 | 2021-09-13 16:04:52 +0100 | [diff] [blame] | 85 | 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 Trafimovich | 5298bcd | 2021-11-09 14:46:22 +0000 | [diff] [blame] | 92 | msgerror "Failed to find .apex or .capex file to extract for ${src_apex_path}" |
Martin Stjernholm | f513a76 | 2021-09-13 16:04:52 +0100 | [diff] [blame] | 93 | exit 1 |
| 94 | fi |
Ulya Trafimovich | 5298bcd | 2021-11-09 14:46:22 +0000 | [diff] [blame] | 95 | msginfo "Extracting APEX ${src_apex_file}..." |
Martin Stjernholm | aea51b5 | 2021-04-24 17:17:39 +0100 | [diff] [blame] | 96 | mkdir -p $src_apex_path |
| 97 | $ANDROID_HOST_OUT/bin/deapexer --debugfs_path $ANDROID_HOST_OUT/bin/debugfs_static \ |
Martin Stjernholm | f513a76 | 2021-09-13 16:04:52 +0100 | [diff] [blame] | 98 | extract ${src_apex_file} $src_apex_path |
Martin Stjernholm | aea51b5 | 2021-04-24 17:17:39 +0100 | [diff] [blame] | 99 | fi |
| 100 | |
Ulya Trafimovich | 5298bcd | 2021-11-09 14:46:22 +0000 | [diff] [blame] | 101 | msginfo "Activating APEX ${src_apex} as ${dst_apex}..." |
Jooyung Han | 2d34867 | 2020-02-12 15:14:15 +0900 | [diff] [blame] | 102 | adb shell rm -rf "$ART_TEST_CHROOT/apex/${dst_apex}" |
Martin Stjernholm | aea51b5 | 2021-04-24 17:17:39 +0100 | [diff] [blame] | 103 | adb push $src_apex_path "$ART_TEST_CHROOT/apex/${dst_apex}" |
Jooyung Han | 2d34867 | 2020-02-12 15:14:15 +0900 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | # "Activate" the required APEX modules. |
| 107 | activate_apex com.android.art.testing com.android.art |
| 108 | activate_apex com.android.i18n |
| 109 | activate_apex com.android.runtime |
| 110 | activate_apex com.android.tzdata |
| 111 | activate_apex com.android.conscrypt |
Eric Holk | 39d529f | 2021-02-17 12:48:53 -0800 | [diff] [blame] | 112 | activate_apex com.android.os.statsd |