1#!/bin/bash
2# Script to perform a 2nd step of Android Finalization: REL 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 "'$repo_branch'" ;
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 '"$repo_upload_dry_run_arg"' --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    local repo_branch="$FINAL_PLATFORM_CODENAME-SDK-Finalization-Rel"
22    source $top/build/make/tools/finalization/command-line-options.sh
23
24    # prebuilts etc
25    source $top/build/make/tools/finalization/finalize-sdk-rel.sh
26
27    # move all changes to finalization branch/topic and upload to gerrit
28    commit_step_2_changes
29
30    # build to confirm everything is OK
31    local m_next="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=next TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug"
32    $m_next
33
34    local m_fina="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=fina_2 TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug"
35    $m_fina
36}
37
38finalize_step_2_main $@
39