Merge remote-tracking branch 'overlays-gentoo-org/master' into prefix
authorFabian Groffen <grobian@gentoo.org>
Sun, 17 Jul 2011 08:11:06 +0000 (10:11 +0200)
committerFabian Groffen <grobian@gentoo.org>
Sun, 17 Jul 2011 08:11:06 +0000 (10:11 +0200)
Conflicts:
bin/binhost-snapshot
bin/ebuild-helpers/doman
bin/ebuild-helpers/prepall
bin/ebuild-helpers/prepallman
bin/ebuild-helpers/prepinfo
bin/ebuild-helpers/prepman
bin/ebuild-helpers/prepstrip
bin/ebuild.sh
bin/filter-bash-environment.py
bin/misc-functions.sh
pym/_emerge/Binpkg.py
pym/_emerge/main.py
pym/portage/elog/mod_save.py
pym/portage/elog/mod_save_summary.py
pym/portage/package/ebuild/prepare_build_dirs.py

35 files changed:
1  2 
bin/binhost-snapshot
bin/ebuild-helpers/doman
bin/ebuild-helpers/prepall
bin/ebuild-helpers/prepallman
bin/ebuild-helpers/prepinfo
bin/ebuild-helpers/prepman
bin/ebuild-helpers/prepstrip
bin/ebuild.sh
bin/egencache
bin/emerge-webrsync
bin/filter-bash-environment.py
bin/isolated-functions.sh
bin/misc-functions.sh
bin/portageq
bin/repoman
pym/_emerge/Binpkg.py
pym/_emerge/EbuildBuild.py
pym/_emerge/actions.py
pym/_emerge/depgraph.py
pym/_emerge/emergelog.py
pym/_emerge/main.py
pym/portage/__init__.py
pym/portage/const.py
pym/portage/dbapi/bintree.py
pym/portage/dbapi/vartree.py
pym/portage/dispatch_conf.py
pym/portage/elog/mod_save.py
pym/portage/elog/mod_save_summary.py
pym/portage/output.py
pym/portage/package/ebuild/_config/special_env_vars.py
pym/portage/package/ebuild/doebuild.py
pym/portage/package/ebuild/fetch.py
pym/portage/package/ebuild/prepare_build_dirs.py
pym/portage/util/__init__.py
pym/portage/util/env_update.py

index 662b027e26c487af29ebb13f7b6b80e854a53d36,9d2697d032b828fb485a145451a68e25e7d9fe33..54d210218aaa9b06edee02718c2038bdd4d4403f
@@@ -1,8 -1,8 +1,8 @@@
 -#!/usr/bin/python
 +#!@PREFIX_PORTAGE_PYTHON@
- # Copyright 2010 Gentoo Foundation
+ # Copyright 2010-2011 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
- import codecs
+ import io
  import optparse
  import os
  import sys
index cfe8a8f73bf6eca3126f4821237da48bb72de6b5,4561bef1810ba070f45851bb419d9d0888f073a9..e947e0d38850adcf9568d72b2ca16d5fc0853341
@@@ -1,8 -1,8 +1,8 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2010 Gentoo Foundation
+ # Copyright 1999-2011 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
 -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh
  
  if [[ $# -lt 1 ]] ; then
        helpers_die "${0##*/}: at least one argument needed"
index f9164c18f27ceafc7498c6f881e7c97e990d38ea,701ecba213734e4a64992610a5176fa298ae9b22..a765756ccc40724099037e348207e59faf11d852
@@@ -1,17 -1,15 +1,17 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2007 Gentoo Foundation
+ # Copyright 1999-2011 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
 -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh
 +
 +[[ -d ${ED} ]] || exit 0
  
- if hasq chflags $FEATURES ; then
+ if has chflags $FEATURES ; then
        # Save all the file flags for restoration at the end of prepall.
 -      mtree -c -p "${D}" -k flags > "${T}/bsdflags.mtree"
 +      mtree -c -p "${ED}" -k flags > "${T}/bsdflags.mtree"
        # Remove all the file flags so that prepall can do anything necessary.
 -      chflags -R noschg,nouchg,nosappnd,nouappnd "${D}"
 -      chflags -R nosunlnk,nouunlnk "${D}" 2>/dev/null
 +      chflags -R noschg,nouchg,nosappnd,nouappnd "${ED}"
 +      chflags -R nosunlnk,nouunlnk "${ED}" 2>/dev/null
  fi
  
  prepallman
@@@ -19,7 -17,7 +19,7 @@@ prepallinf
  
  prepallstrip
  
- if hasq chflags $FEATURES ; then
+ if has chflags $FEATURES ; then
        # Restore all the file flags that were saved at the beginning of prepall.
 -      mtree -U -e -p "${D}" -k flags < "${T}/bsdflags.mtree" &> /dev/null
 +      mtree -U -e -p "${ED}" -k flags < "${T}/bsdflags.mtree" &> /dev/null
  fi
index 20880fb06ef2088a3311146e019bf949f681f6eb,e50de6d67e97a6623d23bc5b7c6f7c2e9fe40124..19437dd009baa5243f3c0d6907bc758034531d13
@@@ -1,11 -1,11 +1,11 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2010 Gentoo Foundation
+ # Copyright 1999-2011 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
 -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh
  
  # replaced by controllable compression in EAPI 4
- hasq "${EAPI}" 0 1 2 3 || exit 0
+ has "${EAPI}" 0 1 2 3 || exit 0
  
  ret=0
  
index 94e67f0a4f8afdc2b188ef12429ff1bc65bd0cb7,691fd1372bf16aaea72d2376899878e4bbfff48f..c350fba0fb8cdf350d85f5522ef62d4600785654
@@@ -1,16 -1,16 +1,16 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2010 Gentoo Foundation
+ # Copyright 1999-2011 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
 -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh
  
  if [[ -z $1 ]] ; then
 -      infodir="/usr/share/info"
 +      infodir="${EPREFIX}/usr/share/info"
  else
 -      if [[ -d ${D}$1/share/info ]] ; then
 -              infodir="$1/share/info"
 +      if [[ -d ${ED}$1/share/info ]] ; then
 +              infodir="${EPREFIX}$1/share/info"
        else
 -              infodir="$1/info"
 +              infodir="${EPREFIX}$1/info"
        fi
  fi
  
index 231f9aef89faf8a36d2ae37e4393c454b2d08207,c9add8a30662826c47194f35bd359f8c9546304b..f8c670feca0b69d0daefe89a5b952f6abbf2c73c
@@@ -1,13 -1,13 +1,13 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2010 Gentoo Foundation
+ # Copyright 1999-2011 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
 -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh
  
  if [[ -z $1 ]] ; then 
 -      mandir="${D}usr/share/man"
 +      mandir="${ED}usr/share/man"
  else
 -      mandir="${D}$1/man"
 +      mandir="${ED}$1/man"
  fi
  
  if [[ ! -d ${mandir} ]] ; then
index 320e332735b8a9f6836d518d6f9437a368123d9f,d25259dca7b0e3c286c9f0614ff33da771afe034..9c5d9dad65b52acdcf521545adaa4d9931447751
@@@ -1,8 -1,8 +1,8 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2007 Gentoo Foundation
+ # Copyright 1999-2011 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
 -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh
  
  banner=false
  SKIP_STRIP=false
@@@ -23,9 -23,9 +23,9 @@@ type -P -- ${OBJCOPY} > /dev/null || OB
  # of the section when it has the ALLOC flag set on it ...
  export SAFE_STRIP_FLAGS="--strip-unneeded"
  export PORTAGE_STRIP_FLAGS=${PORTAGE_STRIP_FLAGS-${SAFE_STRIP_FLAGS} -R .comment}
 -prepstrip_sources_dir=/usr/src/debug/${CATEGORY}/${PF}
 +prepstrip_sources_dir="${EPREFIX}"/usr/src/debug/${CATEGORY}/${PF}
  
- if hasq installsources ${FEATURES} && ! type -P debugedit >/dev/null ; then
+ if has installsources ${FEATURES} && ! type -P debugedit >/dev/null ; then
        ewarn "FEATURES=installsources is enabled but the debugedit binary could not"
        ewarn "be found. This feature will not work unless debugedit is installed!"
  fi
@@@ -53,10 -53,10 +53,10 @@@ save_elf_sources() 
  }
  
  save_elf_debug() {
-       hasq splitdebug ${FEATURES} || return 0
+       has splitdebug ${FEATURES} || return 0
  
        local x=$1
 -      local y="${D}usr/lib/debug/${x:${#D}}.debug"
 +      local y="${ED}usr/lib/debug/${x:${#D}}.debug"
  
        # dont save debug info twice
        [[ ${x} == *".debug" ]] && return 0
diff --cc bin/ebuild.sh
index a0b7b154e0f1d6fdac786685ee274687b872b5f9,4aef4134de7bc8123e820547462c2101420e4baf..eaf96ea7998afe5ab4d3999efafd7262bb0252e2
@@@ -2137,13 -2124,13 +2139,13 @@@ if ! has "$EBUILD_PHASE" clean cleanrm 
                        x=LIBDIR_${DEFAULT_ABI}
                        [[ -n $DEFAULT_ABI && -n ${!x} ]] && x=${!x} || x=lib
  
-                       if hasq distcc $FEATURES ; then
+                       if has distcc $FEATURES ; then
 -                              PATH="/usr/$x/distcc/bin:$PATH"
 +                              PATH="${EPREFIX}/usr/$x/distcc/bin:$PATH"
                                [[ -n $DISTCC_LOG ]] && addwrite "${DISTCC_LOG%/*}"
                        fi
  
-                       if hasq ccache $FEATURES ; then
+                       if has ccache $FEATURES ; then
 -                              PATH="/usr/$x/ccache/bin:$PATH"
 +                              PATH="${EPREFIX}/usr/$x/ccache/bin:$PATH"
  
                                if [[ -n $CCACHE_DIR ]] ; then
                                        addread "$CCACHE_DIR"
diff --cc bin/egencache
Simple merge
Simple merge
index 126e4801a93addade6cff436ff453a024097befb,b9aec96d0e50c564a6dd68a88ab4e6d91d33c516..9cb42c1aa825563c4072784c4b0dd2ef0dea580a
@@@ -1,5 -1,5 +1,5 @@@
 -#!/usr/bin/python
 +#!@PREFIX_PORTAGE_PYTHON@
- # Copyright 1999-2007 Gentoo Foundation
+ # Copyright 1999-2011 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  import codecs
Simple merge
index 5b4ff8af3b0d8c86ac611383a6a43f12fb206c57,8c191ff8cce1bc9fcf1fcd0f974fdd80bafe2a0a..eb2235d5a86f926e78e6c8c93bb50bddc6bdf6ff
mode 100644,100755..100644
@@@ -177,41 -175,7 +177,41 @@@ install_qa_check() 
                sleep 1
        done
  
-       if type -P scanelf > /dev/null && ! hasq binchecks ${RESTRICT}; then
 +      # anything outside the prefix should be caught by the Prefix QA
 +      # check, so if there's nothing in ED, we skip searching for QA
 +      # checks there, the specific QA funcs can hence rely on ED existing
 +      if [[ -d ${ED} ]] ; then
 +              case ${CHOST} in
 +                      *-darwin*)
 +                              # Mach-O platforms (NeXT, Darwin, OSX)
 +                              install_qa_check_macho
 +                      ;;
 +                      *-interix*|*-winnt*)
 +                              # PECOFF platforms (Windows/Interix)
 +                              install_qa_check_pecoff
 +                      ;;
 +                      *-aix*)
 +                              # XCOFF platforms (AIX)
 +                              install_qa_check_xcoff
 +                      ;;
 +                      *)
 +                              # because this is the majority: ELF platforms (Linux,
 +                              # Solaris, *BSD, IRIX, etc.)
 +                              install_qa_check_elf
 +                      ;;
 +              esac
 +      fi
 +
 +      # this is basically here such that the diff with trunk remains just
 +      # offsetted and not out of order
 +      install_qa_check_misc
 +
 +      # Prefix specific checks
 +      [[ -n ${EPREFIX} ]] && install_qa_check_prefix
 +}
 +
 +install_qa_check_elf() {
+       if type -P scanelf > /dev/null && ! has binchecks ${RESTRICT}; then
                local qa_var insecure_rpath=0 tmp_quiet=${PORTAGE_QUIET}
                local x
  
@@@ -736,10 -692,10 +736,10 @@@ install_qa_check_misc() 
        fi
  
        # Portage regenerates this on the installed system.
 -      rm -f "${D}"/usr/share/info/dir{,.gz,.bz2}
 +      rm -f "${ED}"/usr/share/info/dir{,.gz,.bz2}
  
-       if hasq multilib-strict ${FEATURES} && \
+       if has multilib-strict ${FEATURES} && \
 -         [[ -x /usr/bin/file && -x /usr/bin/find ]] && \
 +         [[ -x ${EPREFIX}/usr/bin/file && -x ${EPREFIX}/usr/bin/find ]] && \
           [[ -n ${MULTILIB_STRICT_DIRS} && -n ${MULTILIB_STRICT_DENY} ]]
        then
                local abort=no dir file firstrun=yes
        fi
  }
  
-                       hasq stricter ${FEATURES} && \
 +install_qa_check_prefix() {
 +      if [[ -d ${ED}/${D} ]] ; then
 +              find "${ED}/${D}" | \
 +              while read i ; do
 +                      eqawarn "QA Notice: /${i##${ED}/${D}} installed in \${ED}/\${D}"
 +              done
 +              die "Aborting due to QA concerns: files installed in ${ED}/${D}"
 +      fi
 +
 +      if [[ -d ${ED}/${EPREFIX} ]] ; then
 +              find "${ED}/${EPREFIX}/" | \
 +              while read i ; do
 +                      eqawarn "QA Notice: ${i#${D}} double prefix"
 +              done
 +              die "Aborting due to QA concerns: double prefix files installed"
 +      fi
 +
 +      if [[ -d ${D} ]] ; then
 +              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;} }') 
 +              if [[ -n ${INSTALLTOD} ]] ; then
 +                      eqawarn "QA Notice: the following files are outside of the prefix:"
 +                      eqawarn "${INSTALLTOD}"
 +                      die "Aborting due to QA concerns: there are files installed outside the prefix"
 +              fi
 +      fi
 +
 +      # all further checks rely on ${ED} existing
 +      [[ -d ${ED} ]] || return
 +
 +      # this does not really belong here, but it's closely tied to
 +      # the code below; many runscripts generate positives here, and we
 +      # know they don't work (bug #196294) so as long as that one
 +      # remains an issue, simply remove them as they won't work
 +      # anyway, avoid etc/init.d/functions.sh from being thrown away
 +      if [[ ( -d "${ED}"/etc/conf.d || -d "${ED}"/etc/init.d ) && ! -f "${ED}"/etc/init.d/functions.sh ]] ; then
 +              ewarn "removed /etc/init.d and /etc/conf.d directories until bug #196294 has been resolved"
 +              rm -Rf "${ED}"/etc/{conf,init}.d
 +      fi
 +
 +      # check shebangs, bug #282539
 +      rm -f "${T}"/non-prefix-shebangs-errs
 +      local WHITELIST=" /usr/bin/env "
 +      # this is hell expensive, but how else?
 +      find "${ED}" -executable \! -type d -print0 \
 +                      | xargs -0 grep -H -n -m1 "^#!" \
 +                      | while read f ;
 +      do
 +              local fn=${f%%:*}
 +              local pos=${f#*:} ; pos=${pos%:*}
 +              local line=${f##*:}
 +              # shebang always appears on the first line ;)
 +              [[ ${pos} != 1 ]] && continue
 +              local oldIFS=${IFS}
 +              IFS=$'\r'$'\n'$'\t'" "
 +              line=( ${line#"#!"} )
 +              IFS=${oldIFS}
 +              [[ ${WHITELIST} == *" ${line[0]} "* ]] && continue
 +              local fp=${fn#${D}} ; fp=/${fp%/*}
 +              # line[0] can be an absolutised path, bug #342929
 +              local eprefix=$(canonicalize ${EPREFIX})
 +              local rf=${fn}
 +              # in case we deal with a symlink, make sure we don't replace it
 +              # with a real file (sed -i does that)
 +              if [[ -L ${fn} ]] ; then
 +                      rf=$(readlink ${fn})
 +                      [[ ${rf} != /* ]] && rf=${fn%/*}/${rf}
 +                      # ignore symlinks pointing to outside prefix
 +                      # as seen in sys-devel/native-cctools
 +                      [[ ${rf} != ${EPREFIX}/* && $(canonicalize "${rf}") != ${eprefix}/* ]] && continue
 +              fi
 +              # does the shebang start with ${EPREFIX}, and does it exist?
 +              if [[ ${line[0]} == ${EPREFIX}/* || ${line[0]} == ${eprefix}/* ]] ; then
 +                      if [[ ! -e ${ROOT%/}${line[0]} && ! -e ${D%/}${line[0]} ]] ; then
 +                              # hmm, refers explicitly to $EPREFIX, but doesn't exist,
 +                              # if it's in PATH that's wrong in any case
 +                              if [[ ":${PATH}:" == *":${fp}:"* ]] ; then
 +                                      echo "${fn#${D}}:${line[0]} (explicit EPREFIX but target not found)" \
 +                                              >> "${T}"/non-prefix-shebangs-errs
 +                              else
 +                                      eqawarn "${fn#${D}} has explicit EPREFIX in shebang but target not found (${line[0]})"
 +                              fi
 +                      fi
 +                      continue
 +              fi
 +              # unprefixed shebang, is the script directly in $PATH?
 +              if [[ ":${PATH}:" == *":${fp}:"* ]] ; then
 +                      if [[ -e ${EROOT}${line[0]} || -e ${ED}${line[0]} ]] ; then
 +                              # is it unprefixed, but we can just fix it because a
 +                              # prefixed variant exists
 +                              eqawarn "prefixing shebang of ${fn#${D}}"
 +                              # statement is made idempotent on purpose, because
 +                              # symlinks may point to the same target, and hence the
 +                              # same real file may be sedded multiple times since we
 +                              # read the shebangs in one go upfront for performance
 +                              # reasons
 +                              sed -i -e '1s:^#! \?'"${line[0]}"':#!'"${EPREFIX}"${line[0]}':' "${rf}"
 +                              continue
 +                      else
 +                              # this is definitely wrong: script in $PATH and invalid shebang
 +                              echo "${fn#${D}}:${line[0]} (script ${fn##*/} installed in PATH but interpreter ${line[0]} not found)" \
 +                                      >> "${T}"/non-prefix-shebangs-errs
 +                      fi
 +              else
 +                      # unprefixed/invalid shebang, but outside $PATH, this may be
 +                      # intended (e.g. config.guess) so remain silent by default
-       if ! hasq binchecks ${RESTRICT} ; then
++                      has stricter ${FEATURES} && \
 +                              eqawarn "invalid shebang in ${fn#${D}}: ${line[0]}"
 +              fi
 +      done
 +      if [[ -e "${T}"/non-prefix-shebangs-errs ]] ; then
 +              eqawarn "QA Notice: the following files use invalid (possible non-prefixed) shebangs:"
 +              while read line ; do
 +                      eqawarn "  ${line}"
 +              done < "${T}"/non-prefix-shebangs-errs
 +              rm -f "${T}"/non-prefix-shebangs-errs
 +              die "Aborting due to QA concerns: invalid shebangs found"
 +      fi
 +}
 +
 +install_qa_check_macho() {
-               hasq allow_broken_install_names ${FEATURES} || \
++      if ! has binchecks ${RESTRICT} ; then
 +              # on Darwin, dynamic libraries are called .dylibs instead of
 +              # .sos.  In addition the version component is before the
 +              # extension, not after it.  Check for this, and *only* warn
 +              # about it.  Some packages do ship .so files on Darwin and make
 +              # it work (ugly!).
 +              rm -f "${T}/mach-o.check"
 +              find ${ED%/} -name "*.so" -or -name "*.so.*" | \
 +              while read i ; do
 +                      [[ $(file $i) == *"Mach-O"* ]] && \
 +                              echo "${i#${D}}" >> "${T}/mach-o.check"
 +              done
 +              if [[ -f ${T}/mach-o.check ]] ; then
 +                      f=$(< "${T}/mach-o.check")
 +                      vecho -ne '\a\n'
 +                      eqawarn "QA Notice: Found .so dynamic libraries on Darwin:"
 +                      eqawarn "    ${f//$'\n'/\n    }"
 +              fi
 +              rm -f "${T}/mach-o.check"
 +
 +              # The naming for dynamic libraries is different on Darwin; the
 +              # version component is before the extention, instead of after
 +              # it, as with .sos.  Again, make this a warning only.
 +              rm -f "${T}/mach-o.check"
 +              find ${ED%/} -name "*.dylib.*" | \
 +              while read i ; do
 +                      echo "${i#${D}}" >> "${T}/mach-o.check"
 +              done
 +              if [[ -f "${T}/mach-o.check" ]] ; then
 +                      f=$(< "${T}/mach-o.check")
 +                      vecho -ne '\a\n'
 +                      eqawarn "QA Notice: Found wrongly named dynamic libraries on Darwin:"
 +                      eqawarn "    ${f// /\n    }"
 +              fi
 +              rm -f "${T}/mach-o.check"
 +      fi
 +
 +      # While we generate the NEEDED files, check that we don't get kernel
 +      # traps at runtime because of broken install_names on Darwin.
 +      rm -f "${T}"/.install_name_check_failed
 +      scanmacho -qyRF '%a;%p;%S;%n' "${D}" | { while IFS= read l ; do
 +              arch=${l%%;*}; l=${l#*;}
 +              obj="/${l%%;*}"; l=${l#*;}
 +              install_name=${l%%;*}; l=${l#*;}
 +              needed=${l%%;*}; l=${l#*;}
 +
 +              # See if the self-reference install_name points to an existing
 +              # and to be installed file.  This usually is a symlink for the
 +              # major version.
 +              if [[ ! -e ${D}${install_name} ]] ; then
 +                      eqawarn "QA Notice: invalid self-reference install_name ${install_name} in ${obj}"
 +                      # remember we are in an implicit subshell, that's
 +                      # why we touch a file here ... ideally we should be
 +                      # able to die correctly/nicely here
 +                      touch "${T}"/.install_name_check_failed
 +              fi
 +
 +              # this is ugly, paths with spaces won't work
 +              reevaluate=0
 +              for lib in ${needed//,/ } ; do
 +                      if [[ ${lib} == ${D}* ]] ; then
 +                              eqawarn "QA Notice: install_name references \${D}: ${lib} in ${obj}"
 +                              touch "${T}"/.install_name_check_failed
 +                      elif [[ ${lib} == ${S}* ]] ; then
 +                              eqawarn "QA Notice: install_name references \${S}: ${lib} in ${obj}"
 +                              touch "${T}"/.install_name_check_failed
 +                      elif [[ ! -e ${lib} && ! -e ${D}${lib} && ${lib} != "@executable_path/"* && ${lib} != "@loader_path/"* ]] ; then
 +                              # try to "repair" this if possible, happens because of
 +                              # gen_usr_ldscript tactics
 +                              s=${lib%usr/*}${lib##*/usr/}
 +                              if [[ -e ${D}${s} ]] ; then
 +                                      ewarn "correcting install_name from ${lib} to ${s} in ${obj}"
 +                                      install_name_tool -change \
 +                                              "${lib}" "${s}" "${D}${obj}"
 +                                      reevaluate=1
 +                              else
 +                                      eqawarn "QA Notice: invalid reference to ${lib} in ${obj}"
 +                                      # remember we are in an implicit subshell, that's
 +                                      # why we touch a file here ... ideally we should be
 +                                      # able to die correctly/nicely here
 +                                      touch "${T}"/.install_name_check_failed
 +                              fi
 +                      fi
 +              done
 +              if [[ ${reevaluate} == 1 ]]; then
 +                      # install_name(s) have been changed, refresh data so we
 +                      # store the correct meta data
 +                      l=$(scanmacho -qyF '%a;%p;%S;%n' ${D}${obj})
 +                      arch=${l%%;*}; l=${l#*;}
 +                      obj="/${l%%;*}"; l=${l#*;}
 +                      install_name=${l%%;*}; l=${l#*;}
 +                      needed=${l%%;*}; l=${l#*;}
 +              fi
 +
 +              # backwards compatability
 +              echo "${obj} ${needed}" >> "${PORTAGE_BUILDDIR}"/build-info/NEEDED
 +              # what we use
 +              echo "${arch};${obj};${install_name};${needed}" >> "${PORTAGE_BUILDDIR}"/build-info/NEEDED.MACHO.3
 +      done }
 +      if [[ -f ${T}/.install_name_check_failed ]] ; then
 +              # secret switch "allow_broken_install_names" to get
 +              # around this and install broken crap (not a good idea)
-       if ! hasq binchecks ${RESTRICT}; then
++              has allow_broken_install_names ${FEATURES} || \
 +                      die "invalid install_name found, your application or library will crash at runtime"
 +      fi
 +}
 +
 +install_qa_check_pecoff() {
 +      local _pfx_scan="readpecoff ${CHOST}"
 +
 +      # this one uses readpecoff, which supports multiple prefix platforms!
 +      # this is absolutely _not_ optimized for speed, and there may be plenty
 +      # of possibilities by introducing one or the other cache!
-       if ! hasq binchecks ${RESTRICT}; then
++      if ! has binchecks ${RESTRICT}; then
 +              # copied and adapted from the above scanelf code.
 +              local qa_var insecure_rpath=0 tmp_quiet=${PORTAGE_QUIET}
 +              local f x
 +
 +              # display warnings when using stricter because we die afterwards
 +              if has stricter ${FEATURES} ; then
 +                      unset PORTAGE_QUIET
 +              fi
 +
 +              local _exec_find_opt="-executable"
 +              [[ ${CHOST} == *-winnt* ]] && _exec_find_opt='-name *.dll -o -name *.exe'
 +
 +              # Make sure we disallow insecure RUNPATH/RPATH's
 +              # Don't want paths that point to the tree where the package was built
 +              # (older, broken libtools would do this).  Also check for null paths
 +              # because the loader will search $PWD when it finds null paths.
 +
 +              f=$(
 +                      find "${ED}" -type f '(' ${_exec_find_opt} ')' -print0 | xargs -0 ${_pfx_scan} | \
 +                      while IFS=";" read arch obj soname rpath needed ; do \
 +                      echo "${rpath}" | grep -E "(${PORTAGE_BUILDDIR}|: |::|^:|^ )" > /dev/null 2>&1 \
 +                              && echo "${obj}"; done;
 +              )
 +              # Reject set*id binaries with $ORIGIN in RPATH #260331
 +              x=$(
 +                      find "${ED}" -type f '(' -perm -u+s -o -perm -g+s ')' -print0 | \
 +                      xargs -0 ${_pfx_scan} | while IFS=";" read arch obj soname rpath needed; do \
 +                      echo "${rpath}" | grep '$ORIGIN' > /dev/null 2>&1 && echo "${obj}"; done;
 +              )
 +              if [[ -n ${f}${x} ]] ; then
 +                      vecho -ne '\a\n'
 +                      eqawarn "QA Notice: The following files contain insecure RUNPATH's"
 +                      eqawarn " Please file a bug about this at http://bugs.gentoo.org/"
 +                      eqawarn " with the maintaining herd of the package."
 +                      eqawarn "${f}${f:+${x:+\n}}${x}"
 +                      vecho -ne '\a\n'
 +                      if [[ -n ${x} ]] || has stricter ${FEATURES} ; then
 +                              insecure_rpath=1
 +                      else
 +                              eqawarn "cannot automatically fix runpaths on interix platforms!"
 +                      fi
 +              fi
 +
 +              rm -f "${PORTAGE_BUILDDIR}"/build-info/NEEDED
 +              rm -f "${PORTAGE_BUILDDIR}"/build-info/NEEDED.PECOFF.1
 +
 +              # Save NEEDED information after removing self-contained providers
 +              find "${ED}" -type f '(' ${_exec_find_opt} ')' -print0 | xargs -0 ${_pfx_scan} | { while IFS=';' read arch obj soname rpath needed; do
 +                      # need to strip image dir from object name.
 +                      obj="/${obj#${D}}"
 +                      if [ -z "${rpath}" -o -n "${rpath//*ORIGIN*}" ]; then
 +                              # object doesn't contain $ORIGIN in its runpath attribute
 +                              echo "${obj} ${needed}" >> "${PORTAGE_BUILDDIR}"/build-info/NEEDED
 +                              echo "${arch};${obj};${soname};${rpath};${needed}" >> "${PORTAGE_BUILDDIR}"/build-info/NEEDED.PECOFF.1
 +                      else
 +                              dir=${obj%/*}
 +                              # replace $ORIGIN with the dirname of the current object for the lookup
 +                              opath=$(echo :${rpath}: | sed -e "s#.*:\(.*\)\$ORIGIN\(.*\):.*#\1${dir}\2#")
 +                              sneeded=$(echo ${needed} | tr , ' ')
 +                              rneeded=""
 +                              for lib in ${sneeded}; do
 +                                      found=0
 +                                      for path in ${opath//:/ }; do
 +                                              [ -e "${ED}/${path}/${lib}" ] && found=1 && break
 +                                      done
 +                                      [ "${found}" -eq 0 ] && rneeded="${rneeded},${lib}"
 +                              done
 +                              rneeded=${rneeded:1}
 +                              if [ -n "${rneeded}" ]; then
 +                                      echo "${obj} ${rneeded}" >> "${PORTAGE_BUILDDIR}"/build-info/NEEDED
 +                                      echo "${arch};${obj};${soname};${rpath};${rneeded}" >> "${PORTAGE_BUILDDIR}"/build-info/NEEDED.PECOFF.1
 +                              fi
 +                      fi
 +              done }
 +              
 +              if [[ ${insecure_rpath} -eq 1 ]] ; then
 +                      die "Aborting due to serious QA concerns with RUNPATH/RPATH"
 +              elif [[ -n ${die_msg} ]] && has stricter ${FEATURES} ; then
 +                      die "Aborting due to QA concerns: ${die_msg}"
 +              fi
 +
 +              local _so_ext='.so*'
 +
 +              case "${CHOST}" in
 +                      *-winnt*) _so_ext=".dll" ;; # no "*" intentionally!
 +              esac
 +
 +              # Run some sanity checks on shared libraries
 +              for d in "${ED}"lib* "${ED}"usr/lib* ; do
 +                      [[ -d "${d}" ]] || continue
 +                      f=$(find "${d}" -name "lib*${_so_ext}" -print0 | \
 +                              xargs -0 ${_pfx_scan} | while IFS=";" read arch obj soname rpath needed; \
 +                              do [[ -z "${soname}" ]] && echo "${obj}"; done)
 +                      if [[ -n ${f} ]] ; then
 +                              vecho -ne '\a\n'
 +                              eqawarn "QA Notice: The following shared libraries lack a SONAME"
 +                              eqawarn "${f}"
 +                              vecho -ne '\a\n'
 +                              sleep 1
 +                      fi
 +
 +                      f=$(find "${d}" -name "lib*${_so_ext}" -print0 | \
 +                              xargs -0 ${_pfx_scan} | while IFS=";" read arch obj soname rpath needed; \
 +                              do [[ -z "${needed}" ]] && echo "${obj}"; done)
 +                      if [[ -n ${f} ]] ; then
 +                              vecho -ne '\a\n'
 +                              eqawarn "QA Notice: The following shared libraries lack NEEDED entries"
 +                              eqawarn "${f}"
 +                              vecho -ne '\a\n'
 +                              sleep 1
 +                      fi
 +              done
 +
 +              PORTAGE_QUIET=${tmp_quiet}
 +      fi
 +}
 +
 +install_qa_check_xcoff() {
++      if ! has binchecks ${RESTRICT}; then
 +              local tmp_quiet=${PORTAGE_QUIET}
 +              local queryline deplib
 +              local insecure_rpath_list= undefined_symbols_list=
 +
 +              # display warnings when using stricter because we die afterwards
 +              if has stricter ${FEATURES} ; then
 +                      unset PORTAGE_QUIET
 +              fi
 +
 +              rm -f "${PORTAGE_BUILDDIR}"/build-info/NEEDED.XCOFF.1
 +
 +              local neededfd
 +              for neededfd in {3..1024} none; do ( : <&${neededfd} ) 2>/dev/null || break; done
 +              [[ ${neededfd} != none ]] || die "cannot find free file descriptor handle"
 +
 +              eval "exec ${neededfd}>\"${PORTAGE_BUILDDIR}\"/build-info/NEEDED.XCOFF.1" || die "cannot open ${PORTAGE_BUILDDIR}/build-info/NEEDED.XCOFF.1"
 +
 +              (       # work around a problem in /usr/bin/dump (used by aixdll-query)
 +                      # dumping core when path names get too long.
 +                      cd "${ED}" >/dev/null &&
 +                      find . -not -type d -exec \
 +                              aixdll-query '{}' FILE MEMBER FLAGS FORMAT RUNPATH DEPLIBS ';'
 +              ) > "${T}"/needed 2>/dev/null
 +
 +              # Symlinking shared archive libraries is not a good idea on aix,
 +              # as there is nothing like "soname" on pure filesystem level.
 +              # So we create a copy instead of the symlink.
 +              local prev_FILE=
 +              local FILE MEMBER FLAGS FORMAT RUNPATH DEPLIBS
 +              while read queryline
 +              do
 +                      FILE= MEMBER= FLAGS= FORMAT= RUNPATH= DEPLIBS=
 +                      eval ${queryline}
 +                      FILE=${FILE#./}
 +
 +                      if [[ ${prev_FILE} != ${FILE} ]]; then
 +                              if [[ " ${FLAGS} " == *" SHROBJ "* && -h ${ED}${FILE} ]]; then
 +                                      prev_FILE=${FILE}
 +                                      local target=$(readlink "${ED}${FILE}")
 +                                      if [[ ${target} == /* ]]; then
 +                                              target=${D}${target}
 +                                      else
 +                                              target=${FILE%/*}/${target}
 +                                      fi
 +                                      rm -f "${ED}${FILE}" || die "cannot prune ${FILE}"
 +                                      cp -f "${ED}${target}" "${ED}${FILE}" || die "cannot copy ${target} to ${FILE}"
 +                              fi
 +                      fi
 +              done <"${T}"/needed
 +
 +              prev_FILE=
 +              while read queryline
 +              do
 +                      FILE= MEMBER= FLAGS= FORMAT= RUNPATH= DEPLIBS=
 +                      eval ${queryline}
 +                      FILE=${FILE#./}
 +
 +                      if [[ -n ${MEMBER} && ${prev_FILE} != ${FILE} ]]; then
 +                              # Save NEEDED information for each archive library stub
 +                              # even if it is static only: the already installed archive
 +                              # may contain shared objects to be preserved.
 +                              echo "${FORMAT##* }${FORMAT%%-*};${EPREFIX}/${FILE};${FILE##*/};;" >&${neededfd}
 +                      fi
 +                      prev_FILE=${FILE}
 +
 +                      # shared objects have both EXEC and SHROBJ flags,
 +                      # while executables have EXEC flag only.
 +                      [[ " ${FLAGS} " == *" EXEC "* ]] || continue
 +
 +                      # Make sure we disallow insecure RUNPATH's
 +                      # Don't want paths that point to the tree where the package was built
 +                      # (older, broken libtools would do this).  Also check for null paths
 +                      # because the loader will search $PWD when it finds null paths.
 +                      # And we really want absolute paths only.
 +                      if [[ -n $(echo ":${RUNPATH}:" | grep -E "(${PORTAGE_BUILDDIR}|::|:[^/])") ]]; then
 +                              insecure_rpath_list="${insecure_rpath_list}\n${FILE}${MEMBER:+[${MEMBER}]}"
 +                      fi
 +
 +                      local needed=
 +                      [[ -n ${MEMBER} ]] && needed=${FILE##*/}
 +                      for deplib in ${DEPLIBS}; do
 +                              eval deplib=${deplib}
 +                              if [[ ${deplib} == '.' || ${deplib} == '..' ]]; then
 +                                      # Although we do have runtime linking, we don't want undefined symbols.
 +                                      # AIX does indicate this by needing either '.' or '..'
 +                                      undefined_symbols_list="${undefined_symbols_list}\n${FILE}"
 +                              else
 +                                      needed="${needed}${needed:+,}${deplib}"
 +                              fi
 +                      done
 +
 +                      FILE=${EPREFIX}/${FILE}
 +
 +                      [[ -n ${MEMBER} ]] && MEMBER="[${MEMBER}]"
 +                      # Save NEEDED information
 +                      echo "${FORMAT##* }${FORMAT%%-*};${FILE}${MEMBER};${FILE##*/}${MEMBER};${RUNPATH};${needed}" >&${neededfd}
 +              done <"${T}"/needed
 +
 +              eval "exec ${neededfd}>&-" || die "cannot close handle to ${PORTAGE_BUILDDIR}/build-info/NEEDED.XCOFF.1"
 +
 +              if [[ -n ${undefined_symbols_list} ]]; then
 +                      vecho -ne '\a\n'
 +                      eqawarn "QA Notice: The following files contain undefined symbols."
 +                      eqawarn " Please file a bug about this at http://bugs.gentoo.org/"
 +                      eqawarn " with 'prefix' as the maintaining herd of the package."
 +                      eqawarn "${undefined_symbols_list}"
 +                      vecho -ne '\a\n'
 +              fi
 +
 +              if [[ -n ${insecure_rpath_list} ]] ; then
 +                      vecho -ne '\a\n'
 +                      eqawarn "QA Notice: The following files contain insecure RUNPATH's"
 +                      eqawarn " Please file a bug about this at http://bugs.gentoo.org/"
 +                      eqawarn " with 'prefix' as the maintaining herd of the package."
 +                      eqawarn "${insecure_rpath_list}"
 +                      vecho -ne '\a\n'
 +                      if has stricter ${FEATURES} ; then
 +                              insecure_rpath=1
 +                      fi
 +              fi
 +
 +              if [[ ${insecure_rpath} -eq 1 ]] ; then
 +                      die "Aborting due to serious QA concerns with RUNPATH/RPATH"
 +              elif [[ -n ${die_msg} ]] && has stricter ${FEATURES} ; then
 +                      die "Aborting due to QA concerns: ${die_msg}"
 +              fi
 +
 +              PORTAGE_QUIET=${tmp_quiet}
 +      fi
 +}
 +
  
  install_mask() {
        local root="$1"
        set -${shopts}
  }
  
-       if [[ ${CHOST} != *-aix* ]] || hasq binchecks ${RESTRICT}; then
 +preinst_aix() {
-       if [[ ${CHOST} != *-aix* ]] || hasq binchecks ${RESTRICT}; then
++      if [[ ${CHOST} != *-aix* ]] || has binchecks ${RESTRICT}; then
 +              return 0
 +      fi
 +      local ar strip
 +      if type ${CHOST}-ar >/dev/null 2>&1 && type ${CHOST}-strip >/dev/null 2>&1; then
 +              ar=${CHOST}-ar
 +              strip=${CHOST}-strip
 +      elif [[ ${CBUILD} == "${CHOST}" ]] && type ar >/dev/null 2>&1 && type strip >/dev/null 2>&1; then
 +              ar=ar
 +              strip=strip
 +      elif [[ -x /usr/ccs/bin/ar && -x /usr/ccs/bin/strip ]]; then
 +              ar=/usr/ccs/bin/ar
 +              strip=/usr/ccs/bin/strip
 +      else
 +              die "cannot find where to use 'ar' and 'strip' from"
 +      fi
 +      local archives_members= archives=() chmod400files=()
 +      local archive_member soname runpath needed archive contentmember
 +      while read archive_member; do
 +              archive_member=${archive_member#*;${EPREFIX}/} # drop "^type;EPREFIX/"
 +              soname=${archive_member#*;}
 +              runpath=${soname#*;}
 +              needed=${runpath#*;}
 +              soname=${soname%%;*}
 +              runpath=${runpath%%;*}
 +              archive_member=${archive_member%%;*} # drop ";soname;runpath;needed$"
 +              archive=${archive_member%[*}
 +              if [[ ${archive_member} != *'['*']' ]]; then
 +                      if [[ "${soname};${runpath};${needed}" == "${archive##*/};;" && -e ${EROOT}${archive} ]]; then
 +                              # most likely is an archive stub that already exists,
 +                              # may have to preserve members being a shared object.
 +                              archives[${#archives[@]}]=${archive}
 +                      fi
 +                      continue
 +              fi
 +              archives_members="${archives_members}:(${archive_member}):"
 +              contentmember="${archive%/*}/.${archive##*/}${archive_member#${archive}}"
 +              # portage does os.lstat() on merged files every now
 +              # and then, so keep stamp-files for archive members
 +              # around to get the preserve-libs feature working.
 +              {       echo "Please leave this file alone, it is an important helper"
 +                      echo "for portage to implement the 'preserve-libs' feature on AIX." 
 +              } > "${ED}${contentmember}" || die "cannot create ${contentmember}"
 +              chmod400files[${#chmod400files[@]}]=${ED}${contentmember}
 +      done < "${PORTAGE_BUILDDIR}"/build-info/NEEDED.XCOFF.1
 +      [[ ${#chmod400files[@]} == 0 ]] ||
 +      chmod 0400 "${chmod400files[@]}" || die "cannot chmod ${chmod400files[@]}"
 +
 +      local preservemembers libmetadir prunedirs=()
 +      local FILE MEMBER FLAGS
 +      for archive in "${archives[@]}"; do
 +              preservemembers=
 +              while read line; do
 +                      [[ -n ${line} ]] || continue
 +                      FILE= MEMBER= FLAGS=
 +                      eval ${line}
 +                      [[ ${FILE} == ${EROOT}${archive} ]] ||
 +                      die "invalid result of aixdll-query for ${EROOT}${archive}"
 +                      [[ -n ${MEMBER} && " ${FLAGS} " == *" SHROBJ "* ]] || continue
 +                      [[ ${archives_members} == *":(${archive}[${MEMBER}]):"* ]] && continue
 +                      preservemembers="${preservemembers} ${MEMBER}"
 +              done <<-EOF
 +                      $(aixdll-query "${EROOT}${archive}" FILE MEMBER FLAGS)
 +              EOF
 +              [[ -n ${preservemembers} ]] || continue
 +              einfo "preserving (on spec) ${archive}[${preservemembers# }]"
 +              libmetadir=${ED}${archive%/*}/.${archive##*/}
 +              mkdir "${libmetadir}" || die "cannot create ${libmetadir}"
 +              pushd "${libmetadir}" >/dev/null || die "cannot cd to ${libmetadir}"
 +              ${ar} -X32_64 -x "${EROOT}${archive}" ${preservemembers} || die "cannot unpack ${EROOT}${archive}"
 +              chmod u+w ${preservemembers} || die "cannot chmod${preservemembers}"
 +              ${strip} -X32_64 -e ${preservemembers} || die "cannot strip${preservemembers}"
 +              ${ar} -X32_64 -q "${ED}${archive}" ${preservemembers} || die "cannot update ${archive}"
 +              eend $?
 +              popd >/dev/null || die "cannot leave ${libmetadir}"
 +              prunedirs[${#prunedirs[@]}]=${libmetadir}
 +      done
 +      [[ ${#prunedirs[@]} == 0 ]] ||
 +      rm -rf "${prunedirs[@]}" || die "cannot prune ${prunedirs[@]}"
 +      return 0
 +}
 +
 +postinst_aix() {
++      if [[ ${CHOST} != *-aix* ]] || has binchecks ${RESTRICT}; then
 +              return 0
 +      fi
 +      local MY_PR=${PR%r0}
 +      local ar strip
 +      if type ${CHOST}-ar >/dev/null 2>&1 && type ${CHOST}-strip >/dev/null 2>&1; then
 +              ar=${CHOST}-ar
 +              strip=${CHOST}-strip
 +      elif [[ ${CBUILD} == "${CHOST}" ]] && type ar >/dev/null 2>&1 && type strip >/dev/null 2>&1; then
 +              ar=ar
 +              strip=strip
 +      elif [[ -x /usr/ccs/bin/ar && -x /usr/ccs/bin/strip ]]; then
 +              ar=/usr/ccs/bin/ar
 +              strip=/usr/ccs/bin/strip
 +      else
 +              die "cannot find where to use 'ar' and 'strip' from"
 +      fi
 +      local archives_members= archives=() activearchives=
 +      local archive_member soname runpath needed
 +      while read archive_member; do
 +              archive_member=${archive_member#*;${EPREFIX}/} # drop "^type;EPREFIX/"
 +              soname=${archive_member#*;}
 +              runpath=${soname#*;}
 +              needed=${runpath#*;}
 +              soname=${soname%%;*}
 +              runpath=${runpath%%;*}
 +              archive_member=${archive_member%%;*} # drop ";soname;runpath;needed$"
 +              [[ ${archive_member} == *'['*']' ]] && continue
 +              [[ "${soname};${runpath};${needed}" == "${archive_member##*/};;" ]] || continue
 +              # most likely is an archive stub, we might have to
 +              # drop members being preserved shared objects.
 +              archives[${#archives[@]}]=${archive_member}
 +              activearchives="${activearchives}:(${archive_member}):"
 +      done < "${PORTAGE_BUILDDIR}"/build-info/NEEDED.XCOFF.1
 +
 +      local type allcontentmembers= oldarchives=()
 +      local contentmember
 +      while read type contentmember; do
 +              [[ ${type} == 'obj' ]] || continue
 +              contentmember=${contentmember% *} # drop " timestamp$"
 +              contentmember=${contentmember% *} # drop " hash$"
 +              [[ ${contentmember##*/} == *'['*']' ]] || continue
 +              contentmember=${contentmember#${EPREFIX}/}
 +              allcontentmembers="${allcontentmembers}:(${contentmember}):"
 +              contentmember=${contentmember%[*}
 +              contentmember=${contentmember%/.*}/${contentmember##*/.}
 +              [[ ${activearchives} == *":(${contentmember}):"* ]] && continue
 +              oldarchives[${#oldarchives[@]}]=${contentmember}
 +      done < "${EPREFIX}/var/db/pkg/${CATEGORY}/${P}${MY_PR:+-}${MY_PR}/CONTENTS"
 +
 +      local archive line delmembers
 +      local FILE MEMBER FLAGS
 +      for archive in "${archives[@]}"; do
 +              [[ -r ${EROOT}${archive} && -w ${EROOT}${archive} ]] ||
 +              chmod a+r,u+w "${EROOT}${archive}" || die "cannot chmod ${EROOT}${archive}"
 +              delmembers=
 +              while read line; do
 +                      [[ -n ${line} ]] || continue
 +                      FILE= MEMBER= FLAGS=
 +                      eval ${line}
 +                      [[ ${FILE} == "${EROOT}${archive}" ]] ||
 +                      die "invalid result '${FILE}' of aixdll-query, expected '${EROOT}${archive}'"
 +                      [[ -n ${MEMBER} && " ${FLAGS} " == *" SHROBJ "* ]] || continue
 +                      [[ ${allcontentmembers} == *":(${archive%/*}/.${archive##*/}[${MEMBER}]):"* ]] && continue
 +                      delmembers="${delmembers} ${MEMBER}"
 +              done <<-EOF
 +                      $(aixdll-query "${EROOT}${archive}" FILE MEMBER FLAGS)
 +              EOF
 +              [[ -n ${delmembers} ]] || continue
 +              einfo "dropping ${archive}[${delmembers# }]"
 +              rm -f "${EROOT}${archive}".new || die "cannot prune ${EROOT}${archive}.new"
 +              cp "${EROOT}${archive}" "${EROOT}${archive}".new || die "cannot backup ${archive}"
 +              ${ar} -X32_64 -z -o -d "${EROOT}${archive}".new ${delmembers} || die "cannot remove${delmembers} from ${archive}.new"
 +              mv -f "${EROOT}${archive}".new "${EROOT}${archive}" || die "cannot put ${EROOT}${archive} in place"
 +              eend $?
 +      done
 +      local libmetadir keepmembers prunedirs=()
 +      for archive in "${oldarchives[@]}"; do
 +              [[ -r ${EROOT}${archive} && -w ${EROOT}${archive} ]] ||
 +              chmod a+r,u+w "${EROOT}${archive}" || die "cannot chmod ${EROOT}${archive}"
 +              keepmembers=
 +              while read line; do
 +                      FILE= MEMBER= FLAGS=
 +                      eval ${line}
 +                      [[ ${FILE} == "${EROOT}${archive}" ]] ||
 +                      die "invalid result of aixdll-query for ${EROOT}${archive}"
 +                      [[ -n ${MEMBER} && " ${FLAGS} " == *" SHROBJ "* ]] || continue
 +                      [[ ${allcontentmembers} == *":(${archive%/*}/.${archive##*/}[${MEMBER}]):"* ]] || continue
 +                      keepmembers="${keepmembers} ${MEMBER}"
 +              done <<-EOF
 +                      $(aixdll-query "${EROOT}${archive}" FILE MEMBER FLAGS)
 +              EOF
 +
 +              if [[ -n ${keepmembers} ]]; then
 +                      einfo "preserving (extra)${keepmembers}"
 +                      libmetadir=${EROOT}${archive%/*}/.${archive##*/}
 +                      [[ ! -e ${libmetadir} ]] || rm -rf "${libmetadir}" || die "cannot prune ${libmetadir}"
 +                      mkdir "${libmetadir}" || die "cannot create ${libmetadir}"
 +                      pushd "${libmetadir}" >/dev/null || die "cannot cd to ${libmetadir}"
 +                      ${ar} -X32_64 -x "${EROOT}${archive}" ${keepmembers} || die "cannot unpack ${archive}"
 +                      ${strip} -X32_64 -e ${keepmembers} || die "cannot strip ${keepmembers}"
 +                      rm -f "${EROOT}${archive}.new" || die "cannot prune ${EROOT}${archive}.new"
 +                      ${ar} -X32_64 -q "${EROOT}${archive}.new" ${keepmembers} || die "cannot create ${EROOT}${archive}.new"
 +                      mv -f "${EROOT}${archive}.new" "${EROOT}${archive}" || die "cannot put ${EROOT}${archive} in place"
 +                      popd > /dev/null || die "cannot leave ${libmetadir}"
 +                      prunedirs[${#prunedirs[@]}]=${libmetadir}
 +                      eend $?
 +              fi
 +      done
 +      [[ ${#prunedirs[@]} == 0 ]] ||
 +      rm -rf "${prunedirs[@]}" || die "cannot prune ${prunedirs[@]}"
 +      return 0
 +}
 +
  preinst_mask() {
        if [ -z "${D}" ]; then
                 eerror "${FUNCNAME}: D is unset"
        # remove man pages, info pages, docs if requested
        local f
        for f in man info doc; do
-               if hasq no${f} $FEATURES; then
+               if has no${f} $FEATURES; then
 -                      INSTALL_MASK="${INSTALL_MASK} /usr/share/${f}"
 +                      INSTALL_MASK="${INSTALL_MASK} ${EPREFIX}/usr/share/${f}"
                fi
        done
  
@@@ -1545,9 -819,9 +1545,9 @@@ preinst_suid_scan() 
                 return 1
        fi
        # total suid control.
-       if hasq suidctl $FEATURES; then
+       if has suidctl $FEATURES; then
                local i sfconf x
 -              sfconf=${PORTAGE_CONFIGROOT}etc/portage/suidctl.conf
 +              sfconf=${PORTAGE_CONFIGROOT}${EPREFIX#/}/etc/portage/suidctl.conf
                # sandbox prevents us from writing directly
                # to files outside of the sandbox, but this
                # can easly be bypassed using the addwrite() function
diff --cc bin/portageq
Simple merge
diff --cc bin/repoman
Simple merge
index eded78b1ac569861a075271271903158aa744d7e,bc6511e73ca3751d57a47a08fe9e65c0572e595d..6c944e2cd021dd36045cdeccd317347ccdbf9446
@@@ -15,17 -14,11 +15,12 @@@ from portage.util import writems
  import portage
  from portage import os
  from portage import _encodings
+ from portage import _unicode_decode
  from portage import _unicode_encode
- import codecs
- import sys
- if os.environ.__contains__("PORTAGE_PYTHONPATH"):
-       sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
- else:
-       sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
- import portage
+ import io
  import logging
  from portage.output import colorize
 +from portage.const import EPREFIX
  
  class Binpkg(CompositeTask):
  
Simple merge
index 24dd4d7ec227d57341b7971e317e7bc013a807d9,f6c2721fa392ed4f9fd5d5d1a97ea1509a98c4d8..049b10f0442e06a8179166246f060105ddc352d5
@@@ -25,10 -21,10 +21,10 @@@ from itertools import chai
  
  import portage
  from portage import os
- from portage import digraph
+ from portage import subprocess_getstatusoutput
  from portage import _unicode_decode
  from portage.cache.cache_errors import CacheError
 -from portage.const import GLOBAL_CONFIG_PATH, NEWS_LIB_PATH
 +from portage.const import GLOBAL_CONFIG_PATH, NEWS_LIB_PATH, EPREFIX
  from portage.const import _ENABLE_DYN_LINK_MAP, _ENABLE_SET_CONFIG
  from portage.dbapi.dep_expand import dep_expand
  from portage.dbapi._expand_new_virt import expand_new_virt
Simple merge
index 20cec9fb8e9ad0396d631f5b9a500367900b4cc6,d6ef1b4dfe3011ae9780763d4eef7fa7d9cf72f6..629dae8430b23c2058f8ca669e550442f6bee000
@@@ -18,8 -18,12 +19,12 @@@ from portage.const import EPREFI
  # dblink.merge() and we don't want that to trigger log writes
  # unless it's really called via emerge.
  _disable = True
 -_emerge_log_dir = '/var/log'
 +_emerge_log_dir = EPREFIX + '/var/log'
  
+ # Coerce to unicode, in order to prevent TypeError when writing
+ # raw bytes to TextIOWrapper with python2.
+ _log_fmt = _unicode_decode("%.0f: %s\n")
  def emergelog(xterm_titles, mystr, short_msg=None):
  
        if _disable:
index 7a9fa9c4903761193fa37a3c00a27a3e38b08622,42ce81069b7c832160f04d4ee9d8de891b629891..b97e72b5fdf005bb4dbbf8dd9c8e9007862b8eea
@@@ -163,7 -158,9 +159,9 @@@ def chk_updated_info_files(root, infodi
                                                                        raise
                                                                del e
                                        processed_count += 1
-                                       myso=subprocess_getstatusoutput("LANG=C LANGUAGE=C "+EPREFIX+"/usr/bin/install-info --dir-file="+inforoot+"/dir "+inforoot+"/"+x)[1]
+                                       myso = portage.subprocess_getstatusoutput(
 -                                              "LANG=C LANGUAGE=C /usr/bin/install-info " +
 -                                              "--dir-file=%s/dir %s/%s" % (inforoot, inforoot, x))[1]
++                                              "LANG=C LANGUAGE=C %s/usr/bin/install-info " +
++                                              "--dir-file=%s/dir %s/%s" % (EPREFIX, inforoot, inforoot, x))[1]
                                        existsstr="already exists, for file `"
                                        if myso!="":
                                                if re.search(existsstr,myso):
Simple merge
Simple merge
Simple merge
index 3ed96e975e9e6c78b531f49020112fed4a7fcba3,9efc47ff9d5637c7f405526dad4f4f7298ebba97..e57df13bde4f9ef3f8c8fd2a839e94b590ce49e2
@@@ -37,10 -34,9 +37,9 @@@ portage.proxy.lazyimport.lazyimport(glo
  )
  
  from portage.const import CACHE_PATH, CONFIG_MEMORY_FILE, \
 -      PORTAGE_PACKAGE_ATOM, PRIVATE_PATH, VDB_PATH
 +      PORTAGE_PACKAGE_ATOM, PRIVATE_PATH, VDB_PATH, EPREFIX, EPREFIX_LSTRIP, BASH_BINARY
  from portage.const import _ENABLE_DYN_LINK_MAP, _ENABLE_PRESERVE_LIBS
  from portage.dbapi import dbapi
- from portage.dep import _slot_separator
  from portage.exception import CommandNotFound, \
        InvalidData, InvalidLocation, InvalidPackageName, \
        FileNotFound, PermissionDenied, UnsupportedAPIException
Simple merge
index f6a577e4a59445cf395f38c356edef7f3b17fafa,9350a6e580b666c20e4a2173ab2ebfe0115666b3..d1c9bb86c210f20b5e67f5d54ca5ab56ff01ac2d
@@@ -8,18 -8,24 +8,25 @@@ from portage import o
  from portage import _encodings
  from portage import _unicode_decode
  from portage import _unicode_encode
- from portage.data import portage_uid, portage_gid
- from portage.util import ensure_dirs
- from portage.const import EPREFIX
+ from portage.data import portage_gid, portage_uid
+ from portage.package.ebuild.prepare_build_dirs import _ensure_log_subdirs
+ from portage.util import ensure_dirs, normalize_path
++from portage.const import EPREFIX_LSTRIP
  
  def process(mysettings, key, logentries, fulltext):
-       path = key.replace("/", ":")
  
-       if mysettings["PORT_LOGDIR"] != "":
-               elogdir = os.path.join(mysettings["PORT_LOGDIR"], "elog")
+       if mysettings.get("PORT_LOGDIR"):
+               logdir = normalize_path(mysettings["PORT_LOGDIR"])
        else:
-               elogdir = os.path.join(EPREFIX, "var", "log", "portage", "elog")
-       ensure_dirs(elogdir, uid=portage_uid, gid=portage_gid, mode=0o2770)
 -              logdir = os.path.join(os.sep, "var", "log", "portage")
++              logdir = os.path.join(os.sep, EPREFIX_LSTRIP, "var", "log", "portage")
+       if not os.path.isdir(logdir):
+               # Only initialize group/mode if the directory doesn't
+               # exist, so that we don't override permissions if they
+               # were previously set by the administrator.
+               # NOTE: These permissions should be compatible with our
+               # default logrotate config as discussed in bug 374287.
+               ensure_dirs(logdir, uid=portage_uid, gid=portage_gid, mode=0o2770)
  
        cat = mysettings['CATEGORY']
        pf = mysettings['PF']
index 5d99a7e43a47edd286fe3994c8a39ece3af69d1d,4adc6f34cae9338b7c86458ef396709c9fb49d27..b0ea4a19484b6675e3496c50f634809320d478aa
@@@ -8,17 -8,27 +8,28 @@@ from portage import o
  from portage import _encodings
  from portage import _unicode_decode
  from portage import _unicode_encode
- from portage.data import portage_uid, portage_gid
+ from portage.data import portage_gid, portage_uid
  from portage.localization import _
- from portage.util import ensure_dirs, apply_permissions
+ from portage.package.ebuild.prepare_build_dirs import _ensure_log_subdirs
+ from portage.util import apply_permissions, ensure_dirs, normalize_path
 +from portage.const import EPREFIX_LSTRIP
  
  def process(mysettings, key, logentries, fulltext):
-       if mysettings["PORT_LOGDIR"] != "":
-               elogdir = os.path.join(mysettings["PORT_LOGDIR"], "elog")
+       if mysettings.get("PORT_LOGDIR"):
+               logdir = normalize_path(mysettings["PORT_LOGDIR"])
        else:
-               elogdir = os.path.join("/", EPREFIX_LSTRIP, "var", "log", "portage", "elog")
-       ensure_dirs(elogdir, uid=portage_uid, gid=portage_gid, mode=0o2770)
 -              logdir = os.path.join(os.sep, "var", "log", "portage")
++              logdir = os.path.join(os.sep, EPREFIX_LSTRIP, "var", "log", "portage")
+       if not os.path.isdir(logdir):
+               # Only initialize group/mode if the directory doesn't
+               # exist, so that we don't override permissions if they
+               # were previously set by the administrator.
+               # NOTE: These permissions should be compatible with our
+               # default logrotate config as discussed in bug 374287.
+               ensure_dirs(logdir, uid=portage_uid, gid=portage_gid, mode=0o2770)
+       elogdir = os.path.join(logdir, "elog")
+       _ensure_log_subdirs(logdir, elogdir)
  
        # TODO: Locking
        elogfilename = elogdir+"/summary.log"
Simple merge
index b2cc2a3a1b7fbcb289a8d5f1ca8ea40ce86b424f,2ae1fe85b0b89f1a369aea5bf4ee63dde491cbd5..388c209272ac7c28581e9ea38838478e7d937c38
@@@ -29,10 -29,9 +29,10 @@@ from portage import OrderedDict, os, se
  from portage.checksum import hashfunc_map, perform_md5, verify_all
  from portage.const import BASH_BINARY, CUSTOM_MIRRORS_FILE, \
        GLOBAL_CONFIG_PATH
 +from portage.const import rootgid
  from portage.data import portage_gid, portage_uid, secpass, userpriv_groups
  from portage.exception import FileNotFound, OperationNotPermitted, \
-       PermissionDenied, PortageException, TryAgain
+       PortageException, TryAgain
  from portage.localization import _
  from portage.locks import lockfile, unlockfile
  from portage.manifest import Manifest
index 053ebccd9b73b0544f556f4904d8aa3f05a0ed58,616dc2e06844438f12eed35768b2bfe47784bc06..16ba052e2e49dcf778cf221821d2c3487a3c642c
@@@ -16,8 -16,7 +16,8 @@@ from portage.exception import Directory
  from portage.localization import _
  from portage.output import colorize
  from portage.util import apply_recursive_permissions, \
-       apply_secpass_permissions, ensure_dirs, writemsg
+       apply_secpass_permissions, ensure_dirs, normalize_path, writemsg
 +from portage.const import EPREFIX
  
  def prepare_build_dirs(myroot=None, settings=None, cleanup=False):
        """
Simple merge
index 4587a2ca73e3dcc47b85d10393e8827964f59358,eb8a0d95139d1f79d163451709dc09f9bd4f8c08..2650f152331aa6dcddf52598bbb05f71b3b48669
@@@ -124,19 -123,9 +124,19 @@@ def env_update(makelinks=1, target_root
                they won't be overwritten by this dict.update call."""
                env.update(myconfig)
  
 +      if EPREFIX == '':
 +              dolinkingstuff(target_root, specials, prelink_capable,
 +                              makelinks, contents, prev_mtimes, env)
 +      writeshellprofile(target_root, env)
 +
 +def dolinkingstuff(target_root, specials, prelink_capable, makelinks,
 +              contents, prev_mtimes, env):
 +      # updating this stuff will never work in an offset, other than ROOT
 +      # (e.g. not in Prefix), hence the EPREFIX is not taken into account
 +      # here since this code should never be triggered on an offset install
        ldsoconf_path = os.path.join(target_root, "etc", "ld.so.conf")
        try:
-               myld = codecs.open(_unicode_encode(ldsoconf_path,
+               myld = io.open(_unicode_encode(ldsoconf_path,
                        encoding=_encodings['fs'], errors='strict'),
                        mode='r', encoding=_encodings['content'], errors='replace')
                myldlines=myld.readlines()