volcano.sh/volcano@v1.9.0/hack/verify-vendor-licenses.sh (about)

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