aboutsummaryrefslogtreecommitdiff
blob: f944be9e6307818382137c09e929e7445fcea5d0 (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
50
# 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
		MULTILIB_STRICT_EXEMPT=$(echo ${MULTILIB_STRICT_EXEMPT} | sed -e 's:\([(|)]\):\\\1:g')
		for dir in ${MULTILIB_STRICT_DIRS} ; do
			[[ -d ${ED}/${dir} ]] || continue
			for file in $(find ${ED}/${dir} -type f | grep -v "^${ED}/${dir}/${MULTILIB_STRICT_EXEMPT}"); do
				if file ${file} | egrep -q "${MULTILIB_STRICT_DENY}" ; then
					echo "${file#${ED}//}" >> "${T}/multilib-strict.log"
				fi
			done
		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