prepare_vscode.sh 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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 "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. fi
  90. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  91. setpath "product" "nameShort" "VSCodium - Insiders"
  92. setpath "product" "nameLong" "VSCodium - Insiders"
  93. setpath "product" "applicationName" "codium-insiders"
  94. setpath "product" "dataFolderName" ".vscodium-insiders"
  95. setpath "product" "linuxIconName" "vscodium-insiders"
  96. setpath "product" "quality" "insider"
  97. setpath "product" "urlProtocol" "vscodium-insiders"
  98. setpath "product" "serverApplicationName" "codium-server-insiders"
  99. setpath "product" "serverDataFolderName" ".vscodium-server-insiders"
  100. setpath "product" "darwinBundleIdentifier" "com.vscodium.VSCodiumInsiders"
  101. setpath "product" "win32AppUserModelId" "VSCodium.VSCodiumInsiders"
  102. setpath "product" "win32DirName" "VSCodium Insiders"
  103. setpath "product" "win32MutexName" "vscodiuminsiders"
  104. setpath "product" "win32NameVersion" "VSCodium Insiders"
  105. setpath "product" "win32RegValueName" "VSCodiumInsiders"
  106. setpath "product" "win32ShellNameShort" "VSCodium Insiders"
  107. setpath "product" "win32AppId" "{{EF35BB36-FA7E-4BB9-B7DA-D1E09F2DA9C9}"
  108. setpath "product" "win32x64AppId" "{{B2E0DDB2-120E-4D34-9F7E-8C688FF839A2}"
  109. setpath "product" "win32arm64AppId" "{{44721278-64C6-4513-BC45-D48E07830599}"
  110. setpath "product" "win32UserAppId" "{{ED2E5618-3E7E-4888-BF3C-A6CCC84F586F}"
  111. setpath "product" "win32x64UserAppId" "{{20F79D0D-A9AC-4220-9A81-CE675FFB6B41}"
  112. setpath "product" "win32arm64UserAppId" "{{2E362F92-14EA-455A-9ABD-3E656BBBFE71}"
  113. else
  114. setpath "product" "nameShort" "VSCodium"
  115. setpath "product" "nameLong" "VSCodium"
  116. setpath "product" "applicationName" "codium"
  117. setpath "product" "linuxIconName" "vscodium"
  118. setpath "product" "quality" "stable"
  119. setpath "product" "urlProtocol" "vscodium"
  120. setpath "product" "serverApplicationName" "codium-server"
  121. setpath "product" "serverDataFolderName" ".vscodium-server"
  122. setpath "product" "darwinBundleIdentifier" "com.vscodium"
  123. setpath "product" "win32AppUserModelId" "VSCodium.VSCodium"
  124. setpath "product" "win32DirName" "VSCodium"
  125. setpath "product" "win32MutexName" "vscodium"
  126. setpath "product" "win32NameVersion" "VSCodium"
  127. setpath "product" "win32RegValueName" "VSCodium"
  128. setpath "product" "win32ShellNameShort" "VSCodium"
  129. setpath "product" "win32AppId" "{{763CBF88-25C6-4B10-952F-326AE657F16B}"
  130. setpath "product" "win32x64AppId" "{{88DA3577-054F-4CA1-8122-7D820494CFFB}"
  131. setpath "product" "win32arm64AppId" "{{67DEE444-3D04-4258-B92A-BC1F0FF2CAE4}"
  132. setpath "product" "win32UserAppId" "{{0FD05EB4-651E-4E78-A062-515204B47A3A}"
  133. setpath "product" "win32x64UserAppId" "{{2E1F05D1-C245-4562-81EE-28188DB6FD17}"
  134. setpath "product" "win32arm64UserAppId" "{{57FD70A5-1B8D-4875-9F40-C5553F094828}"
  135. fi
  136. echo "$( jq -s '.[0] * .[1]' product.json ../product.json )" > product.json
  137. cat product.json
  138. # package.json
  139. cp package.json package.json.bak
  140. setpath "package" "version" $( echo "${RELEASE_VERSION}" | sed -n -E "s/^(.*)\.([0-9]+)(-insider)?$/\1/p" )
  141. setpath "package" "release" $( echo "${RELEASE_VERSION}" | sed -n -E "s/^(.*)\.([0-9]+)(-insider)?$/\2/p" )
  142. replace 's|Microsoft Corporation|VSCodium|' package.json
  143. ../undo_telemetry.sh
  144. replace 's|Microsoft Corporation|VSCodium|' build/lib/electron.js
  145. replace 's|Microsoft Corporation|VSCodium|' build/lib/electron.ts
  146. replace 's|([0-9]) Microsoft|\1 VSCodium|' build/lib/electron.js
  147. replace 's|([0-9]) Microsoft|\1 VSCodium|' build/lib/electron.ts
  148. if [[ "${OS_NAME}" == "linux" ]]; then
  149. # microsoft adds their apt repo to sources
  150. # unless the app name is code-oss
  151. # as we are renaming the application to vscodium
  152. # we need to edit a line in the post install template
  153. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  154. sed -i "s/code-oss/codium-insiders/" resources/linux/debian/postinst.template
  155. else
  156. sed -i "s/code-oss/codium/" resources/linux/debian/postinst.template
  157. fi
  158. # fix the packages metadata
  159. # code.appdata.xml
  160. sed -i 's|Visual Studio Code|VSCodium|g' resources/linux/code.appdata.xml
  161. sed -i 's|https://code.visualstudio.com/docs/setup/linux|https://github.com/VSCodium/vscodium#download-install|' resources/linux/code.appdata.xml
  162. sed -i 's|https://code.visualstudio.com/home/home-screenshot-linux-lg.png|https://vscodium.com/img/vscodium.png|' resources/linux/code.appdata.xml
  163. sed -i 's|https://code.visualstudio.com|https://vscodium.com|' resources/linux/code.appdata.xml
  164. # control.template
  165. sed -i 's|Microsoft Corporation <vscode-linux@microsoft.com>|VSCodium Team https://github.com/VSCodium/vscodium/graphs/contributors|' resources/linux/debian/control.template
  166. sed -i 's|https://code.visualstudio.com|https://vscodium.com|' resources/linux/debian/control.template
  167. sed -i 's|Visual Studio Code|VSCodium|g' resources/linux/debian/control.template
  168. sed -i 's|https://code.visualstudio.com/docs/setup/linux|https://github.com/VSCodium/vscodium#download-install|' resources/linux/debian/control.template
  169. # code.spec.template
  170. sed -i 's|https://code.visualstudio.com/docs/setup/linux|https://github.com/VSCodium/vscodium#download-install|' resources/linux/rpm/code.spec.template
  171. sed -i 's|Microsoft Corporation|VSCodium Team|' resources/linux/rpm/code.spec.template
  172. 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
  173. sed -i 's|https://code.visualstudio.com|https://vscodium.com|' resources/linux/rpm/code.spec.template
  174. sed -i 's|Visual Studio Code|VSCodium|' resources/linux/rpm/code.spec.template
  175. # snapcraft.yaml
  176. sed -i 's|Visual Studio Code|VSCodium|' resources/linux/rpm/code.spec.template
  177. elif [[ "${OS_NAME}" == "windows" ]]; then
  178. # code.iss
  179. sed -i 's|https://code.visualstudio.com|https://vscodium.com|' build/win32/code.iss
  180. sed -i 's|Microsoft Corporation|VSCodium|' build/win32/code.iss
  181. fi
  182. cd ..