prepare_vscode.sh 9.7 KB

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