update_patches.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/usr/bin/env bash
  2. export VSCODE_QUALITY="stable"
  3. while getopts ":i" opt; do
  4. case "$opt" in
  5. i)
  6. export VSCODE_QUALITY="insider"
  7. ;;
  8. *)
  9. ;;
  10. esac
  11. done
  12. check_file() {
  13. while [ $# -gt 1 ]; do
  14. git apply --reject "${1}"
  15. shift
  16. done
  17. if [[ -f "${1}.bak" ]]; then
  18. mv -f $1{.bak,}
  19. fi
  20. if [[ -f "${1}" ]]; then
  21. git apply --reject "../patches/helper/settings.patch"
  22. git add .
  23. git commit --no-verify -q -m "VSCODIUM HELPER"
  24. echo applying patch: "${1}"
  25. if ! git apply --ignore-whitespace "${1}"; then
  26. echo failed to apply patch "${1}"
  27. git apply --reject "${1}"
  28. read -rp "Press any key when the conflict have been resolved..." -n1 -s
  29. git restore .vscode/settings.json
  30. git add .
  31. git diff --staged -U1 > "${1}"
  32. fi
  33. git add .
  34. git reset -q --hard HEAD~
  35. fi
  36. }
  37. cd vscode || { echo "'vscode' dir not found"; exit 1; }
  38. git add .
  39. git reset -q --hard HEAD
  40. for FILE in ../patches/*.patch; do
  41. check_file "${FILE}"
  42. done
  43. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  44. for FILE in ../patches/insider/*.patch; do
  45. check_file "${FILE}"
  46. done
  47. fi
  48. for ARCH in alpine linux osx windows; do
  49. for FILE in "../patches/${ARCH}/"*.patch; do
  50. if [[ "${ARCH}" == "linux" && "${FILE}" == *"/arch-"* ]] || [[ "${ARCH}" == "windows" && "${FILE}" == *"/cli"* ]]; then
  51. echo "skip ${FILE}"
  52. else
  53. check_file "${FILE}"
  54. fi
  55. done
  56. if [[ "${ARCH}" == "linux" ]]; then
  57. check_file "../patches/cli.patch" "../patches/linux/arch-0-support.patch"
  58. check_file "../patches/cli.patch" "../patches/linux/arch-0-support.patch" "../patches/linux/arch-1-ppc64le.patch"
  59. check_file "../patches/cli.patch" "../patches/linux/arch-0-support.patch" "../patches/linux/arch-1-ppc64le.patch" "../patches/linux/arch-2-riscv64.patch"
  60. check_file "../patches/cli.patch" "../patches/linux/arch-0-support.patch" "../patches/linux/arch-1-ppc64le.patch" "../patches/linux/arch-2-riscv64.patch" "../patches/linux/arch-3-loong64.patch"
  61. check_file "../patches/cli.patch" "../patches/linux/arch-0-support.patch" "../patches/linux/arch-1-ppc64le.patch" "../patches/linux/arch-2-riscv64.patch" "../patches/linux/arch-3-loong64.patch" "../patches/linux/arch-4-s390x.patch"
  62. elif [[ "${ARCH}" == "windows" ]]; then
  63. check_file "../patches/cli.patch" "../patches/windows/cli.patch"
  64. fi
  65. for TARGET in client reh; do
  66. for FILE in "../patches/${ARCH}/${TARGET}/"*.patch; do
  67. check_file "${FILE}"
  68. done
  69. for FILE in "../patches/${ARCH}/${TARGET}/"*/*.patch; do
  70. check_file "${FILE}"
  71. done
  72. done
  73. done