package_linux_reh.sh 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 18 is buggy so use 20 here for now: https://github.com/VSCodium/vscodium/issues/2060
  19. NODE_VERSION="20.16.0"
  20. fi
  21. export VSCODE_PLATFORM='linux'
  22. export VSCODE_SKIP_NODE_VERSION_CHECK=1
  23. export VSCODE_SYSROOT_PREFIX="-glibc-${GLIBC_VERSION}"
  24. VSCODE_HOST_MOUNT="$( pwd )"
  25. export VSCODE_HOST_MOUNT
  26. if [[ "${VSCODE_ARCH}" == "x64" || "${VSCODE_ARCH}" == "arm64" ]]; then
  27. VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:centos7-devtoolset8-${VSCODE_ARCH}"
  28. elif [[ "${VSCODE_ARCH}" == "armhf" ]]; then
  29. VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:bionic-devtoolset-arm32v7"
  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_REPO='VSCodium/vscode-linux-build-agent'
  35. export VSCODE_SYSROOT_VERSION='20240129-253798'
  36. elif [[ "${VSCODE_ARCH}" == "riscv64" ]]; then
  37. VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:focal-devtoolset-riscv64"
  38. export ELECTRON_SKIP_BINARY_DOWNLOAD=1
  39. export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
  40. fi
  41. export VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME
  42. sed -i "/target/s/\"20.*\"/\"${NODE_VERSION}\"/" remote/.npmrc
  43. if [[ "${NODE_VERSION}" != 16* ]]; then
  44. if [[ -f "../patches/linux/reh/node16.patch" ]]; then
  45. mv "../patches/linux/reh/node16.patch" "../patches/linux/reh/node16.patch.no"
  46. fi
  47. fi
  48. if [[ -d "../patches/linux/reh/" ]]; then
  49. for file in "../patches/linux/reh/"*.patch; do
  50. if [[ -f "${file}" ]]; then
  51. echo applying patch: "${file}";
  52. if ! git apply --ignore-whitespace "${file}"; then
  53. echo failed to apply patch "${file}" >&2
  54. exit 1
  55. fi
  56. fi
  57. done
  58. fi
  59. if [[ "${VSCODE_ARCH}" == "ppc64le" ]]; then
  60. INCLUDES=$(cat <<EOF
  61. {
  62. "target_defaults": {
  63. "conditions": [
  64. ["OS=='linux'", {
  65. 'cflags_cc!': [ '-std=gnu++20' ],
  66. 'cflags_cc': [ '-std=gnu++2a' ],
  67. }]
  68. ]
  69. }
  70. }
  71. EOF
  72. )
  73. if [ ! -d "$HOME/.gyp" ]; then
  74. mkdir -p "$HOME/.gyp"
  75. fi
  76. echo "${INCLUDES}" > "$HOME/.gyp/include.gypi"
  77. fi
  78. for i in {1..5}; do # try 5 times
  79. npm ci --prefix build && break
  80. if [[ $i == 3 ]]; then
  81. echo "Npm install failed too many times" >&2
  82. exit 1
  83. fi
  84. echo "Npm install failed $i, trying again..."
  85. done
  86. if [[ "${VSCODE_ARCH}" == "ppc64le" ]]; then
  87. source ./build/azure-pipelines/linux/setup-env.sh
  88. else
  89. ./build/azure-pipelines/linux/setup-env.sh --only-remote
  90. fi
  91. for i in {1..5}; do # try 5 times
  92. npm ci && break
  93. if [[ $i == 3 ]]; then
  94. echo "Npm install failed too many times" >&2
  95. exit 1
  96. fi
  97. echo "Npm install failed $i, trying again..."
  98. done
  99. node build/azure-pipelines/distro/mixin-npm
  100. export VSCODE_NODE_GLIBC="-glibc-${GLIBC_VERSION}"
  101. if [[ "${SHOULD_BUILD_REH}" != "no" ]]; then
  102. echo "Building REH"
  103. yarn gulp minify-vscode-reh
  104. yarn gulp "vscode-reh-${VSCODE_PLATFORM}-${VSCODE_ARCH}-min-ci"
  105. 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
  106. echo "Archiving REH"
  107. pushd "../vscode-reh-${VSCODE_PLATFORM}-${VSCODE_ARCH}"
  108. tar czf "../assets/${APP_NAME_LC}-reh-${VSCODE_PLATFORM}-${VSCODE_ARCH}-${RELEASE_VERSION}.tar.gz" .
  109. popd
  110. fi
  111. if [[ "${SHOULD_BUILD_REH_WEB}" != "no" ]]; then
  112. echo "Building REH-web"
  113. yarn gulp minify-vscode-reh-web
  114. yarn gulp "vscode-reh-web-${VSCODE_PLATFORM}-${VSCODE_ARCH}-min-ci"
  115. 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
  116. echo "Archiving REH-web"
  117. pushd "../vscode-reh-web-${VSCODE_PLATFORM}-${VSCODE_ARCH}"
  118. tar czf "../assets/${APP_NAME_LC}-reh-web-${VSCODE_PLATFORM}-${VSCODE_ARCH}-${RELEASE_VERSION}.tar.gz" .
  119. popd
  120. fi
  121. cd ..
  122. npm install -g checksum
  123. sum_file() {
  124. if [[ -f "${1}" ]]; then
  125. echo "Calculating checksum for ${1}"
  126. checksum -a sha256 "${1}" > "${1}".sha256
  127. checksum "${1}" > "${1}".sha1
  128. fi
  129. }
  130. cd assets
  131. for FILE in *; do
  132. if [[ -f "${FILE}" ]]; then
  133. sum_file "${FILE}"
  134. fi
  135. done
  136. cd ..