package_linux_reh.sh 6.6 KB

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