From 1d80da9640b5f46790b59acf0a3deeaf10f20eba Mon Sep 17 00:00:00 2001 From: Nolen Johnson Date: Thu, 21 Nov 2024 14:05:04 -0500 Subject: [PATCH] troika: Switch to py extract Change-Id: I3d4bea635c390d8e682f878f86dee66f362ab52e --- extract-files.py | 76 ++++++++++++++++++++++++++++++++++++++++++++++ extract-files.sh | 54 -------------------------------- setup-makefiles.py | 1 + setup-makefiles.sh | 16 ---------- 4 files changed, 77 insertions(+), 70 deletions(-) create mode 100755 extract-files.py delete mode 100755 extract-files.sh create mode 100755 setup-makefiles.py delete mode 100755 setup-makefiles.sh diff --git a/extract-files.py b/extract-files.py new file mode 100755 index 0000000..266ffe2 --- /dev/null +++ b/extract-files.py @@ -0,0 +1,76 @@ +#!/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_remove, + lib_fixup_vendorcompat, + lib_fixups, + lib_fixups_user_type, + libs_proto_3_9_1, +) + +from extract_utils.main import ( + ExtractUtils, + ExtractUtilsModule, +) + +namespace_imports = [ + 'vendor/motorola/exynos9610-common', + 'device/motorola/exynos9610-common', + 'hardware/samsung_slsi-linaro/graphics', +] + +libs_add_vendor_suffix = ( + 'libhwjpeg', +) + +def lib_fixup_vendor_suffix(lib: str, partition: str, *args, **kwargs): + return f'{lib}_{partition}' if partition == 'vendor' else None + +libs_remove = ( + 'libandroidicu', + 'libcsc', + 'libexynosutils', + 'libexynosv4l2', + 'libGrallocWrapper', +) + +lib_fixups: lib_fixups_user_type = { + libs_proto_3_9_1: lib_fixup_vendorcompat, + libs_add_vendor_suffix: lib_fixup_vendor_suffix, + libs_remove: lib_fixup_remove, +} + +blob_fixups: blob_fixups_user_type = { + 'vendor/lib/libaudioproxy.so': blob_fixup() + .patchelf_version('0_18') + .add_needed('libaudioproxy_shim.so'), + ('vendor/lib/sensors.chub.so', 'vendor/lib64/sensors.chub.so', 'vendor/lib/hw/sensors.troika_sprout.so', 'vendor/lib64/hw/sensors.troika_sprout.so'): blob_fixup() + .patchelf_version('0_18') + .replace_needed('libutils.so', 'libutils-v32.so'), + ('vendor/lib/libril_sitril.so', 'vendor/lib64/libril_sitril.so'): blob_fixup() + .patchelf_version('0_18') + .remove_needed('libhidltransport.so') + .remove_needed('libhwbinder.so'), +} # fmt: skip + +module = ExtractUtilsModule( + 'troika', + 'motorola', + namespace_imports=namespace_imports, + blob_fixups=blob_fixups, + lib_fixups=lib_fixups, + add_firmware_proprietary_file=True, +) + +if __name__ == '__main__': + utils = ExtractUtils.device_with_common(module, 'exynos9610-common', module.vendor) + utils.run() diff --git a/extract-files.sh b/extract-files.sh deleted file mode 100755 index 7e507f4..0000000 --- a/extract-files.sh +++ /dev/null @@ -1,54 +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 - # Missing libaudioproxy symbols - vendor/lib/libaudioproxy.so) - [ "$2" = "" ] && return 0 - for LIBAUDIOPROXY_SHIM in $(grep -L "libaudioproxy_shim.so" "${2}"); do - "${PATCHELF}" --add-needed "libaudioproxy_shim.so" "${LIBAUDIOPROXY_SHIM}" - done - ;; - # Missing libutils symbols - vendor/lib*/sensors.chub.so|vendor/lib*/hw/sensors.troika_sprout.so) - [ "$2" = "" ] && return 0 - "${PATCHELF}" --replace-needed "libutils.so" "libutils-v32.so" "${2}" - ;; - # Remove libhidltransport/libhwbinder dependencies - vendor/lib*/libril_sitril.so) - [ "$2" = "" ] && return 0 - "${PATCHELF}" --remove-needed "libhidltransport.so" "${2}" - "${PATCHELF}" --remove-needed "libhwbinder.so" "${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=troika -export DEVICE_COMMON=exynos9610-common -export VENDOR=motorola -export VENDOR_COMMON=${VENDOR} - -"./../../${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 92fbc38..0000000 --- a/setup-makefiles.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2016 The CyanogenMod Project -# Copyright (C) 2017-2020 The LineageOS Project -# -# SPDX-License-Identifier: Apache-2.0 -# - -set -e - -export DEVICE=troika -export DEVICE_COMMON=exynos9610-common -export VENDOR=motorola -export VENDOR_COMMON=${VENDOR} - -"./../../${VENDOR_COMMON}/${DEVICE_COMMON}/setup-makefiles.sh" "$@"