Skip to content

Commit

Permalink
Merge pull request #48 from dmitrylyzo/sort-licenses
Browse files Browse the repository at this point in the history
Sort licenses
  • Loading branch information
dmitrylyzo committed Mar 24, 2023
2 parents 72346b3 + 49d371c commit d51494c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Expand Up @@ -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
Expand Down
24 changes: 20 additions & 4 deletions build/license_extract.sh
Expand Up @@ -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
Expand Down Expand Up @@ -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"
}
}
Expand Down

0 comments on commit d51494c

Please sign in to comment.