check-LICENSE.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env bash
  2. #
  3. # Licensed to the Apache Software Foundation (ASF) under one or more
  4. # contributor license agreements. See the NOTICE file distributed with
  5. # this work for additional information regarding copyright ownership.
  6. # The ASF licenses this file to You under the Apache License, Version 2.0
  7. # (the "License"); you may not use this file except in compliance with
  8. # the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. #
  18. if [ -d "dist" ];then
  19. rm -rf dist
  20. fi
  21. mkdir dist || true
  22. tar -zxf dolphinscheduler-dist/target/apache-dolphinscheduler*-bin.tar.gz --strip=1 -C dist
  23. # List all modules(jars) that belong to the DolphinScheduler itself, these will be ignored when checking the dependency
  24. # licenses
  25. echo '=== Self modules: ' && ./mvnw --batch-mode --quiet -Dexec.executable='echo' -Dexec.args='${project.artifactId}-${project.version}.jar' exec:exec | tee self-modules.txt
  26. echo '=== Distributed dependencies: ' && find dist -name "*.jar" -exec basename {} \; | sort | uniq | tee all-dependencies.txt
  27. # Exclude all self modules(jars) to generate all third-party dependencies
  28. echo '=== Third party dependencies: ' && grep -vf self-modules.txt all-dependencies.txt | sort | uniq | tee third-party-dependencies.txt
  29. # 1. Compare the third-party dependencies with known dependencies, expect that all third-party dependencies are KNOWN
  30. # and the exit code of the command is 0, otherwise we should add its license to LICENSE file
  31. # [dolphinscheduler-dist/release-docs/LICENSE] and [dolphinscheduler-dist/release-docs/licenses/]
  32. # and add the dependency to known-dependencies.txt.
  33. #
  34. # 2. Unify the `sort` behaviour: here we'll sort them again in case that the behaviour of `sort` command in
  35. # target OS is different from what we used to sort the file `known-dependencies.txt`, i.e. "sort the two file
  36. # using the same command (and default arguments)"
  37. diff -w -B -U0 <(sort < tools/dependencies/known-dependencies.txt) <(sort < third-party-dependencies.txt)