"Fossies" - the Fresh Open Source Software Archive

Member "apache-pulsar-2.6.0/src/check-binary-license" (9 Jun 2020, 3857 Bytes) of package /linux/misc/apache-pulsar-2.6.0-src.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "check-binary-license": 2.4.2_vs_2.5.0.

    1 #!/usr/bin/env bash
    2 #
    3 # Licensed to the Apache Software Foundation (ASF) under one
    4 # or more contributor license agreements.  See the NOTICE file
    5 # distributed with this work for additional information
    6 # regarding copyright ownership.  The ASF licenses this file
    7 # to you under the Apache License, Version 2.0 (the
    8 # "License"); you may not use this file except in compliance
    9 # with the License.  You may obtain a copy of the License at
   10 #
   11 #   http://www.apache.org/licenses/LICENSE-2.0
   12 #
   13 # Unless required by applicable law or agreed to in writing,
   14 # software distributed under the License is distributed on an
   15 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   16 # KIND, either express or implied.  See the License for the
   17 # specific language governing permissions and limitations
   18 # under the License.
   19 #
   20 
   21 # Script to check licenses on a binary tarball.
   22 # It extracts the list of bundled jars, the NOTICE, and the LICENSE
   23 # files. It checked that every non-pulsar jar bundled is mentioned in the
   24 # LICENSE file. It checked that all jar files mentioned in NOTICE and
   25 # LICENSE are actually bundled.
   26 
   27 # all error fatal
   28 set -e
   29 
   30 TARBALL="$1"
   31 if [ -z $TARBALL ]; then
   32     echo "Usage: $0 <binary-tarball>"
   33     exit -1
   34 fi
   35 
   36 JARS=$(tar -tf $TARBALL | grep '\.jar' | grep -v 'lib/presto/' | grep -v '/examples/' | grep -v '/instances/' | sed 's!.*/!!' | sort)
   37 
   38 LICENSEPATH=$(tar -tf $TARBALL  | awk '/^[^\/]*\/LICENSE/')
   39 LICENSE=$(tar -O -xf $TARBALL "$LICENSEPATH")
   40 NOTICEPATH=$(tar -tf $TARBALL  | awk '/^[^\/]*\/NOTICE/')
   41 NOTICE=$(tar -O -xf $TARBALL $NOTICEPATH)
   42 
   43 LICENSEJARS=$(echo "$LICENSE" | sed -nE 's!.* (.*\.jar).*!\1!gp')
   44 NOTICEJARS=$(echo "$NOTICE" | sed -nE 's!.* (.*\.jar).*!\1!gp')
   45 
   46 LINKEDINLICENSE=$(echo "$LICENSE" | sed -nE 's!.*(lib/[[:graph:]]*).*!\1!gp' | sed 's!\.$!!')
   47 
   48 # errors not fatal
   49 set +e
   50 
   51 EXIT=0
   52 
   53 
   54 # Check all bundled jars are mentioned in LICENSE
   55 for J in $JARS; do
   56     echo $J | grep -q "org.apache.pulsar"
   57     if [ $? == 0 ]; then
   58         continue
   59     fi
   60 
   61     echo "$LICENSE" | grep -q $J
   62     if [ $? != 0 ]; then
   63         echo $J unaccounted for in LICENSE
   64         EXIT=1
   65     fi
   66 done
   67 
   68 # Check all jars mentioned in LICENSE are bundled
   69 for J in $LICENSEJARS; do
   70     echo "$JARS" | grep -q $J
   71     if [ $? != 0 ]; then
   72         echo $J mentioned in LICENSE, but not bundled
   73         EXIT=2
   74     fi
   75 done
   76 
   77 # Check all jars mentioned in NOTICE are bundled
   78 for J in $NOTICEJARS; do
   79     if [ $J == "checker-qual.jar" ]; then
   80         continue
   81     fi
   82     echo "$JARS" | grep -q $J
   83     if [ $? != 0 ]; then
   84         echo $J mentioned in NOTICE, but not bundled
   85         EXIT=3
   86     fi
   87 done
   88 
   89 # check pulsar sql jars
   90 JARS=$(tar -tf $TARBALL | grep '\.jar' | grep 'lib/presto/' | grep -v 'managed-ledger' | grep -v  'pulsar-client-admin' | grep -v  'pulsar-client-api' | grep -v 'pulsar-functions-api' | grep -v 'pulsar-presto-connector-original' | grep -v 'pulsar-presto-distribution' | grep -v 'pulsar-common' | grep -v 'pulsar-functions-proto' | grep -v 'pulsar-functions-utils' | grep -v 'pulsar-io-core' | grep -v 'pulsar-transaction-common' | sed 's!.*/!!' | sort)
   91 LICENSEPATH=$(tar -tf $TARBALL  | awk '/^[^\/]*\/lib\/presto\/LICENSE/')
   92 LICENSE=$(tar -O -xf $TARBALL "$LICENSEPATH")
   93 LICENSEJARS=$(echo "$LICENSE" | sed -nE 's!.* (.*\.jar).*!\1!gp')
   94 
   95 
   96 for J in $JARS; do
   97     echo $J | grep -q "org.apache.pulsar"
   98     if [ $? == 0 ]; then
   99         continue
  100     fi
  101 
  102     echo "$LICENSE" | grep -q $J
  103     if [ $? != 0 ]; then
  104         echo $J unaccounted for in lib/presto/LICENSE
  105         EXIT=1
  106     fi
  107 done
  108 
  109 # Check all jars mentioned in LICENSE are bundled
  110 for J in $LICENSEJARS; do
  111     echo "$JARS" | grep -q $J
  112     if [ $? != 0 ]; then
  113         echo $J mentioned in lib/presto/LICENSE, but not bundled
  114         EXIT=2
  115     fi
  116 done
  117 
  118 if [ $EXIT != 0 ]; then
  119     echo
  120     echo It looks like there are issues with the LICENSE/NOTICE.
  121 fi
  122 
  123 exit $EXIT
  124