浏览代码

feat(bundler/nsis): migrate to `nsis_tauri_utils` (#6120)

Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>
Amr Bashir 2 年之前
父节点
当前提交
328583e12e
共有 2 个文件被更改,包括 12 次插入36 次删除
  1. 7 31
      tooling/bundler/src/bundle/windows/nsis.rs
  2. 5 5
      tooling/bundler/src/bundle/windows/templates/installer.nsi

+ 7 - 31
tooling/bundler/src/bundle/windows/nsis.rs

@@ -37,14 +37,10 @@ const NSIS_URL: &str =
   "https://sourceforge.net/projects/nsis/files/NSIS%203/3.08/nsis-3.08.zip/download";
 #[cfg(target_os = "windows")]
 const NSIS_SHA1: &str = "057e83c7d82462ec394af76c87d06733605543d4";
-const NSIS_NSCURL_URL: &str =
-  "https://github.com/tauri-apps/binary-releases/releases/download/nsis-plugins-v0/NScurl-1.2022.6.7.zip";
 const NSIS_APPLICATIONID_URL: &str = "https://github.com/tauri-apps/binary-releases/releases/download/nsis-plugins-v0/NSIS-ApplicationID.zip";
-const NSIS_NSPROCESS_URL: &str =
-  "https://github.com/tauri-apps/binary-releases/releases/download/nsis-plugins-v0/NsProcess.zip";
-const NSIS_SEMVER_COMPARE: &str =
-  "https://github.com/tauri-apps/nsis-semvercompare/releases/download/v0.3.0/nsis_semvercompare.dll";
-const NSIS_SEMVER_COMPARE_SHA1: &str = "1789062E121AC392A6CBBE886F9B1443462912C2";
+const NSIS_TAURI_UTILS: &str =
+  "https://github.com/tauri-apps/nsis-tauri-utils/releases/download/nsis_tauri_utils-v0.1.0/nsis_tauri_utils.dll";
+const NSIS_TAURI_UTILS_SHA1: &str = "BA62B7A7B41063ECAA97FEBC0723CD36D6BCF92A";
 
 #[cfg(target_os = "windows")]
 const NSIS_REQUIRED_FILES: &[&str] = &[
@@ -52,20 +48,16 @@ const NSIS_REQUIRED_FILES: &[&str] = &[
   "Bin/makensis.exe",
   "Stubs/lzma-x86-unicode",
   "Stubs/lzma_solid-x86-unicode",
-  "Plugins/x86-unicode/NScurl.dll",
   "Plugins/x86-unicode/ApplicationID.dll",
-  "Plugins/x86-unicode/nsProcess.dll",
-  "Plugins/x86-unicode/nsis_semvercompare.dll",
+  "Plugins/x86-unicode/nsis_tauri_utils.dll",
   "Include/MUI2.nsh",
   "Include/FileFunc.nsh",
   "Include/x64.nsh",
 ];
 #[cfg(not(target_os = "windows"))]
 const NSIS_REQUIRED_FILES: &[&str] = &[
-  "Plugins/x86-unicode/NScurl.dll",
   "Plugins/x86-unicode/ApplicationID.dll",
-  "Plugins/x86-unicode/nsProcess.dll",
-  "Plugins/x86-unicode/nsis_semvercompare.dll",
+  "Plugins/x86-unicode/nsis_tauri_utils.dll",
 ];
 
 /// Runs all of the commands to build the NSIS installer.
@@ -102,10 +94,6 @@ fn get_and_extract_nsis(nsis_toolset_path: &Path, _tauri_tools_path: &Path) -> c
 
   let nsis_plugins = nsis_toolset_path.join("Plugins");
 
-  let data = download(NSIS_NSCURL_URL)?;
-  info!("extracting NSIS NScurl plugin");
-  extract_zip(&data, &nsis_plugins)?;
-
   let data = download(NSIS_APPLICATIONID_URL)?;
   info!("extracting NSIS ApplicationID plugin");
   extract_zip(&data, &nsis_plugins)?;
@@ -116,23 +104,11 @@ fn get_and_extract_nsis(nsis_toolset_path: &Path, _tauri_tools_path: &Path) -> c
     nsis_plugins.join("x86-unicode").join("ApplicationID.dll"),
   )?;
 
-  let data = download(NSIS_NSPROCESS_URL)?;
-  info!("extracting NSIS NsProcess plugin");
-  extract_zip(&data, &nsis_plugins)?;
-  copy(
-    nsis_plugins.join("Plugin").join("nsProcessW.dll"),
-    nsis_plugins.join("x86-unicode").join("nsProcess.dll"),
-  )?;
-
-  let data = download_and_verify(
-    NSIS_SEMVER_COMPARE,
-    NSIS_SEMVER_COMPARE_SHA1,
-    HashAlgorithm::Sha1,
-  )?;
+  let data = download_and_verify(NSIS_TAURI_UTILS, NSIS_TAURI_UTILS_SHA1, HashAlgorithm::Sha1)?;
   write(
     nsis_plugins
       .join("x86-unicode")
-      .join("nsis_semvercompare.dll"),
+      .join("nsis_tauri_utils.dll"),
     data,
   )?;
 

+ 5 - 5
tooling/bundler/src/bundle/windows/templates/installer.nsi

@@ -107,7 +107,7 @@ Function PageReinstall
   ReadRegStr $R0 SHCTX "${UNINSTKEY}" "DisplayVersion"
   ${IfThen} $R0 == "" ${|} StrCpy $R4 "$(unknown)" ${|}
 
-  nsis_semvercompare::SemverCompare "${VERSION}" $R0
+  nsis_tauri_utils::SemverCompare "${VERSION}" $R0
   Pop $R0
   ; Reinstalling the same version
   ${If} $R0 == 0
@@ -301,9 +301,9 @@ Section Webview2
   !if "${INSTALLWEBVIEW2MODE}" == "downloadBootstrapper"
     Delete "$TEMP\MicrosoftEdgeWebview2Setup.exe"
     DetailPrint "$(webview2Downloading)"
-    NScurl::http GET "https://go.microsoft.com/fwlink/p/?LinkId=2124703" "$TEMP\MicrosoftEdgeWebview2Setup.exe" /CANCEL /END
+    nsis_tauri_utils::download "https://go.microsoft.com/fwlink/p/?LinkId=2124703" "$TEMP\MicrosoftEdgeWebview2Setup.exe"
     Pop $0
-    ${If} $0 == "OK"
+    ${If} $0 == 0
       DetailPrint "$(webview2DownloadSuccess)"
     ${Else}
       DetailPrint "$(webview2DownloadError)"
@@ -346,7 +346,7 @@ Section Webview2
 SectionEnd
 
 !macro CheckIfAppIsRunning
-  nsProcess::_FindProcess "${MAINBINARYNAME}.exe"
+  nsis_tauri_utils::FindProcess "${MAINBINARYNAME}.exe"
   Pop $R0
   ${If} $R0 = 0
     IfSilent silent ui
@@ -361,7 +361,7 @@ SectionEnd
     ui:
       MessageBox MB_OKCANCEL "$(appRunningOkKill)" IDOK ok IDCANCEL cancel
       ok:
-        nsProcess::_KillProcess "${MAINBINARYNAME}.exe"
+        nsis_tauri_utils::KillProcess "${MAINBINARYNAME}.exe"
         Pop $R0
         Sleep 500
         ${If} $R0 = 0