sm8550-common: Sync extract scripts with templates

Change-Id: I98a36854c5a0c0390592911bb2558b34eff77efc
This commit is contained in:
Michael Bestas
2024-09-17 15:43:15 +08:00
committed by chaptsand
parent af42246aec
commit 9d0dc390c7
2 changed files with 64 additions and 29 deletions

View File

@@ -1,8 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# Copyright (C) 2016 The CyanogenMod Project # SPDX-FileCopyrightText: 2016 The CyanogenMod Project
# Copyright (C) 2017-2020 The LineageOS Project # SPDX-FileCopyrightText: 2017-2024 The LineageOS Project
#
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
@@ -14,6 +13,10 @@ if [[ ! -d "${MY_DIR}" ]]; then MY_DIR="${PWD}"; fi
ANDROID_ROOT="${MY_DIR}/../../.." ANDROID_ROOT="${MY_DIR}/../../.."
# If XML files don't have comments before the XML header, use this flag
# Can still be used with broken XML files by using blob_fixup
export TARGET_DISABLE_XML_FIXING=true
HELPER="${ANDROID_ROOT}/tools/extract-utils/extract_utils.sh" HELPER="${ANDROID_ROOT}/tools/extract-utils/extract_utils.sh"
if [ ! -f "${HELPER}" ]; then if [ ! -f "${HELPER}" ]; then
echo "Unable to find helper script at ${HELPER}" echo "Unable to find helper script at ${HELPER}"
@@ -25,6 +28,7 @@ source "${HELPER}"
CLEAN_VENDOR=true CLEAN_VENDOR=true
ONLY_COMMON= ONLY_COMMON=
ONLY_FIRMWARE=
ONLY_TARGET= ONLY_TARGET=
KANG= KANG=
SECTION= SECTION=
@@ -34,6 +38,9 @@ while [ "${#}" -gt 0 ]; do
--only-common) --only-common)
ONLY_COMMON=true ONLY_COMMON=true
;; ;;
--only-firmware)
ONLY_FIRMWARE=true
;;
--only-target) --only-target)
ONLY_TARGET=true ONLY_TARGET=true
;; ;;
@@ -44,7 +51,8 @@ while [ "${#}" -gt 0 ]; do
KANG="--kang" KANG="--kang"
;; ;;
-s | --section) -s | --section)
SECTION="${2}"; shift SECTION="${2}"
shift
CLEAN_VENDOR=false CLEAN_VENDOR=false
;; ;;
*) *)
@@ -61,36 +69,53 @@ fi
function blob_fixup() { function blob_fixup() {
case "${1}" in case "${1}" in
vendor/bin/hw/android.hardware.security.keymint-service) vendor/bin/hw/android.hardware.security.keymint-service)
[ "$2" = "" ] && return 0
grep -q "android.hardware.security.rkp-V3-ndk.so" "${2}" || ${PATCHELF} --add-needed "android.hardware.security.rkp-V3-ndk.so" "${2}" grep -q "android.hardware.security.rkp-V3-ndk.so" "${2}" || ${PATCHELF} --add-needed "android.hardware.security.rkp-V3-ndk.so" "${2}"
${PATCHELF} --replace-needed libcrypto.so libcrypto-v33.so "${2}" ${PATCHELF} --replace-needed libcrypto.so libcrypto-v33.so "${2}"
;; ;;
vendor/lib64/hw/gatekeeper.mdfpp.so) vendor/lib64/hw/gatekeeper.mdfpp.so)
[ "$2" = "" ] && return 0
${PATCHELF} --replace-needed libcrypto.so libcrypto-v33.so "${2}" ${PATCHELF} --replace-needed libcrypto.so libcrypto-v33.so "${2}"
;; ;;
vendor/lib64/libsec-ril.so) vendor/lib64/libsec-ril.so)
[ "$2" = "" ] && return 0
xxd -p -c0 "${2}" | sed "s/600e40f9e10315aa820c8052e30314aa/600e40f9e10315aa820c8052030080d2/g" | xxd -r -p > "${2}".patched xxd -p -c0 "${2}" | sed "s/600e40f9e10315aa820c8052e30314aa/600e40f9e10315aa820c8052030080d2/g" | xxd -r -p > "${2}".patched
mv "${2}".patched "${2}" mv "${2}".patched "${2}"
sed -i 's/ril.dds.call.ongoing/vendor.calls.slot_id/g' "${2}" sed -i 's/ril.dds.call.ongoing/vendor.calls.slot_id/g' "${2}"
;; ;;
vendor/etc/vintf/manifest/sec_c2_manifest_default0_1_0.xml) vendor/etc/vintf/manifest/sec_c2_manifest_default0_1_0.xml)
[ "$2" = "" ] && return 0
sed -i 's/default0/software/g' "${2}" sed -i 's/default0/software/g' "${2}"
;; ;;
vendor/etc/media_codecs_kalama.xml|vendor/etc/media_codecs_kalama_vendor.xml) vendor/etc/media_codecs_kalama.xml|vendor/etc/media_codecs_kalama_vendor.xml)
[ "$2" = "" ] && return 0
sed -Ei "/media_codecs_(google_audio|google_c2|google_telephony|google_video|vendor_audio)/d" "${2}" sed -Ei "/media_codecs_(google_audio|google_c2|google_telephony|google_video|vendor_audio)/d" "${2}"
;; ;;
vendor/etc/seccomp_policy/qwesd@2.0.policy) vendor/etc/seccomp_policy/qwesd@2.0.policy)
[ "$2" = "" ] && return 0
echo "pipe2: 1" >> "${2}" echo "pipe2: 1" >> "${2}"
;; ;;
vendor/etc/init/vendor.qti.media.c2audio@1.0-service.rc) vendor/etc/init/vendor.qti.media.c2audio@1.0-service.rc)
[ "$2" = "" ] && return 0
sed -i '/disabled/d' "${2}" sed -i '/disabled/d' "${2}"
;; ;;
vendor/lib64/unihal_android.so) vendor/lib64/unihal_android.so)
[ "$2" = "" ] && return 0
grep -q libui_shim.so "$2" || "$PATCHELF" --add-needed libui_shim.so "$2" grep -q libui_shim.so "$2" || "$PATCHELF" --add-needed libui_shim.so "$2"
;; ;;
*)
return 1
;;
esac esac
return 0
} }
if [ -z "${ONLY_TARGET}" ]; then function blob_fixup_dry() {
blob_fixup "$1" ""
}
if [ -z "${ONLY_FIRMWARE}" ] && [ -z "${ONLY_TARGET}" ]; then
# Initialize the helper for common device # Initialize the helper for common device
setup_vendor "${DEVICE_COMMON}" "${VENDOR_COMMON:-$VENDOR}" "${ANDROID_ROOT}" true "${CLEAN_VENDOR}" setup_vendor "${DEVICE_COMMON}" "${VENDOR_COMMON:-$VENDOR}" "${ANDROID_ROOT}" true "${CLEAN_VENDOR}"
@@ -102,7 +127,13 @@ if [ -z "${ONLY_COMMON}" ] && [ -s "${MY_DIR}/../../${VENDOR}/${DEVICE}/propriet
source "${MY_DIR}/../../${VENDOR}/${DEVICE}/extract-files.sh" source "${MY_DIR}/../../${VENDOR}/${DEVICE}/extract-files.sh"
setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false "${CLEAN_VENDOR}" setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false "${CLEAN_VENDOR}"
if [ -z "${ONLY_FIRMWARE}" ]; then
extract "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}" extract "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}"
fi fi
if [ -z "${SECTION}" ] && [ -f "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-firmware.txt" ]; then
extract_firmware "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-firmware.txt" "${SRC}"
fi
fi
"${MY_DIR}/setup-makefiles.sh" "${MY_DIR}/setup-makefiles.sh"

View File

@@ -1,8 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# Copyright (C) 2016 The CyanogenMod Project # SPDX-FileCopyrightText: 2016 The CyanogenMod Project
# Copyright (C) 2017-2020 The LineageOS Project # SPDX-FileCopyrightText: 2017-2024 The LineageOS Project
#
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
@@ -28,20 +27,25 @@ setup_vendor "${DEVICE_COMMON}" "${VENDOR_COMMON:-$VENDOR}" "${ANDROID_ROOT}" tr
write_headers "dm1q dm2q dm3q" write_headers "dm1q dm2q dm3q"
# The standard common blobs # The standard common blobs
write_makefiles "${MY_DIR}/proprietary-files.txt" true write_makefiles "${MY_DIR}/proprietary-files.txt"
# Finish # Finish
write_footers write_footers
if [ -s "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-files.txt" ]; then if [ -s "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-files.txt" ]; then
# Reinitialize the helper for device # Reinitialize the helper for device
source "${MY_DIR}/../../${VENDOR}/${DEVICE}/setup-makefiles.sh"
setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false
# Warning headers and guards # Warning headers and guards
write_headers write_headers
# The standard device blobs # The standard device blobs
write_makefiles "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-files.txt" true write_makefiles "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-files.txt"
if [ -f "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-firmware.txt" ]; then
append_firmware_calls_to_makefiles "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-firmware.txt"
fi
# Finish # Finish
write_footers write_footers