GUACAMOLE-1298: Ensure LICENSE/NOTICE generation takes current build into account (not central repository).

This commit is contained in:
Michael Jumper
2021-03-31 17:35:29 -07:00
parent 73e582b478
commit 7ae3cc1084
2 changed files with 48 additions and 21 deletions

View File

@@ -28,8 +28,8 @@
# generate-license-files.sh
# -------------------------
#
# Automatically iterates through the runtime dependencies of the Maven project
# in the current directory, creating new LICENSE and NOTICE files which
# Automatically iterates through the provided runtime dependencies of the Maven
# project in the current directory, creating new LICENSE and NOTICE files which
# contain all the license information of bundled dependencies, as well as any
# required notices.
#
@@ -38,10 +38,12 @@
#
# USAGE:
#
# path/to/generate-license-files.sh OUTPUT_DIRECTORY
# path/to/generate-license-files.sh DEPENDENCY_LIST OUTPUT_DIRECTORY
#
# where OUTPUT_DIRECTORY is the directory in which the LICENSE and NOTICE
# files should be written, along with verbatim copies of all relevant licenses.
# where DEPENDENCY_LIST is the list of Maven dependencies to consider when
# generating LICENSE and NOTICE (as produced by "mvn dependency:list") and
# OUTPUT_DIRECTORY is the directory in which the LICENSE and NOTICE files
# should be written.
#
# Structure of license information
# --------------------------------
@@ -110,26 +112,22 @@ LICENSES_DIR="`dirname "$0"`"
##
BASEDIR="$LICENSES_DIR/../.."
##
## The file containing all relevant runtime dependencies, as generated by
## "mvn dependency:list".
##
DEPENDENCY_LIST="$1"
##
## The output directory in which the generated LICENSE, NOTICE, etc. files
## should be placed.
##
OUTPUT_DIR="$1"
##
## Lists the Maven coordinates of all runtime dependencies of the current
## project. Each dependency is listed on its own line.
##
list_dependencies() {
mvn -q dependency:list -DincludeScope=runtime -DoutputFile=/dev/stdout \
| grep -v '\<org\.apache\.guacamole\>' \
| grep -o '[^: ]*:[^: ]*:[^: ]*:[^: ]*' | sort -u
}
OUTPUT_DIR="$2"
##
## Lists the license information directories (subdirectories of the
## "doc/licenses/" directory in the main guacamole-client source tree) that
## apply to runtime dependencies of the current project. If any runtime
## apply to the list of runtime dependencies provided via STDIN. If any runtime
## dependencies are not described by license information included in the
## guacamole-client source tree, a error is printed to STDERR.
##
@@ -141,7 +139,7 @@ list_dependency_license_info() {
# List the license directories of all runtime dependencies, as dictated by
# the "maven-coordinates.txt" files included within those directores
list_dependencies | while read DEPENDENCY; do
grep -o '[^: ]*:[^: ]*:[^: ]*:[^: ]*' | while read DEPENDENCY; do
if ! grep -l "$DEPENDENCY[[:space:]]*$" "$LICENSES_DIR"/*/maven-coordinates.txt; then
error "License information missing for $DEPENDENCY"
@@ -269,8 +267,14 @@ trim_file() {
}
# Verify that an output directory was provided
if [ -z "$OUTPUT_DIR" ]; then
error "USAGE: $0 OUTPUT_DIRECTORY"
if [ -z "$DEPENDENCY_LIST" -o -z "$OUTPUT_DIR" ]; then
error "USAGE: $0 DEPENDENCY_LIST OUTPUT_DIRECTORY"
exit 1
fi
# Verify input file actually exists
if [ ! -r "$DEPENDENCY_LIST" ]; then
error "$DEPENDENCY_LIST cannot be read."
exit 1
fi
@@ -293,7 +297,7 @@ cp "$BASEDIR/NOTICE" "$OUTPUT_DIR/"
#
PREAMBLE_ADDED=0
list_dependency_license_info | sort_dependency_license_info | \
list_dependency_license_info < "$DEPENDENCY_LIST" | sort_dependency_license_info | \
while read LICENSE_INFO_DIR; do
# Add subcomponent license preamble if not already added