From 2c2f3294b7f98c2715c56eb8c21c6b586bddbb09 Mon Sep 17 00:00:00 2001 From: Nelson Li Date: Thu, 11 Jul 2024 14:13:02 +0800 Subject: [PATCH] Convert *-developer-gsi.avbpubkey to Android.bp Use `soong_config_module_type` to install `*-developer-gsi.avbpubkey` to either `ramdisk` or `vendor_ramdisk` based on the value of `BOARD_MOVE_GSI_AVB_KEYS_TO_VENDOR_BOOT` in each device. In build/soong/android/paths.go's modulePartition() function, there is already logic to construct `vendor_ramdisk` and `ramdisk` partitions based on the different values of `BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT` and `BOARD_USES_RECOVERY_AS_BOOT`. And the logic is identical to the original Android.mk. Therefore, this change only needs to determine whether the avb public keys should be placed in `vendor_ramdisk` or `ramdisk` based on the value of `BOARD_MOVE_GSI_AVB_KEYS_TO_VENDOR_BOOT`. The rest of the judgment logic can be ignored. Bug: 347636127 Test: 1) lunch aosp_cf_x86_64_phone && m q-developer-gsi.avbpubkey 2) check it installed to vendor_ramdisk/first_stage_ramdisk/avb/ 3) lunch yukawa && m q-developer-gsi.avbpubkey 4) check it installed to ramdisk/avb/q-developer-gsi.avbpubkey Change-Id: I6de1a038261f2feeae4504d8097c7392b166848d --- rootdir/avb/Android.bp | 71 ++++++++++++++++++++++++++++++++++++++++++ rootdir/avb/Android.mk | 56 --------------------------------- 2 files changed, 71 insertions(+), 56 deletions(-) create mode 100644 rootdir/avb/Android.bp delete mode 100644 rootdir/avb/Android.mk diff --git a/rootdir/avb/Android.bp b/rootdir/avb/Android.bp new file mode 100644 index 000000000..a584e3e59 --- /dev/null +++ b/rootdir/avb/Android.bp @@ -0,0 +1,71 @@ +// Copyright (C) 2024 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +soong_config_module_type { + name: "avb_keys_prebuilt_avb", + module_type: "prebuilt_avb", + config_namespace: "ANDROID", + bool_variables: [ + "BOARD_MOVE_GSI_AVB_KEYS_TO_VENDOR_BOOT", + ], + properties: [ + "ramdisk", + "vendor_ramdisk", + ], +} + +avb_keys_prebuilt_avb { + name: "q-developer-gsi.avbpubkey", + src: "q-developer-gsi.avbpubkey", + soong_config_variables: { + BOARD_MOVE_GSI_AVB_KEYS_TO_VENDOR_BOOT: { + ramdisk: false, + vendor_ramdisk: true, + conditions_default: { + ramdisk: true, + vendor_ramdisk: false, + }, + }, + }, +} + +avb_keys_prebuilt_avb { + name: "r-developer-gsi.avbpubkey", + src: "r-developer-gsi.avbpubkey", + soong_config_variables: { + BOARD_MOVE_GSI_AVB_KEYS_TO_VENDOR_BOOT: { + ramdisk: false, + vendor_ramdisk: true, + conditions_default: { + ramdisk: true, + vendor_ramdisk: false, + }, + }, + }, +} + +avb_keys_prebuilt_avb { + name: "s-developer-gsi.avbpubkey", + src: "s-developer-gsi.avbpubkey", + soong_config_variables: { + BOARD_MOVE_GSI_AVB_KEYS_TO_VENDOR_BOOT: { + ramdisk: false, + vendor_ramdisk: true, + conditions_default: { + ramdisk: true, + vendor_ramdisk: false, + }, + }, + }, +} diff --git a/rootdir/avb/Android.mk b/rootdir/avb/Android.mk deleted file mode 100644 index 8cf317231..000000000 --- a/rootdir/avb/Android.mk +++ /dev/null @@ -1,56 +0,0 @@ -LOCAL_PATH:= $(call my-dir) - -ifeq ($(BOARD_MOVE_GSI_AVB_KEYS_TO_VENDOR_BOOT),true) # AVB keys are installed to vendor ramdisk - ifeq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true) # no dedicated recovery partition - my_gsi_avb_keys_path := $(TARGET_VENDOR_RAMDISK_OUT)/first_stage_ramdisk/avb - else # device has a dedicated recovery partition - my_gsi_avb_keys_path := $(TARGET_VENDOR_RAMDISK_OUT)/avb - endif -else - ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true) # no dedicated recovery partition - my_gsi_avb_keys_path := $(TARGET_RECOVERY_ROOT_OUT)/first_stage_ramdisk/avb - else # device has a dedicated recovery partition - my_gsi_avb_keys_path := $(TARGET_RAMDISK_OUT)/avb - endif -endif - -####################################### -# q-developer-gsi.avbpubkey -include $(CLEAR_VARS) - -LOCAL_MODULE := q-developer-gsi.avbpubkey -LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 -LOCAL_LICENSE_CONDITIONS := notice -LOCAL_MODULE_CLASS := ETC -LOCAL_SRC_FILES := $(LOCAL_MODULE) -LOCAL_MODULE_PATH := $(my_gsi_avb_keys_path) - -include $(BUILD_PREBUILT) - -####################################### -# r-developer-gsi.avbpubkey -include $(CLEAR_VARS) - -LOCAL_MODULE := r-developer-gsi.avbpubkey -LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 -LOCAL_LICENSE_CONDITIONS := notice -LOCAL_MODULE_CLASS := ETC -LOCAL_SRC_FILES := $(LOCAL_MODULE) -LOCAL_MODULE_PATH := $(my_gsi_avb_keys_path) - -include $(BUILD_PREBUILT) - -####################################### -# s-developer-gsi.avbpubkey -include $(CLEAR_VARS) - -LOCAL_MODULE := s-developer-gsi.avbpubkey -LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 -LOCAL_LICENSE_CONDITIONS := notice -LOCAL_MODULE_CLASS := ETC -LOCAL_SRC_FILES := $(LOCAL_MODULE) -LOCAL_MODULE_PATH := $(my_gsi_avb_keys_path) - -include $(BUILD_PREBUILT) - -my_gsi_avb_keys_path :=