forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use exact dependency version in LICENSE file and use check-binary-lic…
…ense to enforce (apache#1820)
- Loading branch information
Showing
2 changed files
with
244 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
|
||
# Script to check licenses on a binary tarball. | ||
# It extracts the list of bundled jars, the NOTICE, and the LICENSE | ||
# files. It checked that every non-pulsar jar bundled is mentioned in the | ||
# LICENSE file. It checked that all jar files mentioned in NOTICE and | ||
# LICENSE are actually bundled. | ||
|
||
# all error fatal | ||
set -e | ||
|
||
TARBALL="$1" | ||
if [ -z $TARBALL ]; then | ||
echo "Usage: $0 <binary-tarball>" | ||
exit -1 | ||
fi | ||
|
||
JARS=$(tar -tf $TARBALL | grep '\.jar' | grep -v '/examples/' | grep -v '/instances/'| sed 's!.*/!!' | sort) | ||
|
||
LICENSEPATH=$(tar -tf $TARBALL | awk '/^[^\/]*\/LICENSE/') | ||
LICENSE=$(tar -O -xf $TARBALL "$LICENSEPATH") | ||
NOTICEPATH=$(tar -tf $TARBALL | awk '/^[^\/]*\/NOTICE/') | ||
NOTICE=$(tar -O -xf $TARBALL $NOTICEPATH) | ||
|
||
LICENSEJARS=$(echo "$LICENSE" | sed -nE 's!.* (.*\.jar).*!\1!gp') | ||
NOTICEJARS=$(echo "$NOTICE" | sed -nE 's!.* (.*\.jar).*!\1!gp') | ||
|
||
LINKEDINLICENSE=$(echo "$LICENSE" | sed -nE 's!.*(lib/[[:graph:]]*).*!\1!gp' | sed 's!\.$!!') | ||
|
||
# errors not fatal | ||
set +e | ||
|
||
EXIT=0 | ||
|
||
|
||
# Check all bundled jars are mentioned in LICENSE | ||
for J in $JARS; do | ||
echo $J | grep -q "org.apache.pulsar" | ||
if [ $? == 0 ]; then | ||
continue | ||
fi | ||
|
||
echo "$LICENSE" | grep -q $J | ||
if [ $? != 0 ]; then | ||
echo $J unaccounted for in LICENSE | ||
EXIT=1 | ||
fi | ||
done | ||
|
||
# Check all jars mentioned in LICENSE are bundled | ||
for J in $LICENSEJARS; do | ||
echo "$JARS" | grep -q $J | ||
if [ $? != 0 ]; then | ||
echo $J mentioned in LICENSE, but not bundled | ||
EXIT=2 | ||
fi | ||
done | ||
|
||
# Check all jars mentioned in NOTICE are bundled | ||
for J in $NOTICEJARS; do | ||
echo "$JARS" | grep -q $J | ||
if [ $? != 0 ]; then | ||
echo $J mentioned in NOTICE, but not bundled | ||
EXIT=3 | ||
fi | ||
done | ||
|
||
|
||
if [ $EXIT != 0 ]; then | ||
echo | ||
echo It looks like there are issues with the LICENSE/NOTICE. | ||
fi | ||
|
||
exit $EXIT | ||
|