Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nsis): add an option to disable compression #9932

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changes/nsis-no-compression.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"tauri-utils": patch::breaking
"tauri-bundler": patch::breaking
"tauri-cli": patch::breaking
"@tauri-apps/cli": patch::breaking
---

Add an option to disable NSIS compression
amrbashir marked this conversation as resolved.
Show resolved Hide resolved
13 changes: 9 additions & 4 deletions core/tauri-config-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2290,12 +2290,10 @@
},
"compression": {
"description": "Set the compression algorithm used to compress files in the installer.\n\nSee <https://nsis.sourceforge.io/Reference/SetCompressor>",
"anyOf": [
"default": "lzma",
"allOf": [
{
"$ref": "#/definitions/NsisCompression"
},
{
"type": "null"
}
]
},
Expand Down Expand Up @@ -2358,6 +2356,13 @@
"enum": [
"lzma"
]
},
{
"description": "Disable compression",
"type": "string",
"enum": [
"none"
]
}
]
},
Expand Down
71 changes: 40 additions & 31 deletions core/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,44 @@ pub enum NsisCompression {
Bzip2,
/// LZMA (default) is a new compression method that gives very good compression ratios. The decompression speed is high (10-20 MB/s on a 2 GHz CPU), the compression speed is lower. The memory size that will be used for decompression is the dictionary size plus a few KBs, the default is 8 MB.
Lzma,
/// Disable compression
None,
}

impl Default for NsisCompression {
fn default() -> Self {
Self::Lzma
}
}

/// Install Modes for the NSIS installer.
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[cfg_attr(feature = "schema", derive(JsonSchema))]
pub enum NSISInstallerMode {
/// Default mode for the installer.
///
/// Install the app by default in a directory that doesn't require Administrator access.
///
/// Installer metadata will be saved under the `HKCU` registry path.
CurrentUser,
/// Install the app by default in the `Program Files` folder directory requires Administrator
/// access for the installation.
///
/// Installer metadata will be saved under the `HKLM` registry path.
PerMachine,
/// Combines both modes and allows the user to choose at install time
/// whether to install for the current user or per machine. Note that this mode
/// will require Administrator access even if the user wants to install it for the current user only.
///
/// Installer metadata will be saved under the `HKLM` or `HKCU` registry path based on the user's choice.
Both,
}

impl Default for NSISInstallerMode {
fn default() -> Self {
Self::CurrentUser
}
}

/// Configuration for the Installer bundle using NSIS.
Expand Down Expand Up @@ -730,7 +768,8 @@ pub struct NsisConfig {
/// Set the compression algorithm used to compress files in the installer.
///
/// See <https://nsis.sourceforge.io/Reference/SetCompressor>
pub compression: Option<NsisCompression>,
#[serde(default)]
pub compression: NsisCompression,
/// A path to a `.nsh` file that contains special NSIS macros to be hooked into the
/// main installer.nsi script.
///
Expand Down Expand Up @@ -769,36 +808,6 @@ pub struct NsisConfig {
pub installer_hooks: Option<PathBuf>,
}

/// Install Modes for the NSIS installer.
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[cfg_attr(feature = "schema", derive(JsonSchema))]
pub enum NSISInstallerMode {
/// Default mode for the installer.
///
/// Install the app by default in a directory that doesn't require Administrator access.
///
/// Installer metadata will be saved under the `HKCU` registry path.
CurrentUser,
/// Install the app by default in the `Program Files` folder directory requires Administrator
/// access for the installation.
///
/// Installer metadata will be saved under the `HKLM` registry path.
PerMachine,
/// Combines both modes and allows the user to choose at install time
/// whether to install for the current user or per machine. Note that this mode
/// will require Administrator access even if the user wants to install it for the current user only.
///
/// Installer metadata will be saved under the `HKLM` or `HKCU` registry path based on the user's choice.
Both,
}

impl Default for NSISInstallerMode {
fn default() -> Self {
Self::CurrentUser
}
}

/// Install modes for the Webview2 runtime.
/// Note that for the updater bundle [`Self::DownloadBootstrapper`] is used.
///
Expand Down
2 changes: 1 addition & 1 deletion tooling/bundler/src/bundle/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ pub struct NsisSettings {
/// By default the OS language is selected, with a fallback to the first language in the `languages` array.
pub display_language_selector: bool,
/// Set compression algorithm used to compress files in the installer.
pub compression: Option<NsisCompression>,
pub compression: NsisCompression,
/// A path to a `.nsh` file that contains special NSIS macros to be hooked into the
/// main installer.nsi script.
///
Expand Down
3 changes: 2 additions & 1 deletion tooling/bundler/src/bundle/windows/nsis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,11 @@ fn build_nsis_app_installer(

data.insert(
"compression",
to_json(match &nsis.compression.unwrap_or(NsisCompression::Lzma) {
to_json(match &nsis.compression {
NsisCompression::Zlib => "zlib",
NsisCompression::Bzip2 => "bzip2",
NsisCompression::Lzma => "lzma",
NsisCompression::None => "none",
}),
);

Expand Down
7 changes: 4 additions & 3 deletions tooling/bundler/src/bundle/windows/templates/installer.nsi
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Unicode true
ManifestDPIAware true
; Set the compression algorithm. Default is LZMA.
!if "{{compression}}" == ""
SetCompressor /SOLID lzma

!if "{{compression}}" == "none"
SetCompress false
!else
; Set the compression algorithm. Default is LZMA.
SetCompressor /SOLID "{{compression}}"
!endif

Expand Down
13 changes: 9 additions & 4 deletions tooling/cli/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2290,12 +2290,10 @@
},
"compression": {
"description": "Set the compression algorithm used to compress files in the installer.\n\nSee <https://nsis.sourceforge.io/Reference/SetCompressor>",
"anyOf": [
"default": "lzma",
"allOf": [
{
"$ref": "#/definitions/NsisCompression"
},
{
"type": "null"
}
]
},
Expand Down Expand Up @@ -2358,6 +2356,13 @@
"enum": [
"lzma"
]
},
{
"description": "Disable compression",
"type": "string",
"enum": [
"none"
]
}
]
},
Expand Down