diff --git a/extract-files.py b/extract-files.py new file mode 100644 index 0000000..9722bc3 --- /dev/null +++ b/extract-files.py @@ -0,0 +1,54 @@ +#!/usr/bin/env -S PYTHONPATH=../../../tools/extract-utils python3 +# +# SPDX-FileCopyrightText: 2024 The LineageOS Project +# SPDX-License-Identifier: Apache-2.0 +# + +from extract_utils.fixups_blob import ( + blob_fixup, + blob_fixups_user_type, +) +from extract_utils.fixups_lib import ( + lib_fixups, + lib_fixups_user_type, +) +from extract_utils.main import ( + ExtractUtils, + ExtractUtilsModule, +) + +namespace_imports = [ + 'device/xiaomi/miuicamera-venus', +] + + +def lib_fixup_system_suffix(lib: str, partition: str, *args, **kwargs): + return f'{lib}_{partition}' if partition == 'system' else None + + +lib_fixups: lib_fixups_user_type = { + **lib_fixups, + 'vendor.xiaomi.hardware.campostproc@1.0': lib_fixup_system_suffix, +} + +blob_fixups: blob_fixups_user_type = { + ( + 'system/lib64/libcamera_algoup_jni.xiaomi.so', + 'system/lib64/libcamera_mianode_jni.xiaomi.so', + ): blob_fixup() + .add_needed('libgui_shim_miuicamera.so'), + 'system/lib64/libmicampostproc_client.so': blob_fixup() + .remove_needed('libhidltransport.so'), +} # fmt: skip + +module = ExtractUtilsModule( + 'miuicamera-venus', + 'xiaomi', + blob_fixups=blob_fixups, + lib_fixups=lib_fixups, + namespace_imports=namespace_imports, +) + +if __name__ == '__main__': + utils = ExtractUtils.device(module) + utils.run() diff --git a/extract-files.sh b/extract-files.sh deleted file mode 100755 index 865e616..0000000 --- a/extract-files.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2016 The CyanogenMod Project -# Copyright (C) 2017-2020 The LineageOS Project -# -# SPDX-License-Identifier: Apache-2.0 -# - -set -e - -DEVICE=miuicamera-venus -VENDOR=xiaomi - -# 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 - case "${1}" in - -n | --no-cleanup ) - CLEAN_VENDOR=false - ;; - -k | --kang ) - KANG="--kang" - ;; - -s | --section ) - SECTION="${2}"; shift - CLEAN_VENDOR=false - ;; - * ) - SRC="${1}" - ;; - esac - shift -done - -if [ -z "${SRC}" ]; then - SRC="adb" -fi - -function blob_fixup() { - case "${1}" in - system/lib64/libcamera_algoup_jni.xiaomi.so|system/lib64/libcamera_mianode_jni.xiaomi.so) - "${PATCHELF}" --add-needed "libgui_shim_miuicamera.so" "${2}" - ;; - system/lib64/libmicampostproc_client.so) - "${PATCHELF}" --remove-needed "libhidltransport.so" "${2}" - ;; - esac -} - -# Initialize the helper -setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false "${CLEAN_VENDOR}" - -extract "${MY_DIR}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}" - -"${MY_DIR}/setup-makefiles.sh" diff --git a/proprietary-files.txt b/proprietary-files.txt index 14db9c7..542fe80 100644 --- a/proprietary-files.txt +++ b/proprietary-files.txt @@ -4,5 +4,5 @@ product/priv-app/MiuiCamera/MiuiCamera.apk:system/priv-app/MiuiCamera/MiuiCamera system_ext/lib64/libcamera_algoup_jni.xiaomi.so:system/lib64/libcamera_algoup_jni.xiaomi.so system_ext/lib64/libcamera_mianode_jni.xiaomi.so:system/lib64/libcamera_mianode_jni.xiaomi.so system_ext/lib64/libmicampostproc_client.so:system/lib64/libmicampostproc_client.so -system_ext/lib64/vendor.xiaomi.hardware.campostproc@1.0.so:system/lib64/vendor.xiaomi.hardware.campostproc@1.0.so +system_ext/lib64/vendor.xiaomi.hardware.campostproc@1.0.so:system/lib64/vendor.xiaomi.hardware.campostproc@1.0.so;MODULE_SUFFIX=_system vendor/etc/camera/sceneDetection.xml diff --git a/setup-makefiles.py b/setup-makefiles.py new file mode 100644 index 0000000..32947cf --- /dev/null +++ b/setup-makefiles.py @@ -0,0 +1 @@ +#!./extract-files.py --regenerate_makefiles diff --git a/setup-makefiles.sh b/setup-makefiles.sh deleted file mode 100755 index 000d82e..0000000 --- a/setup-makefiles.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2016 The CyanogenMod Project -# Copyright (C) 2017-2020 The LineageOS Project -# -# SPDX-License-Identifier: Apache-2.0 -# - -set -e - -DEVICE=miuicamera-venus -VENDOR=xiaomi - -# 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