Skip to content

Commit

Permalink
Add a script for merging LICENSE files
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Lytvynov committed Sep 28, 2018
1 parent 64abd3a commit cd32059
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
bazel-*
MERGED_LICENSES
5 changes: 5 additions & 0 deletions tools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ config_setting(
"RELEASE": "devel",
},
)

sh_binary(
name = "merge_licenses",
srcs = ["merge_licenses.sh"],
)
22 changes: 22 additions & 0 deletions tools/merge_licenses.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -o xtrace
set -o errexit
set -o nounset
set -o pipefail

output_path=${BUILD_WORKING_DIRECTORY}/MERGED_LICENSES
# Truncate file.
echo >"${output_path}"

for path in $(find ${BUILD_WORKING_DIRECTORY}/vendor/ -name LICENSE); do
>&2 echo "adding ${path}";
# Trim working directory prefix from output.
cat <<EOF >>"${output_path}"
-----------------------------------------------------------
${path#"$BUILD_WORKING_DIRECTORY"}
------------------------------------------------------------
EOF
cat "${path}" >>"${output_path}"
echo >>"${output_path}"
done

0 comments on commit cd32059

Please sign in to comment.