Skip to content

fix: ship the licences of the Rust libraries inside MemoryStick - #12

Merged
MotherSphere merged 1 commit into
mainfrom
fix/rust-licence-notices
Oct 12, 2026
Merged

MotherSphere merged 1 commit into
mainfrom
fix/rust-licence-notices

Conversation

@MotherSphere

Copy link
Copy Markdown
Member

MIT, BSD, Apache-2.0, ISC and similar licences require a binary distribution to carry their notices. The executable statically links about 320 Rust crates, and until now only Cargo.lock was pointed at.

What changes

  • src-tauri/build.rs runs $CARGO metadata --format-version 1 --locked --offline --filter-platform $TARGET, follows the normal dependencies reachable from memorystick (build and dev dependencies are not linked in), and reads each crate's LICENSE*, LICENCE*, UNLICENSE*, COPYING*, COPYRIGHT* and NOTICE* files plus any declared license-file. Texts that differ only in whitespace are kept once, under the sorted name@version (SPDX) list of crates that ship them. Crates with no licence file are listed at the end with their SPDX expression. The result goes to $OUT_DIR/rust-licenses.txt. No new dependency: serde_json was already in the lockfile.
  • src/licenses.rs embeds that file and exposes it through a new third_party_licenses command, declared in build.rs and allowed in capabilities/default.json (allow-third-party-licenses).
  • Preferences > About gains a collapsible "Third-party licences" section. The text is fetched the first time it opens and shown in a scrollable, focusable pre. New strings preferences_third_party and preferences_third_party_desc in English and French (the existing parity test covers them).
  • docs/third-party-notices.md replaces the Cargo.lock sentence with how the notices travel in the binary; the README licence section mentions them.

Offline behaviour

--offline means the build script never reaches the network: it only reads packages Cargo already downloaded to build them. With --filter-platform, cargo metadata needs exactly the target and host packages the build itself fetched. Verified locally on Linux (no lock contention with the outer build); this PR's CI exercises Windows, macOS and the MSRV toolchain.

Binary size

The embedded text for x86_64-unknown-linux-gnu is 536,217 bytes (168 distinct licence texts for 322 crates; whitespace-only duplicates of the Apache-2.0 text are merged). It is stored uncompressed, so the release binary grows by about 536 KB, about 4.5% of v0.1.1's memorystick-linux (11,899,808 bytes). Windows and macOS link a different set of crates, so their text and delta differ slightly.

Tests

  • licenses::tests::names_the_libraries_memorystick_is_built_on: the generated text is non-empty and lists tauri, comrak and serde.
  • cargo test --locked passes locally (9 tests).

build.rs collects the licence texts of every crate linked into the
executable for the target being built, from cargo metadata run locked and
offline, and embeds them. Preferences > About shows them under
Third-party licences.
@MotherSphere
MotherSphere merged commit 86282e2 into main Oct 12, 2026
9 checks passed
@MotherSphere
MotherSphere deleted the fix/rust-licence-notices branch October 12, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant