verify-vendor-licenses.sh 1.7 KB

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