verify-vendor-licenses.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 vendor licenses file 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. set -o errexit
  20. set -o nounset
  21. set -o pipefail
  22. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
  23. source "${KUBE_ROOT}/hack/lib/init.sh"
  24. # create a nice clean place to put our new licenses
  25. # must be in the user dir (e.g. KUBE_ROOT) in order for the docker volume mount
  26. # to work with docker-machine on macs
  27. mkdir -p "${KUBE_ROOT}/_tmp"
  28. _tmpdir="$(mktemp -d "${KUBE_ROOT}/_tmp/kube-vendor-licenses.XXXXXX")"
  29. #echo "Created workspace: ${_tmpdir}"
  30. function cleanup {
  31. #echo "Removing workspace: ${_tmpdir}"
  32. rm -rf "${_tmpdir}"
  33. }
  34. kube::util::trap_add cleanup EXIT
  35. cp -r "${KUBE_ROOT}/Godeps" "${_tmpdir}/Godeps"
  36. ln -s "${KUBE_ROOT}/LICENSE" "${_tmpdir}"
  37. ln -s "${KUBE_ROOT}/vendor" "${_tmpdir}"
  38. ln -s "${KUBE_ROOT}/staging" "${_tmpdir}"
  39. # Update vendor Licenses
  40. LICENSE_ROOT="${_tmpdir}" "${KUBE_ROOT}/hack/update-vendor-licenses.sh"
  41. # Compare vendor Licenses
  42. if ! _out="$(diff -Naupr "${KUBE_ROOT}/Godeps/LICENSES" "${_tmpdir}/Godeps/LICENSES")"; then
  43. echo "Your vendor licenses file is out of date. Run hack/update-vendor-licenses.sh and commit the results." >&2
  44. echo "${_out}" >&2
  45. exit 1
  46. fi