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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
# Check for issues with installed libraries
scanelf_lib_check() {
local f x i j
# Check for shared libraries lacking SONAMEs
local qa_var="QA_SONAME_${ARCH/-/_}"
eval "[[ -n \${!qa_var} ]] && QA_SONAME=(\"\${${qa_var}[@]}\")"
f=$(scanelf -ByF '%S %p' "${ED}"{,usr/}lib*/lib*.so* | awk '$2 == "" { print }' | sed -e "s:^[[:space:]]${ED}:/:")
if [[ -n ${f} ]] ; then
echo "${f}" > "${T}"/scanelf-missing-SONAME.log
if [[ "${QA_STRICT_SONAME-unset}" == unset ]] ; then
if [[ ${#QA_SONAME[@]} -gt 1 ]] ; then
for x in "${QA_SONAME[@]}" ; do
sed -e "s#^/${x#/}\$##" -i "${T}"/scanelf-missing-SONAME.log
done
else
local shopts=$-
set -o noglob
for x in ${QA_SONAME} ; do
sed -e "s#^/${x#/}\$##" -i "${T}"/scanelf-missing-SONAME.log
done
set +o noglob
set -${shopts}
fi
fi
sed -e "/^\$/d" -i "${T}"/scanelf-missing-SONAME.log
f=$(<"${T}"/scanelf-missing-SONAME.log)
if [[ -n ${f} ]] ; then
__vecho -ne '\n'
eqawarn "QA Notice: The following shared libraries lack a SONAME"
eqawarn "${f}"
__vecho -ne '\n'
sleep 1
else
rm -f "${T}"/scanelf-missing-SONAME.log
fi
fi
# Check for shared libraries lacking NEEDED entries
qa_var="QA_DT_NEEDED_${ARCH/-/_}"
eval "[[ -n \${!qa_var} ]] && QA_DT_NEEDED=(\"\${${qa_var}[@]}\")"
f=$(scanelf -ByF '%n %p' "${ED}"{,usr/}lib*/lib*.so* | awk '$2 == "" { print }' | sed -e "s:^[[:space:]]${ED}:/:")
if [[ -n ${f} ]] ; then
echo "${f}" > "${T}"/scanelf-missing-NEEDED.log
if [[ "${QA_STRICT_DT_NEEDED-unset}" == unset ]] ; then
if [[ ${#QA_DT_NEEDED[@]} -gt 1 ]] ; then
for x in "${QA_DT_NEEDED[@]}" ; do
sed -e "s#^/${x#/}\$##" -i "${T}"/scanelf-missing-NEEDED.log
done
else
local shopts=$-
set -o noglob
for x in ${QA_DT_NEEDED} ; do
sed -e "s#^/${x#/}\$##" -i "${T}"/scanelf-missing-NEEDED.log
done
set +o noglob
set -${shopts}
fi
fi
sed -e "/^\$/d" -i "${T}"/scanelf-missing-NEEDED.log
f=$(<"${T}"/scanelf-missing-NEEDED.log)
if [[ -n ${f} ]] ; then
__vecho -ne '\n'
eqawarn "QA Notice: The following shared libraries lack NEEDED entries"
eqawarn "${f}"
__vecho -ne '\n'
sleep 1
else
rm -f "${T}"/scanelf-missing-NEEDED.log
fi
fi
}
lib_check() {
local f x i j
if type -P scanelf >/dev/null && ! has binchecks ${RESTRICT}; then
scanelf_lib_check
fi
# this should help to ensure that all (most?) shared libraries are executable
# and that all libtool scripts / static libraries are not executable
for i in "${ED}"opt/*/lib* \
"${ED}"lib* \
"${ED}"usr/lib* ; do
[[ ! -d ${i} ]] && continue
for j in "${i}"/*.so.* "${i}"/*.so ; do
[[ ! -e ${j} ]] && continue
[[ -L ${j} ]] && continue
[[ -x ${j} ]] && continue
__vecho "making executable: ${j#${ED}}"
chmod +x "${j}"
done
for j in "${i}"/*.a "${i}"/*.la ; do
[[ ! -e ${j} ]] && continue
[[ -L ${j} ]] && continue
[[ ! -x ${j} ]] && continue
__vecho "removing executable bit: ${j#${ED}}"
chmod -x "${j}"
done
for j in "${i}"/*.{a,dll,dylib,sl,so}.* "${i}"/*.{a,dll,dylib,sl,so} ; do
[[ ! -e ${j} ]] && continue
[[ ! -L ${j} ]] && continue
linkdest=$(readlink "${j}")
if [[ ${linkdest} == /* ]] ; then
__vecho -ne '\n'
eqawarn "QA Notice: Found an absolute symlink in a library directory:"
eqawarn " ${j#${D}} -> ${linkdest}"
eqawarn " It should be a relative symlink if in the same directory"
eqawarn " or a linker script if it crosses the /usr boundary."
fi
done
done
# When installing static libraries into /usr/lib and shared libraries into
# /lib, we have to make sure we have a linker script in /usr/lib along side
# the static library, or gcc will utilize the static lib when linking :(.
# http://bugs.gentoo.org/4411
local abort="no"
local a s
for a in "${ED}"usr/lib*/*.a ; do
s=${a%.a}.so
if [[ ! -e ${s} ]] ; then
s=${s%usr/*}${s##*/usr/}
if [[ -e ${s} ]] ; then
__vecho -ne '\n'
eqawarn "QA Notice: Missing gen_usr_ldscript for ${s##*/}"
abort="yes"
fi
fi
done
[[ ${abort} == "yes" ]] && die "add those ldscripts"
# Make sure people don't store libtool files or static libs in /lib
f=$(ls "${ED}"lib*/*.{a,la} 2>/dev/null)
if [[ -n ${f} ]] ; then
__vecho -ne '\n'
eqawarn "QA Notice: Excessive files found in the / partition"
eqawarn "${f}"
__vecho -ne '\n'
die "static archives (*.a) and libtool library files (*.la) belong in /usr/lib*, not /lib*"
fi
# Verify that the libtool files don't contain bogus $D entries.
local abort=no gentoo_bug=no always_overflow=no
for a in "${ED}"usr/lib*/*.la ; do
s=${a##*/}
if grep -qs "${ED}" "${a}" ; then
__vecho -ne '\n'
eqawarn "QA Notice: ${s} appears to contain PORTAGE_TMPDIR paths"
abort="yes"
fi
done
[[ ${abort} == "yes" ]] && die "soiled libtool library files found"
}
lib_check
: # guarantee successful exit
# vim:ft=sh
|