1#!/bin/bash
2# Script to perform 1st and 2nd step of Android Finalization, create CLs and upload to Gerrit.
3
4function commit_step_2_changes() {
5    repo forall -c '\
6        if [[ $(git status --short) ]]; then
7            repo start "$FINAL_PLATFORM_CODENAME-SDK-Finalization-DryRun-Rel" ;
8            git add -A . ;
9            git commit -m "$FINAL_PLATFORM_CODENAME/$FINAL_PLATFORM_SDK_VERSION is now REL" \
10                       -m "Ignore-AOSP-First: $FINAL_PLATFORM_CODENAME Finalization
11Bug: $FINAL_BUG_ID
12Test: build";
13
14            repo upload --cbr --no-verify -o nokeycheck -t -y . ;
15        fi'
16}
17
18function finalize_step_2_main() {
19    local top="$(dirname "$0")"/../../../..
20    source $top/build/make/tools/finalization/environment.sh
21
22    source $top/build/make/tools/finalization/finalize-sdk-resources.sh
23
24    source $top/build/make/tools/finalization/localonly-steps.sh
25
26    source $top/build/make/tools/finalization/finalize-sdk-rel.sh
27
28    # move all changes to finalization branch/topic and upload to gerrit
29    commit_step_2_changes
30
31    # build to confirm everything is OK
32    local m_next="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=next TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug"
33    $m_next
34
35    local m_fina="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=fina_2 TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug"
36    $m_fina
37}
38
39finalize_step_2_main
40