prepare_vscode.sh 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. if [[ "${OS_NAME}" == "osx" ]]; then
  46. CHILD_CONCURRENCY=1 yarn --frozen-lockfile
  47. yarn postinstall
  48. elif [[ "${npm_config_arch}" == "armv7l" || "${npm_config_arch}" == "ia32" ]]; then
  49. # node-gyp@9.0.0 shipped with node@16.15.0 starts using config.gypi
  50. # from the custom headers path if dist-url option was set, instead of
  51. # using the config value from the process. Electron builds with pointer compression
  52. # enabled for x64 and arm64, but incorrectly ships a single copy of config.gypi
  53. # with v8_enable_pointer_compression option always set for all target architectures.
  54. # We use the force_process_config option to use the config.gypi from the
  55. # nodejs process executing npm for 32-bit architectures.
  56. export npm_config_force_process_config="true"
  57. CHILD_CONCURRENCY=1 yarn --frozen-lockfile
  58. else
  59. CHILD_CONCURRENCY=1 yarn --frozen-lockfile
  60. fi
  61. setpath() {
  62. { set +x; } 2>/dev/null
  63. echo "$( cat "${1}.json" | jq --arg 'path' "${2}" --arg 'value' "${3}" 'setpath([$path]; $value)' )" > "${1}.json"
  64. set -x
  65. }
  66. setpath_json() {
  67. { set +x; } 2>/dev/null
  68. echo "$( cat "${1}.json" | jq --arg 'path' "${2}" --argjson 'value' "${3}" 'setpath([$path]; $value)' )" > "${1}.json"
  69. set -x
  70. }
  71. # product.json
  72. cp product.json product.json.bak
  73. setpath "product" "checksumFailMoreInfoUrl" "https://go.microsoft.com/fwlink/?LinkId=828886"
  74. setpath "product" "documentationUrl" "https://go.microsoft.com/fwlink/?LinkID=533484#vscode"
  75. setpath_json "product" "extensionsGallery" '{"serviceUrl": "https://open-vsx.org/vscode/gallery", "itemUrl": "https://open-vsx.org/vscode/item"}'
  76. setpath "product" "introductoryVideosUrl" "https://go.microsoft.com/fwlink/?linkid=832146"
  77. setpath "product" "keyboardShortcutsUrlLinux" "https://go.microsoft.com/fwlink/?linkid=832144"
  78. setpath "product" "keyboardShortcutsUrlMac" "https://go.microsoft.com/fwlink/?linkid=832143"
  79. setpath "product" "keyboardShortcutsUrlWin" "https://go.microsoft.com/fwlink/?linkid=832145"
  80. setpath "product" "licenseUrl" "https://github.com/VSCodium/vscodium/blob/master/LICENSE"
  81. setpath_json "product" "linkProtectionTrustedDomains" '["https://open-vsx.org"]'
  82. setpath "product" "releaseNotesUrl" "https://go.microsoft.com/fwlink/?LinkID=533483#vscode"
  83. setpath "product" "reportIssueUrl" "https://github.com/VSCodium/vscodium/issues/new"
  84. setpath "product" "requestFeatureUrl" "https://go.microsoft.com/fwlink/?LinkID=533482"
  85. setpath "product" "tipsAndTricksUrl" "https://go.microsoft.com/fwlink/?linkid=852118"
  86. setpath "product" "twitterUrl" "https://go.microsoft.com/fwlink/?LinkID=533687"
  87. if [[ "${DISABLE_UPDATE}" != "yes" ]]; then
  88. setpath "product" "updateUrl" "https://vscodium.now.sh"
  89. setpath "product" "downloadUrl" "https://github.com/VSCodium/vscodium/releases"
  90. fi
  91. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  92. setpath "product" "nameShort" "VSCodium - Insiders"
  93. setpath "product" "nameLong" "VSCodium - Insiders"
  94. setpath "product" "applicationName" "codium-insiders"
  95. setpath "product" "dataFolderName" ".vscodium-insiders"
  96. setpath "product" "linuxIconName" "vscodium-insiders"
  97. setpath "product" "quality" "insider"
  98. setpath "product" "urlProtocol" "vscodium-insiders"
  99. setpath "product" "serverApplicationName" "codium-server-insiders"
  100. setpath "product" "serverDataFolderName" ".vscodium-server-insiders"
  101. setpath "product" "darwinBundleIdentifier" "com.vscodium.VSCodiumInsiders"
  102. setpath "product" "win32AppUserModelId" "VSCodium.VSCodiumInsiders"
  103. setpath "product" "win32DirName" "VSCodium Insiders"
  104. setpath "product" "win32MutexName" "vscodiuminsiders"
  105. setpath "product" "win32NameVersion" "VSCodium Insiders"
  106. setpath "product" "win32RegValueName" "VSCodiumInsiders"
  107. setpath "product" "win32ShellNameShort" "VSCodium Insiders"
  108. setpath "product" "win32AppId" "{{EF35BB36-FA7E-4BB9-B7DA-D1E09F2DA9C9}"
  109. setpath "product" "win32x64AppId" "{{B2E0DDB2-120E-4D34-9F7E-8C688FF839A2}"
  110. setpath "product" "win32arm64AppId" "{{44721278-64C6-4513-BC45-D48E07830599}"
  111. setpath "product" "win32UserAppId" "{{ED2E5618-3E7E-4888-BF3C-A6CCC84F586F}"
  112. setpath "product" "win32x64UserAppId" "{{20F79D0D-A9AC-4220-9A81-CE675FFB6B41}"
  113. setpath "product" "win32arm64UserAppId" "{{2E362F92-14EA-455A-9ABD-3E656BBBFE71}"
  114. else
  115. setpath "product" "nameShort" "VSCodium"
  116. setpath "product" "nameLong" "VSCodium"
  117. setpath "product" "applicationName" "codium"
  118. setpath "product" "linuxIconName" "vscodium"
  119. setpath "product" "quality" "stable"
  120. setpath "product" "urlProtocol" "vscodium"
  121. setpath "product" "serverApplicationName" "codium-server"
  122. setpath "product" "serverDataFolderName" ".vscodium-server"
  123. setpath "product" "darwinBundleIdentifier" "com.vscodium"
  124. setpath "product" "win32AppUserModelId" "VSCodium.VSCodium"
  125. setpath "product" "win32DirName" "VSCodium"
  126. setpath "product" "win32MutexName" "vscodium"
  127. setpath "product" "win32NameVersion" "VSCodium"
  128. setpath "product" "win32RegValueName" "VSCodium"
  129. setpath "product" "win32ShellNameShort" "VSCodium"
  130. setpath "product" "win32AppId" "{{763CBF88-25C6-4B10-952F-326AE657F16B}"
  131. setpath "product" "win32x64AppId" "{{88DA3577-054F-4CA1-8122-7D820494CFFB}"
  132. setpath "product" "win32arm64AppId" "{{67DEE444-3D04-4258-B92A-BC1F0FF2CAE4}"
  133. setpath "product" "win32UserAppId" "{{0FD05EB4-651E-4E78-A062-515204B47A3A}"
  134. setpath "product" "win32x64UserAppId" "{{2E1F05D1-C245-4562-81EE-28188DB6FD17}"
  135. setpath "product" "win32arm64UserAppId" "{{57FD70A5-1B8D-4875-9F40-C5553F094828}"
  136. fi
  137. echo "$( jq -s '.[0] * .[1]' product.json ../product.json )" > product.json
  138. cat product.json
  139. # package.json
  140. cp package.json package.json.bak
  141. setpath "package" "version" $( echo "${RELEASE_VERSION}" | sed -n -E "s/^(.*)\.([0-9]+)(-insider)?$/\1/p" )
  142. setpath "package" "release" $( echo "${RELEASE_VERSION}" | sed -n -E "s/^(.*)\.([0-9]+)(-insider)?$/\2/p" )
  143. replace 's|Microsoft Corporation|VSCodium|' package.json
  144. # announcements
  145. replace "s|\\[\\/\\* BUILTIN_ANNOUNCEMENTS \\*\\/\\]|$( cat ../announcements-builtin.json | tr -d '\n' )|" src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts
  146. ../undo_telemetry.sh
  147. replace 's|Microsoft Corporation|VSCodium|' build/lib/electron.js
  148. replace 's|Microsoft Corporation|VSCodium|' build/lib/electron.ts
  149. replace 's|([0-9]) Microsoft|\1 VSCodium|' build/lib/electron.js
  150. replace 's|([0-9]) Microsoft|\1 VSCodium|' build/lib/electron.ts
  151. if [[ "${OS_NAME}" == "linux" ]]; then
  152. # microsoft adds their apt repo to sources
  153. # unless the app name is code-oss
  154. # as we are renaming the application to vscodium
  155. # we need to edit a line in the post install template
  156. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  157. sed -i "s/code-oss/codium-insiders/" resources/linux/debian/postinst.template
  158. else
  159. sed -i "s/code-oss/codium/" resources/linux/debian/postinst.template
  160. fi
  161. # fix the packages metadata
  162. # code.appdata.xml
  163. sed -i 's|Visual Studio Code|VSCodium|g' resources/linux/code.appdata.xml
  164. sed -i 's|https://code.visualstudio.com/docs/setup/linux|https://github.com/VSCodium/vscodium#download-install|' resources/linux/code.appdata.xml
  165. sed -i 's|https://code.visualstudio.com/home/home-screenshot-linux-lg.png|https://vscodium.com/img/vscodium.png|' resources/linux/code.appdata.xml
  166. sed -i 's|https://code.visualstudio.com|https://vscodium.com|' resources/linux/code.appdata.xml
  167. # control.template
  168. sed -i 's|Microsoft Corporation <vscode-linux@microsoft.com>|VSCodium Team https://github.com/VSCodium/vscodium/graphs/contributors|' resources/linux/debian/control.template
  169. sed -i 's|https://code.visualstudio.com|https://vscodium.com|' resources/linux/debian/control.template
  170. sed -i 's|Visual Studio Code|VSCodium|g' resources/linux/debian/control.template
  171. sed -i 's|https://code.visualstudio.com/docs/setup/linux|https://github.com/VSCodium/vscodium#download-install|' resources/linux/debian/control.template
  172. # code.spec.template
  173. sed -i 's|https://code.visualstudio.com/docs/setup/linux|https://github.com/VSCodium/vscodium#download-install|' resources/linux/rpm/code.spec.template
  174. sed -i 's|Microsoft Corporation|VSCodium Team|' resources/linux/rpm/code.spec.template
  175. 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
  176. sed -i 's|https://code.visualstudio.com|https://vscodium.com|' resources/linux/rpm/code.spec.template
  177. sed -i 's|Visual Studio Code|VSCodium|' resources/linux/rpm/code.spec.template
  178. # snapcraft.yaml
  179. sed -i 's|Visual Studio Code|VSCodium|' resources/linux/rpm/code.spec.template
  180. elif [[ "${OS_NAME}" == "windows" ]]; then
  181. # code.iss
  182. sed -i 's|https://code.visualstudio.com|https://vscodium.com|' build/win32/code.iss
  183. sed -i 's|Microsoft Corporation|VSCodium|' build/win32/code.iss
  184. fi
  185. cd ..