2023-10-03 05:15:45 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
#
|
2024-08-27 22:04:35 +03:00
|
|
|
# SPDX-FileCopyrightText: 2016 The CyanogenMod Project
|
|
|
|
|
# SPDX-FileCopyrightText: 2017-2024 The LineageOS Project
|
2023-10-03 05:15:45 +00:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
2024-08-29 15:44:46 +00:00
|
|
|
DEVICE=sapphire
|
|
|
|
|
VENDOR=xiaomi
|
|
|
|
|
|
2023-10-03 05:15:45 +00:00
|
|
|
# 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}/../../.."
|
|
|
|
|
|
|
|
|
|
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}"
|
|
|
|
|
|
|
|
|
|
# Default to sanitizing the vendor folder before extraction
|
|
|
|
|
CLEAN_VENDOR=true
|
|
|
|
|
|
|
|
|
|
KANG=
|
|
|
|
|
SECTION=
|
|
|
|
|
|
|
|
|
|
while [ "${#}" -gt 0 ]; do
|
|
|
|
|
case "${1}" in
|
|
|
|
|
-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
|
|
|
|
|
|
2023-10-19 11:53:28 +02:00
|
|
|
function blob_fixup() {
|
|
|
|
|
case "${1}" in
|
2024-03-07 01:17:16 +07:00
|
|
|
vendor/bin/hw/android.hardware.security.keymint-service-qti|vendor/lib64/libqtikeymint.so)
|
2024-08-27 22:04:35 +03:00
|
|
|
[ "$2" = "" ] && return 0
|
2022-10-15 23:05:18 +02:00
|
|
|
grep -q "android.hardware.security.rkp-V3-ndk.so" "${2}" || ${PATCHELF} --add-needed "android.hardware.security.rkp-V3-ndk.so" "${2}"
|
2023-10-19 11:53:28 +02:00
|
|
|
;;
|
2023-11-29 16:43:55 +01:00
|
|
|
vendor/lib*/soundfx/libdlbvol.so|vendor/lib*/soundfx/libhwdap.so|vendor/lib64/libdlbdsservice.so | vendor/lib64/libcodec2_soft_ac4dec.so | vendor/lib64/libcodec2_soft_ddpdec.so)
|
2024-08-27 22:04:35 +03:00
|
|
|
[ "$2" = "" ] && return 0
|
2023-11-29 16:43:55 +01:00
|
|
|
"${PATCHELF}" --replace-needed "libstagefright_foundation.so" "libstagefright_foundation-v33.so" "${2}"
|
2023-11-30 10:13:03 +01:00
|
|
|
;;
|
|
|
|
|
vendor/lib64/hw/displayfeature.default.so)
|
2024-08-27 22:04:35 +03:00
|
|
|
[ "$2" = "" ] && return 0
|
2023-11-30 10:13:03 +01:00
|
|
|
"${PATCHELF}" --replace-needed "libstagefright_foundation.so" "libstagefright_foundation-v33.so" "${2}"
|
2024-08-27 22:04:35 +03:00
|
|
|
;;
|
2023-10-19 11:53:28 +02:00
|
|
|
esac
|
2024-08-27 22:04:35 +03:00
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function blob_fixup_dry() {
|
|
|
|
|
blob_fixup "$1" ""
|
2023-10-19 11:53:28 +02:00
|
|
|
}
|
2023-10-03 05:15:45 +00:00
|
|
|
|
2024-08-29 15:44:46 +00:00
|
|
|
extract "${MY_DIR}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}"
|
2023-10-03 05:15:45 +00:00
|
|
|
|
2024-08-19 09:06:00 +03:00
|
|
|
"${MY_DIR}/setup-makefiles.sh"
|