Refactor finalization scripts.

Bug: 264308911
Test: run locally
Change-Id: I60fa1e1121fafb617d8508403fae07f0bdf39e66
This commit is contained in:
Alex Buynytskyy
2023-02-09 22:40:53 +00:00
parent 6698f2f688
commit afddc07570
8 changed files with 258 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
include platform/build/soong:/OWNERS
smoreland@google.com
alexbuy@google.com
patb@google.com
zyy@google.com

21
tools/finalization/cleanup.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
# Brings local repository to a remote head state.
# set -ex
function finalize_revert_local_changes_main() {
local top="$(dirname "$0")"/../../../..
local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug"
# remove the out folder
$m clobber
repo selfupdate
repo forall -c '\
git checkout . ; git revert --abort ; git clean -fdx ;\
git checkout @ ; git branch fina-step1 -D ; git reset --hard; \
repo start fina-step1 ; git checkout @ ; git b fina-step1 -D ;'
}
finalize_revert_local_changes_main

View File

@@ -0,0 +1,16 @@
#!/bin/bash
set -ex
export FINA_BUG_ID='0'
export FINA_PLATFORM_CODENAME='UpsideDownCake'
export FINA_PLATFORM_CODENAME_JAVA='UPSIDE_DOWN_CAKE'
export FINA_PLATFORM_SDK_VERSION='34'
export FINA_PLATFORM_VERSION='14'
export FINA_BUILD_PREFIX='UP1A'
export FINA_MAINLINE_EXTENSION='6'
export FINA_MAINLINE_SDK_COMMIT_MESSAGE=''
export FINA_MAINLINE_SDK_BUILD_ID=0

View File

@@ -0,0 +1,82 @@
#!/bin/bash
set -ex
function finalize_aidl_vndk_sdk_resources() {
local top="$(dirname "$0")"/../../../..
source $top/build/make/tools/finalization/environment.sh
local SDK_CODENAME="public static final int $FINA_PLATFORM_CODENAME_JAVA = CUR_DEVELOPMENT;"
local SDK_VERSION="public static final int $FINA_PLATFORM_CODENAME_JAVA = $FINA_PLATFORM_SDK_VERSION;"
# default target to modify tree and build SDK
local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug"
# This script is WIP and only finalizes part of the Android branch for release.
# The full process can be found at (INTERNAL) go/android-sdk-finalization.
# Update references in the codebase to new API version (TODO)
# ...
# VNDK definitions for new SDK version
cp "$top/development/vndk/tools/definition-tool/datasets/vndk-lib-extra-list-current.txt" \
"$top/development/vndk/tools/definition-tool/datasets/vndk-lib-extra-list-$FINA_PLATFORM_SDK_VERSION.txt"
AIDL_TRANSITIVE_FREEZE=true $m aidl-freeze-api create_reference_dumps
# Generate ABI dumps
ANDROID_BUILD_TOP="$top" \
out/host/linux-x86/bin/create_reference_dumps \
-p aosp_arm64 --build-variant user
echo "NOTE: THIS INTENTIONALLY MAY FAIL AND REPAIR ITSELF (until 'DONE')"
# Update new versions of files. See update-vndk-list.sh (which requires envsetup.sh)
$m check-vndk-list || \
{ cp $top/out/soong/vndk/vndk.libraries.txt $top/build/make/target/product/gsi/current.txt; }
echo "DONE: THIS INTENTIONALLY MAY FAIL AND REPAIR ITSELF"
# Finalize SDK
# build/make
local version_defaults="$top/build/make/core/version_defaults.mk"
sed -i -e "s/PLATFORM_SDK_VERSION := .*/PLATFORM_SDK_VERSION := ${FINA_PLATFORM_SDK_VERSION}/g" $version_defaults
sed -i -e "s/PLATFORM_VERSION_LAST_STABLE := .*/PLATFORM_VERSION_LAST_STABLE := ${FINA_PLATFORM_VERSION}/g" $version_defaults
sed -i -e "s/sepolicy_major_vers := .*/sepolicy_major_vers := ${FINA_PLATFORM_SDK_VERSION}/g" "$top/build/make/core/config.mk"
cp "$top/build/make/target/product/gsi/current.txt" "$top/build/make/target/product/gsi/$FINA_PLATFORM_SDK_VERSION.txt"
# build/soong
sed -i -e "/:.*$((${FINA_PLATFORM_SDK_VERSION}-1)),/a \\\t\t\t\"${FINA_PLATFORM_CODENAME}\": ${FINA_PLATFORM_SDK_VERSION}," "$top/build/soong/android/api_levels.go"
# cts
echo ${FINA_PLATFORM_VERSION} > "$top/cts/tests/tests/os/assets/platform_releases.txt"
sed -i -e "s/EXPECTED_SDK = $((${FINA_PLATFORM_SDK_VERSION}-1))/EXPECTED_SDK = ${FINA_PLATFORM_SDK_VERSION}/g" "$top/cts/tests/tests/os/src/android/os/cts/BuildVersionTest.java"
# libcore
sed -i "s%$SDK_CODENAME%$SDK_VERSION%g" "$top/libcore/dalvik/src/main/java/dalvik/annotation/compat/VersionCodes.java"
# platform_testing
local version_codes="$top/platform_testing/libraries/compatibility-common-util/src/com/android/compatibility/common/util/VersionCodes.java"
sed -i -e "/=.*$((${FINA_PLATFORM_SDK_VERSION}-1));/a \\ ${SDK_VERSION}" $version_codes
# Finalize resources
"$top/frameworks/base/tools/aapt2/tools/finalize_res.py" \
"$top/frameworks/base/core/res/res/values/public-staging.xml" \
"$top/frameworks/base/core/res/res/values/public-final.xml"
# frameworks/base
sed -i "s%$SDK_CODENAME%$SDK_VERSION%g" "$top/frameworks/base/core/java/android/os/Build.java"
sed -i -e "/=.*$((${FINA_PLATFORM_SDK_VERSION}-1)),/a \\ SDK_${FINA_PLATFORM_CODENAME_JAVA} = ${FINA_PLATFORM_SDK_VERSION}," "$top/frameworks/base/tools/aapt/SdkConstants.h"
sed -i -e "/=.*$((${FINA_PLATFORM_SDK_VERSION}-1)),/a \\ SDK_${FINA_PLATFORM_CODENAME_JAVA} = ${FINA_PLATFORM_SDK_VERSION}," "$top/frameworks/base/tools/aapt2/SdkConstants.h"
# Bump Mainline SDK extension version.
"$top/packages/modules/SdkExtensions/gen_sdk/bump_sdk.sh" ${MAINLINE_EXTENSION}
local version_defaults="$top/build/make/core/version_defaults.mk"
sed -i -e "s/PLATFORM_SDK_EXTENSION_VERSION := .*/PLATFORM_SDK_EXTENSION_VERSION := ${MAINLINE_EXTENSION}/g" $version_defaults
# Force update current.txt
$m clobber
$m update-api
}
finalize_aidl_vndk_sdk_resources

View File

@@ -0,0 +1,39 @@
#!/bin/bash
set -ex
function finalize_sdk_rel() {
local top="$(dirname "$0")"/../../../..
source $top/build/make/tools/finalization/environment.sh
# default target to modify tree and build SDK
local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug"
# adb keys
$m adb
LOGNAME=android-eng HOSTNAME=google.com "$top/out/host/linux-x86/bin/adb" keygen "$top/vendor/google/security/adb/${FINA_PLATFORM_VERSION}.adb_key"
# build/make/core/version_defaults.mk
sed -i -e "s/PLATFORM_VERSION_CODENAME.${BUILD_PREFIX} := .*/PLATFORM_VERSION_CODENAME.${BUILD_PREFIX} := REL/g" "$top/build/make/core/version_defaults.mk"
# cts
echo "$FINA_PLATFORM_VERSION" > "$top/cts/tests/tests/os/assets/platform_versions.txt"
git -C "$top/cts" mv hostsidetests/theme/assets/${FINA_PLATFORM_CODENAME} hostsidetests/theme/assets/${FINA_PLATFORM_SDK_VERSION}
# system/sepolicy
mkdir -p "$top/system/sepolicy/prebuilts/api/${FINA_PLATFORM_SDK_VERSION}.0/"
cp -r "$top/system/sepolicy/public/" "$top/system/sepolicy/prebuilts/api/${FINA_PLATFORM_SDK_VERSION}.0/"
cp -r "$top/system/sepolicy/private/" "$top/system/sepolicy/prebuilts/api/${FINA_PLATFORM_SDK_VERSION}.0/"
# prebuilts/abi-dumps/ndk
mv "$top/prebuilts/abi-dumps/ndk/current" "$top/prebuilts/abi-dumps/ndk/$FINA_PLATFORM_SDK_VERSION"
# prebuilts/abi-dumps/vndk
mv "$top/prebuilts/abi-dumps/vndk/$FINA_PLATFORM_CODENAME" "$top/prebuilts/abi-dumps/vndk/$FINA_PLATFORM_SDK_VERSION"
# prebuilts/abi-dumps/platform
mv "$top/prebuilts/abi-dumps/platform/current" "$top/prebuilts/abi-dumps/platform/$FINA_PLATFORM_SDK_VERSION"
}
finalize_sdk_rel

View File

@@ -0,0 +1,17 @@
#!/bin/bash
set -ex
function finalize_locally_mainline_sdk() {
local top="$(dirname "$0")"/../../../..
source $top/build/make/tools/finalization/environment.sh
# Build modules SDKs.
TARGET_BUILD_VARIANT=userdebug UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true "$top/vendor/google/build/mainline_modules_sdks.sh"
# Update prebuilts.
"$top/prebuilts/build-tools/path/linux-x86/python3" "$top/packages/modules/common/tools/finalize_sdk.py" -l -b 0 -f ${FINA_MAINLINE_EXTENSION} -r '' 0
}
finalize_locally_mainline_sdk

37
tools/finalization/step-1.sh Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
# Script to perform a 1st step of Android Finalization: API/SDK finalization, create CLs and upload to Gerrit.
set -ex
function commit_step_1_changes() {
set +e
repo forall -c '\
if [[ $(git status --short) ]]; then
repo start "$FINA_PLATFORM_CODENAME-SDK-Finalization" ;
git add -A . ;
git commit -m "$FINA_PLATFORM_CODENAME is now $FINA_PLATFORM_SDK_VERSION" \
-m "Ignore-AOSP-First: $FINA_PLATFORM_CODENAME Finalization
Bug: $FINA_BUG_ID
Test: build";
repo upload --cbr --no-verify -o nokeycheck -t -y . ;
git clean -fdx ; git reset --hard ;
fi'
}
function finalize_step_1_main() {
local top="$(dirname "$0")"/../../../..
source $top/build/make/tools/finalization/environment.sh
local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug"
# vndk etc finalization
source $top/build/make/tools/finalization/finalize-aidl-vndk-sdk-resources.sh
# build to confirm everything is OK
AIDL_FROZEN_REL=true $m
# move all changes to finalization branch/topic and upload to gerrit
commit_step_1_changes
}
finalize_step_1_main

41
tools/finalization/step-2.sh Executable file
View File

@@ -0,0 +1,41 @@
#!/bin/bash
# Script to perform a 2nd step of Android Finalization: REL finalization, create CLs and upload to Gerrit.
function commit_step_2_changes() {
repo forall -c '\
if [[ $(git status --short) ]]; then
repo start "$FINA_PLATFORM_CODENAME-SDK-Finalization-Rel" ;
git add -A . ;
git commit -m "$FINA_PLATFORM_CODENAME/$FINA_PLATFORM_SDK_VERSION is now REL" \
-m "Ignore-AOSP-First: $FINA_PLATFORM_CODENAME Finalization
Bug: $FINA_BUG_ID
Test: build";
repo upload --cbr --no-verify -o nokeycheck -t -y . ;
git clean -fdx ; git reset --hard ;
fi'
}
function finalize_step_2_main() {
local top="$(dirname "$0")"/../../../..
source $top/build/make/tools/finalization/environment.sh
local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug"
# vndk etc finalization
source $top/build/make/tools/finalization/finalize-aidl-vndk-sdk-resources.sh
# prebuilts etc
source $top/build/make/tools/finalization/finalize-sdk-rel.sh
# Update prebuilts.
"$top/prebuilts/build-tools/path/linux-x86/python3" "$top/packages/modules/common/tools/finalize_sdk.py" -b ${FINA_BUG_ID} -f ${FINA_MAINLINE_EXTENSION} -r "${FINA_MAINLINE_SDK_COMMIT_MESSAGE}" ${FINA_MAINLINE_SDK_BUILD_ID}
# build to confirm everything is OK
AIDL_FROZEN_REL=true $m
# move all changes to finalization branch/topic and upload to gerrit
commit_step_2_changes
}
finalize_step_2_main