prepare_vscode.sh 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. #!/usr/bin/env bash
  2. # shellcheck disable=SC1091,2154
  3. set -e
  4. # include common functions
  5. . ./utils.sh
  6. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  7. cp -rp src/insider/* vscode/
  8. else
  9. cp -rp src/stable/* vscode/
  10. fi
  11. cp -f LICENSE vscode/LICENSE.txt
  12. cd vscode || { echo "'vscode' dir not found"; exit 1; }
  13. ../update_settings.sh
  14. # apply patches
  15. { set +x; } 2>/dev/null
  16. for file in ../patches/*.patch; do
  17. if [[ -f "${file}" ]]; then
  18. echo applying patch: "${file}";
  19. # grep '^+++' "${file}" | sed -e 's#+++ [ab]/#./vscode/#' | while read line; do shasum -a 256 "${line}"; done
  20. if ! git apply --ignore-whitespace "${file}"; then
  21. echo failed to apply patch "${file}" >&2
  22. exit 1
  23. fi
  24. fi
  25. done
  26. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  27. for file in ../patches/insider/*.patch; do
  28. if [[ -f "${file}" ]]; then
  29. echo applying patch: "${file}";
  30. if ! git apply --ignore-whitespace "${file}"; then
  31. echo failed to apply patch "${file}" >&2
  32. exit 1
  33. fi
  34. fi
  35. done
  36. fi
  37. for file in ../patches/user/*.patch; do
  38. if [[ -f "${file}" ]]; then
  39. echo applying user patch: "${file}";
  40. if ! git apply --ignore-whitespace "${file}"; then
  41. echo failed to apply patch "${file}" >&2
  42. exit 1
  43. fi
  44. fi
  45. done
  46. if [[ -d "../patches/${OS_NAME}/" ]]; then
  47. for file in "../patches/${OS_NAME}/"*.patch; do
  48. if [[ -f "${file}" ]]; then
  49. echo applying patch: "${file}";
  50. if ! git apply --ignore-whitespace "${file}"; then
  51. echo failed to apply patch "${file}" >&2
  52. exit 1
  53. fi
  54. fi
  55. done
  56. if [[ -d "../patches/${OS_NAME}/${VSCODE_ARCH}/" ]]; then
  57. for file in "../patches/${OS_NAME}/${VSCODE_ARCH}/"*.patch; do
  58. if [[ -f "${file}" ]]; then
  59. echo applying patch: "${file}";
  60. if ! git apply --ignore-whitespace "${file}"; then
  61. echo failed to apply patch "${file}" >&2
  62. exit 1
  63. fi
  64. fi
  65. done
  66. fi
  67. fi
  68. set -x
  69. export ELECTRON_SKIP_BINARY_DOWNLOAD=1
  70. export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
  71. if [[ "${OS_NAME}" == "linux" ]]; then
  72. export VSCODE_SKIP_NODE_VERSION_CHECK=1
  73. if [[ -f "../.nvmrc.linux" ]]; then
  74. mv ../.nvmrc.linux ../.nvmrc
  75. fi
  76. fi
  77. if [[ "${OS_NAME}" == "linux" ]]; then
  78. if [[ "${npm_config_arch}" == "arm" ]]; then
  79. export npm_config_arm_version=7
  80. fi
  81. if [[ "${CI_BUILD}" == "no" ]]; then
  82. yarn --frozen-lockfile --check-files
  83. else
  84. mkdir -p .build
  85. export VSCODE_SYSROOT_PREFIX='-glibc-2.17'
  86. VSCODE_HOST_MOUNT="$( pwd )"
  87. export VSCODE_HOST_MOUNT
  88. # if [[ "${VSCODE_ARCH}" == "x64" || "${VSCODE_ARCH}" == "arm64" ]]; then
  89. # VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:centos7-devtoolset8-${VSCODE_ARCH}"
  90. # elif [[ "${VSCODE_ARCH}" == "armhf" ]]; then
  91. # VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:bionic-devtoolset-arm32v7"
  92. # elif [[ "${VSCODE_ARCH}" == "ppc64le" ]]; then
  93. # VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:bionic-devtoolset-ppc64le"
  94. # fi
  95. # export VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME
  96. for i in {1..5}; do # try 5 times
  97. yarn --cwd build --frozen-lockfile --check-files && break
  98. if [[ $i == 3 ]]; then
  99. echo "Yarn failed too many times" >&2
  100. exit 1
  101. fi
  102. echo "Yarn failed $i, trying again..."
  103. done
  104. ./build/azure-pipelines/linux/install.sh
  105. EXPECTED_GLIBC_VERSION="2.17" EXPECTED_GLIBCXX_VERSION="3.4.22" ./build/azure-pipelines/linux/verify-glibc-requirements.sh
  106. node build/azure-pipelines/distro/mixin-npm
  107. fi
  108. elif [[ "${OS_NAME}" == "osx" ]]; then
  109. CHILD_CONCURRENCY=1 yarn --frozen-lockfile --network-timeout 180000
  110. yarn postinstall
  111. else
  112. # TODO: Should be replaced with upstream URL once https://github.com/nodejs/node-gyp/pull/2825
  113. # gets merged.
  114. rm -rf .build/node-gyp
  115. mkdir -p .build/node-gyp
  116. cd .build/node-gyp
  117. git config --global user.email "$( echo "${GITHUB_USERNAME}" | awk '{print tolower($0)}' )-ci@not-real.com"
  118. git config --global user.name "${GITHUB_USERNAME} CI"
  119. git clone https://github.com/nodejs/node-gyp.git .
  120. git checkout v9.4.0
  121. git am --3way --whitespace=fix ../../build/npm/gyp/patches/gyp_spectre_mitigation_support.patch
  122. npm install
  123. npm_config_node_gyp="$( pwd )/bin/node-gyp.js"
  124. export npm_config_node_gyp
  125. cd ../..
  126. if [[ "${npm_config_arch}" == "arm" ]]; then
  127. export npm_config_arm_version=7
  128. fi
  129. CHILD_CONCURRENCY=1 yarn --frozen-lockfile --check-files --network-timeout 180000
  130. fi
  131. setpath() {
  132. local jsonTmp
  133. { set +x; } 2>/dev/null
  134. jsonTmp=$( jq --arg 'path' "${2}" --arg 'value' "${3}" 'setpath([$path]; $value)' "${1}.json" )
  135. echo "${jsonTmp}" > "${1}.json"
  136. set -x
  137. }
  138. setpath_json() {
  139. local jsonTmp
  140. { set +x; } 2>/dev/null
  141. jsonTmp=$( jq --arg 'path' "${2}" --argjson 'value' "${3}" 'setpath([$path]; $value)' "${1}.json" )
  142. echo "${jsonTmp}" > "${1}.json"
  143. set -x
  144. }
  145. # product.json
  146. cp product.json{,.bak}
  147. setpath "product" "checksumFailMoreInfoUrl" "https://go.microsoft.com/fwlink/?LinkId=828886"
  148. setpath "product" "documentationUrl" "https://go.microsoft.com/fwlink/?LinkID=533484#vscode"
  149. setpath_json "product" "extensionsGallery" '{"serviceUrl": "https://open-vsx.org/vscode/gallery", "itemUrl": "https://open-vsx.org/vscode/item"}'
  150. setpath "product" "introductoryVideosUrl" "https://go.microsoft.com/fwlink/?linkid=832146"
  151. setpath "product" "keyboardShortcutsUrlLinux" "https://go.microsoft.com/fwlink/?linkid=832144"
  152. setpath "product" "keyboardShortcutsUrlMac" "https://go.microsoft.com/fwlink/?linkid=832143"
  153. setpath "product" "keyboardShortcutsUrlWin" "https://go.microsoft.com/fwlink/?linkid=832145"
  154. setpath "product" "licenseUrl" "https://github.com/VSCodium/vscodium/blob/master/LICENSE"
  155. setpath_json "product" "linkProtectionTrustedDomains" '["https://open-vsx.org"]'
  156. setpath "product" "releaseNotesUrl" "https://go.microsoft.com/fwlink/?LinkID=533483#vscode"
  157. setpath "product" "reportIssueUrl" "https://github.com/VSCodium/vscodium/issues/new"
  158. setpath "product" "requestFeatureUrl" "https://go.microsoft.com/fwlink/?LinkID=533482"
  159. setpath "product" "tipsAndTricksUrl" "https://go.microsoft.com/fwlink/?linkid=852118"
  160. setpath "product" "twitterUrl" "https://go.microsoft.com/fwlink/?LinkID=533687"
  161. if [[ "${DISABLE_UPDATE}" != "yes" ]]; then
  162. setpath "product" "updateUrl" "https://vscodium.now.sh"
  163. setpath "product" "downloadUrl" "https://github.com/VSCodium/vscodium/releases"
  164. fi
  165. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  166. setpath "product" "nameShort" "VSCodium - Insiders"
  167. setpath "product" "nameLong" "VSCodium - Insiders"
  168. setpath "product" "applicationName" "codium-insiders"
  169. setpath "product" "dataFolderName" ".vscodium-insiders"
  170. setpath "product" "linuxIconName" "vscodium-insiders"
  171. setpath "product" "quality" "insider"
  172. setpath "product" "urlProtocol" "vscodium-insiders"
  173. setpath "product" "serverApplicationName" "codium-server-insiders"
  174. setpath "product" "serverDataFolderName" ".vscodium-server-insiders"
  175. setpath "product" "darwinBundleIdentifier" "com.vscodium.VSCodiumInsiders"
  176. setpath "product" "win32AppUserModelId" "VSCodium.VSCodiumInsiders"
  177. setpath "product" "win32DirName" "VSCodium Insiders"
  178. setpath "product" "win32MutexName" "vscodiuminsiders"
  179. setpath "product" "win32NameVersion" "VSCodium Insiders"
  180. setpath "product" "win32RegValueName" "VSCodiumInsiders"
  181. setpath "product" "win32ShellNameShort" "VSCodium Insiders"
  182. setpath "product" "win32AppId" "{{EF35BB36-FA7E-4BB9-B7DA-D1E09F2DA9C9}"
  183. setpath "product" "win32x64AppId" "{{B2E0DDB2-120E-4D34-9F7E-8C688FF839A2}"
  184. setpath "product" "win32arm64AppId" "{{44721278-64C6-4513-BC45-D48E07830599}"
  185. setpath "product" "win32UserAppId" "{{ED2E5618-3E7E-4888-BF3C-A6CCC84F586F}"
  186. setpath "product" "win32x64UserAppId" "{{20F79D0D-A9AC-4220-9A81-CE675FFB6B41}"
  187. setpath "product" "win32arm64UserAppId" "{{2E362F92-14EA-455A-9ABD-3E656BBBFE71}"
  188. else
  189. setpath "product" "nameShort" "VSCodium"
  190. setpath "product" "nameLong" "VSCodium"
  191. setpath "product" "applicationName" "codium"
  192. setpath "product" "linuxIconName" "vscodium"
  193. setpath "product" "quality" "stable"
  194. setpath "product" "urlProtocol" "vscodium"
  195. setpath "product" "serverApplicationName" "codium-server"
  196. setpath "product" "serverDataFolderName" ".vscodium-server"
  197. setpath "product" "darwinBundleIdentifier" "com.vscodium"
  198. setpath "product" "win32AppUserModelId" "VSCodium.VSCodium"
  199. setpath "product" "win32DirName" "VSCodium"
  200. setpath "product" "win32MutexName" "vscodium"
  201. setpath "product" "win32NameVersion" "VSCodium"
  202. setpath "product" "win32RegValueName" "VSCodium"
  203. setpath "product" "win32ShellNameShort" "VSCodium"
  204. setpath "product" "win32AppId" "{{763CBF88-25C6-4B10-952F-326AE657F16B}"
  205. setpath "product" "win32x64AppId" "{{88DA3577-054F-4CA1-8122-7D820494CFFB}"
  206. setpath "product" "win32arm64AppId" "{{67DEE444-3D04-4258-B92A-BC1F0FF2CAE4}"
  207. setpath "product" "win32UserAppId" "{{0FD05EB4-651E-4E78-A062-515204B47A3A}"
  208. setpath "product" "win32x64UserAppId" "{{2E1F05D1-C245-4562-81EE-28188DB6FD17}"
  209. setpath "product" "win32arm64UserAppId" "{{57FD70A5-1B8D-4875-9F40-C5553F094828}"
  210. fi
  211. jsonTmp=$( jq -s '.[0] * .[1]' product.json ../product.json )
  212. echo "${jsonTmp}" > product.json && unset jsonTmp
  213. cat product.json
  214. # package.json
  215. cp package.json{,.bak}
  216. setpath "package" "version" "$( echo "${RELEASE_VERSION}" | sed -n -E "s/^(.*)\.([0-9]+)(-insider)?$/\1/p" )"
  217. setpath "package" "release" "$( echo "${RELEASE_VERSION}" | sed -n -E "s/^(.*)\.([0-9]+)(-insider)?$/\2/p" )"
  218. replace 's|Microsoft Corporation|VSCodium|' package.json
  219. # announcements
  220. replace "s|\\[\\/\\* BUILTIN_ANNOUNCEMENTS \\*\\/\\]|$( tr -d '\n' < ../announcements-builtin.json )|" src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts
  221. ../undo_telemetry.sh
  222. replace 's|Microsoft Corporation|VSCodium|' build/lib/electron.js
  223. replace 's|Microsoft Corporation|VSCodium|' build/lib/electron.ts
  224. replace 's|([0-9]) Microsoft|\1 VSCodium|' build/lib/electron.js
  225. replace 's|([0-9]) Microsoft|\1 VSCodium|' build/lib/electron.ts
  226. if [[ "${OS_NAME}" == "linux" ]]; then
  227. # microsoft adds their apt repo to sources
  228. # unless the app name is code-oss
  229. # as we are renaming the application to vscodium
  230. # we need to edit a line in the post install template
  231. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  232. sed -i "s/code-oss/codium-insiders/" resources/linux/debian/postinst.template
  233. else
  234. sed -i "s/code-oss/codium/" resources/linux/debian/postinst.template
  235. fi
  236. # fix the packages metadata
  237. # code.appdata.xml
  238. sed -i 's|Visual Studio Code|VSCodium|g' resources/linux/code.appdata.xml
  239. sed -i 's|https://code.visualstudio.com/docs/setup/linux|https://github.com/VSCodium/vscodium#download-install|' resources/linux/code.appdata.xml
  240. sed -i 's|https://code.visualstudio.com/home/home-screenshot-linux-lg.png|https://vscodium.com/img/vscodium.png|' resources/linux/code.appdata.xml
  241. sed -i 's|https://code.visualstudio.com|https://vscodium.com|' resources/linux/code.appdata.xml
  242. # control.template
  243. sed -i 's|Microsoft Corporation <vscode-linux@microsoft.com>|VSCodium Team https://github.com/VSCodium/vscodium/graphs/contributors|' resources/linux/debian/control.template
  244. sed -i 's|https://code.visualstudio.com|https://vscodium.com|' resources/linux/debian/control.template
  245. sed -i 's|Visual Studio Code|VSCodium|g' resources/linux/debian/control.template
  246. sed -i 's|https://code.visualstudio.com/docs/setup/linux|https://github.com/VSCodium/vscodium#download-install|' resources/linux/debian/control.template
  247. # code.spec.template
  248. sed -i 's|https://code.visualstudio.com/docs/setup/linux|https://github.com/VSCodium/vscodium#download-install|' resources/linux/rpm/code.spec.template
  249. sed -i 's|Microsoft Corporation|VSCodium Team|' resources/linux/rpm/code.spec.template
  250. sed -i 's|Visual Studio Code Team <vscode-linux@microsoft.com>|VSCodium Team https://github.com/VSCodium/vscodium/graphs/contributors|' resources/linux/rpm/code.spec.template
  251. sed -i 's|https://code.visualstudio.com|https://vscodium.com|' resources/linux/rpm/code.spec.template
  252. sed -i 's|Visual Studio Code|VSCodium|' resources/linux/rpm/code.spec.template
  253. # snapcraft.yaml
  254. sed -i 's|Visual Studio Code|VSCodium|' resources/linux/rpm/code.spec.template
  255. elif [[ "${OS_NAME}" == "windows" ]]; then
  256. # code.iss
  257. sed -i 's|https://code.visualstudio.com|https://vscodium.com|' build/win32/code.iss
  258. sed -i 's|Microsoft Corporation|VSCodium|' build/win32/code.iss
  259. fi
  260. cd ..