otter: Switch to python extract-utils
Change-Id: Ida4b83459d9739ac880b26a91df974e1db8423e9
diff --git a/extract-files.py b/extract-files.py
new file mode 100755
index 0000000..a25394e
--- /dev/null
+++ b/extract-files.py
@@ -0,0 +1,79 @@
+#!/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_remove_arch_suffix,
+ lib_fixup_vendorcompat,
+ lib_fixups_user_type,
+ libs_clang_rt_ubsan,
+ libs_proto_3_9_1,
+)
+from extract_utils.main import (
+ ExtractUtils,
+ ExtractUtilsModule,
+)
+
+namespace_imports = [
+ 'device/shift/otter',
+ 'hardware/qcom-caf/sm8350',
+ 'hardware/qcom-caf/wlan',
+ 'vendor/qcom/opensource/commonsys/display',
+ 'vendor/qcom/opensource/commonsys-intf/display',
+ 'vendor/qcom/opensource/dataservices',
+ 'vendor/qcom/opensource/display',
+]
+
+
+def lib_fixup_vendor_suffix(lib: str, partition: str, *args, **kwargs):
+ return f'{lib}_{partition}' if partition == 'vendor' else None
+
+
+lib_fixups: lib_fixups_user_type = {
+ libs_clang_rt_ubsan: lib_fixup_remove_arch_suffix,
+ libs_proto_3_9_1: lib_fixup_vendorcompat,
+ (
+ 'com.qualcomm.qti.dpm.api@1.0',
+ 'libmmosal',
+ 'vendor.qti.hardware.wifidisplaysession@1.0',
+ 'vendor.qti.imsrtpservice@3.0',
+ ): lib_fixup_vendor_suffix,
+ (
+ 'libOmxCore',
+ 'libwpa_client',
+ ): lib_fixup_remove,
+}
+
+blob_fixups: blob_fixups_user_type = {
+ 'system_ext/lib/libwfdmmsrc_system.so': blob_fixup()
+ .add_needed('libgui_shim.so'),
+ 'system_ext/lib/libwfdservice.so': blob_fixup()
+ .replace_needed('android.media.audio.common.types-V2-cpp.so', 'android.media.audio.common.types-V3-cpp.so'),
+ 'system_ext/lib64/libwfdnative.so': blob_fixup()
+ .replace_needed('android.hidl.base@1.0.so', 'libhidlbase.so')
+ .add_needed('libinput_shim.so'),
+ 'vendor/lib64/hw/fingerprint.lahaina.so': blob_fixup()
+ .fix_soname(),
+ 'vendor/lib64/libwvhidl.so': blob_fixup()
+ .add_needed('libcrypto_shim.so'),
+} # fmt: skip
+
+module = ExtractUtilsModule(
+ 'otter',
+ 'shift',
+ blob_fixups=blob_fixups,
+ lib_fixups=lib_fixups,
+ namespace_imports=namespace_imports,
+ add_firmware_proprietary_file=True,
+)
+
+if __name__ == '__main__':
+ utils = ExtractUtils.device(module)
+ utils.run()