extract-files.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/usr/bin/env -S PYTHONPATH=../../../tools/extract-utils python3
  2. #
  3. # SPDX-FileCopyrightText: 2024 The LineageOS Project
  4. # SPDX-License-Identifier: Apache-2.0
  5. #
  6. from extract_utils.file import File
  7. from extract_utils.fixups_blob import (
  8. BlobFixupCtx,
  9. blob_fixup,
  10. blob_fixups_user_type,
  11. )
  12. from extract_utils.fixups_lib import (
  13. lib_fixup_remove,
  14. lib_fixups,
  15. lib_fixups_user_type,
  16. )
  17. from extract_utils.main import (
  18. ExtractUtils,
  19. ExtractUtilsModule,
  20. )
  21. namespace_imports = [
  22. # FIXME
  23. 'device/samsung/e1q',
  24. 'hardware/samsung',
  25. 'kernel/samsung/sm8650',
  26. 'kernel/samsung/sm8650-modules',
  27. 'hardware/qcom-caf/sm8650',
  28. 'vendor/qcom/opensource/commonsys/display',
  29. 'vendor/qcom/opensource/commonsys-intf/display',
  30. 'hardware/qcom-caf/sm8650/data-ipa-cfg-mgr',
  31. 'vendor/qcom/opensource/dataservices',
  32. 'hardware/qcom-caf/wlan',
  33. ]
  34. def lib_fixup_vendor_suffix(lib: str, partition: str, *args, **kwargs):
  35. return f'{lib}_{partition}' if partition == 'vendor' else None
  36. lib_fixups: lib_fixups_user_type = {
  37. **lib_fixups,
  38. (
  39. 'libsecril-client'
  40. ): lib_fixup_vendor_suffix,
  41. (
  42. 'libagmclient',
  43. 'libpalclient',
  44. 'libwpa_client'
  45. ): lib_fixup_remove,
  46. }
  47. blob_fixups: blob_fixups_user_type = {
  48. ('vendor/lib64/libskeymint_cli.so','vendor/lib64/hw/gatekeeper.mdfpp.so'): blob_fixup()
  49. .replace_needed('libcrypto.so', 'libcrypto-v33.so'),
  50. 'vendor/etc/seccomp_policy/[email protected]': blob_fixup()
  51. .add_line_if_missing('gettid: 1'),
  52. 'vendor/lib64/libsec-ril.so': blob_fixup()
  53. .binary_regex_replace(b'ril.dds.call.ongoing', b'vendor.calls.slot_id')
  54. # mov x3, x21 -> mov x3, #0
  55. .sig_replace('bf c2 00 f8 76 0e 40 f9 80 0e 40 f9 e1 03 16 aa 82 0c 80 52 e3 03 15 aa 24 00 80 52 08 00 40 f9', 'bf c2 00 f8 76 0e 40 f9 80 0e 40 f9 e1 03 16 aa 82 0c 80 52 03 00 80 d2 24 00 80 52 08 00 40 f9'),
  56. 'vendor/lib64/libqcodec2_core.so': blob_fixup()
  57. .add_needed('libcodec2_shim.so'),
  58. 'vendor/lib64/unihal_android.so': blob_fixup()
  59. .add_needed('libui_shim.so'),
  60. 'vendor/etc/vintf/manifest/sec_c2_manifest_default0_1_2.xml': blob_fixup()
  61. .regex_replace('default0', 'software'),
  62. ('vendor/etc/media_codecs.xml', 'vendor/etc/media_codecs_pineapple.xml', 'vendor/etc/media_codecs_pineapple_vendor.xml'): blob_fixup()
  63. .regex_replace('.*media_codecs_(google_audio|google_c2|google_telephony|google_video|vendor_audio).*\n', ''),
  64. 'vendor/lib64/vendor.samsung.hardware.camera.vcc-V1-ndk.so': blob_fixup()
  65. .replace_needed('android.hardware.graphics.common-V4-ndk.so', 'android.hardware.graphics.common-V5-ndk.so'),
  66. } # fmt: skip
  67. module = ExtractUtilsModule(
  68. 'e1q',
  69. 'samsung',
  70. blob_fixups=blob_fixups,
  71. lib_fixups=lib_fixups,
  72. namespace_imports=namespace_imports,
  73. check_elf=True
  74. )
  75. if __name__ == '__main__':
  76. utils = ExtractUtils.device(module)
  77. utils.run()