Skip to content

Commit

Permalink
marlin: Sync extract scripts with templates
Browse files Browse the repository at this point in the history
Change-Id: I98a36854c5a0c0390592911bb2558b34eff77efc
  • Loading branch information
mikeNG authored and npjohnson committed Sep 5, 2024
1 parent 79c9141 commit ec28ddc
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 11 deletions.
32 changes: 29 additions & 3 deletions marlin/extract-files.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# Copyright (C) 2016 The CyanogenMod Project
# Copyright (C) 2017-2023 The LineageOS Project
# SPDX-FileCopyrightText: 2016 The CyanogenMod Project
# SPDX-FileCopyrightText: 2017-2024 The LineageOS Project
#
# SPDX-License-Identifier: Apache-2.0
#
Expand Down Expand Up @@ -43,7 +43,8 @@ while [ "${#}" -gt 0 ]; do
KANG="--kang"
;;
-s | --section )
SECTION="${2}"; shift
SECTION="${2}"
shift
CLEAN_VENDOR=false
;;
* )
Expand All @@ -60,63 +61,88 @@ fi
function blob_fixup() {
case "${1}" in
system/lib/lib-imsvt.so | system/lib64/lib-imsvt.so | system/lib64/libimsmedia_jni.so)
[ "$2" = "" ] && return 0
grep -q "libgui_shim.so" "${2}" || "${PATCHELF}" --add-needed "libgui_shim.so" "${2}"
;;
# Fix typo in qcrilmsgtunnel whitelist
product/etc/sysconfig/nexus.xml)
[ "$2" = "" ] && return 0
sed -i 's/qulacomm/qualcomm/' "${2}"
;;
# Move /data/misc/location to /data/vendor/vndloc for selinux
vendor/bin/loc_launcher|vendor/bin/lowi-server|vendor/bin/xtra-daemon|vendor/lib/hw/gps.default.so|\
vendor/lib/libizat_core.so|vendor/lib/libloc_eng.so|vendor/lib/liblowi_client.so|vendor/lib/libquipc_os_api.so|\
vendor/lib64/hw/gps.default.so|vendor/lib64/libizat_core.so|vendor/lib64/libloc_eng.so|\
vendor/lib64/liblowi_client.so|vendor/lib64/libquipc_os_api.so)
[ "$2" = "" ] && return 0
sed -i 's#/data/misc/location#/data/vendor/vndloc#g' "${2}"
;;
# Patch blobs to load versioned libprotobuf from SDK 29, as SDK 30 removed some symbols
vendor/bin/cnd)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}"
;;
vendor/lib/libcne.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}"
;;
vendor/lib/libcneapiclient.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}"
;;
vendor/lib/libwms.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}"
;;
vendor/lib/libwvhidl.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}"
;;
vendor/lib64/libcne.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}"
;;
vendor/lib64/libcneapiclient.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}"
;;
vendor/lib64/libwms.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}"
;;
vendor/lib64/libwvhidl.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}"
;;
# Patch legacy blobs to use binder instead of vndbinder
vendor/bin/pm-service)
[ "$2" = "" ] && return 0
sed -i "s/vndbinder/binder\x00\x00\x00/" "${2}"
grep -q libutils-v33.so "${2}" || "${PATCHELF}" --add-needed "libutils-v33.so" "${2}"
;;
vendor/lib/libperipheral_client.so)
[ "$2" = "" ] && return 0
sed -i "s/vndbinder/binder\x00\x00\x00/" "${2}"
;;
vendor/lib64/libperipheral_client.so)
[ "$2" = "" ] && return 0
sed -i "s/vndbinder/binder\x00\x00\x00/" "${2}"
;;
# Patch QC RIL to load custom libnano
[ "$2" = "" ] && return 0
vendor/lib64/libril-qc-qmi-1.so)
grep -q "libnanopb393.so" "${2}" || "${PATCHELF}" --add-needed "libnanopb393.so" "${2}"
;;
*)
return 1
;;
esac

return 0
}

function blob_fixup_dry() {
blob_fixup "$1" ""
}

# Initialize the helper
Expand Down
4 changes: 2 additions & 2 deletions marlin/setup-makefiles.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# Copyright (C) 2016 The CyanogenMod Project
# Copyright (C) 2017-2023 The LineageOS Project
# SPDX-FileCopyrightText: 2016 The CyanogenMod Project
# SPDX-FileCopyrightText: 2017-2024 The LineageOS Project
#
# SPDX-License-Identifier: Apache-2.0
#
Expand Down
34 changes: 30 additions & 4 deletions sailfish/extract-files.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# Copyright (C) 2016 The CyanogenMod Project
# Copyright (C) 2017-2023 The LineageOS Project
# SPDX-FileCopyrightText: 2016 The CyanogenMod Project
# SPDX-FileCopyrightText: 2017-2024 The LineageOS Project
#
# SPDX-License-Identifier: Apache-2.0
#
Expand Down Expand Up @@ -43,7 +43,8 @@ while [ "${#}" -gt 0 ]; do
KANG="--kang"
;;
-s | --section )
SECTION="${2}"; shift
SECTION="${2}"
shift
CLEAN_VENDOR=false
;;
* )
Expand All @@ -60,63 +61,88 @@ fi
function blob_fixup() {
case "${1}" in
system/lib/lib-imsvt.so | system/lib64/lib-imsvt.so | system/lib64/libimsmedia_jni.so)
[ "$2" = "" ] && return 0
grep -q "libgui_shim.so" "${2}" || "${PATCHELF}" --add-needed "libgui_shim.so" "${2}"
;;
# Fix typo in qcrilmsgtunnel whitelist
product/etc/sysconfig/nexus.xml)
[ "$2" = "" ] && return 0
sed -i 's/qulacomm/qualcomm/' "${2}"
;;
# Move /data/misc/location to /data/vendor/vndloc for selinux
vendor/bin/loc_launcher|vendor/bin/lowi-server|vendor/bin/xtra-daemon|vendor/lib/hw/gps.default.so|\
vendor/lib/libizat_core.so|vendor/lib/libloc_eng.so|vendor/lib/liblowi_client.so|vendor/lib/libquipc_os_api.so|\
vendor/lib64/hw/gps.default.so|vendor/lib64/libizat_core.so|vendor/lib64/libloc_eng.so|\
vendor/lib64/liblowi_client.so|vendor/lib64/libquipc_os_api.so)
[ "$2" = "" ] && return 0
sed -i 's#/data/misc/location#/data/vendor/vndloc#g' "${2}"
;;
# Patch blobs to load versioned libprotobuf from SDK 29, as SDK 30 removed some symbols
vendor/bin/cnd)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}"
;;
vendor/lib/libcne.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}"
;;
vendor/lib/libcneapiclient.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}"
;;
vendor/lib/libwms.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}"
;;
vendor/lib/libwvhidl.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}"
;;
vendor/lib64/libcne.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}"
;;
vendor/lib64/libcneapiclient.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}"
;;
vendor/lib64/libwms.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}"
;;
vendor/lib64/libwvhidl.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}"
;;
# Patch legacy blobs to use binder instead of vndbinder
vendor/bin/pm-service)
[ "$2" = "" ] && return 0
sed -i "s/vndbinder/binder\x00\x00\x00/" "${2}"
grep -q libutils-v33.so "${2}" || "${PATCHELF}" --add-needed "libutils-v33.so" "${2}"
;;
vendor/lib/libperipheral_client.so)
[ "$2" = "" ] && return 0
sed -i "s/vndbinder/binder\x00\x00\x00/" "${2}"
;;
vendor/lib64/libperipheral_client.so)
[ "$2" = "" ] && return 0
sed -i "s/vndbinder/binder\x00\x00\x00/" "${2}"
;;
# Patch QC RIL to load custom libnano
[ "$2" = "" ] && return 0
vendor/lib64/libril-qc-qmi-1.so)
grep -q "libnanopb393.so" "${2}" || "${PATCHELF}" --add-needed "libnanopb393.so" "${2}"
;;
*)
return 1
;;
esac

return 0
}

function blob_fixup_dry() {
blob_fixup "$1" ""
}

# Initialize the helper
Expand All @@ -128,7 +154,7 @@ if [ -z "${ONLY_FIRMWARE}" ]; then
fi

if [ -z "${SECTION}" ]; then
extract_firmware "${MY_DIR}/proprietary-firmware.txt" "${SRC}"
extract_firmware "${MY_DIR}/${DEVICE}/proprietary-firmware.txt" "${SRC}"
fi

"${MY_DIR}/setup-makefiles.sh"
4 changes: 2 additions & 2 deletions sailfish/setup-makefiles.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# Copyright (C) 2016 The CyanogenMod Project
# Copyright (C) 2017-2023 The LineageOS Project
# SPDX-FileCopyrightText: 2016 The CyanogenMod Project
# SPDX-FileCopyrightText: 2017-2024 The LineageOS Project
#
# SPDX-License-Identifier: Apache-2.0
#
Expand Down

0 comments on commit ec28ddc

Please sign in to comment.