blob: ded0305501af4b9ca7cf65477471741e639c782b [file] [log] [blame]
Michael Bestas411537b2020-12-28 00:58:46 +02001#!/bin/bash
2#
3# Copyright (C) 2016 The CyanogenMod Project
4# Copyright (C) 2017-2020 The LineageOS Project
5#
6# SPDX-License-Identifier: Apache-2.0
7#
8
9set -e
10
merothhfb168c82022-01-02 18:18:04 +053011DEVICE=FP4
12VENDOR=fairphone
Michael Bestas411537b2020-12-28 00:58:46 +020013
14# Load extract_utils and do some sanity checks
15MY_DIR="${BASH_SOURCE%/*}"
16if [[ ! -d "${MY_DIR}" ]]; then MY_DIR="${PWD}"; fi
17
18ANDROID_ROOT="${MY_DIR}/../../.."
19
20HELPER="${ANDROID_ROOT}/tools/extract-utils/extract_utils.sh"
21if [ ! -f "${HELPER}" ]; then
22 echo "Unable to find helper script at ${HELPER}"
23 exit 1
24fi
25source "${HELPER}"
26
27# Default to sanitizing the vendor folder before extraction
28CLEAN_VENDOR=true
29
30KANG=
31SECTION=
32
33while [ "${#}" -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
50done
51
52if [ -z "${SRC}" ]; then
53 SRC="adb"
54fi
55
56function blob_fixup() {
57 case "${1}" in
58 vendor/lib/libsample1.so)
59 sed -i 's|/data/misc/sample1|/data/misc/sample2|g' "${2}"
60 ;;
61 vendor/lib64/libsample2.so)
62 "${PATCHELF}" --remove-needed "libsample3.so" "${2}"
63 "${PATCHELF}" --add-needed "libsample4.so" "${2}"
64 ;;
65 vendor/lib/libsample5.so)
66 "${PATCHELF}" --replace-needed "libsample6.so" "libsample7.so" "${2}"
67 ;;
68 vendor/lib/libsample7.so)
69 "${PATCHELF}" --set-soname "libsample7.so" "${2}"
70 ;;
71 esac
72}
73
74# Initialize the helper
75setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false "${CLEAN_VENDOR}"
76
77extract "${MY_DIR}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}"
78
79"${MY_DIR}/setup-makefiles.sh"