exynos9610: Update extract_utils from templates
authorNolen Johnson <johnsonnolen@gmail.com>
Wed, 3 Jan 2024 03:37:48 +0000 (22:37 -0500)
committerNolen Johnson <johnsonnolen@gmail.com>
Wed, 3 Jan 2024 04:26:25 +0000 (23:26 -0500)
Change-Id: Id8aa150f3efb961f827ad9f61f3e4c4558c3099f

extract-files.sh
setup-makefiles.sh

index 2d54eeea7f0ea9d9980c78b824e2b2e39efd0240..beb91eb45f54775634e1f755322561daed24bb5a 100755 (executable)
@@ -1,16 +1,13 @@
 #!/bin/bash
 #
 # Copyright (C) 2016 The CyanogenMod Project
-# Copyright (C) 2017-2020 The LineageOS Project
+# Copyright (C) 2017-2023 The LineageOS Project
 #
 # SPDX-License-Identifier: Apache-2.0
 #
 
 set -e
 
-DEVICE_COMMON=exynos9610-common
-VENDOR=motorola
-
 # Load extract_utils and do some sanity checks
 MY_DIR="${BASH_SOURCE%/*}"
 if [[ ! -d "${MY_DIR}" ]]; then MY_DIR="${PWD}"; fi
@@ -27,11 +24,23 @@ source "${HELPER}"
 # Default to sanitizing the vendor folder before extraction
 CLEAN_VENDOR=true
 
+ONLY_COMMON=
+ONLY_FIRMWARE=
+ONLY_TARGET=
 KANG=
 SECTION=
 
 while [ "${#}" -gt 0 ]; do
     case "${1}" in
+        --only-common )
+                ONLY_COMMON=true
+                ;;
+        --only-firmware )
+                ONLY_FIRMWARE=true
+                ;;
+        --only-target )
+                ONLY_TARGET=true
+                ;;
         -n | --no-cleanup )
                 CLEAN_VENDOR=false
                 ;;
@@ -53,51 +62,71 @@ if [ -z "${SRC}" ]; then
     SRC="adb"
 fi
 
-# Initialize the helper
-setup_vendor "${DEVICE_COMMON}" "${VENDOR}" "${ANDROID_ROOT}" true "${CLEAN_VENDOR}"
-
-extract "${MY_DIR}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}"
-extract "${MY_DIR}/proprietary-files-vendor.txt" "${SRC}" "${KANG}" --section "${SECTION}"
-
-# Fix proprietary blobs
-BLOB_ROOT="${ANDROID_ROOT}"/vendor/"${VENDOR}"/"${DEVICE_COMMON}"/proprietary
-
-"${PATCHELF}" --replace-needed "libmedia.so" "libmedia_ims.so" "${BLOB_ROOT}"/lib64/libmediaadaptor.so
+function blob_fixup() {
+    case "${1}" in
+        # libmedia symbols moved
+        lib64/libmediaadaptor.so)
+            "${PATCHELF}" --replace-needed "libmedia.so" "libmedia_ims.so" "${2}"
+            ;;
+        # libnetutils shim
+        vendor/bin/wfc-pkt-router)
+            "${PATCHELF}" --replace-needed "libnetutils.so" "libip_checksum_shim.so" "${2}"
+            ;;
+        # Missing libutils symbols
+        vendor/lib*/libexynosdisplay.so|vendor/lib*/hw/hwcomposer.exynos9610.so|vendor/lib*/sensors.rp.so)
+            "${PATCHELF}" --replace-needed "libutils.so" "libutils-v32.so" "${2}"
+            ;;
+        vendor/lib/libaudioproxy.so)
+            for LIBAUDIOPROXY_SHIM in $(grep -L "libaudioproxy_shim.so" "${2}"); do
+                "${PATCHELF}" --add-needed "libaudioproxy_shim.so" "${LIBAUDIOPROXY_SHIM}"
+            done
+            ;;
+        vendor/bin/charge_only_mode)
+            for LIBMEMSET in $(grep -L "libmemset_shim.so" "${2}"); do
+                "${PATCHELF}" --add-needed "libmemset_shim.so" "${LIBMEMSET}"
+            done
+            ;;
+        vendor/lib*/libhifills.so)
+            for LIBDEMANGLE in $(grep -L "libdemangle.so" "${2}"); do
+                "${PATCHELF}" --add-needed "libdemangle.so" "${LIBDEMANGLE}"
+            done
+            ;;
+        # Remove libhidltransport/libhwbinder references
+        vendor/bin/hw/android.hardware.biometrics.fingerprint@2.1-service-rbs|vendor/lib64/hw/android.hardware.gnss@1.0-impl.samsung.so|vendor/lib64/hw/android.hardware.gnss@1.1-impl.samsung.so|vendor/lib64/hw/android.hardware.gnss@2.0-impl.samsung.so|vendor/lib64/hw/vendor.samsung.hardware.gnss@1.0-impl.so)
+            "${PATCHELF}" --remove-needed "libhidltransport.so" "${2}"
+            "${PATCHELF}" --remove-needed "libhwbinder.so" "${2}"
+            ;;
+        # Remove libhwbinder references
+        vendor/etc/permissions/com.motorola.motosignature.xml)
+            sed -i 's|/system/framework|/vendor/framework|' "${2}"
+            ;;
+    esac
+}
 
-"${PATCHELF}" --replace-needed "libnetutils.so" "libip_checksum_shim.so" "${BLOB_ROOT}"/vendor/bin/wfc-pkt-router
+if [ -z "${ONLY_FIRMWARE}" ] && [ -z "${ONLY_TARGET}" ]; then
+    # Initialize the helper for common device
+    setup_vendor "${DEVICE_COMMON}" "${VENDOR_COMMON:-$VENDOR}" "${ANDROID_ROOT}" true "${CLEAN_VENDOR}"
 
-"${PATCHELF}" --replace-needed "libutils.so" "libutils-v32.so" "${BLOB_ROOT}"/vendor/lib/libexynosdisplay.so
-"${PATCHELF}" --replace-needed "libutils.so" "libutils-v32.so" "${BLOB_ROOT}"/vendor/lib64/libexynosdisplay.so
-"${PATCHELF}" --replace-needed "libutils.so" "libutils-v32.so" "${BLOB_ROOT}"/vendor/lib/hw/hwcomposer.exynos9610.so
-"${PATCHELF}" --replace-needed "libutils.so" "libutils-v32.so" "${BLOB_ROOT}"/vendor/lib64/hw/hwcomposer.exynos9610.so
-"${PATCHELF}" --replace-needed "libutils.so" "libutils-v32.so" "${BLOB_ROOT}"/vendor/lib/sensors.rp.so
-"${PATCHELF}" --replace-needed "libutils.so" "libutils-v32.so" "${BLOB_ROOT}"/vendor/lib64/sensors.rp.so
+    extract "${MY_DIR}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}"
+    extract "${MY_DIR}/proprietary-files-vendor.txt" "${SRC}" "${KANG}" --section "${SECTION}"
 
-for LIBAUDIOPROXY_SHIM in $(grep -L "libaudioproxy_shim.so" "${BLOB_ROOT}"/vendor/lib/libaudioproxy.so); do
-    "${PATCHELF}" --add-needed libaudioproxy_shim.so "${LIBAUDIOPROXY_SHIM}"
-done
-for LIBMEMSET in $(grep -L "libmemset_shim.so" "${BLOB_ROOT}"/vendor/bin/charge_only_mode); do
-    "${PATCHELF}" --add-needed "libmemset_shim.so" "${LIBMEMSET}"
-done
-for LIBDEMANGLE in $(grep -L "libdemangle.so" "${BLOB_ROOT}"/vendor/lib/libhifills.so); do
-    "${PATCHELF}" --add-needed "libdemangle.so" "${LIBDEMANGLE}"
-done
-for LIBDEMANGLE64 in $(grep -L "libdemangle.so" "${BLOB_ROOT}"/vendor/lib64/libhifills.so); do
-    "${PATCHELF}" --add-needed "libdemangle.so" "${LIBDEMANGLE64}"
-done
+    # Reinitialize the helper for device
+    source "${MY_DIR}/../../${VENDOR}/${DEVICE}/extract-files.sh"
+    setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false "${CLEAN_VENDOR}"
+fi
 
-sed -i 's|/system/framework|/vendor/framework|' "${BLOB_ROOT}"/vendor/etc/permissions/com.motorola.motosignature.xml
+if [ -z "${ONLY_COMMON}" ] && [ -s "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-files.txt" ]; then
+    # Reinitialize the helper for device
+    source "${MY_DIR}/../../${VENDOR}/${DEVICE}/extract-files.sh"
+    setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false "${CLEAN_VENDOR}"
 
-# Remove libhidltransport dependency
-"${PATCHELF}" --remove-needed "libhidltransport.so" "${BLOB_ROOT}"/vendor/bin/hw/android.hardware.biometrics.fingerprint@2.1-service-rbs
-"${PATCHELF}" --remove-needed "libhidltransport.so" "${BLOB_ROOT}"/vendor/lib64/hw/android.hardware.gnss@1.0-impl.samsung.so
-"${PATCHELF}" --remove-needed "libhidltransport.so" "${BLOB_ROOT}"/vendor/lib64/hw/android.hardware.gnss@1.1-impl.samsung.so
-"${PATCHELF}" --remove-needed "libhidltransport.so" "${BLOB_ROOT}"/vendor/lib64/hw/android.hardware.gnss@2.0-impl.samsung.so
-"${PATCHELF}" --remove-needed "libhidltransport.so" "${BLOB_ROOT}"/vendor/lib64/hw/vendor.samsung.hardware.gnss@1.0-impl.so
+    if [ -z "${ONLY_FIRMWARE}" ]; then
+        extract "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}"
+    fi
 
-# Remove libhwbinder dependency
-"${PATCHELF}" --remove-needed "libhwbinder.so" "${BLOB_ROOT}"/vendor/lib64/hw/android.hardware.gnss@1.0-impl.samsung.so
-"${PATCHELF}" --remove-needed "libhwbinder.so" "${BLOB_ROOT}"/vendor/lib64/hw/android.hardware.gnss@1.1-impl.samsung.so
-"${PATCHELF}" --remove-needed "libhwbinder.so" "${BLOB_ROOT}"/vendor/lib64/hw/android.hardware.gnss@2.0-impl.samsung.so
+    if [ -z "${SECTION}" ] && [ -f "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-firmware.txt" ]; then
+        extract_firmware "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-firmware.txt" "${SRC}"
+    fi
+fi
 
 "${MY_DIR}/setup-makefiles.sh"
index 7649e891287f7d352c6c6bc4a92fa97b7aaa2db6..03ff49b2767943904a110122895e2107590e69f4 100755 (executable)
@@ -1,16 +1,13 @@
 #!/bin/bash
 #
 # Copyright (C) 2016 The CyanogenMod Project
-# Copyright (C) 2017-2020 The LineageOS Project
+# Copyright (C) 2017-2023 The LineageOS Project
 #
 # SPDX-License-Identifier: Apache-2.0
 #
 
 set -e
 
-DEVICE_COMMON=exynos9610-common
-VENDOR=motorola
-
 # Load extract_utils and do some sanity checks
 MY_DIR="${BASH_SOURCE%/*}"
 if [[ ! -d "${MY_DIR}" ]]; then MY_DIR="${PWD}"; fi
@@ -24,14 +21,33 @@ if [ ! -f "${HELPER}" ]; then
 fi
 source "${HELPER}"
 
-# Initialize the helper
-setup_vendor "${DEVICE_COMMON}" "${VENDOR}" "${ANDROID_ROOT}" true
+# Initialize the helper for common
+setup_vendor "${DEVICE_COMMON}" "${VENDOR_COMMON:-$VENDOR}" "${ANDROID_ROOT}" true
 
 # Warning headers and guards
 write_headers "kane troika"
 
+# The standard common blobs
 write_makefiles "${MY_DIR}/proprietary-files.txt" true
 write_makefiles "${MY_DIR}/proprietary-files-vendor.txt" true
 
 # Finish
 write_footers
+
+if [ -s "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-files.txt" ]; then
+    # Reinitialize the helper for device
+    setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false
+
+    # Warning headers and guards
+    write_headers
+
+    # The standard device blobs
+    write_makefiles "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-files.txt" true
+
+    if [ -f "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-firmware.txt" ]; then
+        append_firmware_calls_to_makefiles "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-firmware.txt"
+    fi
+
+    # Finish
+    write_footers
+fi