package_linux_reh.sh 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #!/usr/bin/env bash
  2. # shellcheck disable=SC1091
  3. set -ex
  4. if [[ "${CI_BUILD}" == "no" ]]; then
  5. exit 1
  6. fi
  7. APP_NAME_LC="$( echo "${APP_NAME}" | awk '{print tolower($0)}' )"
  8. mkdir -p assets
  9. tar -xzf ./vscode.tar.gz
  10. cd vscode || { echo "'vscode' dir not found"; exit 1; }
  11. GLIBC_VERSION="2.17"
  12. GLIBCXX_VERSION="3.4.22"
  13. NODE_VERSION="16.20.2"
  14. if [[ "${VSCODE_ARCH}" == "ppc64le" ]]; then
  15. GLIBC_VERSION="2.28"
  16. elif [[ "${VSCODE_ARCH}" == "riscv64" ]]; then
  17. # Unofficial RISC-V nodejs builds doesn't provide v16.x
  18. NODE_VERSION="18.18.1"
  19. fi
  20. export VSCODE_PLATFORM='linux'
  21. export VSCODE_SKIP_NODE_VERSION_CHECK=1
  22. export VSCODE_SYSROOT_PREFIX="-glibc-${GLIBC_VERSION}"
  23. VSCODE_HOST_MOUNT="$( pwd )"
  24. export VSCODE_HOST_MOUNT
  25. if [[ "${VSCODE_ARCH}" == "x64" || "${VSCODE_ARCH}" == "arm64" ]]; then
  26. VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:centos7-devtoolset8-${VSCODE_ARCH}"
  27. elif [[ "${VSCODE_ARCH}" == "armhf" ]]; then
  28. VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:bionic-devtoolset-arm32v7"
  29. elif [[ "${VSCODE_ARCH}" == "ppc64le" ]]; then
  30. VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:bionic-devtoolset-ppc64le"
  31. export ELECTRON_SKIP_BINARY_DOWNLOAD=1
  32. export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
  33. export VSCODE_SYSROOT_REPO='VSCodium/vscode-linux-build-agent'
  34. export VSCODE_SYSROOT_VERSION='20240129-253798'
  35. elif [[ "${VSCODE_ARCH}" == "riscv64" ]]; then
  36. VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:focal-devtoolset-riscv64"
  37. export ELECTRON_SKIP_BINARY_DOWNLOAD=1
  38. export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
  39. fi
  40. export VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME
  41. sed -i "/target/s/\"20.*\"/\"${NODE_VERSION}\"/" remote/.npmrc
  42. if [[ "${NODE_VERSION}" != 16* ]]; then
  43. if [[ -f "../patches/linux/reh/node16.patch" ]]; then
  44. mv "../patches/linux/reh/node16.patch" "../patches/linux/reh/node16.patch.no"
  45. fi
  46. fi
  47. if [[ -d "../patches/linux/reh/" ]]; then
  48. for file in "../patches/linux/reh/"*.patch; do
  49. if [[ -f "${file}" ]]; then
  50. echo applying patch: "${file}";
  51. if ! git apply --ignore-whitespace "${file}"; then
  52. echo failed to apply patch "${file}" >&2
  53. exit 1
  54. fi
  55. fi
  56. done
  57. fi
  58. for i in {1..5}; do # try 5 times
  59. npm ci --prefix build && break
  60. if [[ $i == 3 ]]; then
  61. echo "Npm install failed too many times" >&2
  62. exit 1
  63. fi
  64. echo "Npm install failed $i, trying again..."
  65. done
  66. if [[ "${VSCODE_ARCH}" == "ppc64le" ]]; then
  67. source ./build/azure-pipelines/linux/setup-env.sh
  68. else
  69. ./build/azure-pipelines/linux/setup-env.sh --only-remote
  70. fi
  71. for i in {1..5}; do # try 5 times
  72. npm ci && break
  73. if [[ $i == 3 ]]; then
  74. echo "Npm install failed too many times" >&2
  75. exit 1
  76. fi
  77. echo "Npm install failed $i, trying again..."
  78. done
  79. node build/azure-pipelines/distro/mixin-npm
  80. export VSCODE_NODE_GLIBC="-glibc-${GLIBC_VERSION}"
  81. if [[ "${SHOULD_BUILD_REH}" != "no" ]]; then
  82. echo "Building REH"
  83. yarn gulp minify-vscode-reh
  84. yarn gulp "vscode-reh-${VSCODE_PLATFORM}-${VSCODE_ARCH}-min-ci"
  85. EXPECTED_GLIBC_VERSION="${GLIBC_VERSION}" EXPECTED_GLIBCXX_VERSION="${GLIBCXX_VERSION}" SEARCH_PATH="../vscode-reh-${VSCODE_PLATFORM}-${VSCODE_ARCH}" ./build/azure-pipelines/linux/verify-glibc-requirements.sh
  86. echo "Archiving REH"
  87. pushd "../vscode-reh-${VSCODE_PLATFORM}-${VSCODE_ARCH}"
  88. tar czf "../assets/${APP_NAME_LC}-reh-${VSCODE_PLATFORM}-${VSCODE_ARCH}-${RELEASE_VERSION}.tar.gz" .
  89. popd
  90. fi
  91. if [[ "${SHOULD_BUILD_REH_WEB}" != "no" ]]; then
  92. echo "Building REH-web"
  93. yarn gulp minify-vscode-reh-web
  94. yarn gulp "vscode-reh-web-${VSCODE_PLATFORM}-${VSCODE_ARCH}-min-ci"
  95. EXPECTED_GLIBC_VERSION="${GLIBC_VERSION}" EXPECTED_GLIBCXX_VERSION="${GLIBCXX_VERSION}" SEARCH_PATH="../vscode-reh-web-${VSCODE_PLATFORM}-${VSCODE_ARCH}" ./build/azure-pipelines/linux/verify-glibc-requirements.sh
  96. echo "Archiving REH-web"
  97. pushd "../vscode-reh-web-${VSCODE_PLATFORM}-${VSCODE_ARCH}"
  98. tar czf "../assets/${APP_NAME_LC}-reh-web-${VSCODE_PLATFORM}-${VSCODE_ARCH}-${RELEASE_VERSION}.tar.gz" .
  99. popd
  100. fi
  101. cd ..
  102. npm install -g checksum
  103. sum_file() {
  104. if [[ -f "${1}" ]]; then
  105. echo "Calculating checksum for ${1}"
  106. checksum -a sha256 "${1}" > "${1}".sha256
  107. checksum "${1}" > "${1}".sha1
  108. fi
  109. }
  110. cd assets
  111. for FILE in *; do
  112. if [[ -f "${FILE}" ]]; then
  113. sum_file "${FILE}"
  114. fi
  115. done
  116. cd ..