-
Notifications
You must be signed in to change notification settings - Fork 101
/
Copy pathextract-files.py
executable file
·112 lines (106 loc) · 5.74 KB
/
extract-files.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/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_fixups,
lib_fixups_user_type,
)
from extract_utils.main import (
ExtractUtils,
ExtractUtilsModule,
)
namespace_imports = [
'device/xiaomi/mido',
'hardware/qcom-caf/msm8953',
'vendor/qcom/opensource/dataservices',
'vendor/qcom/opensource/commonsys/display',
'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 = {
**lib_fixups,
(
'libmmosal',
): lib_fixup_vendor_suffix,
('libwpa_client'): lib_fixup_remove,
}
# Define the blob fixups
blob_fixups: blob_fixups_user_type = {
# Camera - Path fixups
'vendor/bin/mm-qcamera-daemon': blob_fixup()
.regex_replace(r'/data/misc/camera/cam_socket', r'/data/vendor/qcam/cam_socket'),
'vendor/lib/libmmcamera2_sensor_modules.so': blob_fixup()
.regex_replace(r'/system/etc/camera', r'/vendor/etc/camera'),
('vendor/lib/libmmcamera2_cpp_module.so', 'vendor/lib/libmmcamera2_dcrf.so', 'vendor/lib/libmmcamera2_iface_modules.so', 'vendor/lib/libmmcamera2_imglib_modules.so', 'vendor/lib/libmmcamera2_mct.so', 'vendor/lib/libmmcamera2_pproc_modules.so', 'vendor/lib/libmmcamera2_q3a_core.so', 'vendor/lib/libmmcamera2_sensor_modules.so', 'vendor/lib/libmmcamera2_stats_algorithm.so', 'vendor/lib/libmmcamera2_stats_modules.so', 'vendor/lib/libmmcamera_dbg.so', 'vendor/lib/libmmcamera_imglib.so', 'vendor/lib/libmmcamera_pdafcamif.so', 'vendor/lib/libmmcamera_pdaf.so', 'vendor/lib/libmmcamera_tintless_algo.so', 'vendor/lib/libmmcamera_tintless_bg_pca_algo.so', 'vendor/lib/libmmcamera_tuning.so'): blob_fixup()
.regex_replace(r'/data/misc/camera/', r'/data/vendor/qcam/'),
# Camera - Property fixup
'vendor/lib/libmmcamera_dbg.so': blob_fixup()
.regex_replace(r'persist.camera.debug.logfile', r'persist.vendor.camera.dbglog'),
# Camera - - libstdc++.so' -> 'libstdc++_vendor.so
('vendor/lib/libmmcamera_hdr_gb_lib.so', 'vendor/lib/libmpbase.so', 'vendor/lib/liboptizoom.so', 'vendor/lib/libseemore.so', 'vendor/lib/libtrueportrait.so', 'vendor/lib/libubifocus.so', 'vendor/lib/libchromaflash.so'): blob_fixup()
.replace_needed('libstdc++.so', 'libstdc++_vendor.so'),
# Camera - shims, uneeded & VNDK fixups
'vendor/lib/libmmcamera_ppeiscore.so': blob_fixup()
.add_needed('libppeiscore_shim.so')
.replace_needed('libGLESv2.so', 'libGLESv2_adreno.so'),
'vendor/lib/libmmcamera_tuning.so': blob_fixup()
.remove_needed('libmm-qcamera.so'),
('vendor/lib/libmmcamera2_stats_modules.so', 'vendor/lib/libmpbase.so'): blob_fixup()
.add_needed('libcamshim.so')
.remove_needed('libandroid.so'),
# Camera - liblog dep.
('vendor/lib/libmmcamera_dbg.so', 'vendor/lib/libmmcamera_pdafcamif.so', 'vendor/lib/libmmcamera_pdaf.so', 'vendor/lib/libmmcamera_imx258_mono.so', 'vendor/lib/libjpegehw.so', 'vendor/lib/libjpegdhw.so', 'vendor/lib/libmmcamera_hdr_gb_lib.so', 'vendor/lib/libmmcamera_imx258_ofilm.so', 'vendor/lib/libmmcamera_imx258_sunny.so', 'vendor/lib/libmmcamera2_sensor_modules.so', 'vendor/lib/libjpegdmahw.so', 'vendor/lib/libmmcamera_imx258.so', 'vendor/lib/libmmcamera_imx258_qtech.so', 'vendor/lib/libmmcamera_le2464c_master_eeprom.so', 'vendor/lib/libmmcamera_tintless_bg_pca_algo.so', 'vendor/lib/libqomx_jpegenc.so', 'vendor/lib/libqomx_jpegdec.so', 'vendor/lib/libqomx_jpegenc_pipe.so'): blob_fixup()
.add_needed('liblog.so'),
# Dolby
('vendor/lib64/libdlbdsservice.so', 'vendor/lib/libstagefright_soft_ddpdec.so'): blob_fixup()
.replace_needed('libstagefright_foundation.so', 'libstagefright_foundation-v33.so'),
# Fingerprint - shims & uneeded
'vendor/bin/gx_fpd': blob_fixup()
.remove_needed('libunwind.so')
.remove_needed('libbacktrace.so')
.add_needed('libshims_gxfpd.so')
.add_needed('fakelogprint.so'),
'vendor/lib64/libfpservice.so': blob_fixup()
.add_needed('libbinder_shim.so'),
('vendor/lib64/hw/fingerprint.goodix.so', 'vendor/lib64/gxfingerprint.default.so'): blob_fixup()
.add_needed('fakelogprint.so'),
# Fingerprint - liblog dep.
('vendor/lib64/libfp_client.so', 'libfpservice.so'): blob_fixup()
.add_needed('liblog.so'),
# Fingerprint - libstdc++.so' -> 'libstdc++_vendor.so
('vendor/lib64/libfp_client.so', 'vendor/lib64/libfpservice.so', 'vendor/lib64/libfpnav.so', 'vendor/lib64/hw/fingerprint.goodix.so', 'vendor/lib64/gxfingerprint.default.so'): blob_fixup()
.replace_needed('libstdc++.so', 'libstdc++_vendor.so'),
# Fingerprint - so name fixups
('vendor/lib64/hw/fingerprint.goodix.so', 'vendor/lib64/hw/gxfingerprint.default.so'):blob_fixup()
.fix_soname(),
# IMS
'system_ext/lib64/lib-imscamera.so': blob_fixup()
.add_needed('libgui_shim.so'),
'system_ext/lib64/lib-imsvideocodec.so': blob_fixup()
.add_needed('libgui_shim.so')
.replace_needed('libqdMetaData.so', 'libqdMetaData.system.so'),
# Thermal
'vendor/lib64/libthermalfeature.so': blob_fixup()
.regex_replace(r'system/etc/', r'vendor/etc/'),
} # fmt: skip
# Define the module
module = ExtractUtilsModule(
'mido',
'xiaomi',
blob_fixups=blob_fixups,
lib_fixups=lib_fixups,
namespace_imports=namespace_imports,
)
if __name__ == '__main__':
utils = ExtractUtils.device(module)
utils.run()