extract-files.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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.extract import extract_fns_user_type
  7. from extract_utils.extract_pixel import (
  8. extract_pixel_factory_image,
  9. extract_pixel_firmware,
  10. pixel_factory_image_regex,
  11. pixel_firmware_regex,
  12. )
  13. from extract_utils.file import FileArgs, FileList
  14. from extract_utils.fixups_blob import (
  15. blob_fixup,
  16. blob_fixups_user_type,
  17. )
  18. from extract_utils.fixups_lib import (
  19. lib_fixup_remove,
  20. lib_fixups,
  21. lib_fixups_user_type,
  22. )
  23. from extract_utils.main import (
  24. ExtractUtils,
  25. ExtractUtilsModule,
  26. )
  27. namespace_imports = [
  28. 'device/google/lynx',
  29. 'hardware/google/av',
  30. 'hardware/google/gchips',
  31. 'hardware/google/graphics/common',
  32. 'hardware/google/interfaces',
  33. 'hardware/google/pixel',
  34. 'hardware/qcom/wlan/wcn6740',
  35. ]
  36. def lib_fixup_vendor_suffix(lib: str, partition: str, *args, **kwargs):
  37. return f'{lib}_{partition}' if partition == 'vendor' else None
  38. lib_fixups: lib_fixups_user_type = {
  39. **lib_fixups,
  40. (
  41. 'com.google.edgetpu_app_service-V3-ndk',
  42. 'com.google.edgetpu_vendor_service-V2-ndk',
  43. ): lib_fixup_vendor_suffix,
  44. 'libwpa_client': lib_fixup_remove,
  45. }
  46. blob_fixups: blob_fixups_user_type = {
  47. 'product/etc/felica/common.cfg': blob_fixup()
  48. .patch_file('osaifu-keitai.patch'),
  49. 'vendor/etc/init/init.modem_logging_control.rc': blob_fixup()
  50. .regex_replace(' && property:ro.debuggable=0', ''),
  51. } # fmt: skip
  52. extract_fns: extract_fns_user_type = {
  53. pixel_factory_image_regex: extract_pixel_factory_image,
  54. pixel_firmware_regex: extract_pixel_firmware,
  55. }
  56. module = ExtractUtilsModule(
  57. 'lynx',
  58. 'google',
  59. device_rel_path='device/google/lynx/lynx',
  60. blob_fixups=blob_fixups,
  61. lib_fixups=lib_fixups,
  62. namespace_imports=namespace_imports,
  63. add_generated_carriersettings_file=True,
  64. add_firmware_proprietary_file=True,
  65. extract_fns=extract_fns,
  66. )
  67. def fix_vendor_file_list(file_list: FileList):
  68. # flp.default & gps.default have incorrect SONAME
  69. # lowi-server depends on libwpa_client, which is a gnu makefile target
  70. disable_checkelf_file_paths = [
  71. 'vendor/bin/lowi-server',
  72. 'vendor/lib64/hw/flp.default.so',
  73. 'vendor/lib64/hw/gps.default.so',
  74. ]
  75. for file_path in disable_checkelf_file_paths:
  76. file_list.get_file(file_path).set_arg(FileArgs.DISABLE_CHECKELF, True)
  77. module_suffix_file_paths = [
  78. 'vendor/lib/com.google.edgetpu_app_service-V3-ndk.so',
  79. 'vendor/lib64/com.google.edgetpu_app_service-V3-ndk.so',
  80. 'vendor/lib64/com.google.edgetpu_vendor_service-V2-ndk.so',
  81. ]
  82. for file_path in module_suffix_file_paths:
  83. file_list.get_file(file_path).set_arg(FileArgs.MODULE_SUFFIX, '_vendor')
  84. module.add_generated_proprietary_file(
  85. 'proprietary-files-vendor.txt',
  86. partition='vendor',
  87. skip_file_list_name='skip-files-vendor.txt',
  88. fix_file_list=fix_vendor_file_list,
  89. )
  90. if __name__ == '__main__':
  91. utils = ExtractUtils.device(module)
  92. utils.run()