aboutsummaryrefslogtreecommitdiff
blob: afd223250d58f2ed68f8a728050253da2afdbd12 (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
47
48
49
# Strict multilib directory checks
multilib_strict_check() {
	if has multilib-strict ${FEATURES} && \
	   [[ -x /usr/bin/file && -x /usr/bin/find ]] && \
	   [[ -n ${MULTILIB_STRICT_DIRS} && -n ${MULTILIB_STRICT_DENY} ]]
	then
		rm -f "${T}/multilib-strict.log"
		local abort=no dir file
		for dir in ${MULTILIB_STRICT_DIRS} ; do
			[[ -d ${ED}/${dir} ]] || continue
			while read -r -d '' file; do
				if file "${file}" | grep -Eq "${MULTILIB_STRICT_DENY}" ; then
					echo "${file#${ED}//}" >> "${T}/multilib-strict.log"
				fi
			done < <(find "${ED}/${dir}" -maxdepth 1 -type f -print0)
		done

		if [[ -s ${T}/multilib-strict.log ]] ; then
			if [[ ${#QA_MULTILIB_PATHS[@]} -eq 1 ]] ; then
				local shopts=$-
				set -o noglob
				QA_MULTILIB_PATHS=(${QA_MULTILIB_PATHS})
				set +o noglob
				set -${shopts}
			fi
			if [ "${QA_STRICT_MULTILIB_PATHS-unset}" = unset ] ; then
				local x
				for x in "${QA_MULTILIB_PATHS[@]}" ; do
					sed -e "s#^${x#/}\$##" -i "${T}/multilib-strict.log"
				done
				sed -e "/^\$/d" -i "${T}/multilib-strict.log"
			fi
			if [[ -s ${T}/multilib-strict.log ]] ; then
				abort=yes
				echo "Files matching a file type that is not allowed:"
				while read -r ; do
					echo "   ${REPLY}"
				done < "${T}/multilib-strict.log"
			fi
		fi

		[[ ${abort} == yes ]] && die "multilib-strict check failed!"
	fi
}

multilib_strict_check
: # guarantee successful exit

# vim:ft=sh