From 49d371c2fa90d658a722a8dc313be5a697f38c92 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Sun, 15 Jan 2023 15:20:27 +0300 Subject: [PATCH] build: sort licenses --- Dockerfile | 1 + build/license_extract.sh | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4f9592d7..5b235101 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/build/license_extract.sh b/build/license_extract.sh index 0d1126f5..63cab69a 100755 --- a/build/license_extract.sh +++ b/build/license_extract.sh @@ -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" } }