2023-03-27 04:42:30 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Compare licenses of Go dependencies against a whitelist.
|
|
|
|
|
2023-03-29 08:13:26 -04:00
|
|
|
###### script header ######
|
|
|
|
|
2023-03-27 04:42:30 -04:00
|
|
|
lib=$(realpath @@BASE_LIB@@) || exit 1
|
2023-03-29 08:13:26 -04:00
|
|
|
stat "${lib}" >> /dev/null || exit 1
|
2023-03-27 04:42:30 -04:00
|
|
|
|
|
|
|
# shellcheck source=../sh/lib.bash
|
|
|
|
if ! source "${lib}"; then
|
|
|
|
echo "Error: could not find import"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-03-29 08:13:26 -04:00
|
|
|
cd "${BUILD_WORKSPACE_DIRECTORY}"
|
|
|
|
|
|
|
|
###### script body ######
|
2023-03-27 04:42:30 -04:00
|
|
|
|
|
|
|
echo "Checking files for missing company license header..."
|
|
|
|
|
|
|
|
noHeader=$(
|
|
|
|
grep \
|
|
|
|
-rL \
|
|
|
|
--include='*.go' \
|
|
|
|
--exclude-dir 3rdparty \
|
2023-03-30 03:41:56 -04:00
|
|
|
--exclude-dir build \
|
2023-03-27 04:42:30 -04:00
|
|
|
-e'SPDX-License-Identifier: AGPL-3.0-only' \
|
|
|
|
-e'DO NOT EDIT'
|
|
|
|
)
|
|
|
|
|
|
|
|
if [[ -z ${noHeader} ]]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "The following files are missing a license header:"
|
|
|
|
readarray -t <<< "${noHeader}"
|
|
|
|
for file in "${MAPFILE[@]}"; do
|
|
|
|
echo " ${file}"
|
|
|
|
done
|
|
|
|
|
|
|
|
exit 1
|