File: vendor

package info (click to toggle)
docker.io 20.10.24%2Bdfsg1-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-proposed-updates
  • size: 60,824 kB
  • sloc: sh: 5,621; makefile: 593; ansic: 179; python: 162; asm: 7
file content (54 lines) | stat: -rwxr-xr-x 1,457 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${SCRIPTDIR}/.validate"

validate_vendor_diff(){
	IFS=$'\n'
	# shellcheck disable=SC2207
	files=( $(validate_diff --diff-filter=ACMR --name-only -- 'vendor.conf' 'vendor/' || true) )
	unset IFS

	if [ -n "${TEST_FORCE_VALIDATE:-}" ] || [ ${#files[@]} -gt 0 ]; then
		# recreate vendor/
		./hack/vendor.sh
		# check if any files have changed
		diffs="$(git status --porcelain -- vendor 2>/dev/null)"
		mfiles="$(echo "$diffs" | awk '/^ M / {print $2}')"
		if [ "$diffs" ]; then
			{
				echo 'The result of vndr differs'
				echo
				echo "$diffs"
				echo
				echo 'Please vendor your package with github.com/LK4D4/vndr.'
				echo
				if [ -n "$mfiles" ] ; then
					git diff -- "$mfiles"
				fi
			} >&2
			false
		else
			echo 'Congratulations! All vendoring changes are done the right way.'
		fi
	else
		echo 'No vendor changes in diff.'
	fi
}

# 1. make sure all the vendored packages are used
# 2. make sure all the packages contain license information (just warning, because it can cause false-positive)
validate_vendor_used() {
	for f in $(mawk '/^[a-zA-Z0-9]/ { print $1 }' vendor.conf); do
	if [ -d "vendor/$f" ]; then
		if ! echo "vendor/$f"/* | grep -qiEc '/(LICENSE|COPYING)'; then
		echo "WARNING: could not find copyright information for $f"
		fi
	else
		echo "WARNING: $f is vendored but unused"
	fi
	done
}

validate_vendor_diff
validate_vendor_used