summaryrefslogtreecommitdiff
path: root/src/chroot-tools/hooks-check.sh
blob: e8120b8ec4068caa4d45fcbe8eea2330f07ea385 (plain)
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
#!/usr/bin/env bash
set -euE

hook_check_pkgbuild+=("check_pkgbuild_dependencies")
check_pkgbuild_dependencies() {
	local s=0
	sudo -EH -u "$LIBREUSER" pkgbuild-check-nonfree -f || s=$?
	case $s in
		0) :;;
		15) error "This PKGBUILD links to known unfree packages"; return 1;;
		*) warning "pkgbuild-check-nonfree failed to run";;
	esac
}

hook_check_pkgbuild+=("check_pkgbuild_license")
check_pkgbuild_license() {
	local s=0
	sudo -EH -u "$LIBREUSER" pkgbuild-check-licenses -f || s=$?
	for i in 1 2 4; do
		if [[ $i -eq $(($s & $i)) ]]; then
			case $i in
				1) warning "pkgbuild-check-licenses encountered an error";;
				2) warning "This PKGBUILD has an uncommon license";;
				4) error   "This PKGBUILD has a known nonfree license"; ret=1;;
			esac
		fi
	done
}

#hook_check_pkgbuild+=("check_pkgbuild_namcap")
check_pkgbuild_namcap() {
	sudo -EH -u "$LIBREUSER" namcap PKGBUILD
}

#hook_check_pkg+=("check_pkg")
check_pkg() {
	# TODO
	:
}