troika: Sync extractors with templates
authorNolen Johnson <johnsonnolen@gmail.com>
Wed, 3 Jan 2024 04:11:25 +0000 (23:11 -0500)
committerNolen Johnson <johnsonnolen@gmail.com>
Wed, 3 Jan 2024 04:33:44 +0000 (23:33 -0500)
Change-Id: I0b2ca01796db7187f0a4bfce952548aea7a83c7e

extract-files.sh
setup-makefiles.sh

index 603c065830dd2d561ad915b7e8fe33743710a6fb..ef20ed8a09f6c54c7b4c0e967d9a39240ffa281e 100755 (executable)
@@ -6,72 +6,31 @@
 # SPDX-License-Identifier: Apache-2.0
 #
 
-set -e
-
-DEVICE=troika
-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.troika_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.troika_sprout.so
-"${PATCHELF}" --replace-needed "libutils.so" "libutils-v32.so" "${BLOB_ROOT}"/vendor/lib64/hw/sensors.troika_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=troika
+export DEVICE_COMMON=exynos9610-common
+export VENDOR=motorola
+export VENDOR_COMMON=${VENDOR}
 
-"${MY_DIR}/setup-makefiles.sh"
+"./../../${VENDOR_COMMON}/${DEVICE_COMMON}/extract-files.sh" "$@"
index 598f39e3ea9ae9b5b05d671534b1afc9a56a7764..92fbc38c05874bc41419df7ec89688ebdfbe1070 100755 (executable)
@@ -8,29 +8,9 @@
 
 set -e
 
-DEVICE=troika
-VENDOR=motorola
+export DEVICE=troika
+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" "$@"