option.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # SPDX-License-Identifier: GPL-3.0-only
  2. # SPDX-FileCopyrightText: 2022 Caleb La Grange <thonkpeasant@protonmail.com>
  3. # SPDX-FileCopyrightText: 2022 Ferass El Hafidi <vitali64pmemail@protonmail.com>
  4. # SPDX-FileCopyrightText: 2020-2024 Leah Rowe <leah@libreboot.org>
  5. vendir="vendorfiles"
  6. appdir="${vendir}/app"
  7. cbdir="src/coreboot/default"
  8. cbcfgsdir="config/coreboot"
  9. ifdtool="cbutils/default/ifdtool"
  10. cbfstool="cbutils/default/cbfstool"
  11. grubcfgsdir="config/grub"
  12. layoutdir="/boot/grub/layouts"
  13. . "${grubcfgsdir}/modules.list"
  14. tmpgit="${PWD}/tmp/gitclone"
  15. eval "$(setvars "" CONFIG_BOARD_DELL_E6400 CONFIG_HAVE_MRC CONFIG_HAVE_ME_BIN \
  16. CONFIG_ME_BIN_PATH CONFIG_KBC1126_FIRMWARE CONFIG_KBC1126_FW1 \
  17. CONFIG_KBC1126_FW1_OFFSET CONFIG_KBC1126_FW2 CONFIG_KBC1126_FW2_OFFSET \
  18. CONFIG_VGA_BIOS_FILE CONFIG_VGA_BIOS_ID CONFIG_GBE_BIN_PATH \
  19. CONFIG_INCLUDE_SMSC_SCH5545_EC_FW CONFIG_SMSC_SCH5545_EC_FW_FILE \
  20. CONFIG_IFD_BIN_PATH CONFIG_MRC_FILE _dest board boarddir \
  21. CONFIG_HAVE_REFCODE_BLOB CONFIG_REFCODE_BLOB_FILE)"
  22. items()
  23. {
  24. rval=1
  25. if [ ! -d "${1}" ]; then
  26. printf "items: directory '%s' doesn't exist" "${1}" 1>&2
  27. return 1
  28. fi
  29. for x in "${1}/"*; do
  30. # -e used because this is for files *or* directories
  31. [ -e "${x}" ] || continue
  32. [ "${x##*/}" = "build.list" ] && continue
  33. printf "%s\n" "${x##*/}" 2>/dev/null
  34. rval=0
  35. done
  36. return ${rval}
  37. }
  38. scan_config()
  39. {
  40. awkstr=" /\{.*${1}.*}{/ {flag=1;next} /\}/{flag=0} flag { print }"
  41. confdir="${2}"
  42. _fail="${3}"
  43. revfile="$(mktemp -t sources.XXXXXXXXXX)"
  44. cat "${confdir}/"* > "${revfile}" || \
  45. "${_fail}" "scan_config ${confdir}: Cannot concatenate files"
  46. while read -r line ; do
  47. set ${line} 1>/dev/null 2>/dev/null || :
  48. if [ "${1%:}" = "depend" ]; then
  49. depend="${depend} ${2}"
  50. else
  51. eval "${1%:}=\"${2}\""
  52. fi
  53. done << EOF
  54. $(eval "awk '${awkstr}' \"${revfile}\"")
  55. EOF
  56. rm -f "$revfile" || "$_fail" "scan_config: Cannot remove tmpfile"
  57. }
  58. check_defconfig()
  59. {
  60. for x in "${1}"/config/*; do
  61. [ -f "${x}" ] && return 1
  62. done
  63. }
  64. handle_coreboot_utils()
  65. {
  66. for util in cbfstool ifdtool; do
  67. x_ ./update trees ${_f} "src/coreboot/${1}/util/${util}"
  68. [ -z "${mode}" ] && [ ! -f "cbutils/${1}/${util}" ] && \
  69. x_ mkdir -p "cbutils/${1}" && \
  70. x_ cp "src/coreboot/${1}/util/${util}/${util}" \
  71. "cbutils/${1}"
  72. [ -z "${mode}" ] || x_ rm -Rf "cbutils/${1}"
  73. done
  74. }
  75. remkdir()
  76. {
  77. rm -Rf "${1}" || err "remkdir: !rm -Rf \"${1}\""
  78. mkdir -p "${1}" || err "remkdir: !mkdir -p \"${1}\""
  79. }