| 1 | #!/bin/bash |
| 2 | |
| 3 | set -euo pipefail |
| 4 | mobile_dir="$(cd "$(dirname "$0")/.." && pwd)" |
| 5 | cd "$mobile_dir/bindings" |
| 6 | output="$mobile_dir/.build/resources/licenses" |
| 7 | mkdir -p "$output" |
| 8 | list="$(mktemp)" |
| 9 | trap 'rm -f "$list"' EXIT |
| 10 | |
| 11 | for target in android ios; do |
| 12 | GOOS="$target" GOARCH=arm64 CGO_ENABLED=1 go list -deps -f '{{with .Module}}{{.Path}}{{"\t"}}{{.Version}}{{"\t"}}{{.Dir}}{{end}}' . |
| 13 | done | awk -F '\t' 'NF == 3 && !seen[$1]++' | LC_ALL=C sort > "$list" |
| 14 | { |
| 15 | cat <<'NOTICE' |
| 16 | Cage mobile third-party notices |
| 17 | |
| 18 | Cage mobile source and build scripts: https://github.com/Lee-xeo/claude-cage |
| 19 | The licenses of the linked Go modules are included below. |
| 20 | |
| 21 | NOTICE |
| 22 | go_license="$(go env GOROOT)/LICENSE" |
| 23 | [[ -f "$go_license" ]] || go_license="$(go env GOROOT)/../LICENSE" |
| 24 | cat "$go_license" |
| 25 | while IFS=$'\t' read -r path version directory; do |
| 26 | for file in "$directory"/LICENSE* "$directory"/LICENCE* "$directory"/COPYING* "$directory"/NOTICE* "$directory"/UNLICENSE*; do |
| 27 | [[ -f "$file" ]] || continue |
| 28 | printf '\n======== %s %s: %s ========\n\n' "$path" "$version" "$(basename "$file")" |
| 29 | cat "$file" |
| 30 | done |
| 31 | done < "$list" |
| 32 | } > "$output/THIRD_PARTY_NOTICES.txt" |
| 33 | for package in react react-dom scheduler lucide-react; do |
| 34 | cp "$mobile_dir/../ui/node_modules/$package/LICENSE" "$output/$package-LICENSE.txt" |
| 35 | done |
| 36 | cp "$mobile_dir/../ui/node_modules/marked/LICENSE" "$output/Marked-LICENSE.txt" |
| 37 | cp "$mobile_dir/android/licenses/ZXing-LICENSE.txt" "$output/ZXing-LICENSE.txt" |
| 38 | if [[ -f "$mobile_dir/.build/android/webkit-1.14.0.aar" ]]; then |
| 39 | unzip -p "$mobile_dir/.build/android/webkit-1.14.0.aar" META-INF/androidx/webkit/webkit/LICENSE.txt > "$output/AndroidX-LICENSE.txt" |
| 40 | fi |