github.com/rita33cool1/iot-system-gateway@v0.0.0-20200911033302-e65bde238cc5/docker-engine/hack/validate/vendor (about) 1 #!/usr/bin/env bash 2 3 export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 source "${SCRIPTDIR}/.validate" 5 6 validate_vendor_diff(){ 7 IFS=$'\n' 8 files=( $(validate_diff --diff-filter=ACMR --name-only -- 'vendor.conf' 'vendor/' || true) ) 9 unset IFS 10 11 if [ ${#files[@]} -gt 0 ]; then 12 # Remove vendor/ first so that anything not included in vendor.conf will 13 # cause the validation to fail. archive/tar is a special case, see vendor.conf 14 # for details. 15 ls -d vendor/* | grep -v vendor/archive | xargs rm -rf 16 # run vndr to recreate vendor/ 17 vndr 18 # check if any files have changed 19 diffs="$(git status --porcelain -- vendor 2>/dev/null)" 20 if [ "$diffs" ]; then 21 { 22 echo 'The result of vndr differs' 23 echo 24 echo "$diffs" 25 echo 26 echo 'Please vendor your package with github.com/LK4D4/vndr.' 27 echo 28 } >&2 29 false 30 else 31 echo 'Congratulations! All vendoring changes are done the right way.' 32 fi 33 else 34 echo 'No vendor changes in diff.' 35 fi 36 } 37 38 # 1. make sure all the vendored packages are used 39 # 2. make sure all the packages contain license information (just warning, because it can cause false-positive) 40 validate_vendor_used() { 41 pkgs=$(mawk '/^[a-zA-Z0-9]/ { print $1 }' < vendor.conf) 42 for f in $pkgs; do 43 if ls -d vendor/$f > /dev/null 2>&1; then 44 found=$(find vendor/$f -iregex '.*LICENSE.*' -or -iregex '.*COPYRIGHT.*' -or -iregex '.*COPYING.*' | wc -l) 45 if [ $found -eq 0 ]; then 46 echo "WARNING: could not find copyright information for $f" 47 fi 48 else 49 echo "WARNING: $f is vendored but unused" 50 fi 51 done 52 } 53 54 validate_vendor_diff 55 validate_vendor_used