extract-files.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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/e3q',
  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': 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. } # fmt: skip
  57. module = ExtractUtilsModule(
  58. 'e3q',
  59. 'samsung',
  60. blob_fixups=blob_fixups,
  61. lib_fixups=lib_fixups,
  62. namespace_imports=namespace_imports,
  63. check_elf=True
  64. )
  65. if __name__ == '__main__':
  66. utils = ExtractUtils.device(module)
  67. utils.run()