build: sort licenses

This commit is contained in:
Dmitry Lyzo 2023-01-15 15:20:27 +03:00
parent 72346b3a39
commit 49d371c2fa
2 changed files with 21 additions and 4 deletions

View File

@ -18,6 +18,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
m4 \
gperf \
licensecheck \
gawk \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /code

View File

@ -45,7 +45,7 @@ set -o pipefail
find "$base_dir" $FINDOPTS -type f -regextype egrep -regex '.*\.(c|h|cpp|hpp|js)$' -print0 \
| xargs -0 -P1 licensecheck --machine --copyright --deb-fmt --encoding UTF-8 \
| awk -F"$tabulator" -v base_dir="$base_dir" \
| gawk -F"$tabulator" -v base_dir="$base_dir" \
-v def_license="$def_license" -v def_copy="$def_copy" '
BEGIN {
split("", lcfiles) # Clear array with only pre-Issue 8 POSIX
@ -91,14 +91,30 @@ find "$base_dir" $FINDOPTS -type f -regextype egrep -regex '.*\.(c|h|cpp|hpp|js)
for(lc in lcfiles) {
split(lc, lico, SUBSEP)
if(lico[1] in tmp)
tmp[lico[1]] = tmp[lico[1]]""SUBSEP" "lico[2]
tmp[lico[1]] = tmp[lico[1]]""SUBSEP""lico[2]
else
tmp[lico[1]] = lico[2]
}
for(license in tmp) {
asorti(tmp, tmp_sorted)
for(i in tmp_sorted) {
license = tmp_sorted[i]
split(tmp[license], sorted_licenses, SUBSEP)
asort(sorted_licenses);
printf "License: %s\n", license
printf "Copyright: %s\n", tmp[license]
printf "Copyright: "
for (j in sorted_licenses) {
if (j > 1)
printf " "
printf "%s\n", sorted_licenses[j]
}
printf "\n"
}
}