prepare_vscode.sh 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. #!/usr/bin/env bash
  2. # shellcheck disable=SC1091,2154
  3. set -e
  4. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  5. cp -rp src/insider/* vscode/
  6. else
  7. cp -rp src/stable/* vscode/
  8. fi
  9. cp -f LICENSE vscode/LICENSE.txt
  10. cd vscode || { echo "'vscode' dir not found"; exit 1; }
  11. { set +x; } 2>/dev/null
  12. # {{{ product.json
  13. cp product.json{,.bak}
  14. setpath() {
  15. local jsonTmp
  16. { set +x; } 2>/dev/null
  17. jsonTmp=$( jq --arg 'value' "${3}" "setpath(path(.${2}); \$value)" "${1}.json" )
  18. echo "${jsonTmp}" > "${1}.json"
  19. set -x
  20. }
  21. setpath_json() {
  22. local jsonTmp
  23. { set +x; } 2>/dev/null
  24. jsonTmp=$( jq --argjson 'value' "${3}" "setpath(path(.${2}); \$value)" "${1}.json" )
  25. echo "${jsonTmp}" > "${1}.json"
  26. set -x
  27. }
  28. setpath "product" "checksumFailMoreInfoUrl" "https://go.microsoft.com/fwlink/?LinkId=828886"
  29. setpath "product" "documentationUrl" "https://go.microsoft.com/fwlink/?LinkID=533484#vscode"
  30. setpath_json "product" "extensionsGallery" '{"serviceUrl": "https://open-vsx.org/vscode/gallery", "itemUrl": "https://open-vsx.org/vscode/item", "latestUrlTemplate": "https://open-vsx.org/vscode/gallery/{publisher}/{name}/latest", "controlUrl": "https://raw.githubusercontent.com/EclipseFdn/publish-extensions/refs/heads/master/extension-control/extensions.json"}'
  31. setpath "product" "introductoryVideosUrl" "https://go.microsoft.com/fwlink/?linkid=832146"
  32. setpath "product" "keyboardShortcutsUrlLinux" "https://go.microsoft.com/fwlink/?linkid=832144"
  33. setpath "product" "keyboardShortcutsUrlMac" "https://go.microsoft.com/fwlink/?linkid=832143"
  34. setpath "product" "keyboardShortcutsUrlWin" "https://go.microsoft.com/fwlink/?linkid=832145"
  35. setpath "product" "licenseUrl" "https://github.com/VSCodium/vscodium/blob/master/LICENSE"
  36. setpath_json "product" "linkProtectionTrustedDomains" '["https://open-vsx.org"]'
  37. setpath "product" "releaseNotesUrl" "https://go.microsoft.com/fwlink/?LinkID=533483#vscode"
  38. setpath "product" "reportIssueUrl" "https://github.com/VSCodium/vscodium/issues/new"
  39. setpath "product" "requestFeatureUrl" "https://go.microsoft.com/fwlink/?LinkID=533482"
  40. setpath "product" "tipsAndTricksUrl" "https://go.microsoft.com/fwlink/?linkid=852118"
  41. setpath "product" "twitterUrl" "https://go.microsoft.com/fwlink/?LinkID=533687"
  42. if [[ "${DISABLE_UPDATE}" != "yes" ]]; then
  43. setpath "product" "updateUrl" "https://raw.githubusercontent.com/VSCodium/versions/refs/heads/master"
  44. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  45. setpath "product" "downloadUrl" "https://github.com/VSCodium/vscodium-insiders/releases"
  46. else
  47. setpath "product" "downloadUrl" "https://github.com/VSCodium/vscodium/releases"
  48. fi
  49. fi
  50. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  51. setpath "product" "nameShort" "VSCodium - Insiders"
  52. setpath "product" "nameLong" "VSCodium - Insiders"
  53. setpath "product" "applicationName" "codium-insiders"
  54. setpath "product" "dataFolderName" ".vscodium-insiders"
  55. setpath "product" "linuxIconName" "vscodium-insiders"
  56. setpath "product" "quality" "insider"
  57. setpath "product" "urlProtocol" "vscodium-insiders"
  58. setpath "product" "serverApplicationName" "codium-server-insiders"
  59. setpath "product" "serverDataFolderName" ".vscodium-server-insiders"
  60. setpath "product" "darwinBundleIdentifier" "com.vscodium.VSCodiumInsiders"
  61. setpath "product" "win32AppUserModelId" "VSCodium.VSCodiumInsiders"
  62. setpath "product" "win32DirName" "VSCodium Insiders"
  63. setpath "product" "win32MutexName" "vscodiuminsiders"
  64. setpath "product" "win32NameVersion" "VSCodium Insiders"
  65. setpath "product" "win32RegValueName" "VSCodiumInsiders"
  66. setpath "product" "win32ShellNameShort" "VSCodium Insiders"
  67. setpath "product" "win32AppId" "{{EF35BB36-FA7E-4BB9-B7DA-D1E09F2DA9C9}"
  68. setpath "product" "win32x64AppId" "{{B2E0DDB2-120E-4D34-9F7E-8C688FF839A2}"
  69. setpath "product" "win32arm64AppId" "{{44721278-64C6-4513-BC45-D48E07830599}"
  70. setpath "product" "win32UserAppId" "{{ED2E5618-3E7E-4888-BF3C-A6CCC84F586F}"
  71. setpath "product" "win32x64UserAppId" "{{20F79D0D-A9AC-4220-9A81-CE675FFB6B41}"
  72. setpath "product" "win32arm64UserAppId" "{{2E362F92-14EA-455A-9ABD-3E656BBBFE71}"
  73. setpath "product" "tunnelApplicationName" "codium-insiders-tunnel"
  74. setpath "product" "win32TunnelServiceMutex" "vscodiuminsiders-tunnelservice"
  75. setpath "product" "win32TunnelMutex" "vscodiuminsiders-tunnel"
  76. setpath "product" "win32ContextMenu.x64.clsid" "90AAD229-85FD-43A3-B82D-8598A88829CF"
  77. setpath "product" "win32ContextMenu.arm64.clsid" "7544C31C-BDBF-4DDF-B15E-F73A46D6723D"
  78. else
  79. setpath "product" "nameShort" "VSCodium"
  80. setpath "product" "nameLong" "VSCodium"
  81. setpath "product" "applicationName" "codium"
  82. setpath "product" "linuxIconName" "vscodium"
  83. setpath "product" "quality" "stable"
  84. setpath "product" "urlProtocol" "vscodium"
  85. setpath "product" "serverApplicationName" "codium-server"
  86. setpath "product" "serverDataFolderName" ".vscodium-server"
  87. setpath "product" "darwinBundleIdentifier" "com.vscodium"
  88. setpath "product" "win32AppUserModelId" "VSCodium.VSCodium"
  89. setpath "product" "win32DirName" "VSCodium"
  90. setpath "product" "win32MutexName" "vscodium"
  91. setpath "product" "win32NameVersion" "VSCodium"
  92. setpath "product" "win32RegValueName" "VSCodium"
  93. setpath "product" "win32ShellNameShort" "VSCodium"
  94. setpath "product" "win32AppId" "{{763CBF88-25C6-4B10-952F-326AE657F16B}"
  95. setpath "product" "win32x64AppId" "{{88DA3577-054F-4CA1-8122-7D820494CFFB}"
  96. setpath "product" "win32arm64AppId" "{{67DEE444-3D04-4258-B92A-BC1F0FF2CAE4}"
  97. setpath "product" "win32UserAppId" "{{0FD05EB4-651E-4E78-A062-515204B47A3A}"
  98. setpath "product" "win32x64UserAppId" "{{2E1F05D1-C245-4562-81EE-28188DB6FD17}"
  99. setpath "product" "win32arm64UserAppId" "{{57FD70A5-1B8D-4875-9F40-C5553F094828}"
  100. setpath "product" "tunnelApplicationName" "codium-tunnel"
  101. setpath "product" "win32TunnelServiceMutex" "vscodium-tunnelservice"
  102. setpath "product" "win32TunnelMutex" "vscodium-tunnel"
  103. setpath "product" "win32ContextMenu.x64.clsid" "D910D5E6-B277-4F4A-BDC5-759A34EEE25D"
  104. setpath "product" "win32ContextMenu.arm64.clsid" "4852FC55-4A84-4EA1-9C86-D53BE3DF83C0"
  105. fi
  106. setpath_json "product" "tunnelApplicationConfig" '{}'
  107. jsonTmp=$( jq -s '.[0] * .[1]' product.json ../product.json )
  108. echo "${jsonTmp}" > product.json && unset jsonTmp
  109. cat product.json
  110. # }}}
  111. # include common functions
  112. . ../utils.sh
  113. # {{{ apply patches
  114. echo "APP_NAME=\"${APP_NAME}\""
  115. echo "APP_NAME_LC=\"${APP_NAME_LC}\""
  116. echo "ASSETS_REPOSITORY=\"${ASSETS_REPOSITORY}\""
  117. echo "BINARY_NAME=\"${BINARY_NAME}\""
  118. echo "GH_REPO_PATH=\"${GH_REPO_PATH}\""
  119. echo "GLOBAL_DIRNAME=\"${GLOBAL_DIRNAME}\""
  120. echo "ORG_NAME=\"${ORG_NAME}\""
  121. echo "TUNNEL_APP_NAME=\"${TUNNEL_APP_NAME}\""
  122. if [[ "${DISABLE_UPDATE}" == "yes" ]]; then
  123. mv ../patches/disable-update.patch.yet ../patches/disable-update.patch
  124. fi
  125. for file in ../patches/*.patch; do
  126. if [[ -f "${file}" ]]; then
  127. apply_patch "${file}"
  128. fi
  129. done
  130. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  131. for file in ../patches/insider/*.patch; do
  132. if [[ -f "${file}" ]]; then
  133. apply_patch "${file}"
  134. fi
  135. done
  136. fi
  137. if [[ -d "../patches/${OS_NAME}/" ]]; then
  138. for file in "../patches/${OS_NAME}/"*.patch; do
  139. if [[ -f "${file}" ]]; then
  140. apply_patch "${file}"
  141. fi
  142. done
  143. fi
  144. for file in ../patches/user/*.patch; do
  145. if [[ -f "${file}" ]]; then
  146. apply_patch "${file}"
  147. fi
  148. done
  149. # }}}
  150. set -x
  151. # {{{ install dependencies
  152. export ELECTRON_SKIP_BINARY_DOWNLOAD=1
  153. export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
  154. if [[ "${OS_NAME}" == "linux" ]]; then
  155. export VSCODE_SKIP_NODE_VERSION_CHECK=1
  156. if [[ "${npm_config_arch}" == "arm" ]]; then
  157. export npm_config_arm_version=7
  158. fi
  159. elif [[ "${OS_NAME}" == "windows" ]]; then
  160. if [[ "${npm_config_arch}" == "arm" ]]; then
  161. export npm_config_arm_version=7
  162. fi
  163. else
  164. if [[ "${CI_BUILD}" != "no" ]]; then
  165. clang++ --version
  166. fi
  167. fi
  168. node build/npm/preinstall.ts
  169. mv .npmrc .npmrc.bak
  170. cp ../npmrc .npmrc
  171. for i in {1..5}; do # try 5 times
  172. if [[ "${CI_BUILD}" != "no" && "${OS_NAME}" == "osx" ]]; then
  173. CXX=clang++ npm ci && break
  174. else
  175. npm ci && break
  176. fi
  177. if [[ $i == 5 ]]; then
  178. echo "Npm install failed too many times" >&2
  179. exit 1
  180. fi
  181. echo "Npm install failed $i, trying again..."
  182. sleep $(( 15 * (i + 1)))
  183. done
  184. mv .npmrc.bak .npmrc
  185. # }}}
  186. # package.json
  187. cp package.json{,.bak}
  188. setpath "package" "version" "${RELEASE_VERSION%-insider}"
  189. replace 's|Microsoft Corporation|VSCodium|' package.json
  190. cp resources/server/manifest.json{,.bak}
  191. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  192. setpath "resources/server/manifest" "name" "VSCodium - Insiders"
  193. setpath "resources/server/manifest" "short_name" "VSCodium - Insiders"
  194. else
  195. setpath "resources/server/manifest" "name" "VSCodium"
  196. setpath "resources/server/manifest" "short_name" "VSCodium"
  197. fi
  198. # announcements
  199. replace "s|\\[\\/\\* BUILTIN_ANNOUNCEMENTS \\*\\/\\]|$( tr -d '\n' < ../announcements-builtin.json )|" src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts
  200. ../undo_telemetry.sh
  201. replace 's|Microsoft Corporation|VSCodium|' build/lib/electron.ts
  202. replace 's|([0-9]) Microsoft|\1 VSCodium|' build/lib/electron.ts
  203. if [[ "${OS_NAME}" == "linux" ]]; then
  204. # microsoft adds their apt repo to sources
  205. # unless the app name is code-oss
  206. # as we are renaming the application to vscodium
  207. # we need to edit a line in the post install template
  208. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  209. sed -i "s/code-oss/codium-insiders/" resources/linux/debian/postinst.template
  210. else
  211. sed -i "s/code-oss/codium/" resources/linux/debian/postinst.template
  212. fi
  213. # fix the packages metadata
  214. # code.appdata.xml
  215. sed -i 's|Visual Studio Code|VSCodium|g' resources/linux/code.appdata.xml
  216. sed -i 's|https://code.visualstudio.com/docs/setup/linux|https://github.com/VSCodium/vscodium#download-install|' resources/linux/code.appdata.xml
  217. sed -i 's|https://code.visualstudio.com/home/home-screenshot-linux-lg.png|https://vscodium.com/img/vscodium.png|' resources/linux/code.appdata.xml
  218. sed -i 's|https://code.visualstudio.com|https://vscodium.com|' resources/linux/code.appdata.xml
  219. # control.template
  220. sed -i 's|Microsoft Corporation <vscode-linux@microsoft.com>|VSCodium Team https://github.com/VSCodium/vscodium/graphs/contributors|' resources/linux/debian/control.template
  221. sed -i 's|Visual Studio Code|VSCodium|g' resources/linux/debian/control.template
  222. sed -i 's|https://code.visualstudio.com/docs/setup/linux|https://github.com/VSCodium/vscodium#download-install|' resources/linux/debian/control.template
  223. sed -i 's|https://code.visualstudio.com|https://vscodium.com|' resources/linux/debian/control.template
  224. # code.spec.template
  225. sed -i 's|Microsoft Corporation|VSCodium Team|' resources/linux/rpm/code.spec.template
  226. 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
  227. sed -i 's|Visual Studio Code|VSCodium|' resources/linux/rpm/code.spec.template
  228. sed -i 's|https://code.visualstudio.com/docs/setup/linux|https://github.com/VSCodium/vscodium#download-install|' resources/linux/rpm/code.spec.template
  229. sed -i 's|https://code.visualstudio.com|https://vscodium.com|' resources/linux/rpm/code.spec.template
  230. # snapcraft.yaml
  231. sed -i 's|Visual Studio Code|VSCodium|' resources/linux/rpm/code.spec.template
  232. elif [[ "${OS_NAME}" == "windows" ]]; then
  233. # code.iss
  234. sed -i 's|https://code.visualstudio.com|https://vscodium.com|' build/win32/code.iss
  235. sed -i 's|Microsoft Corporation|VSCodium|' build/win32/code.iss
  236. fi
  237. cd ..