prepare_vscode.sh 9.4 KB

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