2
0

prepare_vscode.sh 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. apply_patch "${file}"
  19. fi
  20. done
  21. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  22. for file in ../patches/insider/*.patch; do
  23. if [[ -f "${file}" ]]; then
  24. apply_patch "${file}"
  25. fi
  26. done
  27. fi
  28. for file in ../patches/user/*.patch; do
  29. if [[ -f "${file}" ]]; then
  30. apply_patch "${file}"
  31. fi
  32. done
  33. if [[ -d "../patches/${OS_NAME}/" ]]; then
  34. for file in "../patches/${OS_NAME}/"*.patch; do
  35. if [[ -f "${file}" ]]; then
  36. apply_patch "${file}"
  37. fi
  38. done
  39. fi
  40. set -x
  41. export ELECTRON_SKIP_BINARY_DOWNLOAD=1
  42. export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
  43. if [[ "${OS_NAME}" == "linux" ]]; then
  44. export VSCODE_SKIP_NODE_VERSION_CHECK=1
  45. if [[ "${npm_config_arch}" == "arm" ]]; then
  46. export npm_config_arm_version=7
  47. fi
  48. elif [[ "${OS_NAME}" == "windows" ]]; then
  49. if [[ "${npm_config_arch}" == "arm" ]]; then
  50. export npm_config_arm_version=7
  51. fi
  52. fi
  53. mv .npmrc .npmrc.bak
  54. cp ../npmrc .npmrc
  55. for i in {1..5}; do # try 5 times
  56. npm ci && break
  57. if [[ $i == 3 ]]; then
  58. echo "Npm install failed too many times" >&2
  59. exit 1
  60. fi
  61. echo "Npm install failed $i, trying again..."
  62. sleep $(( 15 * (i + 1)))
  63. done
  64. mv .npmrc.bak .npmrc
  65. setpath() {
  66. local jsonTmp
  67. { set +x; } 2>/dev/null
  68. jsonTmp=$( jq --arg 'path' "${2}" --arg 'value' "${3}" 'setpath([$path]; $value)' "${1}.json" )
  69. echo "${jsonTmp}" > "${1}.json"
  70. set -x
  71. }
  72. setpath_json() {
  73. local jsonTmp
  74. { set +x; } 2>/dev/null
  75. jsonTmp=$( jq --arg 'path' "${2}" --argjson 'value' "${3}" 'setpath([$path]; $value)' "${1}.json" )
  76. echo "${jsonTmp}" > "${1}.json"
  77. set -x
  78. }
  79. # product.json
  80. cp product.json{,.bak}
  81. setpath "product" "checksumFailMoreInfoUrl" "https://go.microsoft.com/fwlink/?LinkId=828886"
  82. setpath "product" "documentationUrl" "https://go.microsoft.com/fwlink/?LinkID=533484#vscode"
  83. setpath_json "product" "extensionsGallery" '{"serviceUrl": "https://open-vsx.org/vscode/gallery", "itemUrl": "https://open-vsx.org/vscode/item", "extensionUrlTemplate": "https://open-vsx.org/vscode/gallery/{publisher}/{name}/latest"}'
  84. setpath "product" "introductoryVideosUrl" "https://go.microsoft.com/fwlink/?linkid=832146"
  85. setpath "product" "keyboardShortcutsUrlLinux" "https://go.microsoft.com/fwlink/?linkid=832144"
  86. setpath "product" "keyboardShortcutsUrlMac" "https://go.microsoft.com/fwlink/?linkid=832143"
  87. setpath "product" "keyboardShortcutsUrlWin" "https://go.microsoft.com/fwlink/?linkid=832145"
  88. setpath "product" "licenseUrl" "https://github.com/VSCodium/vscodium/blob/master/LICENSE"
  89. setpath_json "product" "linkProtectionTrustedDomains" '["https://open-vsx.org"]'
  90. setpath "product" "releaseNotesUrl" "https://go.microsoft.com/fwlink/?LinkID=533483#vscode"
  91. setpath "product" "reportIssueUrl" "https://github.com/VSCodium/vscodium/issues/new"
  92. setpath "product" "requestFeatureUrl" "https://go.microsoft.com/fwlink/?LinkID=533482"
  93. setpath "product" "tipsAndTricksUrl" "https://go.microsoft.com/fwlink/?linkid=852118"
  94. setpath "product" "twitterUrl" "https://go.microsoft.com/fwlink/?LinkID=533687"
  95. if [[ "${DISABLE_UPDATE}" != "yes" ]]; then
  96. setpath "product" "updateUrl" "https://raw.githubusercontent.com/VSCodium/versions/refs/heads/master"
  97. setpath "product" "downloadUrl" "https://github.com/VSCodium/vscodium/releases"
  98. fi
  99. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  100. setpath "product" "nameShort" "VSCodium - Insiders"
  101. setpath "product" "nameLong" "VSCodium - Insiders"
  102. setpath "product" "applicationName" "codium-insiders"
  103. setpath "product" "dataFolderName" ".vscodium-insiders"
  104. setpath "product" "linuxIconName" "vscodium-insiders"
  105. setpath "product" "quality" "insider"
  106. setpath "product" "urlProtocol" "vscodium-insiders"
  107. setpath "product" "serverApplicationName" "codium-server-insiders"
  108. setpath "product" "serverDataFolderName" ".vscodium-server-insiders"
  109. setpath "product" "darwinBundleIdentifier" "com.vscodium.VSCodiumInsiders"
  110. setpath "product" "win32AppUserModelId" "VSCodium.VSCodiumInsiders"
  111. setpath "product" "win32DirName" "VSCodium Insiders"
  112. setpath "product" "win32MutexName" "vscodiuminsiders"
  113. setpath "product" "win32NameVersion" "VSCodium Insiders"
  114. setpath "product" "win32RegValueName" "VSCodiumInsiders"
  115. setpath "product" "win32ShellNameShort" "VSCodium Insiders"
  116. setpath "product" "win32AppId" "{{EF35BB36-FA7E-4BB9-B7DA-D1E09F2DA9C9}"
  117. setpath "product" "win32x64AppId" "{{B2E0DDB2-120E-4D34-9F7E-8C688FF839A2}"
  118. setpath "product" "win32arm64AppId" "{{44721278-64C6-4513-BC45-D48E07830599}"
  119. setpath "product" "win32UserAppId" "{{ED2E5618-3E7E-4888-BF3C-A6CCC84F586F}"
  120. setpath "product" "win32x64UserAppId" "{{20F79D0D-A9AC-4220-9A81-CE675FFB6B41}"
  121. setpath "product" "win32arm64UserAppId" "{{2E362F92-14EA-455A-9ABD-3E656BBBFE71}"
  122. else
  123. setpath "product" "nameShort" "VSCodium"
  124. setpath "product" "nameLong" "VSCodium"
  125. setpath "product" "applicationName" "codium"
  126. setpath "product" "linuxIconName" "vscodium"
  127. setpath "product" "quality" "stable"
  128. setpath "product" "urlProtocol" "vscodium"
  129. setpath "product" "serverApplicationName" "codium-server"
  130. setpath "product" "serverDataFolderName" ".vscodium-server"
  131. setpath "product" "darwinBundleIdentifier" "com.vscodium"
  132. setpath "product" "win32AppUserModelId" "VSCodium.VSCodium"
  133. setpath "product" "win32DirName" "VSCodium"
  134. setpath "product" "win32MutexName" "vscodium"
  135. setpath "product" "win32NameVersion" "VSCodium"
  136. setpath "product" "win32RegValueName" "VSCodium"
  137. setpath "product" "win32ShellNameShort" "VSCodium"
  138. setpath "product" "win32AppId" "{{763CBF88-25C6-4B10-952F-326AE657F16B}"
  139. setpath "product" "win32x64AppId" "{{88DA3577-054F-4CA1-8122-7D820494CFFB}"
  140. setpath "product" "win32arm64AppId" "{{67DEE444-3D04-4258-B92A-BC1F0FF2CAE4}"
  141. setpath "product" "win32UserAppId" "{{0FD05EB4-651E-4E78-A062-515204B47A3A}"
  142. setpath "product" "win32x64UserAppId" "{{2E1F05D1-C245-4562-81EE-28188DB6FD17}"
  143. setpath "product" "win32arm64UserAppId" "{{57FD70A5-1B8D-4875-9F40-C5553F094828}"
  144. fi
  145. jsonTmp=$( jq -s '.[0] * .[1]' product.json ../product.json )
  146. echo "${jsonTmp}" > product.json && unset jsonTmp
  147. cat product.json
  148. # package.json
  149. cp package.json{,.bak}
  150. setpath "package" "version" "$( echo "${RELEASE_VERSION}" | sed -n -E "s/^(.*)\.([0-9]+)(-insider)?$/\1/p" )"
  151. setpath "package" "release" "$( echo "${RELEASE_VERSION}" | sed -n -E "s/^(.*)\.([0-9]+)(-insider)?$/\2/p" )"
  152. replace 's|Microsoft Corporation|VSCodium|' package.json
  153. # announcements
  154. replace "s|\\[\\/\\* BUILTIN_ANNOUNCEMENTS \\*\\/\\]|$( tr -d '\n' < ../announcements-builtin.json )|" src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts
  155. ../undo_telemetry.sh
  156. replace 's|Microsoft Corporation|VSCodium|' build/lib/electron.js
  157. replace 's|Microsoft Corporation|VSCodium|' build/lib/electron.ts
  158. replace 's|([0-9]) Microsoft|\1 VSCodium|' build/lib/electron.js
  159. replace 's|([0-9]) Microsoft|\1 VSCodium|' build/lib/electron.ts
  160. if [[ "${OS_NAME}" == "linux" ]]; then
  161. # microsoft adds their apt repo to sources
  162. # unless the app name is code-oss
  163. # as we are renaming the application to vscodium
  164. # we need to edit a line in the post install template
  165. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  166. sed -i "s/code-oss/codium-insiders/" resources/linux/debian/postinst.template
  167. else
  168. sed -i "s/code-oss/codium/" resources/linux/debian/postinst.template
  169. fi
  170. # fix the packages metadata
  171. # code.appdata.xml
  172. sed -i 's|Visual Studio Code|VSCodium|g' resources/linux/code.appdata.xml
  173. sed -i 's|https://code.visualstudio.com/docs/setup/linux|https://github.com/VSCodium/vscodium#download-install|' resources/linux/code.appdata.xml
  174. sed -i 's|https://code.visualstudio.com/home/home-screenshot-linux-lg.png|https://vscodium.com/img/vscodium.png|' resources/linux/code.appdata.xml
  175. sed -i 's|https://code.visualstudio.com|https://vscodium.com|' resources/linux/code.appdata.xml
  176. # control.template
  177. sed -i 's|Microsoft Corporation <vscode-linux@microsoft.com>|VSCodium Team https://github.com/VSCodium/vscodium/graphs/contributors|' resources/linux/debian/control.template
  178. sed -i 's|Visual Studio Code|VSCodium|g' resources/linux/debian/control.template
  179. sed -i 's|https://code.visualstudio.com/docs/setup/linux|https://github.com/VSCodium/vscodium#download-install|' resources/linux/debian/control.template
  180. sed -i 's|https://code.visualstudio.com|https://vscodium.com|' resources/linux/debian/control.template
  181. # code.spec.template
  182. sed -i 's|Microsoft Corporation|VSCodium Team|' resources/linux/rpm/code.spec.template
  183. 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
  184. sed -i 's|Visual Studio Code|VSCodium|' resources/linux/rpm/code.spec.template
  185. sed -i 's|https://code.visualstudio.com/docs/setup/linux|https://github.com/VSCodium/vscodium#download-install|' resources/linux/rpm/code.spec.template
  186. sed -i 's|https://code.visualstudio.com|https://vscodium.com|' resources/linux/rpm/code.spec.template
  187. # snapcraft.yaml
  188. sed -i 's|Visual Studio Code|VSCodium|' resources/linux/rpm/code.spec.template
  189. elif [[ "${OS_NAME}" == "windows" ]]; then
  190. # code.iss
  191. sed -i 's|https://code.visualstudio.com|https://vscodium.com|' build/win32/code.iss
  192. sed -i 's|Microsoft Corporation|VSCodium|' build/win32/code.iss
  193. fi
  194. cd ..