package_reh.sh 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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.28"
  12. GLIBCXX_VERSION="3.4.26"
  13. NODE_VERSION="20.18.1"
  14. export VSCODE_NODEJS_URLROOT='/download/release'
  15. export VSCODE_NODEJS_URLSUFFIX=''
  16. if [[ "${VSCODE_ARCH}" == "x64" ]]; then
  17. GLIBC_VERSION="2.17"
  18. GLIBCXX_VERSION="3.4.22"
  19. VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:centos7-devtoolset8-${VSCODE_ARCH}"
  20. export VSCODE_NODEJS_SITE='https://unofficial-builds.nodejs.org'
  21. export VSCODE_NODEJS_URLSUFFIX='-glibc-217'
  22. elif [[ "${VSCODE_ARCH}" == "arm64" ]]; then
  23. VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:centos7-devtoolset8-${VSCODE_ARCH}"
  24. export VSCODE_SKIP_SYSROOT=1
  25. export USE_GNUPP2A=1
  26. elif [[ "${VSCODE_ARCH}" == "armhf" ]]; then
  27. VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:bionic-devtoolset-arm32v7"
  28. export VSCODE_SKIP_SYSROOT=1
  29. export USE_GNUPP2A=1
  30. elif [[ "${VSCODE_ARCH}" == "ppc64le" ]]; then
  31. VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:bionic-devtoolset-ppc64le"
  32. export ELECTRON_SKIP_BINARY_DOWNLOAD=1
  33. export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
  34. export VSCODE_SYSROOT_REPOSITORY='VSCodium/vscode-linux-build-agent'
  35. export VSCODE_SYSROOT_VERSION='20240129-253798'
  36. export USE_GNUPP2A=1
  37. elif [[ "${VSCODE_ARCH}" == "riscv64" ]]; then
  38. NODE_VERSION="20.16.0"
  39. VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:focal-devtoolset-riscv64"
  40. export ELECTRON_SKIP_BINARY_DOWNLOAD=1
  41. export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
  42. export VSCODE_SKIP_SETUPENV=1
  43. export VSCODE_NODEJS_SITE='https://unofficial-builds.nodejs.org'
  44. elif [[ "${VSCODE_ARCH}" == "loong64" ]]; then
  45. NODE_VERSION="20.16.0"
  46. VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:trixie-devtoolset-loong64"
  47. export ELECTRON_SKIP_BINARY_DOWNLOAD=1
  48. export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
  49. export VSCODE_SKIP_SETUPENV=1
  50. export VSCODE_NODEJS_SITE='https://unofficial-builds.nodejs.org'
  51. elif [[ "${VSCODE_ARCH}" == "s390x" ]]; then
  52. VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:focal-devtoolset-s390x"
  53. export ELECTRON_SKIP_BINARY_DOWNLOAD=1
  54. export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
  55. export VSCODE_SYSROOT_REPOSITORY='VSCodium/vscode-linux-build-agent'
  56. export VSCODE_SYSROOT_VERSION='20241108'
  57. fi
  58. export VSCODE_PLATFORM='linux'
  59. export VSCODE_SKIP_NODE_VERSION_CHECK=1
  60. export VSCODE_SYSROOT_PREFIX="-glibc-${GLIBC_VERSION}"
  61. VSCODE_HOST_MOUNT="$( pwd )"
  62. export VSCODE_HOST_MOUNT
  63. export VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME
  64. sed -i "/target/s/\"20.*\"/\"${NODE_VERSION}\"/" remote/.npmrc
  65. if [[ -d "../patches/linux/reh/" ]]; then
  66. for file in "../patches/linux/reh/"*.patch; do
  67. if [[ -f "${file}" ]]; then
  68. echo applying patch: "${file}";
  69. if ! git apply --ignore-whitespace "${file}"; then
  70. echo failed to apply patch "${file}" >&2
  71. exit 1
  72. fi
  73. fi
  74. done
  75. fi
  76. if [[ -d "../patches/linux/reh/${VSCODE_ARCH}/" ]]; then
  77. for file in "../patches/linux/reh/${VSCODE_ARCH}/"*.patch; do
  78. if [[ -f "${file}" ]]; then
  79. echo applying patch: "${file}";
  80. if ! git apply --ignore-whitespace "${file}"; then
  81. echo failed to apply patch "${file}" >&2
  82. exit 1
  83. fi
  84. fi
  85. done
  86. fi
  87. if [[ -n "${USE_GNUPP2A}" ]]; then
  88. INCLUDES=$(cat <<EOF
  89. {
  90. "target_defaults": {
  91. "conditions": [
  92. ["OS=='linux'", {
  93. 'cflags_cc!': [ '-std=gnu++20' ],
  94. 'cflags_cc': [ '-std=gnu++2a' ],
  95. }]
  96. ]
  97. }
  98. }
  99. EOF
  100. )
  101. if [ ! -d "${HOME}/.gyp" ]; then
  102. mkdir -p "${HOME}/.gyp"
  103. fi
  104. echo "${INCLUDES}" > "${HOME}/.gyp/include.gypi"
  105. fi
  106. for i in {1..5}; do # try 5 times
  107. npm ci --prefix build && break
  108. if [[ $i == 3 ]]; then
  109. echo "Npm install failed too many times" >&2
  110. exit 1
  111. fi
  112. echo "Npm install failed $i, trying again..."
  113. done
  114. if [[ -z "${VSCODE_SKIP_SETUPENV}" ]]; then
  115. if [[ -n "${VSCODE_SKIP_SYSROOT}" ]]; then
  116. source ./build/azure-pipelines/linux/setup-env.sh --skip-sysroot
  117. else
  118. source ./build/azure-pipelines/linux/setup-env.sh
  119. fi
  120. fi
  121. for i in {1..5}; do # try 5 times
  122. npm ci && break
  123. if [[ $i == 3 ]]; then
  124. echo "Npm install failed too many times" >&2
  125. exit 1
  126. fi
  127. echo "Npm install failed $i, trying again..."
  128. done
  129. node build/azure-pipelines/distro/mixin-npm
  130. export VSCODE_NODE_GLIBC="-glibc-${GLIBC_VERSION}"
  131. if [[ "${SHOULD_BUILD_REH}" != "no" ]]; then
  132. echo "Building REH"
  133. yarn gulp minify-vscode-reh
  134. yarn gulp "vscode-reh-${VSCODE_PLATFORM}-${VSCODE_ARCH}-min-ci"
  135. 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
  136. pushd "../vscode-reh-${VSCODE_PLATFORM}-${VSCODE_ARCH}"
  137. if [[ -f "../ripgrep_${VSCODE_PLATFORM}_${VSCODE_ARCH}.sh" ]]; then
  138. bash "../ripgrep_${VSCODE_PLATFORM}_${VSCODE_ARCH}.sh" "node_modules"
  139. fi
  140. echo "Archiving REH"
  141. tar czf "../assets/${APP_NAME_LC}-reh-${VSCODE_PLATFORM}-${VSCODE_ARCH}-${RELEASE_VERSION}.tar.gz" .
  142. popd
  143. fi
  144. if [[ "${SHOULD_BUILD_REH_WEB}" != "no" ]]; then
  145. echo "Building REH-web"
  146. yarn gulp minify-vscode-reh-web
  147. yarn gulp "vscode-reh-web-${VSCODE_PLATFORM}-${VSCODE_ARCH}-min-ci"
  148. 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
  149. pushd "../vscode-reh-web-${VSCODE_PLATFORM}-${VSCODE_ARCH}"
  150. if [[ -f "../ripgrep_${VSCODE_PLATFORM}_${VSCODE_ARCH}.sh" ]]; then
  151. bash "../ripgrep_${VSCODE_PLATFORM}_${VSCODE_ARCH}.sh" "node_modules"
  152. fi
  153. echo "Archiving REH-web"
  154. tar czf "../assets/${APP_NAME_LC}-reh-web-${VSCODE_PLATFORM}-${VSCODE_ARCH}-${RELEASE_VERSION}.tar.gz" .
  155. popd
  156. fi
  157. cd ..
  158. npm install -g checksum
  159. sum_file() {
  160. if [[ -f "${1}" ]]; then
  161. echo "Calculating checksum for ${1}"
  162. checksum -a sha256 "${1}" > "${1}".sha256
  163. checksum "${1}" > "${1}".sha1
  164. fi
  165. }
  166. cd assets
  167. for FILE in *; do
  168. if [[ -f "${FILE}" ]]; then
  169. sum_file "${FILE}"
  170. fi
  171. done
  172. cd ..