blob: b5786e9a28e883db8759e499f77233050c891b71 [file] [log] [blame]
Andreas Gampe99e2b262016-07-09 11:44:12 -07001#!/system/bin/sh
2
3#
4# Copyright (C) 2016 The Android Open Source Project
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18
19# This script will move artifacts for the currently active slot.
20
21SLOT_SUFFIX=$(getprop ro.boot.slot_suffix)
22if test -n "$SLOT_SUFFIX" ; then
23 if test -d /data/ota/$SLOT_SUFFIX/dalvik-cache ; then
24 log -p i -t otapreopt_slot "Moving A/B artifacts for slot ${SLOT_SUFFIX}."
Andreas Gampee7d55522016-08-12 19:35:57 -070025 OLD_SIZE=$(du -h -s /data/dalvik-cache)
Andreas Gampe99e2b262016-07-09 11:44:12 -070026 rm -rf /data/dalvik-cache/*
Andreas Gampee7d55522016-08-12 19:35:57 -070027 NEW_SIZE=$(du -h -s /data/ota/$SLOT_SUFFIX/dalvik-cache)
Andreas Gampe99e2b262016-07-09 11:44:12 -070028 mv /data/ota/$SLOT_SUFFIX/dalvik-cache/* /data/dalvik-cache/
29 rmdir /data/ota/$SLOT_SUFFIX/dalvik-cache
30 rmdir /data/ota/$SLOT_SUFFIX
Andreas Gampee7d55522016-08-12 19:35:57 -070031 log -p i -t otapreopt_slot "Moved ${NEW_SIZE} over ${OLD_SIZE}"
Andreas Gampe99e2b262016-07-09 11:44:12 -070032 else
33 log -p i -t otapreopt_slot "No A/B artifacts found for slot ${SLOT_SUFFIX}."
34 fi
35 exit 0
36else
37 log -p w -t otapreopt_slot "Slot property empty."
38 exit 1
39fi