Michael Bestas | 411537b | 2020-12-28 00:58:46 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2016 The CyanogenMod Project |
Michael Bestas | bfccf73 | 2022-02-22 19:22:26 +0200 | [diff] [blame] | 4 | # Copyright (C) 2017-2023 The LineageOS Project |
Michael Bestas | 411537b | 2020-12-28 00:58:46 +0200 | [diff] [blame] | 5 | # |
| 6 | # SPDX-License-Identifier: Apache-2.0 |
| 7 | # |
| 8 | |
| 9 | set -e |
| 10 | |
Michael Bestas | 1037453 | 2023-08-29 19:41:38 +0300 | [diff] [blame] | 11 | DEVICE=FP5 |
merothh | fb168c8 | 2022-01-02 18:18:04 +0530 | [diff] [blame] | 12 | VENDOR=fairphone |
Michael Bestas | 411537b | 2020-12-28 00:58:46 +0200 | [diff] [blame] | 13 | |
| 14 | # Load extract_utils and do some sanity checks |
| 15 | MY_DIR="${BASH_SOURCE%/*}" |
| 16 | if [[ ! -d "${MY_DIR}" ]]; then MY_DIR="${PWD}"; fi |
| 17 | |
| 18 | ANDROID_ROOT="${MY_DIR}/../../.." |
| 19 | |
| 20 | HELPER="${ANDROID_ROOT}/tools/extract-utils/extract_utils.sh" |
| 21 | if [ ! -f "${HELPER}" ]; then |
| 22 | echo "Unable to find helper script at ${HELPER}" |
| 23 | exit 1 |
| 24 | fi |
| 25 | source "${HELPER}" |
| 26 | |
| 27 | # Default to sanitizing the vendor folder before extraction |
| 28 | CLEAN_VENDOR=true |
| 29 | |
| 30 | KANG= |
| 31 | SECTION= |
| 32 | |
| 33 | while [ "${#}" -gt 0 ]; do |
| 34 | case "${1}" in |
| 35 | -n | --no-cleanup ) |
| 36 | CLEAN_VENDOR=false |
| 37 | ;; |
| 38 | -k | --kang ) |
| 39 | KANG="--kang" |
| 40 | ;; |
| 41 | -s | --section ) |
| 42 | SECTION="${2}"; shift |
| 43 | CLEAN_VENDOR=false |
| 44 | ;; |
| 45 | * ) |
| 46 | SRC="${1}" |
| 47 | ;; |
| 48 | esac |
| 49 | shift |
| 50 | done |
| 51 | |
| 52 | if [ -z "${SRC}" ]; then |
| 53 | SRC="adb" |
| 54 | fi |
| 55 | |
| 56 | function blob_fixup() { |
| 57 | case "${1}" in |
Michael Bestas | c3ad1cd | 2023-10-03 15:27:40 +0300 | [diff] [blame] | 58 | system_ext/lib64/libwfdnative.so) |
| 59 | sed -i "s/android.hidl.base@1.0.so/libhidlbase.so\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00/" "${2}" |
| 60 | ;; |
Rohit Sekhar | 2864746 | 2023-09-10 13:31:18 +0530 | [diff] [blame] | 61 | vendor/etc/libnfc-hal-st.conf) |
| 62 | sed -i 's|STNFC_HAL_LOGLEVEL=.*|STNFC_HAL_LOGLEVEL=0x12|g' "${2}" |
| 63 | ;; |
Michael Bestas | 411537b | 2020-12-28 00:58:46 +0200 | [diff] [blame] | 64 | esac |
| 65 | } |
| 66 | |
| 67 | # Initialize the helper |
| 68 | setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false "${CLEAN_VENDOR}" |
| 69 | |
| 70 | extract "${MY_DIR}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}" |
| 71 | |
Michael Bestas | bfccf73 | 2022-02-22 19:22:26 +0200 | [diff] [blame] | 72 | if [ -z "${SECTION}" ]; then |
| 73 | extract_firmware "${MY_DIR}/proprietary-firmware.txt" "${SRC}" |
| 74 | fi |
| 75 | |
Michael Bestas | 411537b | 2020-12-28 00:58:46 +0200 | [diff] [blame] | 76 | "${MY_DIR}/setup-makefiles.sh" |