package_linux_reh.sh 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. fi
  52. export VSCODE_PLATFORM='linux'
  53. export VSCODE_SKIP_NODE_VERSION_CHECK=1
  54. export VSCODE_SYSROOT_PREFIX="-glibc-${GLIBC_VERSION}"
  55. VSCODE_HOST_MOUNT="$( pwd )"
  56. export VSCODE_HOST_MOUNT
  57. export VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME
  58. sed -i "/target/s/\"20.*\"/\"${NODE_VERSION}\"/" remote/.npmrc
  59. if [[ "${NODE_VERSION}" != 16* ]]; then
  60. if [[ -f "../patches/linux/reh/node16.patch" ]]; then
  61. mv "../patches/linux/reh/node16.patch" "../patches/linux/reh/node16.patch.no"
  62. fi
  63. fi
  64. if [[ -d "../patches/linux/reh/" ]]; then
  65. for file in "../patches/linux/reh/"*.patch; do
  66. if [[ -f "${file}" ]]; then
  67. echo applying patch: "${file}";
  68. if ! git apply --ignore-whitespace "${file}"; then
  69. echo failed to apply patch "${file}" >&2
  70. exit 1
  71. fi
  72. fi
  73. done
  74. fi
  75. if [[ -n "${USE_GNUPP2A}" ]]; then
  76. INCLUDES=$(cat <<EOF
  77. {
  78. "target_defaults": {
  79. "conditions": [
  80. ["OS=='linux'", {
  81. 'cflags_cc!': [ '-std=gnu++20' ],
  82. 'cflags_cc': [ '-std=gnu++2a' ],
  83. }]
  84. ]
  85. }
  86. }
  87. EOF
  88. )
  89. if [ ! -d "$HOME/.gyp" ]; then
  90. mkdir -p "$HOME/.gyp"
  91. fi
  92. echo "${INCLUDES}" > "$HOME/.gyp/include.gypi"
  93. fi
  94. for i in {1..5}; do # try 5 times
  95. npm ci --prefix build && break
  96. if [[ $i == 3 ]]; then
  97. echo "Npm install failed too many times" >&2
  98. exit 1
  99. fi
  100. echo "Npm install failed $i, trying again..."
  101. done
  102. if [[ -z "${VSCODE_SKIP_SETUPENV}" ]]; then
  103. if [[ -n "${VSCODE_SKIP_SYSROOT}" ]]; then
  104. source ./build/azure-pipelines/linux/setup-env.sh --skip-sysroot
  105. else
  106. source ./build/azure-pipelines/linux/setup-env.sh
  107. fi
  108. fi
  109. for i in {1..5}; do # try 5 times
  110. npm ci && break
  111. if [[ $i == 3 ]]; then
  112. echo "Npm install failed too many times" >&2
  113. exit 1
  114. fi
  115. echo "Npm install failed $i, trying again..."
  116. done
  117. node build/azure-pipelines/distro/mixin-npm
  118. export VSCODE_NODE_GLIBC="-glibc-${GLIBC_VERSION}"
  119. if [[ "${SHOULD_BUILD_REH}" != "no" ]]; then
  120. echo "Building REH"
  121. yarn gulp minify-vscode-reh
  122. yarn gulp "vscode-reh-${VSCODE_PLATFORM}-${VSCODE_ARCH}-min-ci"
  123. 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
  124. pushd "../vscode-reh-${VSCODE_PLATFORM}-${VSCODE_ARCH}"
  125. if [[ -f "../ripgrep_${VSCODE_PLATFORM}_${VSCODE_ARCH}.sh" ]]; then
  126. bash "../ripgrep_${VSCODE_PLATFORM}_${VSCODE_ARCH}.sh"
  127. fi
  128. echo "Archiving REH"
  129. tar czf "../assets/${APP_NAME_LC}-reh-${VSCODE_PLATFORM}-${VSCODE_ARCH}-${RELEASE_VERSION}.tar.gz" .
  130. popd
  131. fi
  132. if [[ "${SHOULD_BUILD_REH_WEB}" != "no" ]]; then
  133. echo "Building REH-web"
  134. yarn gulp minify-vscode-reh-web
  135. yarn gulp "vscode-reh-web-${VSCODE_PLATFORM}-${VSCODE_ARCH}-min-ci"
  136. 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
  137. pushd "../vscode-reh-web-${VSCODE_PLATFORM}-${VSCODE_ARCH}"
  138. if [[ -f "../ripgrep_${VSCODE_PLATFORM}_${VSCODE_ARCH}.sh" ]]; then
  139. bash "../ripgrep_${VSCODE_PLATFORM}_${VSCODE_ARCH}.sh"
  140. fi
  141. echo "Archiving REH-web"
  142. tar czf "../assets/${APP_NAME_LC}-reh-web-${VSCODE_PLATFORM}-${VSCODE_ARCH}-${RELEASE_VERSION}.tar.gz" .
  143. popd
  144. fi
  145. cd ..
  146. npm install -g checksum
  147. sum_file() {
  148. if [[ -f "${1}" ]]; then
  149. echo "Calculating checksum for ${1}"
  150. checksum -a sha256 "${1}" > "${1}".sha256
  151. checksum "${1}" > "${1}".sha1
  152. fi
  153. }
  154. cd assets
  155. for FILE in *; do
  156. if [[ -f "${FILE}" ]]; then
  157. sum_file "${FILE}"
  158. fi
  159. done
  160. cd ..