blob: c982dbdf4042f3a331df2beae051707ddc96632d (
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# Check for pkg-config file issues
pkgconfig_check() {
local files=()
# Make a list of .pc files and bail out if there aren't any
mapfile -d '' files < <(
find "${ED}"/usr/{lib*,share}/pkgconfig -maxdepth 1 -type f -name '*.pc' -print0 2>/dev/null
)
[[ -z "${files[@]}" ]] && return
local f
# Look for leaking LDFLAGS into pkg-config files
f=$(grep -E -zsH '^Libs.*-Wl,(-O[012]|--hash-style)' "${files[@]}")
if [[ -n ${f} ]] ; then
eqawarn "QA Notice: pkg-config files with wrong LDFLAGS detected:"
eqatag -v pkgconfig.bad-ldlags "${f//${D}}"
fi
# Bail out now so we can rely on pkgconfig in subsequent checks if we want.
if ! type -P pkg-config >/dev/null ; then
return
fi
# Validate using pkgconfig
# Some less common implementations may not support this?
# seems like f.d.o, OpenBSD, and of course pkgconf do though.
# Need --maximum-traverse-depth=1 to avoid checking deps and giving
# unrelated warnings/errors.
if ! pkg-config --maximum-traverse-depth=1 --with-path="${ED}"/usr/{lib*,share}/pkgconfig --validate "${files[@]}" ; then
eqawarn "QA Notice: pkg-config files which fail validation found!"
eqawarn "Run 'pkg-config --validate ...' for more information"
fi
# Check for unexpected paths
# e.g. https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c90ab38e3577aae61fac2341b34ad593948de1cd
if [[ -n ${EPREFIX} ]] ; then
for f in "${files[@]}" ; do
local key
for key in prefix exec_prefix libdir includedir ; do
# Check if the variable is even in there (bug #860825)
grep -E -q "^${key}" "${f}" || continue
local value=$(pkg-config --variable="${key}" "${f}")
if [[ ${value} != "${EPREFIX}"* ]] ; then
eqawarn "QA Notice: pkg-config files not respecting EPREFIX found"
eqawarn "key=${key} does not respect EPREFIX:"
eqawarn "${key}=${value}"
eqatag -v pkgconfig.bad-paths ${key}="${value}" "${f//${D}}"
# Don't bother repeating for every variable in the same file
break
fi
done
done
fi
# TODO: Generalise for non-lib64 libdir? Not that this is very common now
# that riscv chose a more standard layout.
#
# If we're installing to ${ED}/usr/lib/pkgconfig, let's make sure
# we're not referencing lib64.
#
# e.g. https://bugs.gentoo.org/729642
local bad_libdir=()
for f in "${files[@]}" ; do
if [[ ${f} == *lib/pkgconfig* ]] ; then
if [[ -d "${ED}"/usr/lib && -L "${ED}"/usr/lib ]] ; then
# (Don't bother if /usr/lib is a symlink to /usr/lib64)
continue
fi
# In ${ED}/usr/lib, we shouldn't reference lib64
if grep -E -q "=(/usr)?/lib64" ${f} ; then
bad_libdir+=( "${f//${D}}" )
fi
elif [[ ${f} == *lib64/pkgconfig* ]] ; then
# We want to match /lib/, /lib/foo/, but not e.g. /lib64 or /lib64/, or libfoo
if grep -E -q '=(/usr)?/lib\b' ${f} ; then
bad_libdir+=( "${f//${D}}" )
fi
fi
done
if [[ -n "${bad_libdir[@]}" ]] ; then
eqawarn "QA Notice: pkg-config files not respecting libdir found"
eqawarn "(contains reference to either lib or lib64 in wrong directory)"
eqatag -v pkgconfig.bad-libdir "${bad_libdir[@]}"
fi
}
pkgconfig_check
: # guarantee successful exit
# vim:ft=sh
|