Spacewar: Switch to python extract-utils

Change-Id: Ida4b83459d9739ac880b26a91df974e1db8423e9
This commit is contained in:
Michael Bestas
2024-11-03 07:33:51 +02:00
committed by Wiktor Rudzki
parent 2106ea55f0
commit 2e108eb3bb
4 changed files with 68 additions and 112 deletions

67
extract-files.py Executable file
View File

@@ -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()

View File

@@ -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"

1
setup-makefiles.py Executable file
View File

@@ -0,0 +1 @@
#!./extract-files.py --regenerate_makefiles

View File

@@ -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