Add license compliance to release archives
All checks were successful
CI / test (pull_request) Successful in 14s
All checks were successful
CI / test (pull_request) Successful in 14s
This commit is contained in:
57
scripts/update-third-party-licenses.sh
Executable file
57
scripts/update-third-party-licenses.sh
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
temp_dir="$(mktemp -d)"
|
||||
trap 'rm -rf "$temp_dir"' EXIT
|
||||
|
||||
go_license="$(go env GOROOT)/LICENSE"
|
||||
if [ ! -f "$go_license" ] && [ -f /usr/share/licenses/go/LICENSE ]; then
|
||||
go_license=/usr/share/licenses/go/LICENSE
|
||||
fi
|
||||
if [ ! -f "$go_license" ]; then
|
||||
echo "Go license file was not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat >"$temp_dir/template.txt" <<'EOF'
|
||||
{{ range . }}================================================================================
|
||||
Package: {{ .Name }}
|
||||
License: {{ .LicenseName }}
|
||||
Source: {{ .LicenseURL }}
|
||||
|
||||
{{ .LicenseText }}
|
||||
{{ end }}
|
||||
EOF
|
||||
|
||||
{
|
||||
cat <<'EOF'
|
||||
THIRD-PARTY SOFTWARE NOTICES
|
||||
|
||||
This file contains license notices for third-party software included in the distributed binary.
|
||||
|
||||
================================================================================
|
||||
Package: Go standard library
|
||||
License: BSD-3-Clause
|
||||
Source: https://go.dev/LICENSE
|
||||
|
||||
EOF
|
||||
cat "$go_license"
|
||||
printf '\n'
|
||||
cd "$repo_root"
|
||||
go run github.com/google/go-licenses/v2@v2.0.1 report ./cmd/dataxl \
|
||||
--ignore=git.rumginger.org/agent/dataxl \
|
||||
--template="$temp_dir/template.txt"
|
||||
} >"$temp_dir/THIRD_PARTY_LICENSES.txt"
|
||||
|
||||
awk '
|
||||
{ lines[NR] = $0 }
|
||||
$0 !~ /^[[:space:]]*$/ { last_content_line = NR }
|
||||
END {
|
||||
for (line_number = 1; line_number <= last_content_line; line_number++) {
|
||||
print lines[line_number]
|
||||
}
|
||||
}
|
||||
' "$temp_dir/THIRD_PARTY_LICENSES.txt" >"$temp_dir/THIRD_PARTY_LICENSES.normalized.txt"
|
||||
|
||||
mv "$temp_dir/THIRD_PARTY_LICENSES.normalized.txt" "$repo_root/THIRD_PARTY_LICENSES.txt"
|
||||
Reference in New Issue
Block a user