otapreopt_slot.sh revision 99e2b263dd0df71b55e86f0aec6657eb38b334e1
199e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe#!/system/bin/sh
299e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe
399e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe#
499e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe# Copyright (C) 2016 The Android Open Source Project
599e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe#
699e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe# Licensed under the Apache License, Version 2.0 (the "License");
799e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe# you may not use this file except in compliance with the License.
899e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe# You may obtain a copy of the License at
999e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe#
1099e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe#      http://www.apache.org/licenses/LICENSE-2.0
1199e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe#
1299e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe# Unless required by applicable law or agreed to in writing, software
1399e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe# distributed under the License is distributed on an "AS IS" BASIS,
1499e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1599e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe# See the License for the specific language governing permissions and
1699e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe# limitations under the License.
1799e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe#
1899e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe
1999e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe# This script will move artifacts for the currently active slot.
2099e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe
2199e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas GampeSLOT_SUFFIX=$(getprop ro.boot.slot_suffix)
2299e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampeif test -n "$SLOT_SUFFIX" ; then
2399e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe  if test -d /data/ota/$SLOT_SUFFIX/dalvik-cache ; then
2499e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe    log -p i -t otapreopt_slot "Moving A/B artifacts for slot ${SLOT_SUFFIX}."
2599e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe    rm -rf /data/dalvik-cache/*
2699e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe    mv /data/ota/$SLOT_SUFFIX/dalvik-cache/* /data/dalvik-cache/
2799e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe    rmdir /data/ota/$SLOT_SUFFIX/dalvik-cache
2899e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe    rmdir /data/ota/$SLOT_SUFFIX
2999e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe  else
3099e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe    log -p i -t otapreopt_slot "No A/B artifacts found for slot ${SLOT_SUFFIX}."
3199e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe  fi
3299e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe  exit 0
3399e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampeelse
3499e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe  log -p w -t otapreopt_slot "Slot property empty."
3599e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampe  exit 1
3699e2b263dd0df71b55e86f0aec6657eb38b334e1Andreas Gampefi
37