prepare_vscode.sh 9.9 KB

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