extract-files.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/bin/bash
  2. #
  3. # Copyright (C) 2016 The CyanogenMod Project
  4. # Copyright (C) 2017-2023 The LineageOS Project
  5. #
  6. # SPDX-License-Identifier: Apache-2.0
  7. #
  8. set -e
  9. # Load extract_utils and do some sanity checks
  10. MY_DIR="${BASH_SOURCE%/*}"
  11. if [[ ! -d "${MY_DIR}" ]]; then MY_DIR="${PWD}"; fi
  12. ANDROID_ROOT="${MY_DIR}/../../.."
  13. HELPER="${ANDROID_ROOT}/tools/extract-utils/extract_utils.sh"
  14. if [ ! -f "${HELPER}" ]; then
  15. echo "Unable to find helper script at ${HELPER}"
  16. exit 1
  17. fi
  18. source "${HELPER}"
  19. # Default to sanitizing the vendor folder before extraction
  20. CLEAN_VENDOR=true
  21. ONLY_COMMON=
  22. ONLY_FIRMWARE=
  23. ONLY_TARGET=
  24. KANG=
  25. SECTION=
  26. while [ "${#}" -gt 0 ]; do
  27. case "${1}" in
  28. --only-common )
  29. ONLY_COMMON=true
  30. ;;
  31. --only-firmware )
  32. ONLY_FIRMWARE=true
  33. ;;
  34. --only-target )
  35. ONLY_TARGET=true
  36. ;;
  37. -n | --no-cleanup )
  38. CLEAN_VENDOR=false
  39. ;;
  40. -k | --kang )
  41. KANG="--kang"
  42. ;;
  43. -s | --section )
  44. SECTION="${2}"; shift
  45. CLEAN_VENDOR=false
  46. ;;
  47. * )
  48. SRC="${1}"
  49. ;;
  50. esac
  51. shift
  52. done
  53. if [ -z "${SRC}" ]; then
  54. SRC="adb"
  55. fi
  56. function blob_fixup() {
  57. case "${1}" in
  58. vendor/bin/hw/android.hardware.security.keymint-service-qti|vendor/lib/libqtikeymint.so|vendor/lib64/libqtikeymint.so)
  59. grep -q "android.hardware.security.rkp-V3-ndk.so" "${2}" || "${PATCHELF_0_17_2}" --add-needed "android.hardware.security.rkp-V3-ndk.so" "${2}"
  60. ;;
  61. vendor/etc/init/hw/init.mi_thermald.rc|vendor/etc/init/hw/init.qcom.usb.rc|vendor/etc/init/hw/init.qti.kernel.rc)
  62. sed -i 's/on charger/on property:init.svc.vendor.charger=running/g' "${2}"
  63. ;;
  64. vendor/etc/init/init.embmssl_server.rc)
  65. sed -i -n '/interface/!p' "${2}"
  66. ;;
  67. vendor/etc/vintf/manifest/c2_manifest_vendor.xml)
  68. sed -ni '/dolby/!p' "${2}"
  69. ;;
  70. esac
  71. }
  72. if [ -z "${ONLY_FIRMWARE}" ] && [ -z "${ONLY_TARGET}" ]; then
  73. # Initialize the helper for common device
  74. setup_vendor "${DEVICE_COMMON}" "${VENDOR_COMMON:-$VENDOR}" "${ANDROID_ROOT}" true "${CLEAN_VENDOR}"
  75. extract "${MY_DIR}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}"
  76. fi
  77. if [ -z "${ONLY_COMMON}" ] && [ -s "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-files.txt" ]; then
  78. # Reinitialize the helper for device
  79. source "${MY_DIR}/../../${VENDOR}/${DEVICE}/extract-files.sh"
  80. setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false "${CLEAN_VENDOR}"
  81. if [ -z "${ONLY_FIRMWARE}" ]; then
  82. extract "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}"
  83. fi
  84. if [ -z "${SECTION}" ] && [ -f "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-firmware.txt" ]; then
  85. extract_firmware "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-firmware.txt" "${SRC}"
  86. fi
  87. fi
  88. "${MY_DIR}/setup-makefiles.sh"