summaryrefslogtreecommitdiff
path: root/db-check-nonfree
blob: 1988c4382a1f57b6b7f49b0eeebb8e3dbdf7e1c4 (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
40
41
42
43
44
45
46
#!/bin/bash

source "$(dirname "$(readlink -e "$0")")/etc/dbscripts.cfg"
source "$(dirname "$(readlink -e "$0")")/share/db-functions"

if [ $# -ge 1 ]; then
	error "Calling %s with a specific repository is not supported" "${0##*/}"
	exit 1
fi

# TODO: this might lock too much (main_architectures)
for repo in "${repos[@]}"; do
	for pkgarch in "${main_architectures[@]}"; do
		repo_lock "${repo}" "${pkgarch}" || exit 1
	done
done

msg "Check nonfree in repo:"
nonfree=($(cut -d: -f1 "${blacklist_file}" | sort -u))
for repo in "${derivative_main_repositories[@]}"; do
	for pkgarch in "${main_architectures[@]}"; do
		msg2 "%s %s" "$repo" "$pkgarch"
		if [ ! -f "${root_dir}/${repo}/os/${pkgarch}/${repo}${database_extension_suffixfile}" ]; then
			continue
		fi
		unset dbpkgs
		unset cleanpkgs
		cleanpkgs=()
		dbpkgs=($(bsdtar -xOf "${root_dir}/${repo}/os/${pkgarch}/${repo}${database_extension_suffixfile}" | awk '/^%NAME%/{getline;print}' | sort -u ))
		for pkgname in "${dbpkgs[@]}"; do
			if in_array "${pkgname}" "${nonfree[@]}"; then
				cleanpkgs+=("${pkgname}")
			fi
		done
		if [ ${#cleanpkgs[@]} -ge 1 ]; then
			msg2 "Nonfree: %s" "${cleanpkgs[*]}"
			arch_repo_remove "${repo}" "${pkgarch}" "${cleanpkgs[@]}"
		fi
	done
done

for repo in "${repos[@]}"; do
	for pkgarch in "${main_architectures[@]}"; do
		repo_unlock "${repo}" "${pkgarch}"
	done
done