build(notices): third-party licence notices, generated and checked
Every licence the program's dependencies and bundled fonts carry (MIT, Apache-2.0, BSD, ISC, Zlib, the SIL Open Font License) asks that its copyright notice and licence text travel with each copy of the binary, and until now nothing shipped them. `just notices` (scripts/notices.sh) writes THIRD-PARTY-NOTICES.txt: cargo-about names every crate the `wanderbooks` binary links, from ledger-cli's manifest across every feature and platform the program ships on, with the licence text; the script then adds the embedded fonts and their licence files. `just notices-check`, in the lint part of `just check`, regenerates the file and fails when a dependency or font changed without it, so the committed copy cannot drift. cargo-about is a build tool used to generate and check the file; it is not a dependency of the program (no Cargo.toml or Cargo.lock changes). Its accepted list is deny.toml's allow list word for word. Co-Authored-By: DeepSeek V4.1 Flash
This commit is contained in:
1 parent
1726c8b6dd
commit
7f87ccd3d3
6 files changed
+12524
No files matched your search
+12283
File diff suppressed because it is too large.
Load diff
+43
@@ -0,0 +1,43 @@
|
|||||||
|
# What cargo-about may report when it writes THIRD-PARTY-NOTICES.txt
|
||||||
|
# (`just notices`). The accepted list is deny.toml's `allow` list, word for
|
||||||
|
# word: the gate and the notices describe the same set of licences. A
|
||||||
|
# licence that is not here is not in the program either; if cargo-about
|
||||||
|
# meets one, fix the dependency, never this list.
|
||||||
|
accepted = [
|
||||||
|
"MIT",
|
||||||
|
"MIT-0",
|
||||||
|
"Apache-2.0",
|
||||||
|
"Apache-2.0 WITH LLVM-exception",
|
||||||
|
"BSD-2-Clause",
|
||||||
|
"BSD-3-Clause",
|
||||||
|
"ISC",
|
||||||
|
"Zlib",
|
||||||
|
"0BSD",
|
||||||
|
"BSL-1.0",
|
||||||
|
"CC0-1.0",
|
||||||
|
"Unlicense",
|
||||||
|
"Unicode-3.0",
|
||||||
|
"bzip2-1.0.6",
|
||||||
|
"MPL-2.0",
|
||||||
|
"CDLA-Permissive-2.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
# Every platform the program ships on. The list is fixed rather than the
|
||||||
|
# build machine's, so the notices name the same dependencies everywhere.
|
||||||
|
targets = [
|
||||||
|
"x86_64-unknown-linux-gnu",
|
||||||
|
"aarch64-unknown-linux-gnu",
|
||||||
|
"x86_64-apple-darwin",
|
||||||
|
"aarch64-apple-darwin",
|
||||||
|
"x86_64-pc-windows-msvc",
|
||||||
|
]
|
||||||
|
|
||||||
|
# Only what the binary links: a build script's dependencies and the tests'
|
||||||
|
# are not shipped, so their licences have no notice to travel with.
|
||||||
|
ignore-build-dependencies = true
|
||||||
|
ignore-dev-dependencies = true
|
||||||
|
|
||||||
|
# The workspace's own crates are `publish = false`: they are the program,
|
||||||
|
# not third parties, and the program's own licence is stated at the top of
|
||||||
|
# the notices.
|
||||||
|
private = { ignore = true }
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
{{! Plain-text notices for the third-party crates the program links
|
||||||
|
(`just notices`). The `text` field is licence text, not HTML: triple
|
||||||
|
braces keep it as it is. }}
|
||||||
|
THIRD-PARTY NOTICES
|
||||||
|
|
||||||
|
wanderbooks is licensed under MIT OR Apache-2.0. It is built with the
|
||||||
|
third-party Rust crates named below, each under the licence named in its
|
||||||
|
section, and each licence's text follows. The fonts the program embeds are
|
||||||
|
listed at the end of this file, under FONTS, each with its licence. A
|
||||||
|
build-time or development-only dependency is not part of the program as
|
||||||
|
shipped and is not listed here.
|
||||||
|
|
||||||
|
{{#each licenses}}
|
||||||
|
================================================================================
|
||||||
|
{{{name}}}
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
Used by:
|
||||||
|
{{#each used_by}}
|
||||||
|
{{crate.name}} {{crate.version}}
|
||||||
|
{{/each}}
|
||||||
|
|
||||||
|
{{{text}}}
|
||||||
|
|
||||||
|
{{/each}}
|
||||||
@@ -39,6 +39,7 @@ check-shard shard:
|
|||||||
just server-only
|
just server-only
|
||||||
just check-shards-agree
|
just check-shards-agree
|
||||||
just deny
|
just deny
|
||||||
|
just notices-check
|
||||||
;;
|
;;
|
||||||
# The viewer's tests are half of the suite's time, in two halves
|
# The viewer's tests are half of the suite's time, in two halves
|
||||||
# of their own: its unit tests, and its integration tests. Between
|
# of their own: its unit tests, and its integration tests. Between
|
||||||
@@ -66,6 +67,18 @@ check-shard shard:
|
|||||||
deny:
|
deny:
|
||||||
cargo deny check
|
cargo deny check
|
||||||
|
|
||||||
|
# The third-party notices every licence asks to travel with
|
||||||
|
# (THIRD-PARTY-NOTICES.txt): each crate the `wanderbooks` binary links and
|
||||||
|
# its licence text, then the fonts embedded, each with its licence. Writes
|
||||||
|
# the file; commit it.
|
||||||
|
notices:
|
||||||
|
scripts/notices.sh
|
||||||
|
|
||||||
|
# Whether THIRD-PARTY-NOTICES.txt still matches the dependencies: a crate
|
||||||
|
# added, removed or upgraded without regenerating it fails (`just notices`).
|
||||||
|
notices-check:
|
||||||
|
scripts/notices.sh --check
|
||||||
|
|
||||||
# CI's list of parts is this file's: a part CI never runs is a check
|
# CI's list of parts is this file's: a part CI never runs is a check
|
||||||
# nobody makes, and a part only CI names fails there, not here.
|
# nobody makes, and a part only CI names fails there, not here.
|
||||||
check-shards-agree:
|
check-shards-agree:
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ node = "26"
|
|||||||
# none yanked, none under a licence that does not fit MIT OR Apache-2.0,
|
# none yanked, none under a licence that does not fit MIT OR Apache-2.0,
|
||||||
# none from a source nobody named (deny.toml).
|
# none from a source nobody named (deny.toml).
|
||||||
cargo-deny = "0.20.2"
|
cargo-deny = "0.20.2"
|
||||||
|
# `just notices`: cargo-about reads every crate the program links and the
|
||||||
|
# licence it carries, to write THIRD-PARTY-NOTICES.txt.
|
||||||
|
"cargo:cargo-about" = { version = "0.9.3", features = ["cli"] }
|
||||||
# A compile cache shared by every jj workspace's target dir: point
|
# A compile cache shared by every jj workspace's target dir: point
|
||||||
# cargo's build.rustc-wrapper at it (~/.cargo/config.toml).
|
# cargo's build.rustc-wrapper at it (~/.cargo/config.toml).
|
||||||
sccache = "0.18.0"
|
sccache = "0.18.0"
|
||||||
|
|||||||
Executable
+157
@@ -0,0 +1,157 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# The third-party notices the program must travel with (MIT, Apache-2.0,
|
||||||
|
# BSD, ISC, Zlib, SIL OFL 1.1 and the rest all ask that their copyright
|
||||||
|
# notice and licence text go with every copy).
|
||||||
|
#
|
||||||
|
# scripts/notices.sh write THIRD-PARTY-NOTICES.txt
|
||||||
|
# scripts/notices.sh --check fail if it is out of date (`just notices-check`)
|
||||||
|
#
|
||||||
|
# The file has two parts. The first is cargo-about's: every crate the
|
||||||
|
# `wanderbooks` binary links, with the licence it carries and that
|
||||||
|
# licence's text. cargo-about reads the manifest of `ledger-cli` (the one
|
||||||
|
# executable), every feature and every platform the program ships on, so
|
||||||
|
# the list is what the program contains, not what this machine happens to
|
||||||
|
# build. The second part is the fonts the program embeds: each file under
|
||||||
|
# `crates/ledger-gui/assets/fonts/` and `crates/ledger-import/fonts/`,
|
||||||
|
# with the licence file beside it. A font file that no entry below names
|
||||||
|
# fails the script, so a new font cannot ship without its notice.
|
||||||
|
#
|
||||||
|
# The output is plain text, says nothing about this machine (no dates, no
|
||||||
|
# absolute paths), and is the same on two runs; `--check` compares it with
|
||||||
|
# the committed file byte for byte, so a changed dependency shows up as a
|
||||||
|
# red `just check` until the file is regenerated and committed.
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
cd "$(git rev-parse --show-toplevel)"
|
||||||
|
out=THIRD-PARTY-NOTICES.txt
|
||||||
|
|
||||||
|
case "${1:-}" in
|
||||||
|
"" | --check) ;;
|
||||||
|
*)
|
||||||
|
echo "usage: scripts/notices.sh [--check]" >&2
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
check=${1:-}
|
||||||
|
|
||||||
|
work=$(mktemp -d)
|
||||||
|
trap 'rm -rf "$work"' EXIT
|
||||||
|
|
||||||
|
# Which licence each bundled font carries. Every `*.ttf` and `*.otf`
|
||||||
|
# under the two font folders must match one pattern here; a new font is
|
||||||
|
# added here beside its licence file, never left out of the notices.
|
||||||
|
font_map=(
|
||||||
|
"crates/ledger-gui/assets/fonts/InterTab-*.ttf|crates/ledger-gui/assets/fonts/Inter-LICENSE.txt"
|
||||||
|
"crates/ledger-gui/assets/fonts/Hack-Regular.ttf|crates/ledger-gui/assets/fonts/Hack-LICENSE.txt"
|
||||||
|
"crates/ledger-gui/assets/fonts/NotoEmoji-Regular.ttf|crates/ledger-gui/assets/fonts/NotoEmoji-LICENSE.txt"
|
||||||
|
"crates/ledger-gui/assets/fonts/emoji-icon-font.ttf|crates/ledger-gui/assets/fonts/emoji-icon-font-LICENSE.txt"
|
||||||
|
# The PDFs' Inter is the same font and licence as the viewer's.
|
||||||
|
"crates/ledger-import/fonts/Inter-*.ttf|crates/ledger-gui/assets/fonts/Inter-LICENSE.txt"
|
||||||
|
"crates/ledger-import/fonts/NotoSans*-Regular.ttf|crates/ledger-import/fonts/NotoSans-LICENSE.txt"
|
||||||
|
"crates/ledger-import/fonts/NotoSansCJKsc-*.otf|crates/ledger-import/fonts/NotoSansCJK-LICENSE.txt"
|
||||||
|
)
|
||||||
|
|
||||||
|
# font -> licence, filled from font_map below.
|
||||||
|
declare -A font_licence=()
|
||||||
|
|
||||||
|
for entry in "${font_map[@]}"; do
|
||||||
|
pattern=${entry%%|*}
|
||||||
|
licence=${entry#*|}
|
||||||
|
matched=0
|
||||||
|
for file in $pattern; do
|
||||||
|
[ -f "$file" ] || continue
|
||||||
|
font_licence["$file"]=$licence
|
||||||
|
matched=1
|
||||||
|
done
|
||||||
|
if [ "$matched" -eq 0 ]; then
|
||||||
|
echo "notices: no font matches $pattern (the map in scripts/notices.sh is stale)" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Every font file must be accounted for: a font that no entry names has
|
||||||
|
# no notice to travel with.
|
||||||
|
fonts=$(find crates/ledger-gui/assets/fonts crates/ledger-import/fonts \
|
||||||
|
-type f \( -name '*.ttf' -o -name '*.otf' \) | sort)
|
||||||
|
for font in $fonts; do
|
||||||
|
if [ -z "${font_licence[$font]:-}" ]; then
|
||||||
|
echo "notices: no licence for $font: add it to the map in scripts/notices.sh" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# The fonts section, grouped by licence file: every font that carries a
|
||||||
|
# licence is listed, then that licence's text once.
|
||||||
|
font_section() {
|
||||||
|
echo "================================================================================"
|
||||||
|
echo "FONTS"
|
||||||
|
echo "================================================================================"
|
||||||
|
echo
|
||||||
|
echo "The program embeds the fonts below. Each font file is listed under"
|
||||||
|
echo "the licence it carries, and that licence's text follows."
|
||||||
|
echo
|
||||||
|
local seen=() entry licence font found seen_licence
|
||||||
|
for entry in "${font_map[@]}"; do
|
||||||
|
licence=${entry#*|}
|
||||||
|
found=0
|
||||||
|
for seen_licence in ${seen[@]+"${seen[@]}"}; do
|
||||||
|
[ "$seen_licence" = "$licence" ] && found=1
|
||||||
|
done
|
||||||
|
[ "$found" -eq 0 ] || continue
|
||||||
|
seen+=("$licence")
|
||||||
|
if [ ! -f "$licence" ]; then
|
||||||
|
echo "notices: no licence file $licence" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "--------------------------------------------------------------------------------"
|
||||||
|
echo "$licence"
|
||||||
|
echo "--------------------------------------------------------------------------------"
|
||||||
|
echo
|
||||||
|
echo "Fonts:"
|
||||||
|
while IFS= read -r font; do
|
||||||
|
[ -n "$font" ] || continue
|
||||||
|
[ "${font_licence[$font]:-}" = "$licence" ] || continue
|
||||||
|
echo " $font"
|
||||||
|
done <<<"$fonts"
|
||||||
|
echo
|
||||||
|
cat "$licence"
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# One full copy of the notices, in $1.
|
||||||
|
write_notices() {
|
||||||
|
local target=$1
|
||||||
|
command -v cargo >/dev/null || {
|
||||||
|
echo "notices: cargo is not installed (mise install)" >&2
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
# --offline: no network lookup, so the same crates give the same file
|
||||||
|
# on every machine. The manifest is ledger-cli's, the one executable:
|
||||||
|
# that dependency graph is what the binary links.
|
||||||
|
cargo about generate --locked --all-features --offline \
|
||||||
|
-m crates/ledger-cli/Cargo.toml -c about.toml \
|
||||||
|
deploy/notices/about.hbs > "$work/about.txt"
|
||||||
|
{
|
||||||
|
cat "$work/about.txt"
|
||||||
|
echo
|
||||||
|
font_section
|
||||||
|
} > "$work/all.txt"
|
||||||
|
# Plain text: trailing whitespace off every line, and exactly one
|
||||||
|
# newline at the end (the licence files and cargo-about differ).
|
||||||
|
sed 's/[[:space:]]*$//' "$work/all.txt" > "$work/clean.txt"
|
||||||
|
printf '%s\n' "$(cat "$work/clean.txt")" > "$target"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$check" = --check ]; then
|
||||||
|
write_notices "$work/check.txt"
|
||||||
|
if ! cmp -s "$work/check.txt" "$out"; then
|
||||||
|
diff -u "$out" "$work/check.txt" | head -40 >&2 || true
|
||||||
|
echo 'THIRD-PARTY-NOTICES.txt is out of date: run `just notices` and commit the result' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "notices: $out is up to date"
|
||||||
|
else
|
||||||
|
write_notices "$out"
|
||||||
|
echo "notices: wrote $out"
|
||||||
|
fi
|
||||||
Reference in new issue
Block a user