Last active
October 7, 2024 19:26
-
-
Save Demon000/7c1ff7891920a5a5bb8000d32c598eff to your computer and use it in GitHub Desktop.
extract-files.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # Copyright (C) 2024 The LineageOS Project | |
| # | |
| # SPDX-License-Identifier: Apache-2.0 | |
| # | |
| from typing import List | |
| from extract_utils.main import ( | |
| ExtractUtilsModule, | |
| ) | |
| from extract_utils.fixups_blob import ( | |
| blob_fixups_user_type, | |
| blob_fixup, | |
| ) | |
| from extract_utils.fixups_lib import ( | |
| lib_fixups_user_type, | |
| lib_fixup_vendorcompat, | |
| libs_proto_3_9_1, | |
| ) | |
| from extract_utils.extract import ExtractCtx | |
| from extract_utils.extract_star import extract_star_file_names | |
| namespace_imports = [ | |
| 'device/motorola/sm8475-common', | |
| 'hardware/qcom-caf/sm8450', | |
| 'hardware/qcom-caf/wlan', | |
| 'vendor/qcom/opensource/commonsys/display', | |
| 'vendor/qcom/opensource/dataservices', | |
| ] | |
| libs_add_vendor_suffix = ( | |
| '[email protected]', | |
| '[email protected]', | |
| '[email protected]', | |
| '[email protected]', | |
| '[email protected]', | |
| '[email protected]', | |
| ) | |
| libs_remove = ( | |
| '[email protected]', | |
| 'libagmclient', | |
| 'libpalclient', | |
| 'libwpa_client', | |
| 'libqsap_sdk', | |
| ) | |
| def lib_fixup_vendor_suffix(lib: str, partition: str, *args, **kwargs): | |
| if partition != 'vendor': | |
| return None | |
| return f'{lib}-{partition}' | |
| def lib_fixup_remove(lib: str, *args, **kwargs): | |
| return '' | |
| 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 = { | |
| 'system_ext/etc/permissions/moto-telephony.xml': blob_fixup().regex_replace( | |
| '/system/', '/system_ext/' | |
| ), | |
| ( | |
| 'vendor/bin/hw/android.hardware.security.keymint-service-qti', | |
| 'vendor/lib64/libqtikeymint.so', | |
| ): blob_fixup() | |
| .replace_needed( | |
| 'android.hardware.security.keymint-V1-ndk_platform.so', | |
| 'android.hardware.security.keymint-V1-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', | |
| ) | |
| .add_needed('android.hardware.security.rkp-V1-ndk.so'), | |
| 'vendor/bin/qcc-trd': blob_fixup().replace_needed( | |
| 'libgrpc++_unsecure.so', 'libgrpc++_unsecure_prebuilt.so' | |
| ), | |
| 'vendor/lib64/libmotext_inf.so': blob_fixup().remove_needed('libril.so'), | |
| 'system_ext/priv-app/ims/ims.apk': blob_fixup().apktool_patch( | |
| 'ims-patches' | |
| ), | |
| } | |
| extracted_firmware_files = ['bootloader.img', 'radio.img'] | |
| def firmware_extract( | |
| ctx: ExtractCtx, | |
| work_dir: str, | |
| dump_dir: str, | |
| *args, | |
| **kwargs, | |
| ) -> List[str]: | |
| return extract_star_file_names( | |
| ctx, work_dir, dump_dir, extracted_firmware_files | |
| ) | |
| module = ExtractUtilsModule( | |
| 'sm8475-common', | |
| 'motorola', | |
| blob_fixups=blob_fixups, | |
| lib_fixups=lib_fixups, | |
| namespace_imports=namespace_imports, | |
| extracted_firmware_files=extracted_firmware_files, | |
| extract_fns=[ | |
| firmware_extract, | |
| ], | |
| check_elf=True, | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env -S PYTHONPATH=../../../tools/extract-utils python3 | |
| # | |
| # Copyright (C) 2024 The LineageOS Project | |
| # | |
| # SPDX-License-Identifier: Apache-2.0 | |
| # | |
| from extract_utils.main import ( | |
| ExtractUtils, | |
| ExtractUtilsModule, | |
| ) | |
| from extract_utils.fixups_blob import ( | |
| blob_fixups_user_type, | |
| blob_fixup, | |
| ) | |
| namespace_imports = [ | |
| 'hardware/qcom-caf/sm8450', | |
| 'vendor/qcom/opensource/commonsys-intf/display', | |
| ] | |
| blob_fixups: blob_fixups_user_type = { | |
| 'vendor/lib64/libcamximageformatutils.so': blob_fixup().replace_needed( | |
| 'vendor.qti.hardware.display.config-V2-ndk_platform.so', | |
| 'vendor.qti.hardware.display.config-V2-ndk.so', | |
| ), | |
| } | |
| module = ExtractUtilsModule( | |
| 'eqs', | |
| 'motorola', | |
| blob_fixups=blob_fixups, | |
| namespace_imports=namespace_imports, | |
| check_elf=True, | |
| ) | |
| module.add_generated_carriersettings() | |
| module.add_firmware_proprietary_file() | |
| if __name__ == '__main__': | |
| utils = ExtractUtils.device_with_common( | |
| module, 'sm8475-common', module.vendor | |
| ) | |
| utils.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment