feat(cli): add --no-binary-patching flag to build and bundle - #15619
Conversation
|
let's go with |
--no-binary-patching flag to build and bundle
|
@Legend-Master switched to Pushed in 8d3139d. Rebuilt fmt/clippy clean on |
Package Changes Through 3553abbThere are 14 changes which include tauri with minor, tauri-cli with minor, @tauri-apps/cli with minor, tauri-runtime with minor, tauri-runtime-wry with minor, tauri-utils with minor, tauri-bundler with minor, tauri-build with minor, tauri-macos-sign with minor, tauri-codegen with minor, tauri-macros with minor, tauri-plugin with minor, tauri-driver with minor, @tauri-apps/api with minor Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
Legend-Master
left a comment
There was a problem hiding this comment.
Looks good, just some small nitpicks
Also you'll need to sign your commits for me to merge this
| @@ -0,0 +1,6 @@ | |||
| --- | |||
| "tauri-bundler": "minor:feat" | |||
| "tauri-cli": "minor:feat" | |||
There was a problem hiding this comment.
| "tauri-cli": "minor:feat" | |
| "tauri-cli": "minor:feat" | |
| "@tauri-apps/cli": "minor:feat" |
There was a problem hiding this comment.
Applied — the changefile now lists all three (tauri-bundler, tauri-cli, @tauri-apps/cli) as minor:feat.
|
|
||
| /// Sets whether to disable patching the main binary with bundle type information. | ||
| #[must_use] | ||
| pub fn no_binary_patching(mut self, no_binary_patching: bool) -> Self { |
There was a problem hiding this comment.
I know we had no_sign above, but generally speaking, we should use positive flags (e.g. binary_pacthing and true by default)
There was a problem hiding this comment.
Done — flipped to a positive binary_patching flag defaulting to true (the CLI flag stays --no-binary-patching, which just sets it to false).
8d3139d to
a22ac40
Compare
|
@Legend-Master addressed both:
Also signed all commits (Verified now). |
| Default::default() | ||
| Self { | ||
| binary_patching: true, | ||
| ..Default::default() |
There was a problem hiding this comment.
Let's manually implement the default instead
There was a problem hiding this comment.
Done in a0e9f93fb — dropped #[derive(Default)] and hand-wrote impl Default for SettingsBuilder with binary_patching: true; new() is now just Self::default().
| // Patching rewrites the main binary in place, invalidating any existing code signature. | ||
| // When disabled, leave the binary untouched and skip the post-patch re-sign (whose only | ||
| // purpose is to repair that invalidated signature), preserving an already-signed binary. |
There was a problem hiding this comment.
| // Patching rewrites the main binary in place, invalidating any existing code signature. | |
| // When disabled, leave the binary untouched and skip the post-patch re-sign (whose only | |
| // purpose is to repair that invalidated signature), preserving an already-signed binary. |
Remove this
| if matches!(target_os, TargetPlatform::Windows) && settings.windows().can_sign() { | ||
| windows::sign::try_sign(&main_binary_path, settings)?; | ||
| } | ||
| } |
There was a problem hiding this comment.
Let's add a notice like we did for --no-sign
There was a problem hiding this comment.
Added — logs Skipping binary patching due to --no-binary-patching flag. Put it once before the loop rather than in a per-package_type else so it does not repeat for each bundle; mirrors the single --no-sign notice.
Tauri patches the main executable with bundle type information so the updater plugin can pick the matching installer format when multiple bundle types target the same platform. This rewrites the binary after it is built, invalidating an existing code signature on it, which breaks bundling an already-signed binary (e.g. inside the NSIS bundler). Add a `bundle > disableBinaryPatching` config option (default false). When set, the bundler skips patching the main binary and the subsequent re-sign, leaving the executable untouched. closes tauri-apps#15591
Switch the disable-binary-patching control from the proposed `bundle > disableBinaryPatching` config option to a `--no-binary-patching` CLI flag on `tauri build` and `tauri bundle`, mirroring the `--no-sign` precedent. When set, the bundler skips patching the main executable with bundle type information (and the subsequent re-sign), preserving an already-signed binary. Patching only matters when shipping multiple bundle types per platform.
- Implement Default for SettingsBuilder manually so binary_patching defaults to true, instead of overriding it on top of a derived default. - Log a notice when --no-binary-patching skips patching, mirroring the --no-sign notice, and drop the now-redundant inline comment.
54f7e3d to
a0e9f93
Compare
|
@Legend-Master addressed all nitpicks in |
Closes #15591.
Tauri patches the main executable with bundle type information (
Patching app.exe with bundle type information: nsis) so the updater plugin can pick the matching installer format when several bundle types target the same platform. This rewrites the binary after it is built, invalidating an existing code signature on it — which makes bundling an already-signed binary inside e.g. the NSIS bundler impossible.Change
Add a
bundle > disableBinaryPatchingconfig option (defaultfalse, so patching stays on). When set totrue,bundle_projectskips thepatch_binarycall and the post-patch re-sign, leaving the main binary untouched.I gated the re-sign together with the patch because that re-sign exists only to repair the signature the patch invalidates (the main binary is intentionally skipped by
sign_binaries_if_needed). So with patching disabled the executable is left exactly as built, preserving any existing signature — which is the point of the flag.As @Legend-Master noted in the issue, the patching is only needed when shipping multiple installer types per platform that should each update with their own format, so disabling it is safe otherwise.
Files
tauri-utils: newdisableBinaryPatchingfield onBundleConfig(+ToTokens, regeneratedconfig.schema.json)tauri-bundler:disable_binary_patchingonBundleSettings+Settings::disable_binary_patching(); guard inbundle_projecttauri-cli: map the config field intoBundleSettingsOpen question
I went with a config value (matches the rest of
bundle). Happy to also add a--no-sign-style--disable-binary-patchingCLI flag ontauri build/tauri bundleif you would prefer that too.