# SPDX-License-Identifier: Apache-2.0
#
-set -e
-
-DEVICE=kane
-VENDOR=motorola
-
-# 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
+function blob_fixup() {
case "${1}" in
- -n | --no-cleanup )
- CLEAN_VENDOR=false
- ;;
- -k | --kang )
- KANG="--kang"
- ;;
- -s | --section )
- SECTION="${2}"; shift
- CLEAN_VENDOR=false
- ;;
- * )
- SRC="${1}"
- ;;
+ # Missing libutils symbols
+ vendor/lib*/sensors.chub.so|vendor/lib*/hw/sensors.kane_sprout.so)
+ "${PATCHELF}" --replace-needed "libutils.so" "libutils-v32.so" "${2}"
+ ;;
+ # Remove libhidltransport/libhwbinder dependencies
+ vendor/lib*/libril_sitril.so)
+ "${PATCHELF}" --remove-needed "libhidltransport.so" "${2}"
+ "${PATCHELF}" --remove-needed "libhwbinder.so" "${2}"
+ ;;
esac
- shift
-done
+}
-if [ -z "${SRC}" ]; then
- SRC="adb"
+# If we're being sourced by the common script that we called,
+# stop right here. No need to go down the rabbit hole.
+if [ "${BASH_SOURCE[0]}" != "${0}" ]; then
+ return
fi
-# Initialize the helper
-setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false "${CLEAN_VENDOR}"
-
-extract "${MY_DIR}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}"
-
-# Fix proprietary blobs
-BLOB_ROOT="$ANDROID_ROOT"/vendor/"$VENDOR"/"$DEVICE"/proprietary
-
-"${PATCHELF}" --replace-needed "libutils.so" "libutils-v32.so" "${BLOB_ROOT}"/vendor/lib/sensors.chub.so
-"${PATCHELF}" --replace-needed "libutils.so" "libutils-v32.so" "${BLOB_ROOT}"/vendor/lib64/sensors.chub.so
-"${PATCHELF}" --replace-needed "libutils.so" "libutils-v32.so" "${BLOB_ROOT}"/vendor/lib/hw/sensors.kane_sprout.so
-"${PATCHELF}" --replace-needed "libutils.so" "libutils-v32.so" "${BLOB_ROOT}"/vendor/lib64/hw/sensors.kane_sprout.so
-
-# Remove libhidltransport dependency
-"${PATCHELF}" --remove-needed "libhidltransport.so" "${BLOB_ROOT}"/vendor/lib/libril_sitril.so
-"${PATCHELF}" --remove-needed "libhidltransport.so" "${BLOB_ROOT}"/vendor/lib64/libril_sitril.so
+set -e
-# Remove libhwbinder dependency
-"${PATCHELF}" --remove-needed "libhwbinder.so" "${BLOB_ROOT}"/vendor/lib/libril_sitril.so
-"${PATCHELF}" --remove-needed "libhwbinder.so" "${BLOB_ROOT}"/vendor/lib64/libril_sitril.so
+export DEVICE=kane
+export DEVICE_COMMON=exynos9610-common
+export VENDOR=motorola
+export VENDOR_COMMON=${VENDOR}
-"${MY_DIR}/setup-makefiles.sh"
+"./../../${VENDOR_COMMON}/${DEVICE_COMMON}/extract-files.sh" "$@"
set -e
-DEVICE=kane
-VENDOR=motorola
+export DEVICE=kane
+export DEVICE_COMMON=exynos9610-common
+export VENDOR=motorola
+export VENDOR_COMMON=${VENDOR}
-# 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}"
-
-# Initialize the helper
-setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}"
-
-# Warning headers and guards
-write_headers
-
-write_makefiles "${MY_DIR}/proprietary-files.txt" true
-
-# Finish
-write_footers
+"./../../${VENDOR_COMMON}/${DEVICE_COMMON}/setup-makefiles.sh" "$@"