github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/engine/hack/validate/vendor (about) 1 #!/usr/bin/env bash 2 3 SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 source "${SCRIPTDIR}/.validate" 5 6 validate_vendor_diff(){ 7 IFS=$'\n' 8 # shellcheck disable=SC2207 9 files=( $(validate_diff --diff-filter=ACMR --name-only -- 'vendor.conf' 'vendor/' || true) ) 10 unset IFS 11 12 if [ -n "${TEST_FORCE_VALIDATE:-}" ] || [ ${#files[@]} -gt 0 ]; then 13 # recreate vendor/ 14 ./hack/vendor.sh 15 # check if any files have changed 16 diffs="$(git status --porcelain -- vendor 2>/dev/null)" 17 mfiles="$(echo "$diffs" | awk '/^ M / {print $2}')" 18 if [ "$diffs" ]; then 19 { 20 echo 'The result of vndr differs' 21 echo 22 echo "$diffs" 23 echo 24 echo 'Please vendor your package with github.com/LK4D4/vndr.' 25 echo 26 if [ -n "$mfiles" ] ; then 27 git diff -- "$mfiles" 28 fi 29 } >&2 30 false 31 else 32 echo 'Congratulations! All vendoring changes are done the right way.' 33 fi 34 else 35 echo 'No vendor changes in diff.' 36 fi 37 } 38 39 # 1. make sure all the vendored packages are used 40 # 2. make sure all the packages contain license information (just warning, because it can cause false-positive) 41 validate_vendor_used() { 42 for f in $(mawk '/^[a-zA-Z0-9]/ { print $1 }' vendor.conf); do 43 if [ -d "vendor/$f" ]; then 44 if ! echo "vendor/$f"/* | grep -qiEc '/(LICENSE|COPYING)'; then 45 echo "WARNING: could not find copyright information for $f" 46 fi 47 else 48 echo "WARNING: $f is vendored but unused" 49 fi 50 done 51 } 52 53 validate_vendor_diff 54 validate_vendor_used