1#!/bin/bash
2# Script to perform a 1st step of Android Finalization: API/SDK finalization, create CLs and upload to Gerrit.
3
4set -ex
5
6function commit_step_1_changes() {
7    set +e
8    repo forall -c '\
9        if [[ $(git status --short) ]]; then
10            repo start "'$repo_branch'" ;
11            git add -A . ;
12            git commit -m "$FINAL_PLATFORM_CODENAME is now $FINAL_PLATFORM_SDK_VERSION and extension version $FINAL_MAINLINE_EXTENSION" \
13                       -m "Ignore-AOSP-First: $FINAL_PLATFORM_CODENAME Finalization
14Bug: $FINAL_BUG_ID
15Test: build";
16            repo upload '"$repo_upload_dry_run_arg"' --cbr --no-verify -o nokeycheck -t -y . ;
17        fi'
18}
19
20function finalize_step_1_main() {
21    local top="$(dirname "$0")"/../../../..
22    source $top/build/make/tools/finalization/environment.sh
23    local repo_branch="$FINAL_PLATFORM_CODENAME-SDK-Finalization"
24    source $top/build/make/tools/finalization/command-line-options.sh
25
26    source $top/build/make/tools/finalization/finalize-sdk-resources.sh
27
28    # move all changes to finalization branch/topic and upload to gerrit
29    commit_step_1_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_1 TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug"
36    $m_fina
37}
38
39finalize_step_1_main $@
40