#!/bin/sh # Lists every crate in MathCAT's normal dependency tree for # wasm32-unknown-unknown (a superset of what ends up in the .wasm: it also # names the proc-macro crates, which only run at compile time), with its # licence and the licence files it comes with. A text already printed for an # earlier crate is referred to rather than repeated. set -e cd /wrap seen=$(mktemp) echo "Crates compiled into mathcat_bg.wasm (johnmcm.com Equation Editor braille)," echo "with their licences and the licence files each ships." echo cargo tree -e normal --target wasm32-unknown-unknown --prefix none --format '{p}|{l}' --no-dedupe \ | sed 's/ (.*)|/|/; s/ (\*)$//' | sort -u | while IFS='|' read -r pkg lic; do name=${pkg% v*}; ver=${pkg##* v} case "$name" in mathcat-wasm) continue ;; esac note= if [ "$name" = mathcat ]; then dir=/mathcat elif [ "$name" = dirs ]; then # [patch.crates-io] in Cargo.toml: the stand-in in stub/dirs, not the crates.io crate. dir=/wrap/stub/dirs note="(a stand-in written for this build, stub/dirs in the published build files; not the crates.io crate)" else dir=$(ls -d "$CARGO_HOME"/registry/src/*/"$name-$ver" 2>/dev/null | head -n 1); fi echo "================================================================================" echo "$name $ver - $lic${note:+ $note}" echo "================================================================================" found=0 for f in "$dir"/LICENSE* "$dir"/LICENCE* "$dir"/COPYING* "$dir"/NOTICE* "$dir"/UNLICENSE*; do [ -f "$f" ] || continue found=1 sum=$(md5sum < "$f" | cut -d' ' -f1) first=$(grep "^$sum " "$seen" | head -n 1 | cut -d' ' -f2-) if [ -n "$first" ]; then echo "--- $(basename "$f"): the same text as $first above" else echo "$sum $name $ver $(basename "$f")" >> "$seen" echo "--- $(basename "$f")" cat "$f" echo fi done [ $found = 1 ] || echo "(no licence file in the crate; licence as declared above)" echo done rm -f "$seen"