From f2ac07aeac89e03e4e89129772e9a5dcbadea8b3 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Tue, 15 Oct 2024 22:04:03 +0200 Subject: [PATCH] tama-common: Switch to py extract utils Change-Id: Ia13b728464495ff208ca1a706847b11af5c93ae8 --- extract-files.py | 47 ++++++++++++++++++++ extract-files.sh | 108 --------------------------------------------- setup-makefiles.py | 1 + setup-makefiles.sh | 48 -------------------- 4 files changed, 48 insertions(+), 156 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..25c7173 --- /dev/null +++ b/extract-files.py @@ -0,0 +1,47 @@ +#!/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.main import ( + ExtractUtils, + ExtractUtilsModule, +) + +blob_fixups: blob_fixups_user_type = { + ( + 'system_ext/etc/permissions/com.qualcomm.qti.imscmservice-V2.0-java.xml', + 'system_ext/etc/permissions/com.qualcomm.qti.imscmservice-V2.1-java.xml', + 'system_ext/etc/permissions/com.qualcomm.qti.imscmservice-V2.2-java.xml', + 'system_ext/etc/permissions/qcrilhook.xml', + 'system_ext/etc/permissions/telephonyservice.xml' + ): blob_fixup() + .regex_replace('/product/framework/', '/system_ext/framework/'), + 'system_ext/lib64/lib-imsvideocodec.so': blob_fixup() + .add_needed('libgui_shim.so'), + 'vendor/bin/pm-service': blob_fixup() + .add_needed('libutils-v33.so'), + 'vendor/bin/sony-modem-switcher': blob_fixup() + .binary_regex_replace(b'/oem/modem-config/%s/modem.conf', b'/vendor/modemconf/%s/modem.conf') + .binary_regex_replace(b'/oem/modem-config/modem.conf', b'/vendor/modemconf/modem.conf') + .binary_regex_replace(b'persist.radio.multisim.config', b'vendor.radio.multisim.config\x00') + .binary_regex_replace(b'persist.somc.cust.modem(0|1)\x00', b'persist.vendor.somc.sim\\1\x00'), + 'vendor/etc/init/init.sony-modem-switcher.rc': blob_fixup() + .regex_replace('/system/bin/sony-modem-switcher', '/vendor/bin/sony-modem-switcher') + .regex_replace('persist.somc.cust.modem(0|1)', 'persist.vendor.somc.sim\\1'), +} # fmt: skip + +module = ExtractUtilsModule( + 'tama-common', + 'sony', + blob_fixups=blob_fixups, +) + +if __name__ == '__main__': + utils = ExtractUtils.device(module) + utils.run() diff --git a/extract-files.sh b/extract-files.sh deleted file mode 100755 index 5ec7500..0000000 --- a/extract-files.sh +++ /dev/null @@ -1,108 +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 - -# 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}" - -function blob_fixup() { - case "${1}" in - system_ext/etc/permissions/com.qualcomm.qti.imscmservice-V2.0-java.xml) - ;& - system_ext/etc/permissions/com.qualcomm.qti.imscmservice-V2.1-java.xml) - ;& - system_ext/etc/permissions/com.qualcomm.qti.imscmservice-V2.2-java.xml) - ;& - system_ext/etc/permissions/qcrilhook.xml) - ;& - system_ext/etc/permissions/telephonyservice.xml) - sed -i "s/\/product\/framework\//\/system_ext\/framework\//g" "${2}" - ;; - system_ext/lib64/lib-imsvideocodec.so) - grep -q "libgui_shim.so" "${2}" || "${PATCHELF}" --add-needed "libgui_shim.so" "${2}" - ;; - vendor/bin/pm-service) - grep -q libutils-v33.so "${2}" || "${PATCHELF}" --add-needed "libutils-v33.so" "${2}" - ;; - vendor/bin/sony-modem-switcher) - sed -i "s/\/oem\/modem-config\/%s\/modem.conf/\/vendor\/modemconf\/%s\/modem.conf/" "${2}" - sed -i "s/\/oem\/modem-config\/modem.conf/\/vendor\/modemconf\/modem.conf/" "${2}" - sed -i "s/persist.radio.multisim.config/vendor.radio.multisim.config\x00/" "${2}" - sed -i -r 's/persist\.somc\.cust\.modem(0|1)\x00/persist.vendor.somc.sim\1\x00/' "${2}" - ;; - vendor/etc/init/init.sony-modem-switcher.rc) - sed -i "s/\/system\/bin\/sony-modem-switcher/\/vendor\/bin\/sony-modem-switcher/" "${2}" - sed -i -r 's/persist\.somc\.cust\.modem(0|1)/persist.vendor.somc.sim\1/' "${2}" - ;; - esac -} - -# Default to sanitizing the vendor folder before extraction -CLEAN_VENDOR=true - -ONLY_COMMON= -ONLY_TARGET= -SECTION= -KANG= - -while [ "${#}" -gt 0 ]; do - case "${1}" in - --only-common ) - ONLY_COMMON=true - ;; - --only-target ) - ONLY_TARGET=true - ;; - -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 - -if [ -z "${ONLY_TARGET}" ]; then - # Initialize the helper for common device - setup_vendor "${DEVICE_COMMON}" "${VENDOR}" "${ANDROID_ROOT}" true "${CLEAN_VENDOR}" - - extract "${MY_DIR}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}" -fi - -if [ -z "${ONLY_COMMON}" ] && [ -s "${MY_DIR}/../${DEVICE}/proprietary-files.txt" ]; then - # Reinitialize the helper for device - source "${MY_DIR}/../${DEVICE}/extract-files.sh" - setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false "${CLEAN_VENDOR}" - - extract "${MY_DIR}/../${DEVICE}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}" -fi - -"${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 e5c8313..0000000 --- a/setup-makefiles.sh +++ /dev/null @@ -1,48 +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 - -# 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 for common -setup_vendor "${DEVICE_COMMON}" "${VENDOR}" "${ANDROID_ROOT}" true - -# Warning headers and guards -write_headers "akari akatsuki aurora xz2c" - -# The standard common blobs -write_makefiles "${MY_DIR}/proprietary-files.txt" true - -# Finish -write_footers - -if [ -s "${MY_DIR}/../${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}/../${DEVICE}/proprietary-files.txt" true - - # Finish - write_footers -fi