Skip to repository content87 lines · 2.6 KB · text
tenant.openagents/omega
No repository description is available.
OpenAgents Git authority 2026-07-27T23:34:23.467Z Public web read
NIP-34 coordinate
30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omegaMaintainersHidden in public view
References2 branches · 1 tag
Read-only clone
git clone https://openagents.com/git/tenant.openagents/omega.gitBrowse files
check-licenses
1#!/usr/bin/env bash
2
3set -euo pipefail
4
5check_manifest_for_agpl () {
6 local cargo_toml="$1"
7
8 if grep -Eiq '(agpl|affero)' "$cargo_toml"; then
9 echo "Error: $cargo_toml references an AGPL license. First-party crates must use LICENSE-GPL or LICENSE-APACHE."
10 exit 1
11 fi
12
13 if grep -Eiq '^[[:space:]]*license-file[[:space:]]*=' "$cargo_toml"; then
14 echo "Error: $cargo_toml uses license-file. First-party crates must declare LICENSE-GPL or LICENSE-APACHE via the license field and symlink."
15 exit 1
16 fi
17}
18
19check_no_agpl_license_file () {
20 if [[ -e "LICENSE-AGPL" || -L "LICENSE-AGPL" ]]; then
21 echo "Error: LICENSE-AGPL exists. First-party code must use LICENSE-GPL or LICENSE-APACHE."
22 exit 1
23 fi
24
25 while IFS= read -r -d '' license_file; do
26 if [[ -e "$license_file" || -L "$license_file" ]]; then
27 echo "Error: $license_file exists. First-party crates must use LICENSE-GPL or LICENSE-APACHE."
28 exit 1
29 fi
30 done < <(git ls-files -z -- "*/LICENSE-AGPL")
31}
32
33check_symlink_target () {
34 local symlink_path="$1"
35 local license_name="$2"
36
37 local target=$(readlink "$symlink_path")
38
39 local dir=$(dirname "$symlink_path")
40 local depth=$(echo "$dir" | tr '/' '\n' | wc -l)
41 local expected_prefix=""
42 for ((i = 0; i < depth; i++)); do
43 expected_prefix="../$expected_prefix"
44 done
45 local expected_target="${expected_prefix}${license_name}"
46
47 if [[ "$target" != "$expected_target" ]]; then
48 echo "Error: $symlink_path points to '$target' but should point to '$expected_target'"
49 exit 1
50 fi
51
52 if [[ ! -e "$symlink_path" ]]; then
53 echo "Error: $symlink_path is a broken symlink (target '$target' does not exist)"
54 exit 1
55 fi
56}
57
58check_license () {
59 local dir="$1"
60 local allowed_licenses=("LICENSE-GPL" "LICENSE-APACHE")
61
62 for license in "${allowed_licenses[@]}"; do
63 if [[ -L "$dir/$license" ]]; then
64 check_symlink_target "$dir/$license" "$license"
65 return 0
66 elif [[ -e "$dir/$license" ]]; then
67 echo "Error: $dir/$license exists but is not a symlink."
68 exit 1
69 fi
70 done
71
72 echo "Error: $dir does not contain a LICENSE-GPL or LICENSE-APACHE symlink"
73 exit 1
74}
75
76check_no_agpl_license_file
77
78git ls-files -z -- "Cargo.toml" "**/Cargo.toml" | while IFS= read -r -d '' cargo_toml; do
79 check_manifest_for_agpl "$cargo_toml"
80
81 if [[ "$cargo_toml" == */Cargo.toml ]]; then
82 check_license "$(dirname "$cargo_toml")"
83 fi
84done
85
86echo "check-licenses succeeded"
87