Repository navigation
fix: make embedded assets codegen and config serialization deterministic - #15777
Conversation
generate_context! emitted the embedded asset map and the CSP script/style hashes in filesystem walk order (varies across machines) and HashMap iteration order (varies per process), and serializing the processed config wrote the csp/headers/plugins maps in HashMap iteration order. Both broke reproducible builds: the same source built on two machines produced different binaries and a different tauri.conf.json in the generated Android project. Iterate all of them sorted, complementing tauri-apps#14986 which sorted the same config maps on the ToTokens path. closes tauri-apps#14978
|
Please let me know if you want any changes to this PR. Would love to have this shipped in coming versions as right now I have to either host a whole tauri-codegen source in my project's tree, add a patch-cargo dependency that works like patch-package in JS world or write complex shell scripts that do pretty much the same thing as patch-cargo but without third party tool. |
Package Changes Through ad5f600There 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 |
Hi, I'm developing an app with Tauri that requires reproducible builds. I found a non-determenistic build part that has to do with CSP. I have seen #14978 and #14986 but those didn't fix it fully.
ToTokens for EmbeddedAssetsemits the embedded asset map and the CSP script/style hash lists in the order the assets were collected,WalkDirtraversal without sorting, i.e. raw readdir order. It differs on different machines with e.g. ext4 hashed directories soCspHashslice is differentSerializeforCsp::DirectiveMap,HeaderSource::MapandPluginConfigwritesHashMapkey order, which is random per process. Tauri cli serializes processed config into the generated android project (assets/tauri.conf.json) so every build of the same source produces a differently ordered fileWith this patched I was able to produce identical unsigned apks with Tauri with CSP enabled.