package_linux_reh.sh 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. if [[ "${VSCODE_ARCH}" == "ppc64le" ]]; then
  59. INCLUDES=$(cat <<EOF
  60. {
  61. "target_defaults": {
  62. "conditions": [
  63. ["OS=='linux'", {
  64. 'cflags_cc!': [ '-std=gnu++20' ],
  65. 'cflags_cc': [ '-std=gnu++2a' ],
  66. }]
  67. ]
  68. }
  69. }
  70. EOF
  71. )
  72. if [ ! -d "$HOME/.gyp" ]; then
  73. mkdir -p "$HOME/.gyp"
  74. fi
  75. echo "${INCLUDES}" > "$HOME/.gyp/include.gypi"
  76. fi
  77. for i in {1..5}; do # try 5 times
  78. npm ci --prefix build && break
  79. if [[ $i == 3 ]]; then
  80. echo "Npm install failed too many times" >&2
  81. exit 1
  82. fi
  83. echo "Npm install failed $i, trying again..."
  84. done
  85. if [[ "${VSCODE_ARCH}" == "ppc64le" ]]; then
  86. source ./build/azure-pipelines/linux/setup-env.sh
  87. else
  88. ./build/azure-pipelines/linux/setup-env.sh --only-remote
  89. fi
  90. for i in {1..5}; do # try 5 times
  91. npm ci && break
  92. if [[ $i == 3 ]]; then
  93. echo "Npm install failed too many times" >&2
  94. exit 1
  95. fi
  96. echo "Npm install failed $i, trying again..."
  97. done
  98. node build/azure-pipelines/distro/mixin-npm
  99. export VSCODE_NODE_GLIBC="-glibc-${GLIBC_VERSION}"
  100. if [[ "${SHOULD_BUILD_REH}" != "no" ]]; then
  101. echo "Building REH"
  102. yarn gulp minify-vscode-reh
  103. yarn gulp "vscode-reh-${VSCODE_PLATFORM}-${VSCODE_ARCH}-min-ci"
  104. 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
  105. echo "Archiving REH"
  106. pushd "../vscode-reh-${VSCODE_PLATFORM}-${VSCODE_ARCH}"
  107. tar czf "../assets/${APP_NAME_LC}-reh-${VSCODE_PLATFORM}-${VSCODE_ARCH}-${RELEASE_VERSION}.tar.gz" .
  108. popd
  109. fi
  110. if [[ "${SHOULD_BUILD_REH_WEB}" != "no" ]]; then
  111. echo "Building REH-web"
  112. yarn gulp minify-vscode-reh-web
  113. yarn gulp "vscode-reh-web-${VSCODE_PLATFORM}-${VSCODE_ARCH}-min-ci"
  114. 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
  115. echo "Archiving REH-web"
  116. pushd "../vscode-reh-web-${VSCODE_PLATFORM}-${VSCODE_ARCH}"
  117. tar czf "../assets/${APP_NAME_LC}-reh-web-${VSCODE_PLATFORM}-${VSCODE_ARCH}-${RELEASE_VERSION}.tar.gz" .
  118. popd
  119. fi
  120. cd ..
  121. npm install -g checksum
  122. sum_file() {
  123. if [[ -f "${1}" ]]; then
  124. echo "Calculating checksum for ${1}"
  125. checksum -a sha256 "${1}" > "${1}".sha256
  126. checksum "${1}" > "${1}".sha1
  127. fi
  128. }
  129. cd assets
  130. for FILE in *; do
  131. if [[ -f "${FILE}" ]]; then
  132. sum_file "${FILE}"
  133. fi
  134. done
  135. cd ..