From 2e108eb3bb1fa1e2ebcd815817e08d08d4481735 Mon Sep 17 00:00:00 2001 From: Michael Bestas Date: Sun, 3 Nov 2024 07:33:51 +0200 Subject: [PATCH] Spacewar: Switch to python extract-utils Change-Id: Ida4b83459d9739ac880b26a91df974e1db8423e9 --- extract-files.py | 67 ++++++++++++++++++++++++++++++++++++++++ extract-files.sh | 76 ---------------------------------------------- setup-makefiles.py | 1 + setup-makefiles.sh | 36 ---------------------- 4 files changed, 68 insertions(+), 112 deletions(-) create mode 100755 extract-files.py delete mode 100755 extract-files.sh create mode 100755 setup-makefiles.py delete mode 100755 setup-makefiles.sh diff --git a/extract-files.py b/extract-files.py new file mode 100755 index 0000000..041a537 --- /dev/null +++ b/extract-files.py @@ -0,0 +1,67 @@ +#!/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_fixup_remove, + lib_fixups, + lib_fixups_user_type, +) +from extract_utils.main import ( + ExtractUtils, + ExtractUtilsModule, +) + +namespace_imports = [ + 'vendor/nothing/Spacewar', + 'hardware/qcom-caf/sm8350', + 'hardware/qcom-caf/wlan', + 'hardware/nothing', + 'vendor/qcom/opensource/commonsys-intf/display', + 'vendor/qcom/opensource/commonsys/display', + 'vendor/qcom/opensource/dataservices', + 'vendor/qcom/opensource/display', +] + +def lib_fixup_vendor_suffix(lib: str, partition: str, *args, **kwargs): + return f'{lib}_{partition}' if partition == 'vendor' else None + +lib_fixups: lib_fixups_user_type = { + **lib_fixups, + ( + 'com.qualcomm.qti.dpm.api@1.0', + 'libmmosal', + 'vendor.qti.hardware.wifidisplaysession@1.0', + 'vendor.qti.imsrtpservice@3.0', + ): lib_fixup_vendor_suffix, + ( + 'libwpa_client', + ): lib_fixup_remove, +} + +blob_fixups: blob_fixups_user_type = { + 'vendor/lib64/hw/fingerprint.lahaina.so': blob_fixup() + .fix_soname(), + 'vendor/lib64/libwvhidl.so': blob_fixup() + .add_needed('libcrypto_shim.so'), + ('vendor/lib64/libgf_hal.so'): blob_fixup() + .sig_replace('72 6F 2E 62 6F 6F 74 2E 66 6C 61 73 68 2E 6C 6F 63 6B 65 64', '72 6F 2E 62 6F 6F 74 6C 6F 61 64 65 72 2E 6C 6F 63 6B 65 64'), +} # fmt: skip + +module = ExtractUtilsModule( + 'Spacewar', + 'nothing', + 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 f76e713..0000000 --- a/extract-files.sh +++ /dev/null @@ -1,76 +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=Spacewar -VENDOR=nothing - -# 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 - vendor/lib64/hw/fingerprint.lahaina.so) - "${PATCHELF}" --set-soname "fingerprint.lahaina.so" "${2}" - ;; - vendor/lib64/libgf_hal.so) - sed -i "s|ro.boot.flash.locked|ro.bootloader.locked|g" "${2}" - ;; - vendor/lib64/libwvhidl.so | vendor/lib64/mediadrm/libwvdrmengine.so) - [ "$2" = "" ] && return 0 - grep -q "libcrypto_shim.so" "${2}" || "${PATCHELF}" --add-needed "libcrypto_shim.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/setup-makefiles.py b/setup-makefiles.py new file mode 100755 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 586df22..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=Spacewar -VENDOR=nothing - -# 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