From: Bruno Martins Date: Sun, 20 Oct 2024 10:35:53 +0000 (+0100) Subject: sabrina: Adopt Python extract utils X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=refs%2Fheads%2Flineage-22.0;p=GitHub%2FLineageOS%2FG12%2Fandroid_device_google_sabrina.git sabrina: Adopt Python extract utils Change-Id: I56cc92329e15a50a86da2239b91822aee59e8d2b --- diff --git a/extract-files.py b/extract-files.py new file mode 100755 index 0000000..eabfaf9 --- /dev/null +++ b/extract-files.py @@ -0,0 +1,53 @@ +#!/usr/bin/env -S PYTHONPATH=../../../tools/extract-utils python3 +# +# SPDX-FileCopyrightText: 2024 The LineageOS Project +# SPDX-License-Identifier: Apache-2.0 +# + +from extract_utils.fixups_blob import ( + blob_fixup, + blob_fixups_user_type, +) + +from extract_utils.fixups_lib import ( + lib_fixup_vendorcompat, + lib_fixups_user_type, + libs_proto_3_9_1, +) + +from extract_utils.main import ( + ExtractUtils, + ExtractUtilsModule, +) + +namespace_imports = [ + 'vendor/amlogic/sm1-common', +] + +blob_fixups: blob_fixups_user_type = { + 'vendor/bin/hw/android.hardware.security.keymint-service.amlogic': blob_fixup() + .replace_needed('android.hardware.security.keymint-V1-ndk_platform.so', 'android.hardware.security.keymint-V3-ndk.so') + .replace_needed('android.hardware.security.secureclock-V1-ndk_platform.so', 'android.hardware.security.secureclock-V1-ndk.so') + .replace_needed('android.hardware.security.sharedsecret-V1-ndk_platform.so', 'android.hardware.security.sharedsecret-V1-ndk.so'), + 'vendor/etc/init/led_control_service.rc': blob_fixup() + .regex_replace(' seclabel u:r:led_control_service:s0', ''), + 'vendor/etc/init/tee-supplicant.rc': blob_fixup() + .regex_replace('/vendor/lib/', '/vendor/lib/modules/'), +} # fmt: skip + +lib_fixups: lib_fixups_user_type = { + libs_proto_3_9_1: lib_fixup_vendorcompat, +} + +module = ExtractUtilsModule( + 'sabrina', + 'google', + blob_fixups=blob_fixups, + lib_fixups=lib_fixups, + namespace_imports=namespace_imports, + add_firmware_proprietary_file=True, +) + +if __name__ == '__main__': + utils = ExtractUtils.device_with_common(module, '../amlogic/sm1-common', module.vendor) + utils.run() diff --git a/extract-files.sh b/extract-files.sh deleted file mode 100755 index c00efdb..0000000 --- a/extract-files.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -# -# SPDX-FileCopyrightText: 2016 The CyanogenMod Project -# SPDX-FileCopyrightText: 2017-2024 The LineageOS Project -# -# SPDX-License-Identifier: Apache-2.0 -# - -function blob_fixup() { - case "${1}" in - vendor/bin/hw/android.hardware.security.keymint-service.amlogic) - [ "$2" = "" ] && return 0 - "${PATCHELF_0_18}" --replace-needed "android.hardware.security.keymint-V1-ndk_platform.so" "android.hardware.security.keymint-V3-ndk.so" "${2}" - "${PATCHELF_0_18}" --replace-needed "android.hardware.security.secureclock-V1-ndk_platform.so" "android.hardware.security.secureclock-V1-ndk.so" "${2}" - "${PATCHELF_0_18}" --replace-needed "android.hardware.security.sharedsecret-V1-ndk_platform.so" "android.hardware.security.sharedsecret-V1-ndk.so" "${2}" - ;; - # Use generic Light HAL context for led_control_service - vendor/etc/init/led_control_service.rc) - [ "$2" = "" ] && return 0 - sed -i "8d" "${2}" - ;; - vendor/etc/init/tee-supplicant.rc) - [ "$2" = "" ] && return 0 - sed -i 's#/vendor/lib/#/vendor/lib/modules/#g' "${2}" - ;; - *) - return 1 - ;; - esac - - return 0 -} - -function blob_fixup_dry() { - blob_fixup "$1" "" -} - -# If we're being sourced by the common script that we called, -# stop right here. No need to go down the rabbit hole. -if [ "${BASH_SOURCE[0]}" != "${0}" ]; then - return -fi - -set -e - -export DEVICE=sabrina -export DEVICE_COMMON=sm1-common -export VENDOR=google -export VENDOR_BRAND="${VENDOR}" -export VENDOR_COMMON=amlogic - -"./../../${VENDOR_COMMON}/${DEVICE_COMMON}/extract-files.sh" "$@" diff --git a/setup-makefiles.py b/setup-makefiles.py new file mode 100755 index 0000000..32947cf --- /dev/null +++ b/setup-makefiles.py @@ -0,0 +1 @@ +#!./extract-files.py --regenerate_makefiles diff --git a/setup-makefiles.sh b/setup-makefiles.sh deleted file mode 100755 index 063d897..0000000 --- a/setup-makefiles.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# -# SPDX-FileCopyrightText: 2016 The CyanogenMod Project -# SPDX-FileCopyrightText: 2017-2024 The LineageOS Project -# -# SPDX-License-Identifier: Apache-2.0 -# - -# If we're being sourced by the common script that we called, -# stop right here. No need to go down the rabbit hole. -if [ "${BASH_SOURCE[0]}" != "${0}" ]; then - return -fi - -set -e - -export DEVICE=sabrina -export DEVICE_COMMON=sm1-common -export VENDOR=google -export VENDOR_BRAND="${VENDOR}" -export VENDOR_COMMON=amlogic - -"./../../${VENDOR_COMMON}/${DEVICE_COMMON}/setup-makefiles.sh" "$@"