You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

verify-vendor-licenses.sh 2.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env bash
  2. # Copyright 2015 The Kubernetes Authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # This script checks whether updating of licenses files is needed
  16. # or not. We should run `hack/update-vendor-licenses.sh` and commit the results,
  17. # if actually updates them.
  18. # Usage: `hack/verify-vendor-licenses.sh`.
  19. #
  20. # -----------------------------------------------------------------------------
  21. # CHANGELOG
  22. # KubeEdge Authors:
  23. # - File derived from kubernetes v1.19.0-beta.2
  24. # - Changed KUBE_ROOT value to use absolute path
  25. # - Stop echo "_out" to avoid long-winded output of license diff
  26. set -o errexit
  27. set -o nounset
  28. set -o pipefail
  29. KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
  30. source "${KUBE_ROOT}/hack/lib/init.sh"
  31. # create a nice clean place to put our new licenses
  32. # must be in the user dir (e.g. KUBE_ROOT) in order for the docker volume mount
  33. # to work with docker-machine on macs
  34. mkdir -p "${KUBE_ROOT}/_tmp"
  35. _tmpdir="$(mktemp -d "${KUBE_ROOT}/_tmp/kube-licenses.XXXXXX")"
  36. #echo "Created workspace: ${_tmpdir}"
  37. function cleanup {
  38. #echo "Removing workspace: ${_tmpdir}"
  39. rm -rf "${_tmpdir}"
  40. }
  41. kube::util::trap_add cleanup EXIT
  42. # symlink all vendor subfolders in temp vendor
  43. mkdir -p "${_tmpdir}/vendor"
  44. for child in "${KUBE_ROOT}/vendor"/*
  45. do
  46. ln -s "${child}" "${_tmpdir}/vendor"
  47. done
  48. ln -s "${KUBE_ROOT}/LICENSE" "${_tmpdir}"
  49. # Update licenses
  50. LICENSE_ROOT="${_tmpdir}" "${KUBE_ROOT}/hack/update-vendor-licenses.sh"
  51. # Compare licenses
  52. if ! _out="$(diff -Naupr -x OWNERS "${KUBE_ROOT}/LICENSES" "${_tmpdir}/LICENSES")"; then
  53. echo "Your LICENSES tree is out of date. Run hack/update-vendor-licenses.sh and commit the results." >&2
  54. #echo "${_out}" >&2
  55. exit 1
  56. fi