a71-common: Switch to py extract utils

* [Haky86]: Also add missing shared libraries.

Co-authored-by: LuK1337 <priv.luk@gmail.com>
Co-authored-by: Haky86 <hakamelassouad@gmail.com>

Change-Id: I10a2bc3472ff3294823a4565f80b558c6c14d9ec
This commit is contained in:
LuK1337
2024-11-03 11:12:47 +01:00
committed by Haky86
parent e71b48c87d
commit c0f6e6291a
5 changed files with 84 additions and 188 deletions

79
extract-files.py Executable file
View File

@@ -0,0 +1,79 @@
#!/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_fixup_remove_arch_suffix,
lib_fixup_vendorcompat,
lib_fixups_user_type,
libs_clang_rt_ubsan,
libs_proto_3_9_1,
)
from extract_utils.main import (
ExtractUtils,
ExtractUtilsModule,
)
namespace_imports = [
'device/samsung/a71-common',
'hardware/qcom-caf/sm8150',
'hardware/qcom-caf/wlan',
'hardware/samsung',
'vendor/qcom/opensource/dataservices',
'vendor/qcom/opensource/commonsys/display',
'vendor/qcom/opensource/commonsys-intf/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 = {
libs_clang_rt_ubsan: lib_fixup_remove_arch_suffix,
libs_proto_3_9_1: lib_fixup_vendorcompat,
(
'com.qualcomm.qti.ant@1.0_vendor',
'libmmosal',
): lib_fixup_vendor_suffix,
(
'libOmxCore',
'libwpa_client',
): lib_fixup_remove,
}
blob_fixups: blob_fixups_user_type = {
('vendor/lib64/hw/gatekeeper.mdfpp.so', 'vendor/lib64/libkeymaster_helper.so', 'vendor/lib64/libskeymaster4device.so'): blob_fixup()
.replace_needed('libcrypto.so', 'libcrypto-v33.so'),
('vendor/lib/mediadrm/libwvdrmengine.so', 'vendor/lib/libwvhidl.so'): blob_fixup()
.add_needed('libcrypto_shim.so'),
'vendor/lib/libDualCamBokehCapture.camera.samsung.so': blob_fixup()
.add_needed('libhigh_dynamic_range_bokeh.so'),
'vendor/lib64/libsec-ril.so': blob_fixup()
.binary_regex_replace(b'ril.dds.call.ongoing', b'vendor.calls.slot_id')
.sig_replace('E1 03 15 AA 08 00 40 F9 E3 03 14 AA 08 09 40 F9', 'E1 03 15 AA 08 00 40 F9 03 00 80 D2 08 09 40 F9'),
'vendor/lib/libsensorlistener.so': blob_fixup()
.add_needed('libshim_sensorndkbridge.so'),
} # fmt: skip
module = ExtractUtilsModule(
'a71-common',
'samsung',
blob_fixups=blob_fixups,
lib_fixups=lib_fixups,
namespace_imports=namespace_imports,
check_elf=True,
)
if __name__ == '__main__':
utils = ExtractUtils.device(module)
utils.run()

View File

@@ -1,100 +0,0 @@
#!/bin/bash
#
# Copyright (C) 2024 The LineageOS Project
#
# SPDX-License-Identifier: Apache-2.0
#
set -e
# Load extract_utils and do some sanity checks
MY_DIR="${BASH_SOURCE%/*}"
if [[ ! -d "${MY_DIR}" ]]; then MY_DIR="${PWD}"; fi
ANDROID_ROOT="${MY_DIR}/../../.."
export TARGET_ENABLE_CHECKELF=true
HELPER="${ANDROID_ROOT}/tools/extract-utils/extract_utils.sh"
if [ ! -f "${HELPER}" ]; then
echo "Unable to find helper script at ${HELPER}"
exit 1
fi
source "${HELPER}"
function blob_fixup() {
case "${1}" in
vendor/lib64/libsec-ril.so)
# Replace SlotID prop
sed -i 's/ril.dds.call.ongoing/vendor.calls.slot_id/g' "${2}"
# Pass an empty value to SecRil::RequestComplete in OnGetSmscAddressDone (mov x3,x20 -> mov,x3,#0x0)
xxd -p -c0 "${2}" | sed "s/600e40f9820c805224008052e10315aa080040f9e30314aa/600e40f9820c805224008052e10315aa080040f9030080d2/g" | xxd -r -p > "${2}".patched
mv "${2}".patched "${2}"
;;
vendor/lib*/libsensorlistener.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --add-needed "libshim_sensorndkbridge.so" "${2}"
;;
vendor/lib/mediadrm/libwvdrmengine.so|vendor/lib/libwvhidl.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --add-needed "libcrypto_shim.so" "${2}"
;;
vendor/lib64/hw/gatekeeper.mdfpp.so|vendor/lib64/libkeymaster_helper.so|vendor/lib64/libskeymaster4device.so)
"${PATCHELF}" --replace-needed "libcrypto.so" "libcrypto-v33.so" "${2}"
;;
esac
}
# Default to sanitizing the vendor folder before extraction
CLEAN_VENDOR=true
ONLY_COMMON=
ONLY_TARGET=
KANG=
SECTION=
while [ "${#}" -gt 0 ]; do
case "${1}" in
--only-common )
ONLY_COMMON=true
;;
--only-target )
ONLY_TARGET=true
;;
-n | --no-cleanup )
CLEAN_VENDOR=false
;;
-k | --kang )
KANG="--kang"
;;
-s | --section )
SECTION="${2}"; shift
CLEAN_VENDOR=false
;;
* )
SRC="${1}"
;;
esac
shift
done
if [ -z "${SRC}" ]; then
SRC="adb"
fi
if [ -z "${ONLY_TARGET}" ]; then
# Initialize the helper for common device
setup_vendor "${DEVICE_COMMON}" "${VENDOR}" "${ANDROID_ROOT}" true "${CLEAN_VENDOR}"
extract "${MY_DIR}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}"
fi
if [ -z "${ONLY_COMMON}" ] && [ -s "${MY_DIR}/../${DEVICE}/proprietary-files.txt" ]; then
# Reinitialize the helper for device
source "${MY_DIR}/../${DEVICE}/extract-files.sh"
setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false "${CLEAN_VENDOR}"
extract "${MY_DIR}/../${DEVICE}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}"
fi
"${MY_DIR}/setup-makefiles.sh"

View File

@@ -32,7 +32,7 @@ vendor/lib/rfsa/adsp/libsnpe_dsp_v65_domains_v2_skel.so
vendor/lib/rfsa/adsp/libsnpe_dsp_v66_domains_v2_skel.so
# Audio
system/system_ext/framework/audiosphere.jar
system_ext/framework/audiosphere.jar
vendor/bin/audioflacapp
vendor/lib/hw/audio.primary.sm6150.so:vendor/lib/hw/audio.primary.qcom.so;FIX_SONAME
vendor/lib/hw/audio.sec_primary.default.so
@@ -144,7 +144,7 @@ vendor/lib64/vendor.samsung.hardware.bluetooth.a2dpsink@1.0.so
# Bluetooth (ANT+)
vendor/lib/com.qualcomm.qti.ant@1.0.so
vendor/lib64/com.qualcomm.qti.ant@1.0.so;MODULE_SUFFIX=_vendor
vendor/lib64/com.qualcomm.qti.ant@1.0.so
# Bluetooth (Firmware)
vendor/firmware/apbtfw11.tlv
@@ -248,6 +248,8 @@ vendor/lib/libdualcam_optical_zoom_control.so
vendor/lib/libdualcam_refocus_image.so
vendor/lib/libdualcam_refocus_video.so
vendor/lib/libdualcapture.so
vendor/lib/libhigh_dynamic_range.so
vendor/lib/libhigh_dynamic_range_bokeh.so
vendor/lib/libjpegQtable_interface.so
vendor/lib/liblivefocus_capture_engine.so
vendor/lib/liblivefocus_capture_interface.so
@@ -357,8 +359,6 @@ vendor/lib64/libjnihelper.so
vendor/lib64/libjpegQtable_interface.so
vendor/lib64/liblivefocus_capture_engine.so
vendor/lib64/liblivefocus_capture_interface.so
vendor/lib64/liblivefocus_preview_engine.so
vendor/lib64/liblivefocus_preview_interface.so
vendor/lib64/liblow_light_hdr.so
vendor/lib64/libmpbase.so
vendor/lib64/libpadm.so

1
setup-makefiles.py Executable file
View File

@@ -0,0 +1 @@
#!./extract-files.py --regenerate_makefiles

View File

@@ -1,84 +0,0 @@
#!/bin/bash
#
# Copyright (C) 2024 The LineageOS Project
#
# SPDX-License-Identifier: Apache-2.0
#
set -e
# Load extract_utils and do some sanity checks
MY_DIR="${BASH_SOURCE%/*}"
if [[ ! -d "${MY_DIR}" ]]; then MY_DIR="${PWD}"; fi
ANDROID_ROOT="${MY_DIR}/../../.."
export TARGET_ENABLE_CHECKELF=true
HELPER="${ANDROID_ROOT}/tools/extract-utils/extract_utils.sh"
if [ ! -f "${HELPER}" ]; then
echo "Unable to find helper script at ${HELPER}"
exit 1
fi
source "${HELPER}"
function vendor_imports() {
cat <<EOF >>"$1"
"device/samsung/a71-common",
"hardware/qcom-caf/sm8150",
"hardware/qcom-caf/wlan",
"hardware/samsung",
"vendor/qcom/opensource/dataservices",
"vendor/qcom/opensource/commonsys/display",
"vendor/qcom/opensource/commonsys-intf/display",
"vendor/qcom/opensource/display",
EOF
}
function lib_to_package_fixup_vendor_variants() {
if [ "$2" != "vendor" ]; then
return 1
fi
case "$1" in
com.qualcomm.qti.ant@1.0 | \
libmmosal | libantradio \
)
echo "$1_vendor"
;;
libOmxCore | \
libwpa_client) ;;
*)
return 1
;;
esac
}
function lib_to_package_fixup() {
lib_to_package_fixup_clang_rt_ubsan_standalone "$1" ||
lib_to_package_fixup_proto_3_9_1 "$1" ||
lib_to_package_fixup_vendor_variants "$@"
}
# Initialize the helper for common
setup_vendor "${DEVICE_COMMON}" "${VENDOR}" "${ANDROID_ROOT}" true
# Warning headers and guards
write_headers "a71 m51"
# The standard common blobs
write_makefiles "${MY_DIR}/proprietary-files.txt" true
# Finish
write_footers
if [ -s "${MY_DIR}/../${DEVICE}/proprietary-files.txt" ]; then
# Reinitialize the helper for device
setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false
# Warning headers and guards
write_headers
# The standard device blobs
write_makefiles "${MY_DIR}/../${DEVICE}/proprietary-files.txt" true
# Finish
write_footers
fi