From 413795eb8948e5c1623ab4414fd90d829162dee7 Mon Sep 17 00:00:00 2001 From: Giovanni Ricca Date: Fri, 15 Nov 2024 22:32:12 +0100 Subject: [PATCH] msm8953-common: Migrate to py extract utils Change-Id: I2a7a0e7803940ef6105e55b88a94b7ba066a1929 --- extract-files.py | 44 +++++++++++++++ extract-files.sh | 122 ------------------------------------------ proprietary-files.txt | 18 +++---- setup-makefiles.py | 1 + setup-makefiles.sh | 48 ----------------- update-sha1sums.py | 81 ++++++++++++++-------------- 6 files changed, 96 insertions(+), 218 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..2126687 --- /dev/null +++ b/extract-files.py @@ -0,0 +1,44 @@ +#!/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 = { + ('product/etc/permissions/vendor.qti.hardware.data.connection-V1.0-java.xml', 'product/etc/permissions/vendor.qti.hardware.data.connection-V1.1-java.xml'): blob_fixup() + .regex_replace('version="2.0"', 'version="1.0"'), + ('system_ext/etc/init/dpmd.rc', 'system_ext/etc/permissions/com.qti.dpmframework.xml', '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/dpmapi.xml', 'system_ext/etc/permissions/embms.xml', 'system_ext/etc/permissions/qcrilhook.xml', 'system_ext/etc/permissions/telephonyservice.xml'): blob_fixup() + .regex_replace('/product/', '/system_ext/'), + 'system_ext/lib64/libdpmframework.so': blob_fixup() + .add_needed('libcutils_shim.so'), + '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/etc/data/dsi_config.xml', 'vendor/etc/data/netmgr_config.xml'): blob_fixup() + .fix_xml(), + ('vendor/lib/mediadrm/libwvdrmengine.so', 'vendor/lib64/mediadrm/libwvdrmengine.so', 'vendor/lib64/libwvhidl.so'): blob_fixup() + .replace_needed('libprotobuf-cpp-lite.so', 'libprotobuf-cpp-lite-v29.so'), + ('vendor/lib64/libril-qc-hal-qmi.so', 'vendor/lib64/libsettings.so',): blob_fixup() + .replace_needed('libprotobuf-cpp-full.so', 'libprotobuf-cpp-full-v29.so'), +} # fmt: skip + +module = ExtractUtilsModule( + 'msm8953-common', + 'xiaomi', + blob_fixups=blob_fixups, + check_elf=False, +) + +if __name__ == '__main__': + utils = ExtractUtils.device(module) + utils.run() diff --git a/extract-files.sh b/extract-files.sh deleted file mode 100755 index 725d5f6..0000000 --- a/extract-files.sh +++ /dev/null @@ -1,122 +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}" - -# Default to sanitizing the vendor folder before extraction -CLEAN_VENDOR=true - -ONLY_COMMON= -ONLY_TARGET= -KANG= -SECTION= - -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 - -function blob_fixup() { - case "${1}" in - product/etc/permissions/vendor.qti.hardware.data.connection-V1.0-java.xml | product/etc/permissions/vendor.qti.hardware.data.connection-V1.1-java.xml) - sed -i 's/version="2.0"/version="1.0"/g' "${2}" - ;; - system_ext/etc/init/dpmd.rc) - sed -i "s|/system/product/bin/|/system/system_ext/bin/|g" "${2}" - ;; - system_ext/etc/permissions/com.qti.dpmframework.xml \ - | 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/dpmapi.xml \ - | system_ext/etc/permissions/telephonyservice.xml ) - sed -i "s|/system/product/framework/|/system/system_ext/framework/|g" "${2}" - ;; - system_ext/etc/permissions/embms.xml) - sed -i "s|/product/framework/|/system_ext/framework/|g" "${2}" - ;; - system_ext/etc/permissions/qcrilhook.xml) - sed -i 's|/product/framework/qcrilhook.jar|/system_ext/framework/qcrilhook.jar|g' "${2}" - ;; - system_ext/lib64/libdpmframework.so) - grep -q "libcutils_shim.so" "${2}" || "${PATCHELF}" --add-needed "libcutils_shim.so" "${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/lib/mediadrm/libwvdrmengine.so|vendor/lib64/mediadrm/libwvdrmengine.so) - "${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}" - ;; - vendor/lib64/libril-qc-hal-qmi.so) - "${PATCHELF}" --replace-needed "libprotobuf-cpp-full.so" "libprotobuf-cpp-full-v29.so" "${2}" - ;; - vendor/lib64/libsettings.so) - "${PATCHELF}" --replace-needed "libprotobuf-cpp-full.so" "libprotobuf-cpp-full-v29.so" "${2}" - ;; - vendor/lib64/libwvhidl.so) - "${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}" - ;; - esac -} - -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/proprietary-files.txt b/proprietary-files.txt index 507ff0e..a0dc9a5 100644 --- a/proprietary-files.txt +++ b/proprietary-files.txt @@ -98,9 +98,6 @@ vendor/firmware/cpp_firmware_v1_6_0.fw vendor/firmware/cpp_firmware_v1_8_0.fw # CNE -etc/cne/Nexus/ATT/ATT_profiles.xml -etc/cne/Nexus/ROW/ROW_profiles.xml -etc/cne/Nexus/VZW/VZW_profiles.xml product/etc/permissions/vendor.qti.hardware.data.connection-V1.0-java.xml product/etc/permissions/vendor.qti.hardware.data.connection-V1.1-java.xml product/framework/com.quicinc.cne.api-V1.1-java.jar @@ -131,6 +128,9 @@ product/lib64/vendor.qti.hardware.data.connection@1.1.so product/lib64/vendor.qti.hardware.data.dynamicdds@1.0.so product/lib64/vendor.qti.hardware.data.iwlan@1.0.so product/lib64/vendor.qti.hardware.data.qmi@1.0.so +system/etc/cne/Nexus/ATT/ATT_profiles.xml +system/etc/cne/Nexus/ROW/ROW_profiles.xml +system/etc/cne/Nexus/VZW/VZW_profiles.xml vendor/app/CneApp/CneApp.apk vendor/app/IWlanService/IWlanService.apk vendor/bin/cnd @@ -194,7 +194,6 @@ vendor/lib64/libsysmon_cdsp_skel.so vendor/bin/hvdcp_opti # DPM -framework/tcmclient.jar product/bin/dpmd:system_ext/bin/dpmd product/etc/dpm/dpm.conf:system_ext/etc/dpm/dpm.conf product/etc/init/dpmd.rc:system_ext/etc/init/dpmd.rc @@ -213,6 +212,7 @@ product/lib64/libdpmfdmgr.so:system_ext/lib64/libdpmfdmgr.so product/lib64/libdpmframework.so:system_ext/lib64/libdpmframework.so product/lib64/libdpmtcm.so:system_ext/lib64/libdpmtcm.so product/priv-app/dpmserviceapp/dpmserviceapp.apk:system_ext/priv-app/dpmserviceapp/dpmserviceapp.apk +system/framework/tcmclient.jar vendor/bin/dpmQmiMgr vendor/etc/init/dpmQmiMgr.rc vendor/lib/com.qualcomm.qti.dpm.api@1.0.so @@ -419,8 +419,8 @@ vendor/lib/libperipheral_client.so vendor/lib64/libperipheral_client.so # Postprocessing -etc/permissions/com.qti.snapdragon.sdk.display.xml -framework/com.qti.snapdragon.sdk.display.jar +system/etc/permissions/com.qti.snapdragon.sdk.display.xml +system/framework/com.qti.snapdragon.sdk.display.jar vendor/bin/hw/vendor.display.color@1.0-service vendor/bin/hw/vendor.qti.hardware.qdutils_disp@1.0-service-qti vendor/bin/mm-pp-dpps @@ -444,8 +444,8 @@ vendor/lib64/hw/vendor.qti.hardware.alarm@1.0-impl.so|f2b57130987c65a1dc596bf83a vendor/lib64/vendor.qti.hardware.alarm@1.0.so|74675e4f720d75db031a0db4ca21463ebd331f34 # QMI -etc/permissions/qti_libpermissions.xml -etc/permissions/qti_permissions.xml +system/etc/permissions/qti_libpermissions.xml +system/etc/permissions/qti_permissions.xml vendor/bin/irsc_util vendor/etc/sec_config vendor/lib/libdiag.so @@ -562,7 +562,6 @@ vendor/radio/qcril_database/upgrade/6_version_update_ecc_table.sql vendor/radio/qcril_database/qcril.db # Radio - IMS -etc/permissions/com.qualcomm.qti.imscmservice.xml product/app/imssettings/imssettings.apk:system_ext/app/imssettings/imssettings.apk product/app/uceShimService/uceShimService.apk:system_ext/app/uceShimService/uceShimService.apk product/etc/permissions/com.qualcomm.qti.imscmservice-V2.0-java.xml:system_ext/etc/permissions/com.qualcomm.qti.imscmservice-V2.0-java.xml @@ -594,6 +593,7 @@ product/lib64/vendor.qti.ims.rcsconfig@1.0.so:system_ext/lib64/vendor.qti.ims.rc product/lib64/vendor.qti.imsrtpservice@2.0.so:system_ext/lib64/vendor.qti.imsrtpservice@2.0.so product/lib64/vendor.qti.imsrtpservice@2.1.so:system_ext/lib64/vendor.qti.imsrtpservice@2.1.so product/priv-app/ims/ims.apk:system_ext/priv-app/ims/ims.apk +system/etc/permissions/com.qualcomm.qti.imscmservice.xml vendor/bin/ims_rtp_daemon vendor/bin/imsdatadaemon vendor/bin/imsqmidaemon 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 be47a7a..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 "daisy mido sakura tissot vince ysl" - -# 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 diff --git a/update-sha1sums.py b/update-sha1sums.py index f1e35e3..f734728 100755 --- a/update-sha1sums.py +++ b/update-sha1sums.py @@ -16,64 +16,67 @@ # limitations under the License. # -from hashlib import sha1 import sys +from hashlib import sha1 -device='msm8953-common' -vendor='xiaomi' +device = 'msm8953-common' +vendor = 'xiaomi' -lines = [ line for line in open('proprietary-files.txt', 'r') ] +lines = [line for line in open('proprietary-files.txt', 'r')] vendorPath = '../../../vendor/' + vendor + '/' + device + '/proprietary' needSHA1 = False + def cleanup(): - for index, line in enumerate(lines): - # Remove '\n' character - line = line[:-1] + for index, line in enumerate(lines): + # Remove '\n' character + line = line[:-1] - # Skip empty or commented lines - if len(line) == 0 or line[0] == '#': - continue + # Skip empty or commented lines + if len(line) == 0 or line[0] == '#': + continue + + # Drop SHA1 hash, if existing + if '|' in line: + line = line.split('|')[0] + lines[index] = '%s\n' % (line) - # Drop SHA1 hash, if existing - if '|' in line: - line = line.split('|')[0] - lines[index] = '%s\n' % (line) def update(): - for index, line in enumerate(lines): - # Remove '\n' character - line = line[:-1] + for index, line in enumerate(lines): + # Remove '\n' character + line = line[:-1] - # Skip empty lines - if len(line) == 0: - continue + # Skip empty lines + if len(line) == 0: + continue - # Check if we need to set SHA1 hash for the next files - if line[0] == '#': - needSHA1 = (' - from' in line) - continue + # Check if we need to set SHA1 hash for the next files + if line[0] == '#': + needSHA1 = ' - from' in line + continue - if needSHA1: - # Remove existing SHA1 hash - line = line.split('|')[0] - filePath = line.split(':')[1] if len(line.split(':')) == 2 else line + if needSHA1: + # Remove existing SHA1 hash + line = line.split('|')[0] + filePath = line.split(':')[1] if len(line.split(':')) == 2 else line - if filePath[0] == '-': - file = open('%s/%s' % (vendorPath, filePath[1:]), 'rb').read() - else: - file = open('%s/%s' % (vendorPath, filePath), 'rb').read() + if filePath[0] == '-': + file = open('%s/%s' % (vendorPath, filePath[1:]), 'rb').read() + else: + file = open('%s/%s' % (vendorPath, filePath), 'rb').read() + + hash = sha1(file).hexdigest() + lines[index] = '%s|%s\n' % (line, hash) - hash = sha1(file).hexdigest() - lines[index] = '%s|%s\n' % (line, hash) if len(sys.argv) == 2 and sys.argv[1] == '-c': - cleanup() + cleanup() else: - update() + update() with open('proprietary-files.txt', 'w') as file: - for line in lines: - file.write(line) + for line in lines: + file.write(line) - file.close() + file.close()