ud3tn/tools/analysis/license-check.sh
Felix Walter 1dd5961bc4 Add AAP 2.0 component stub with Protobuf support via Nanopb
This adds the Nanopb library as submodule under `external/` and adds
corresponding build configuration to the Makefiles. Additionally, a
Protobuf stub for AAP 2.0 is included along with a `make` target to
build the corresponding C language files (`aap2-proto-headers`).

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-11-08 15:11:52 +01:00

37 lines
1,021 B
Bash
Executable file

#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause OR Apache-2.0
if [ ! -e ./LICENSE ] || [ ! -e ./README.md ]; then
echo "Please run this script from the project root!"
exit 1
fi
SPDX_LICENSE_STR="SPDX-License-Identifier: $(head -n 1 LICENSE)"
echo 'Searching for SPDX expression "'"$SPDX_LICENSE_STR"'"'
DIRS="components doc dockerfiles include mk pyd3tn python-ud3tn-utils tools test"
FILES=$(find $DIRS -type f \( -name "*.[ch]" -o -name "*.proto" -o -name "*.py" -o -name "*.rs" -o -name "*.sh" \) )
declare -a MISSING_SPDX_FILES
for file in $FILES; do
head -n 2 "$file" | grep -q --fixed-strings "$SPDX_LICENSE_STR"
if [ $? -ne 0 ]; then
MISSING_SPDX_FILES+=("$file")
fi
done
grep -q --fixed-strings "$SPDX_LICENSE_STR" README.md
if [ $? -ne 0 ]; then
MISSING_SPDX_FILES+=("README.md")
fi
if [ ${#MISSING_SPDX_FILES[@]} -gt 0 ]; then
echo
echo "SPDX expression not found in the following files:"
echo
printf '%s\n' "${MISSING_SPDX_FILES[@]}"
exit 1
else
echo "Looks good :-)"
fi