extract-files.sh 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_TARGET=
  23. KANG=
  24. SECTION=
  25. while [ "${#}" -gt 0 ]; do
  26. case "${1}" in
  27. --only-common )
  28. ONLY_COMMON=true
  29. ;;
  30. --only-target )
  31. ONLY_TARGET=true
  32. ;;
  33. -n | --no-cleanup )
  34. CLEAN_VENDOR=false
  35. ;;
  36. -k | --kang )
  37. KANG="--kang"
  38. ;;
  39. -s | --section )
  40. SECTION="${2}"; shift
  41. CLEAN_VENDOR=false
  42. ;;
  43. * )
  44. SRC="${1}"
  45. ;;
  46. esac
  47. shift
  48. done
  49. if [ -z "${SRC}" ]; then
  50. SRC="adb"
  51. fi
  52. function blob_fixup() {
  53. case "${1}" in
  54. vendor/etc/init/hw/init.mi_thermald.rc|vendor/etc/init/hw/init.qcom.usb.rc|vendor/etc/init/hw/init.qti.kernel.rc)
  55. sed -i 's/on charger/on property:init.svc.vendor.charger=running/g' "${2}"
  56. ;;
  57. vendor/etc/init/init.embmssl_server.rc)
  58. sed -i -n '/interface/!p' "${2}"
  59. ;;
  60. vendor/etc/vintf/manifest/c2_manifest_vendor.xml)
  61. sed -ni '/dolby/!p' "${2}"
  62. ;;
  63. esac
  64. }
  65. if [ -z "${ONLY_TARGET}" ]; then
  66. # Initialize the helper for common device
  67. setup_vendor "${DEVICE_COMMON}" "${VENDOR_COMMON:-$VENDOR}" "${ANDROID_ROOT}" true "${CLEAN_VENDOR}"
  68. extract "${MY_DIR}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}"
  69. fi
  70. if [ -z "${ONLY_COMMON}" ] && [ -s "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-files.txt" ]; then
  71. # Reinitialize the helper for device
  72. source "${MY_DIR}/../../${VENDOR}/${DEVICE}/extract-files.sh"
  73. setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false "${CLEAN_VENDOR}"
  74. extract "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}"
  75. if [ -z "${SECTION}" ] && [ -f "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-firmware.txt" ]; then
  76. extract_firmware "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-firmware.txt" "${SRC}"
  77. fi
  78. fi
  79. "${MY_DIR}/setup-makefiles.sh"