agones.dev/agones@v1.54.0/build/extract-licenses.sh (about) 1 #!/usr/bin/env bash 2 # Copyright 2017 Google LLC All Rights Reserved. 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 16 set -o errexit 17 set -o nounset 18 set -o pipefail 19 20 append_license() { 21 lib=$1 22 path=$2 23 echo "================================================================================" >> ${TMP_LICENSES} 24 echo "= ${lib} licensed under: =" >> ${TMP_LICENSES} 25 echo >> ${TMP_LICENSES} 26 cat "$path" >> ${TMP_LICENSES} 27 echo >> ${TMP_LICENSES} 28 echo "= ${path} MD5 $(cat "${path}" | md5sum | awk '{print $1}')" >> ${TMP_LICENSES} 29 echo "================================================================================" >> ${TMP_LICENSES} 30 echo >> ${TMP_LICENSES} 31 32 } 33 34 SRC_ROOT=$(dirname "${BASH_SOURCE}")/.. 35 TMP_LICENSES=/tmp/LICENSES 36 37 cd ${SRC_ROOT} 38 39 # Clear file 40 echo > ${TMP_LICENSES} 41 42 append_license "Agones" "LICENSE" 43 44 while read -r entry; do 45 LIBRARY=${entry#vendor\/} 46 LIBRARY=$(expr match "$LIBRARY" '\(.*\)/LICENSE.*\?') 47 append_license ${LIBRARY} ${entry} 48 done <<< "$(find vendor/ -regextype posix-extended -iregex '.*LICENSE(\.txt)?')" 49 50 for ddir in ${SRC_ROOT}/cmd/controller/bin/ ${SRC_ROOT}/cmd/extensions/bin/ ${SRC_ROOT}/cmd/ping/bin/ ${SRC_ROOT}/cmd/sdk-server/bin/ ${SRC_ROOT}/cmd/allocator/bin/ ${SRC_ROOT}/cmd/processor/bin/; do 51 mkdir -p ${ddir} 52 cp ${TMP_LICENSES} ${ddir} 53 done 54