Gentoo Archives: gentoo-commits

From: "Fabian Groffen (grobian)" <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r14746 - main/branches/prefix/bin
Date: Wed, 28 Oct 2009 20:40:28
Message-Id: E1N3FJh-0005hy-7t@stork.gentoo.org
1 Author: grobian
2 Date: 2009-10-28 20:40:24 +0000 (Wed, 28 Oct 2009)
3 New Revision: 14746
4
5 Modified:
6 main/branches/prefix/bin/ebuild.sh
7 main/branches/prefix/bin/misc-functions.sh
8 Log:
9 Attempt to align this more with trunk
10 - reshuffle qa_check code using functions such that the order is the
11 same as in trunk, but with some extra offsets
12 (at the same time avoid running QA checks for platforms other than the
13 current one)
14 - split out elf, macho, pecoff, xcoff, misc and prefix qa code blocks,
15 keep a bit of general (misc) checks in the original qa_check func for
16 the point mentioned above
17 - only chdir to ${D}, not ${ED}, this has the advantage that if that
18 fails we're on the same panic level as normal Portage, and that we no
19 longer need default src_install implementations that just create
20 ${ED} to avoid a failing QA check, like bug #290245
21
22
23
24 Modified: main/branches/prefix/bin/ebuild.sh
25 ===================================================================
26 --- main/branches/prefix/bin/ebuild.sh 2009-10-28 19:38:53 UTC (rev 14745)
27 +++ main/branches/prefix/bin/ebuild.sh 2009-10-28 20:40:24 UTC (rev 14746)
28 @@ -597,10 +597,6 @@
29 _eapi2_src_compile
30 }
31
32 -_eapi0_src_install() {
33 - _eapi1_src_install
34 -}
35 -
36 _eapi0_src_test() {
37 if emake -j1 check -n &> /dev/null; then
38 vecho ">>> Test phase [check]: ${CATEGORY}/${PF}"
39 @@ -624,15 +620,6 @@
40 _eapi2_src_compile
41 }
42
43 -_eapi1_src_install() {
44 - if use prefix ; then
45 - # this avoids misc QA errors in Prefix because it doesn't exist
46 - # by default
47 - mkdir -p "${ED}"
48 - return
49 - fi
50 -}
51 -
52 _eapi2_src_configure() {
53 if [[ -x ${ECONF_SOURCE:-.}/configure ]] ; then
54 econf
55 @@ -661,10 +648,6 @@
56 else
57 dodoc ${DOCS}
58 fi
59 -
60 - # this avoids misc QA errors in Prefix because it doesn't exist
61 - # by default
62 - use prefix && mkdir -p "${ED}"
63 }
64
65 ebuild_phase() {
66
67 Modified: main/branches/prefix/bin/misc-functions.sh
68 ===================================================================
69 --- main/branches/prefix/bin/misc-functions.sh 2009-10-28 19:38:53 UTC (rev 14745)
70 +++ main/branches/prefix/bin/misc-functions.sh 2009-10-28 20:40:24 UTC (rev 14746)
71 @@ -18,7 +18,9 @@
72 source @PORTAGE_BASE@/bin/ebuild.sh
73
74 install_symlink_html_docs() {
75 - cd "${ED}" || die "cd failed"
76 + cd "${D}" || die "cd failed"
77 + [[ ! -d ${ED} ]] && dodir /
78 + cd "${ED}" || die "cd shouldn't have failed"
79 #symlink the html documentation (if DOC_SYMLINKS_DIR is set in make.conf)
80 if [ -n "${DOC_SYMLINKS_DIR}" ] ; then
81 local mydocdir docdir
82 @@ -42,7 +44,7 @@
83 }
84
85 install_qa_check() {
86 - cd "${ED}" || die "cd failed"
87 + cd "${D}" || die "cd failed"
88
89 export STRIP_MASK
90 prepall
91 @@ -59,7 +61,36 @@
92 sleep 1
93 done
94
95 - if [[ ${CHOST} != *-darwin* ]] && type -P scanelf > /dev/null && ! hasq binchecks ${RESTRICT}; then
96 + case ${CHOST} in
97 + *-darwin*)
98 + # Mach-O platforms (NeXT, Darwin, OSX)
99 + install_qa_check_macho
100 + ;;
101 + *-interix*|*-winnt*)
102 + # PECOFF platforms (Windows/Interix)
103 + install_qa_check_pecoff
104 + ;;
105 + *-aix*)
106 + # XCOFF platforms (AIX)
107 + install_qa_check_xcoff
108 + ;;
109 + *)
110 + # because this is the majority: ELF platforms (Linux,
111 + # Solaris, *BSD, IRIX, etc.)
112 + install_qa_check_elf
113 + ;;
114 + esac
115 +
116 + # this is basically here such that the diff with trunk remains just
117 + # offsetted and not out of order
118 + install_qa_check_misc
119 +
120 + # Prefix specific checks
121 + [[ -n ${EPREFIX} ]] && install_qa_check_prefix
122 +}
123 +
124 +install_qa_check_elf() {
125 + if type -P scanelf > /dev/null && ! hasq binchecks ${RESTRICT}; then
126 local qa_var insecure_rpath=0 tmp_quiet=${PORTAGE_QUIET}
127 local f x
128
129 @@ -313,13 +344,414 @@
130
131 PORTAGE_QUIET=${tmp_quiet}
132 fi
133 +}
134
135 +install_qa_check_misc() {
136 + local unsafe_files=$(find "${ED}" -type f '(' -perm -2002 -o -perm -4002 ')')
137 + if [[ -n ${unsafe_files} ]] ; then
138 + eqawarn "QA Notice: Unsafe files detected (set*id and world writable)"
139 + eqawarn "${unsafe_files}"
140 + die "Unsafe files found in \${ED}. Portage will not install them."
141 + fi
142 +
143 + if [[ -d ${D}/${D} ]] ; then
144 + find "${D}/${D}" | \
145 + while read i ; do
146 + eqawarn "QA Notice: /${i##${D}/${D}} installed in \${D}/\${D}"
147 + done
148 + die "Aborting due to QA concerns: files installed in ${D}/${D}"
149 + fi
150 +
151 + # this should help to ensure that all (most?) shared libraries are executable
152 + # and that all libtool scripts / static libraries are not executable
153 + for i in "${ED}"opt/*/lib{,32,64} \
154 + "${ED}"lib{,32,64} \
155 + "${ED}"usr/lib{,32,64} \
156 + "${ED}"usr/X11R6/lib{,32,64} ; do
157 + [[ ! -d ${i} ]] && continue
158 +
159 + for j in "${i}"/*.so.* "${i}"/*.so "${i}"/*.dylib "${i}"/*.dll ; do
160 + [[ ! -e ${j} ]] && continue
161 + if [[ -L ${j} ]] ; then
162 + linkdest=$(readlink "${j}")
163 + if [[ ${linkdest} == /* ]] ; then
164 + vecho -ne '\a\n'
165 + eqawarn "QA Notice: Found an absolute symlink in a library directory:"
166 + eqawarn " ${j#${D}} -> ${linkdest}"
167 + eqawarn " It should be a relative symlink if in the same directory"
168 + eqawarn " or a linker script if it crosses the /usr boundary."
169 + fi
170 + continue
171 + fi
172 + [[ -x ${j} ]] && continue
173 + vecho "making executable: ${j#${D}}"
174 + chmod +x "${j}"
175 + done
176 +
177 + for j in "${i}"/*.a "${i}"/*.la ; do
178 + [[ ! -e ${j} ]] && continue
179 + [[ -L ${j} ]] && continue
180 + [[ ! -x ${j} ]] && continue
181 + vecho "removing executable bit: ${j#${D}}"
182 + chmod -x "${j}"
183 + done
184 + done
185 +
186 + # When installing static libraries into /usr/lib and shared libraries into
187 + # /lib, we have to make sure we have a linker script in /usr/lib along side
188 + # the static library, or gcc will utilize the static lib when linking :(.
189 + # http://bugs.gentoo.org/4411
190 + abort="no"
191 + for a in "${ED}"usr/lib*/*.a ; do
192 + [[ ${CHOST} == *-darwin* ]] \
193 + && s=${a%.a}.dylib \
194 + || s=${a%.a}.so
195 + if [[ ! -e ${s} ]] ; then
196 + s=${s%usr/*}${s##*/usr/}
197 + if [[ -e ${s} ]] ; then
198 + vecho -ne '\a\n'
199 + eqawarn "QA Notice: Missing gen_usr_ldscript for ${s##*/}"
200 + abort="yes"
201 + fi
202 + fi
203 + done
204 + [[ ${abort} == "yes" ]] && die "add those ldscripts"
205 +
206 + # Make sure people don't store libtool files or static libs in /lib
207 + # on AIX, "dynamic libs" have extention .a, so don't get false
208 + # positives
209 + [[ ${CHOST} == *-aix* ]] \
210 + && f=$(ls "${ED}"lib*/*.la 2>/dev/null || true) \
211 + || f=$(ls "${ED}"lib*/*.{a,la} 2>/dev/null)
212 + if [[ -n ${f} ]] ; then
213 + vecho -ne '\a\n'
214 + eqawarn "QA Notice: Excessive files found in the / partition"
215 + eqawarn "${f}"
216 + vecho -ne '\a\n'
217 + die "static archives (*.a) and libtool library files (*.la) do not belong in /"
218 + fi
219 +
220 + # Verify that the libtool files don't contain bogus $D entries.
221 + local abort=no gentoo_bug=no
222 + for a in "${ED}"usr/lib*/*.la ; do
223 + s=${a##*/}
224 + if grep -qs "${D}" "${a}" ; then
225 + vecho -ne '\a\n'
226 + eqawarn "QA Notice: ${s} appears to contain PORTAGE_TMPDIR paths"
227 + abort="yes"
228 + fi
229 + done
230 + [[ ${abort} == "yes" ]] && die "soiled libtool library files found"
231 +
232 + # Evaluate misc gcc warnings
233 + if [[ -n ${PORTAGE_LOG_FILE} && -r ${PORTAGE_LOG_FILE} ]] ; then
234 + # In debug mode, this variable definition and corresponding grep calls
235 + # will produce false positives if they're shown in the trace.
236 + local reset_debug=0
237 + if [[ ${-/x/} != $- ]] ; then
238 + set +x
239 + reset_debug=1
240 + fi
241 + local m msgs=(
242 + ": warning: dereferencing type-punned pointer will break strict-aliasing rules$"
243 + ": warning: dereferencing pointer .* does break strict-aliasing rules$"
244 + ": warning: implicit declaration of function "
245 + ": warning: incompatible implicit declaration of built-in function "
246 + ": warning: is used uninitialized in this function$" # we'll ignore "may" and "might"
247 + ": warning: comparisons like X<=Y<=Z do not have their mathematical meaning$"
248 + ": warning: null argument where non-null required "
249 + )
250 + abort="no"
251 + i=0
252 + while [[ -n ${msgs[${i}]} ]] ; do
253 + m=${msgs[$((i++))]}
254 + # force C locale to work around slow unicode locales #160234
255 + f=$(LC_ALL=C grep "${m}" "${PORTAGE_LOG_FILE}")
256 + if [[ -n ${f} ]] ; then
257 + vecho -ne '\a\n'
258 + eqawarn "QA Notice: Package has poor programming practices which may compile"
259 + eqawarn " fine but exhibit random runtime failures."
260 + eqawarn "${f}"
261 + vecho -ne '\a\n'
262 + abort="yes"
263 + fi
264 + done
265 + [[ $reset_debug = 1 ]] && set -x
266 + f=$(cat "${PORTAGE_LOG_FILE}" | \
267 + EPYTHON= "$PORTAGE_BIN_PATH"/check-implicit-pointer-usage.py)
268 + if [[ -n ${f} ]] ; then
269 +
270 + # In the future this will be a forced "die". In preparation,
271 + # increase the log level from "qa" to "eerror" so that people
272 + # are aware this is a problem that must be fixed asap.
273 +
274 + # just warn on 32bit hosts but bail on 64bit hosts
275 + case ${CHOST} in
276 + alpha*|hppa64*|ia64*|powerpc64*|mips64*|sparc64*|sparcv9*|x86_64*) gentoo_bug=yes ;;
277 + esac
278 +
279 + abort=yes
280 +
281 + if [[ $gentoo_bug = yes ]] ; then
282 + eerror
283 + eerror "QA Notice: Package has poor programming practices which may compile"
284 + eerror " but will almost certainly crash on 64bit architectures."
285 + eerror
286 + eerror "${f}"
287 + eerror
288 + eerror " Please file a bug about this at http://bugs.gentoo.org/"
289 + eerror " with the maintaining herd of the package."
290 + eerror
291 + else
292 + vecho -ne '\a\n'
293 + eqawarn "QA Notice: Package has poor programming practices which may compile"
294 + eqawarn " but will almost certainly crash on 64bit architectures."
295 + eqawarn "${f}"
296 + vecho -ne '\a\n'
297 + fi
298 +
299 + fi
300 + if [[ ${abort} == "yes" ]] ; then
301 + if [[ ${gentoo_bug} == "yes" ]] ; then
302 + die "install aborted due to" \
303 + "poor programming practices shown above"
304 + else
305 + echo "Please do not file a Gentoo bug and instead" \
306 + "report the above QA issues directly to the upstream" \
307 + "developers of this software." | fmt -w 70 | \
308 + while read line ; do eqawarn "${line}" ; done
309 + eqawarn "Homepage: ${HOMEPAGE}"
310 + hasq stricter ${FEATURES} && die "install aborted due to" \
311 + "poor programming practices shown above"
312 + fi
313 + fi
314 + fi
315 +
316 + # Compiled python objects do not belong in /usr/share (FHS violation)
317 + # and can be a pain when upgrading python
318 + f=$([ -d "${ED}"/usr/share ] && \
319 + find "${ED}"usr/share -name '*.py[co]' | sed "s:${D}:/:")
320 + if [[ -n ${f} ]] ; then
321 + vecho -ne '\a\n'
322 + eqawarn "QA Notice: Precompiled python object files do not belong in /usr/share"
323 + eqawarn "${f}"
324 + vecho -ne '\a\n'
325 + fi
326 +
327 + # Portage regenerates this on the installed system.
328 + rm -f "${ED}"/usr/share/info/dir{,.gz,.bz2}
329 +
330 + if hasq multilib-strict ${FEATURES} && \
331 + [[ -x ${EPREFIX}/usr/bin/file && -x ${EPREFIX}/usr/bin/find ]] && \
332 + [[ -n ${MULTILIB_STRICT_DIRS} && -n ${MULTILIB_STRICT_DENY} ]]
333 + then
334 + local abort=no firstrun=yes
335 + MULTILIB_STRICT_EXEMPT=$(echo ${MULTILIB_STRICT_EXEMPT} | sed -e 's:\([(|)]\):\\\1:g')
336 + for dir in ${MULTILIB_STRICT_DIRS} ; do
337 + [[ -d ${ED}/${dir} ]] || continue
338 + for file in $(find ${ED}/${dir} -type f | grep -v "^${ED}/${dir}/${MULTILIB_STRICT_EXEMPT}"); do
339 + if file ${file} | egrep -q "${MULTILIB_STRICT_DENY}" ; then
340 + if [[ ${firstrun} == yes ]] ; then
341 + echo "Files matching a file type that is not allowed:"
342 + firstrun=no
343 + fi
344 + abort=yes
345 + echo " ${file#${ED}//}"
346 + fi
347 + done
348 + done
349 + [[ ${abort} == yes ]] && die "multilib-strict check failed!"
350 + fi
351 +}
352 +
353 +install_qa_check_prefix() {
354 + if [[ -d ${ED}/${D} ]] ; then
355 + find "${ED}/${D}" | \
356 + while read i ; do
357 + eqawarn "QA Notice: /${i##${ED}/${D}} installed in \${ED}/\${D}"
358 + done
359 + die "Aborting due to QA concerns: files installed in ${ED}/${D}"
360 + fi
361 +
362 + if [[ -d ${ED}/${EPREFIX} ]] ; then
363 + find "${ED}/${EPREFIX}/" | \
364 + while read i ; do
365 + eqawarn "QA Notice: ${i#${D}} double prefix"
366 + done
367 + die "Aborting due to QA concerns: double prefix files installed"
368 + fi
369 +
370 + if [[ -n ${EPREFIX} && -d ${D} ]] ; then
371 + INSTALLTOD=$(find ${D%/} | egrep -v "^${ED}" | sed -e "s|^${D%/}||" | awk '{if (length($0) <= length("'"${EPREFIX}"'")) { if (substr("'"${EPREFIX}"'", 1, length($0)) != $0) {print $0;} } else if (substr($0, 1, length("'"${EPREFIX}"'")) != "'"${EPREFIX}"'") {print $0;} }')
372 + if [[ -n ${INSTALLTOD} ]] ; then
373 + eqawarn "QA Notice: the following files are outside of the prefix:"
374 + eqawarn "${INSTALLTOD}"
375 + die "Aborting due to QA concerns: there are files installed outside the prefix"
376 + fi
377 + fi
378 +
379 + # Check shebangs, bug #282539
380 + if [[ -n ${EPREFIX} ]] ; then
381 + # this does not really belong here, but it's closely tied to
382 + # this code; many runscripts generate positives here, and we
383 + # know they don't work (bug #196294) so as long as that one
384 + # remains an issue, simply remove them as they won't work
385 + # anyway, avoid etc/init.d/functions.sh from being thrown away
386 + if [[ ( -d "${ED}"/etc/conf.d || -d "${ED}"/etc/init.d ) && ! -f "${ED}"/etc/init.d/functions.sh ]] ; then
387 + ewarn "removed /etc/init.d and /etc/conf.d directories until bug #196294 has been resolved"
388 + rm -Rf "${ED}"/etc/{conf,init}.d
389 + fi
390 +
391 + rm -f "${T}"/non-prefix-shebangs-errs
392 + local WHITELIST=" /usr/bin/env "
393 + # this is hell expensive, but how else?
394 + find "${ED}" -type f -executable -print0 \
395 + | xargs -0 grep -H -n -m1 "^#!" \
396 + | while read f ;
397 + do
398 + local fn=${f%%:*}
399 + local pos=${f#*:} ; pos=${pos%:*}
400 + local line=${f##*:}
401 + # shebang always appears on the first line ;)
402 + [[ ${pos} != 1 ]] && continue
403 + line=( ${line#"#!"} )
404 + [[ ${WHITELIST} == *" ${line[0]} "* ]] && continue
405 + # does the shebang start with ${EPREFIX}?
406 + [[ ${line[0]} == ${EPREFIX}* ]] && continue
407 + # can we just fix it(tm)?
408 + if [[ -x ${EPREFIX}${line[0]} || -x ${ED}${line[0]} ]] ; then
409 + eqawarn "prefixing shebang of ${fn#${D}}"
410 + sed -i -e '1s:^#! \?:#!'"${EPREFIX}"':' "${fn}"
411 + continue
412 + fi
413 + # all else is an error if the found script is in $PATH
414 + local fp=${fn#${D}} ; fp=${fp%/*}
415 + if [[ ":${PATH}:" == *":${fp}:"* ]] || hasq stricter ${FEATURES} ;
416 + then
417 + echo "${fn#${D}}:${line[0]}" \
418 + >> "${T}"/non-prefix-shebangs-errs
419 + else
420 + eqawarn "invalid shebang in ${fn#${D}}: ${line[0]}"
421 + fi
422 + done
423 + if [[ -e "${T}"/non-prefix-shebangs-errs ]] ; then
424 + eqawarn "QA Notice: the following files use invalid (possible non-prefixed) shebangs:"
425 + eqawarn "$(<"${T}"/non-prefix-shebangs-errs)"
426 + die "Aborting due to QA concerns: invalid shebangs found"
427 + rm -f "${T}"/non-prefix-shebangs-errs
428 + fi
429 + fi
430 +}
431 +
432 +install_qa_check_macho() {
433 + if ! hasq binchecks ${RESTRICT} ; then
434 + # on Darwin, dynamic libraries are called .dylibs instead of
435 + # .sos. In addition the version component is before the
436 + # extension, not after it. Check for this, and *only* warn
437 + # about it. Some packages do ship .so files on Darwin and make
438 + # it work (ugly!).
439 + rm -f "${T}/mach-o.check"
440 + find ${ED%/} -name "*.so" -or -name "*.so.*" | \
441 + while read i ; do
442 + [[ $(file $i) == *"Mach-O"* ]] && \
443 + echo "${i#${D}}" >> "${T}/mach-o.check"
444 + done
445 + if [[ -f ${T}/mach-o.check ]] ; then
446 + f=$(< "${T}/mach-o.check")
447 + vecho -ne '\a\n'
448 + eqawarn "QA Notice: Found .so dynamic libraries on Darwin:"
449 + eqawarn " ${f//$'\n'/\n }"
450 + fi
451 + rm -f "${T}/mach-o.check"
452 +
453 + # The naming for dynamic libraries is different on Darwin; the
454 + # version component is before the extention, instead of after
455 + # it, as with .sos. Again, make this a warning only.
456 + rm -f "${T}/mach-o.check"
457 + find ${ED%/} -name "*.dylib.*" | \
458 + while read i ; do
459 + echo "${i#${D}}" >> "${T}/mach-o.check"
460 + done
461 + if [[ -f "${T}/mach-o.check" ]] ; then
462 + f=$(< "${T}/mach-o.check")
463 + vecho -ne '\a\n'
464 + eqawarn "QA Notice: Found wrongly named dynamic libraries on Darwin:"
465 + eqawarn " ${f// /\n }"
466 + fi
467 + rm -f "${T}/mach-o.check"
468 + fi
469 +
470 + # While we generate the NEEDED files, check that we don't get kernel
471 + # traps at runtime because of broken install_names on Darwin.
472 + rm -f "${T}"/.install_name_check_failed
473 + scanmacho -qyRF '%a;%p;%S;%n' "${D}" | { while IFS= read l ; do
474 + arch=${l%%;*}; l=${l#*;}
475 + obj="/${l%%;*}"; l=${l#*;}
476 + install_name=${l%%;*}; l=${l#*;}
477 + needed=${l%%;*}; l=${l#*;}
478 +
479 + # See if the self-reference install_name points to an existing
480 + # and to be installed file. This usually is a symlink for the
481 + # major version.
482 + if [[ ! -e ${D}${install_name} ]] ; then
483 + eqawarn "QA Notice: invalid self-reference install_name ${install_name} in ${obj}"
484 + # remember we are in an implicit subshell, that's
485 + # why we touch a file here ... ideally we should be
486 + # able to die correctly/nicely here
487 + touch "${T}"/.install_name_check_failed
488 + fi
489 +
490 + # this is ugly, paths with spaces won't work
491 + reevaluate=0
492 + for lib in $(echo ${needed} | tr , ' '); do
493 + if [[ ! -e ${lib} && ! -e ${D}${lib} && ${lib} != "@executable_path/"* && *${lib} != "@loader_path/"* ]] ; then
494 + # try to "repair" this if possible, happens because of
495 + # gen_usr_ldscript tactics
496 + s=${lib%usr/*}${lib##*/usr/}
497 + if [[ -e ${D}${s} ]] ; then
498 + ewarn "correcting install_name from ${lib} to ${s} in ${obj}"
499 + install_name_tool -change \
500 + "${lib}" "${s}" "${D}${obj}"
501 + reevaluate=1
502 + else
503 + eqawarn "QA Notice: invalid reference to ${lib} in ${obj}"
504 + # remember we are in an implicit subshell, that's
505 + # why we touch a file here ... ideally we should be
506 + # able to die correctly/nicely here
507 + touch "${T}"/.install_name_check_failed
508 + fi
509 + fi
510 + done
511 + if [[ ${reevaluate} == 1 ]]; then
512 + # install_name(s) have been changed, refresh data so we
513 + # store the correct meta data
514 + l=$(scanmacho -qyF '%a;%p;%S;%n' ${D}${obj})
515 + arch=${l%%;*}; l=${l#*;}
516 + obj="/${l%%;*}"; l=${l#*;}
517 + install_name=${l%%;*}; l=${l#*;}
518 + needed=${l%%;*}; l=${l#*;}
519 + fi
520 +
521 + # backwards compatability
522 + echo "${obj} ${needed}" >> "${PORTAGE_BUILDDIR}"/build-info/NEEDED
523 + # what we use
524 + echo "${arch};${obj};${install_name};${needed}" >> "${PORTAGE_BUILDDIR}"/build-info/NEEDED.MACHO.3
525 + done }
526 + if [[ -f ${T}/.install_name_check_failed ]] ; then
527 + # secret switch "allow_broken_install_names" to get
528 + # around this and install broken crap (not a good idea)
529 + hasq allow_broken_install_names ${FEATURES} || \
530 + die "invalid install_name found, your application or library will crash at runtime"
531 + fi
532 +}
533 +
534 +install_qa_check_pecoff() {
535 local _pfx_scan="readpecoff ${CHOST}"
536
537 # this one uses readpecoff, which supports multiple prefix platforms!
538 # this is absolutely _not_ optimized for speed, and there may be plenty
539 # of possibilities by introducing one or the other cache!
540 - if [[ ${CHOST} == *-interix* || ${CHOST} == *-winnt* ]] && ! hasq binchecks ${RESTRICT}; then
541 + if ! hasq binchecks ${RESTRICT}; then
542 # copied and adapted from the above scanelf code.
543 local qa_var insecure_rpath=0 tmp_quiet=${PORTAGE_QUIET}
544 local f x
545 @@ -404,7 +836,7 @@
546 local _so_ext='.so*'
547
548 case "${CHOST}" in
549 - *-winnt*) _so_ext=".dll" ;; # no "*" intentionally!
550 + *-winnt*) _so_ext=".dll" ;; # no "*" intentionally!
551 esac
552
553 # Run some sanity checks on shared libraries
554 @@ -435,8 +867,10 @@
555
556 PORTAGE_QUIET=${tmp_quiet}
557 fi
558 +}
559
560 - if [[ ${CHOST} == *-aix* ]] && ! hasq binchecks ${RESTRICT}; then
561 +install_qa_check_xcoff() {
562 + if ! hasq binchecks ${RESTRICT}; then
563 local tmp_quiet=${PORTAGE_QUIET}
564 local queryline deplib
565 local insecure_rpath_list= undefined_symbols_list=
566 @@ -543,391 +977,6 @@
567
568 PORTAGE_QUIET=${tmp_quiet}
569 fi
570 -
571 - local unsafe_files=$(find "${ED}" -type f '(' -perm -2002 -o -perm -4002 ')')
572 - if [[ -n ${unsafe_files} ]] ; then
573 - eqawarn "QA Notice: Unsafe files detected (set*id and world writable)"
574 - eqawarn "${unsafe_files}"
575 - die "Unsafe files found in \${ED}. Portage will not install them."
576 - fi
577 -
578 - if [[ -d ${ED}/${D} ]] ; then
579 - find "${ED}/${D}" | \
580 - while read i ; do
581 - eqawarn "QA Notice: /${i##${ED}/${D}} installed in \${ED}/\${D}"
582 - done
583 - die "Aborting due to QA concerns: files installed in ${ED}/${D}"
584 - fi
585 -
586 - if [[ -n ${EPREFIX} && -d ${ED}/${EPREFIX} ]] ; then
587 - find "${ED}/${EPREFIX}/" | \
588 - while read i ; do
589 - eqawarn "QA Notice: ${i#${D}} double prefix"
590 - done
591 - die "Aborting due to QA concerns: double prefix files installed"
592 - fi
593 -
594 - if [[ -n ${EPREFIX} && -d ${D} ]] ; then
595 - INSTALLTOD=$(find ${D%/} | egrep -v "^${ED}" | sed -e "s|^${D%/}||" | awk '{if (length($0) <= length("'"${EPREFIX}"'")) { if (substr("'"${EPREFIX}"'", 1, length($0)) != $0) {print $0;} } else if (substr($0, 1, length("'"${EPREFIX}"'")) != "'"${EPREFIX}"'") {print $0;} }')
596 - if [[ -n ${INSTALLTOD} ]] ; then
597 - eqawarn "QA Notice: the following files are outside of the prefix:"
598 - eqawarn "${INSTALLTOD}"
599 - die "Aborting due to QA concerns: there are files installed outside the prefix"
600 - fi
601 - fi
602 -
603 - # Check shebangs, bug #282539
604 - if [[ -n ${EPREFIX} ]] ; then
605 - # this does not really belong here, but it's closely tied to
606 - # this code; many runscripts generate positives here, and we
607 - # know they don't work (bug #196294) so as long as that one
608 - # remains an issue, simply remove them as they won't work
609 - # anyway, avoid etc/init.d/functions.sh from being thrown away
610 - if [[ ( -d "${ED}"/etc/conf.d || -d "${ED}"/etc/init.d ) && ! -f "${ED}"/etc/init.d/functions.sh ]] ; then
611 - ewarn "removed /etc/init.d and /etc/conf.d directories until bug #196294 has been resolved"
612 - rm -Rf "${ED}"/etc/{conf,init}.d
613 - fi
614 -
615 - rm -f "${T}"/non-prefix-shebangs-errs
616 - local WHITELIST=" /usr/bin/env "
617 - # this is hell expensive, but how else?
618 - find "${ED}" -type f -executable -print0 \
619 - | xargs -0 grep -H -n -m1 "^#!" \
620 - | while read f ;
621 - do
622 - local fn=${f%%:*}
623 - local pos=${f#*:} ; pos=${pos%:*}
624 - local line=${f##*:}
625 - # shebang always appears on the first line ;)
626 - [[ ${pos} != 1 ]] && continue
627 - line=( ${line#"#!"} )
628 - [[ ${WHITELIST} == *" ${line[0]} "* ]] && continue
629 - # does the shebang start with ${EPREFIX}?
630 - [[ ${line[0]} == ${EPREFIX}* ]] && continue
631 - # can we just fix it(tm)?
632 - if [[ -x ${EPREFIX}${line[0]} || -x ${ED}${line[0]} ]] ; then
633 - eqawarn "prefixing shebang of ${fn#${D}}"
634 - sed -i -e '1s:^#! \?:#!'"${EPREFIX}"':' "${fn}"
635 - continue
636 - fi
637 - # all else is an error if the found script is in $PATH
638 - local fp=${fn#${D}} ; fp=${fp%/*}
639 - if [[ ":${PATH}:" == *":${fp}:"* ]] || hasq stricter ${FEATURES} ;
640 - then
641 - echo "${fn#${D}}:${line[0]}" \
642 - >> "${T}"/non-prefix-shebangs-errs
643 - else
644 - eqawarn "invalid shebang in ${fn#${D}}: ${line[0]}"
645 - fi
646 - done
647 - if [[ -e "${T}"/non-prefix-shebangs-errs ]] ; then
648 - eqawarn "QA Notice: the following files use invalid (possible non-prefixed) shebangs:"
649 - eqawarn "$(<"${T}"/non-prefix-shebangs-errs)"
650 - die "Aborting due to QA concerns: invalid shebangs found"
651 - rm -f "${T}"/non-prefix-shebangs-errs
652 - fi
653 - fi
654 -
655 - if [[ ${CHOST} == *-darwin* ]] && ! hasq binchecks ${RESTRICT} ; then
656 - # on Darwin, dynamic libraries are called .dylibs instead of
657 - # .sos. In addition the version component is before the
658 - # extension, not after it. Check for this, and *only* warn
659 - # about it. Some packages do ship .so files on Darwin and make
660 - # it work (ugly!).
661 - rm -f "${T}/mach-o.check"
662 - find ${ED%/} -name "*.so" -or -name "*.so.*" | \
663 - while read i ; do
664 - [[ $(file $i) == *"Mach-O"* ]] && \
665 - echo "${i#${D}}" >> "${T}/mach-o.check"
666 - done
667 - if [[ -f ${T}/mach-o.check ]] ; then
668 - f=$(< "${T}/mach-o.check")
669 - vecho -ne '\a\n'
670 - eqawarn "QA Notice: Found .so dynamic libraries on Darwin:"
671 - eqawarn " ${f//$'\n'/\n }"
672 - fi
673 - rm -f "${T}/mach-o.check"
674 -
675 - # The naming for dynamic libraries is different on Darwin; the
676 - # version component is before the extention, instead of after
677 - # it, as with .sos. Again, make this a warning only.
678 - rm -f "${T}/mach-o.check"
679 - find ${ED%/} -name "*.dylib.*" | \
680 - while read i ; do
681 - echo "${i#${D}}" >> "${T}/mach-o.check"
682 - done
683 - if [[ -f "${T}/mach-o.check" ]] ; then
684 - f=$(< "${T}/mach-o.check")
685 - vecho -ne '\a\n'
686 - eqawarn "QA Notice: Found wrongly named dynamic libraries on Darwin:"
687 - eqawarn " ${f// /\n }"
688 - fi
689 - rm -f "${T}/mach-o.check"
690 - fi
691 -
692 - # this should help to ensure that all (most?) shared libraries are executable
693 - # and that all libtool scripts / static libraries are not executable
694 - for i in "${ED}"opt/*/lib{,32,64} \
695 - "${ED}"lib{,32,64} \
696 - "${ED}"usr/lib{,32,64} \
697 - "${ED}"usr/X11R6/lib{,32,64} ; do
698 - [[ ! -d ${i} ]] && continue
699 -
700 - for j in "${i}"/*.so.* "${i}"/*.so "${i}"/*.dylib "${i}"/*.dll ; do
701 - [[ ! -e ${j} ]] && continue
702 - if [[ -L ${j} ]] ; then
703 - linkdest=$(readlink "${j}")
704 - if [[ ${linkdest} == /* ]] ; then
705 - vecho -ne '\a\n'
706 - eqawarn "QA Notice: Found an absolute symlink in a library directory:"
707 - eqawarn " ${j#${D}} -> ${linkdest}"
708 - eqawarn " It should be a relative symlink if in the same directory"
709 - eqawarn " or a linker script if it crosses the /usr boundary."
710 - fi
711 - continue
712 - fi
713 - [[ -x ${j} ]] && continue
714 - vecho "making executable: ${j#${D}}"
715 - chmod +x "${j}"
716 - done
717 -
718 - for j in "${i}"/*.a "${i}"/*.la ; do
719 - [[ ! -e ${j} ]] && continue
720 - [[ -L ${j} ]] && continue
721 - [[ ! -x ${j} ]] && continue
722 - vecho "removing executable bit: ${j#${D}}"
723 - chmod -x "${j}"
724 - done
725 - done
726 -
727 - # When installing static libraries into /usr/lib and shared libraries into
728 - # /lib, we have to make sure we have a linker script in /usr/lib along side
729 - # the static library, or gcc will utilize the static lib when linking :(.
730 - # http://bugs.gentoo.org/4411
731 - abort="no"
732 - for a in "${ED}"usr/lib*/*.a ; do
733 - [[ ${CHOST} == *-darwin* ]] \
734 - && s=${a%.a}.dylib \
735 - || s=${a%.a}.so
736 - if [[ ! -e ${s} ]] ; then
737 - s=${s%usr/*}${s##*/usr/}
738 - if [[ -e ${s} ]] ; then
739 - vecho -ne '\a\n'
740 - eqawarn "QA Notice: Missing gen_usr_ldscript for ${s##*/}"
741 - abort="yes"
742 - fi
743 - fi
744 - done
745 - [[ ${abort} == "yes" ]] && die "add those ldscripts"
746 -
747 - # Make sure people don't store libtool files or static libs in /lib
748 - # on AIX, "dynamic libs" have extention .a, so don't get false
749 - # positives
750 - [[ ${CHOST} == *-aix* ]] \
751 - && f=$(ls "${ED}"lib*/*.la 2>/dev/null || true) \
752 - || f=$(ls "${ED}"lib*/*.{a,la} 2>/dev/null)
753 - if [[ -n ${f} ]] ; then
754 - vecho -ne '\a\n'
755 - eqawarn "QA Notice: Excessive files found in the / partition"
756 - eqawarn "${f}"
757 - vecho -ne '\a\n'
758 - die "static archives (*.a) and libtool library files (*.la) do not belong in /"
759 - fi
760 -
761 - # Verify that the libtool files don't contain bogus $D entries.
762 - local abort=no gentoo_bug=no
763 - for a in "${ED}"usr/lib*/*.la ; do
764 - s=${a##*/}
765 - if grep -qs "${D}" "${a}" ; then
766 - vecho -ne '\a\n'
767 - eqawarn "QA Notice: ${s} appears to contain PORTAGE_TMPDIR paths"
768 - abort="yes"
769 - fi
770 - done
771 - [[ ${abort} == "yes" ]] && die "soiled libtool library files found"
772 -
773 - # While we generate the NEEDED files, check that we don't get kernel
774 - # traps at runtime because of broken install_names on Darwin.
775 - rm -f "${T}"/.install_name_check_failed
776 - [[ ${CHOST} == *-darwin* ]] && scanmacho -qyRF '%a;%p;%S;%n' "${D}" | { while IFS= read l ; do
777 - arch=${l%%;*}; l=${l#*;}
778 - obj="/${l%%;*}"; l=${l#*;}
779 - install_name=${l%%;*}; l=${l#*;}
780 - needed=${l%%;*}; l=${l#*;}
781 -
782 - # See if the self-reference install_name points to an existing
783 - # and to be installed file. This usually is a symlink for the
784 - # major version.
785 - if [[ ! -e ${D}${install_name} ]] ; then
786 - eqawarn "QA Notice: invalid self-reference install_name ${install_name} in ${obj}"
787 - # remember we are in an implicit subshell, that's
788 - # why we touch a file here ... ideally we should be
789 - # able to die correctly/nicely here
790 - touch "${T}"/.install_name_check_failed
791 - fi
792 -
793 - # this is ugly, paths with spaces won't work
794 - reevaluate=0
795 - for lib in $(echo ${needed} | tr , ' '); do
796 - if [[ ! -e ${lib} && ! -e ${D}${lib} && ${lib} != "@executable_path/"* && *${lib} != "@loader_path/"* ]] ; then
797 - # try to "repair" this if possible, happens because of
798 - # gen_usr_ldscript tactics
799 - s=${lib%usr/*}${lib##*/usr/}
800 - if [[ -e ${D}${s} ]] ; then
801 - ewarn "correcting install_name from ${lib} to ${s} in ${obj}"
802 - install_name_tool -change \
803 - "${lib}" "${s}" "${D}${obj}"
804 - reevaluate=1
805 - else
806 - eqawarn "QA Notice: invalid reference to ${lib} in ${obj}"
807 - # remember we are in an implicit subshell, that's
808 - # why we touch a file here ... ideally we should be
809 - # able to die correctly/nicely here
810 - touch "${T}"/.install_name_check_failed
811 - fi
812 - fi
813 - done
814 - if [[ ${reevaluate} == 1 ]]; then
815 - # install_name(s) have been changed, refresh data so we
816 - # store the correct meta data
817 - l=$(scanmacho -qyF '%a;%p;%S;%n' ${D}${obj})
818 - arch=${l%%;*}; l=${l#*;}
819 - obj="/${l%%;*}"; l=${l#*;}
820 - install_name=${l%%;*}; l=${l#*;}
821 - needed=${l%%;*}; l=${l#*;}
822 - fi
823 -
824 - # backwards compatability
825 - echo "${obj} ${needed}" >> "${PORTAGE_BUILDDIR}"/build-info/NEEDED
826 - # what we use
827 - echo "${arch};${obj};${install_name};${needed}" >> "${PORTAGE_BUILDDIR}"/build-info/NEEDED.MACHO.3
828 - done }
829 - if [[ -f ${T}/.install_name_check_failed ]] ; then
830 - # secret switch "allow_broken_install_names" to get
831 - # around this and install broken crap (not a good idea)
832 - hasq allow_broken_install_names ${FEATURES} || \
833 - die "invalid install_name found, your application or library will crash at runtime"
834 - fi
835 -
836 - # Evaluate misc gcc warnings
837 - if [[ -n ${PORTAGE_LOG_FILE} && -r ${PORTAGE_LOG_FILE} ]] ; then
838 - # In debug mode, this variable definition and corresponding grep calls
839 - # will produce false positives if they're shown in the trace.
840 - local reset_debug=0
841 - if [[ ${-/x/} != $- ]] ; then
842 - set +x
843 - reset_debug=1
844 - fi
845 - local m msgs=(
846 - ": warning: dereferencing type-punned pointer will break strict-aliasing rules$"
847 - ": warning: dereferencing pointer .* does break strict-aliasing rules$"
848 - ": warning: implicit declaration of function "
849 - ": warning: incompatible implicit declaration of built-in function "
850 - ": warning: is used uninitialized in this function$" # we'll ignore "may" and "might"
851 - ": warning: comparisons like X<=Y<=Z do not have their mathematical meaning$"
852 - ": warning: null argument where non-null required "
853 - )
854 - abort="no"
855 - i=0
856 - while [[ -n ${msgs[${i}]} ]] ; do
857 - m=${msgs[$((i++))]}
858 - # force C locale to work around slow unicode locales #160234
859 - f=$(LC_ALL=C grep "${m}" "${PORTAGE_LOG_FILE}")
860 - if [[ -n ${f} ]] ; then
861 - vecho -ne '\a\n'
862 - eqawarn "QA Notice: Package has poor programming practices which may compile"
863 - eqawarn " fine but exhibit random runtime failures."
864 - eqawarn "${f}"
865 - vecho -ne '\a\n'
866 - abort="yes"
867 - fi
868 - done
869 - [[ $reset_debug = 1 ]] && set -x
870 - f=$(cat "${PORTAGE_LOG_FILE}" | \
871 - EPYTHON= "$PORTAGE_BIN_PATH"/check-implicit-pointer-usage.py)
872 - if [[ -n ${f} ]] ; then
873 -
874 - # In the future this will be a forced "die". In preparation,
875 - # increase the log level from "qa" to "eerror" so that people
876 - # are aware this is a problem that must be fixed asap.
877 -
878 - # just warn on 32bit hosts but bail on 64bit hosts
879 - case ${CHOST} in
880 - alpha*|hppa64*|ia64*|powerpc64*|mips64*|sparc64*|sparcv9*|x86_64*) gentoo_bug=yes ;;
881 - esac
882 -
883 - abort=yes
884 -
885 - if [[ $gentoo_bug = yes ]] ; then
886 - eerror
887 - eerror "QA Notice: Package has poor programming practices which may compile"
888 - eerror " but will almost certainly crash on 64bit architectures."
889 - eerror
890 - eerror "${f}"
891 - eerror
892 - eerror " Please file a bug about this at http://bugs.gentoo.org/"
893 - eerror " with the maintaining herd of the package."
894 - eerror
895 - else
896 - vecho -ne '\a\n'
897 - eqawarn "QA Notice: Package has poor programming practices which may compile"
898 - eqawarn " but will almost certainly crash on 64bit architectures."
899 - eqawarn "${f}"
900 - vecho -ne '\a\n'
901 - fi
902 -
903 - fi
904 - if [[ ${abort} == "yes" ]] ; then
905 - if [[ ${gentoo_bug} == "yes" ]] ; then
906 - die "install aborted due to" \
907 - "poor programming practices shown above"
908 - else
909 - echo "Please do not file a Gentoo bug and instead" \
910 - "report the above QA issues directly to the upstream" \
911 - "developers of this software." | fmt -w 70 | \
912 - while read line ; do eqawarn "${line}" ; done
913 - eqawarn "Homepage: ${HOMEPAGE}"
914 - hasq stricter ${FEATURES} && die "install aborted due to" \
915 - "poor programming practices shown above"
916 - fi
917 - fi
918 - fi
919 -
920 - # Compiled python objects do not belong in /usr/share (FHS violation)
921 - # and can be a pain when upgrading python
922 - f=$([ -d "${ED}"/usr/share ] && \
923 - find "${ED}"usr/share -name '*.py[co]' | sed "s:${D}:/:")
924 - if [[ -n ${f} ]] ; then
925 - vecho -ne '\a\n'
926 - eqawarn "QA Notice: Precompiled python object files do not belong in /usr/share"
927 - eqawarn "${f}"
928 - vecho -ne '\a\n'
929 - fi
930 -
931 - # Portage regenerates this on the installed system.
932 - rm -f "${ED}"/usr/share/info/dir{,.gz,.bz2}
933 -
934 - if hasq multilib-strict ${FEATURES} && \
935 - [[ -x ${EPREFIX}/usr/bin/file && -x ${EPREFIX}/usr/bin/find ]] && \
936 - [[ -n ${MULTILIB_STRICT_DIRS} && -n ${MULTILIB_STRICT_DENY} ]]
937 - then
938 - local abort=no firstrun=yes
939 - MULTILIB_STRICT_EXEMPT=$(echo ${MULTILIB_STRICT_EXEMPT} | sed -e 's:\([(|)]\):\\\1:g')
940 - for dir in ${MULTILIB_STRICT_DIRS} ; do
941 - [[ -d ${ED}/${dir} ]] || continue
942 - for file in $(find ${ED}/${dir} -type f | grep -v "^${ED}/${dir}/${MULTILIB_STRICT_EXEMPT}"); do
943 - if file ${file} | egrep -q "${MULTILIB_STRICT_DENY}" ; then
944 - if [[ ${firstrun} == yes ]] ; then
945 - echo "Files matching a file type that is not allowed:"
946 - firstrun=no
947 - fi
948 - abort=yes
949 - echo " ${file#${ED}//}"
950 - fi
951 - done
952 - done
953 - [[ ${abort} == yes ]] && die "multilib-strict check failed!"
954 - fi
955 }