github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/debian/helpers/ls-vendor.sh (about) 1 #!/bin/bash 2 3 # List all vendored go packages in all of the MUT components, 4 # removing duplicates. It makes it easy to see what vendor 5 # directories are kept, and to spot anything that shouldn't 6 # be here. 7 # 8 # Typical use-case: after bumping the package to a new version, 9 # run it to see if new vendor directories were added by upstream. 10 # You might want to add those to the Files-Excluded list. 11 # 12 # Copyright: Arnaud Rebillout <elboulangero@gmail.com> 13 # License: GPL-3+ 14 15 set -e 16 set -u 17 18 export LC_ALL=C 19 20 get_vendor_tree() { 21 # Get the list of vendor directories. We distinguish two cases: 22 # 1. github.com: we need granularity down to the package level, 23 # ie. 'github.com/containerd/aufs' 24 # 2. others: we only need granularity to the project level, 25 # ie. 'code.cloudfoundry.org' 26 27 local vendor_dir=$1/vendor 28 local dirs=() 29 local dir= 30 31 if ! [ -d "$vendor_dir" ]; then 32 return 33 fi 34 35 for dir in "$vendor_dir"/*; do 36 if ! [ -d "$dir" ]; then 37 continue 38 fi 39 case "$dir" in 40 (*/github.com) ;& 41 (*/golang.org) 42 dirs+=($( find "$dir" -mindepth 2 -maxdepth 2 -type d )) 43 ;; 44 (*) 45 dirs+=("$dir") 46 ;; 47 esac 48 done 49 50 if [ ${#dirs[@]} -eq 0 ]; then 51 return 52 fi 53 54 printf "%s\n" "${dirs[@]}" \ 55 | sed 's;^.*/vendor/;vendor/;' \ 56 | sort -u 57 } 58 59 VD= # vendor directories 60 ALLVD= # all vendor directories 61 62 for d in *; do 63 [ -d "$d" ] || continue 64 [ "$d" = debian ] && continue 65 VD=$( get_vendor_tree "$d" ) 66 #echo "==== ${d^^} ====" 67 #echo "$VD" 68 #echo 69 ALLVD=$( printf '%s\n' $ALLVD $VD | sort -u ) 70 done 71 72 if [ -z "$ALLVD" ]; then 73 echo "Nothing in the vendor directories!" 74 else 75 echo "List of vendor directories in all MUT components." 76 echo "Anything that shouldn't be here must be added to Files-Excluded." 77 echo "" 78 echo "$ALLVD" 79 fi 80 81 # vim: et sts=4 sw=4