Roland Levillain | e4f1c51 | 2017-10-30 13:28:28 +0000 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2017 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 | |
| 17 | green='\033[0;32m' |
| 18 | nc='\033[0m' |
| 19 | |
| 20 | # Setup as root, as device cleanup requires it. |
| 21 | adb root |
| 22 | adb wait-for-device |
| 23 | |
| 24 | if [[ -n "$ART_TEST_CHROOT" ]]; then |
| 25 | # Check that ART_TEST_CHROOT is correctly defined. |
| 26 | if [[ "x$ART_TEST_CHROOT" != x/* ]]; then |
| 27 | echo "$ART_TEST_CHROOT is not an absolute path" |
| 28 | exit 1 |
| 29 | fi |
| 30 | |
| 31 | echo -e "${green}Clean up /system in chroot${nc}" |
| 32 | # Remove all files under /system except the potential property_contexts file. |
| 33 | # |
| 34 | # The current ART Buildbot set-up runs the "setup device" step |
| 35 | # (performed by script tools/setup-buildbot-device.sh) before the |
| 36 | # "device cleanup" step (implemented by this script). As |
| 37 | # property_contexts file aliases are created during the former step, |
| 38 | # we need this exception to prevent the property_contexts file under |
| 39 | # /system in the chroot from being removed by the latter step. |
| 40 | # |
| 41 | # TODO: Reorder ART Buildbot steps so that "device cleanup" happens |
| 42 | # before "setup device" and remove this special case. |
| 43 | # |
| 44 | # TODO: Also consider adding a "tear down device" step on the ART |
| 45 | # Buildbot (at the very end of a build) undoing (some of) the work |
| 46 | # done in the "device setup" step. |
| 47 | adb shell find "$ART_TEST_CHROOT/system" \ |
| 48 | ! -path "$ART_TEST_CHROOT/system/etc/selinux/plat_property_contexts" \ |
| 49 | ! -type d \ |
| 50 | -exec rm -f \{\} + |
| 51 | |
| 52 | echo -e "${green}Clean up some subdirs in /data in chroot${nc}" |
| 53 | adb shell rm -rf \ |
| 54 | "$ART_TEST_CHROOT/data/local/tmp/*" \ |
| 55 | "$ART_TEST_CHROOT/data/art-test" \ |
| 56 | "$ART_TEST_CHROOT/data/nativetest" \ |
| 57 | "$ART_TEST_CHROOT/data/nativetest64" \ |
| 58 | "$ART_TEST_CHROOT/data/run-test" \ |
| 59 | "$ART_TEST_CHROOT/data/dalvik-cache/*" \ |
| 60 | "$ART_TEST_CHROOT/data/misc/trace/*" |
| 61 | else |
| 62 | adb shell rm -rf \ |
| 63 | /data/local/tmp /data/art-test /data/nativetest /data/nativetest64 '/data/misc/trace/*' |
| 64 | fi |