commit:     c5f668f60d49c36d2c5ff75d57266bb43c5e84da
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May 18 19:25:41 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May 18 19:25:41 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=c5f668f6

Merge remote-tracking branch 'overlays-gentoo-org/master' into prefix

 .travis.yml                                        |    4 +
 NEWS                                               |   17 +
 RELEASE-NOTES                                      |  195 ++++
 bin/doins.py                                       |   38 +-
 bin/eapi.sh                                        |   60 +-
 bin/eapi7-ver-funcs.sh                             |  191 ++++
 bin/ebuild                                         |   10 +-
 bin/ebuild-helpers/dobin                           |   16 +-
 bin/ebuild-helpers/doconfd                         |   11 +-
 bin/ebuild-helpers/dodir                           |    4 +-
 bin/ebuild-helpers/dodoc                           |    2 +-
 bin/ebuild-helpers/doenvd                          |   11 +-
 bin/ebuild-helpers/doexe                           |    8 +-
 bin/ebuild-helpers/dohard                          |    6 +-
 bin/ebuild-helpers/doheader                        |    8 +-
 bin/ebuild-helpers/dohtml                          |    7 +-
 bin/ebuild-helpers/doinfo                          |    8 +-
 bin/ebuild-helpers/doins                           |   20 +-
 bin/ebuild-helpers/dolib                           |   17 +-
 bin/ebuild-helpers/dolib.a                         |    4 +-
 bin/ebuild-helpers/dolib.so                        |    4 +-
 bin/ebuild-helpers/doman                           |    8 +-
 bin/ebuild-helpers/domo                            |   21 +-
 bin/ebuild-helpers/dosbin                          |   16 +-
 bin/ebuild-helpers/dosed                           |    4 +-
 bin/ebuild-helpers/dosym                           |    8 +-
 bin/ebuild-helpers/ecompressdir                    |   27 +-
 bin/ebuild-helpers/fowners                         |    4 +-
 bin/ebuild-helpers/fperms                          |    4 +-
 bin/ebuild-helpers/keepdir                         |    6 +-
 bin/ebuild-helpers/newins                          |    2 +-
 bin/ebuild-helpers/nonfatal                        |   14 +
 bin/ebuild-helpers/prepall                         |    2 +-
 bin/ebuild-helpers/prepalldocs                     |    4 +-
 bin/ebuild-helpers/prepallinfo                     |    4 +-
 bin/ebuild-helpers/prepallstrip                    |    4 +
 bin/ebuild-helpers/prepinfo                        |   12 +-
 bin/ebuild-helpers/prepman                         |   10 +-
 bin/ebuild-helpers/prepstrip                       |  401 +-------
 bin/ebuild-ipc.py                                  |   55 +-
 bin/ebuild.sh                                      |   50 +-
 bin/egencache                                      |    5 +-
 bin/emaint                                         |    3 +
 bin/emerge                                         |    6 +
 bin/emerge-webrsync                                |   11 +-
 bin/emirrordist                                    |    6 +-
 bin/{ebuild-helpers/prepstrip => estrip}           |   98 +-
 bin/etc-update                                     |   55 +-
 bin/filter-bash-environment.py                     |   47 +-
 bin/install-qa-check.d/10ignored-flags             |    2 +-
 bin/install-qa-check.d/60udev                      |    6 +-
 bin/install-qa-check.d/80libraries                 |   24 +-
 bin/install-qa-check.d/90cmake-warnings            |   28 +
 bin/install-qa-check.d/95empty-dirs                |   42 +
 bin/isolated-functions.sh                          |   40 +-
 bin/misc-functions.sh                              |   91 +-
 bin/phase-functions.sh                             |   60 +-
 bin/phase-helpers.sh                               |  273 ++---
 bin/portageq                                       |   24 +-
 bin/postinst-qa-check.d/50gnome2-utils             |    3 +
 bin/quickpkg                                       |   14 +-
 bin/save-ebuild-env.sh                             |    8 +-
 bin/xattr-helper.py                                |   19 +-
 cnf/repos.conf                                     |    9 +
 man/ebuild.5                                       |   28 +-
 man/egencache.1                                    |    6 +-
 man/emaint.1                                       |   22 +-
 man/emerge.1                                       |  166 ++--
 man/make.conf.5                                    |    4 +
 man/portage.5                                      |   45 +-
 misc/emerge-delta-webrsync                         |   11 +-
 pym/_emerge/AbstractEbuildProcess.py               |   97 +-
 pym/_emerge/AbstractPollTask.py                    |   87 +-
 pym/_emerge/AsynchronousLock.py                    |   76 +-
 pym/_emerge/AsynchronousTask.py                    |   60 +-
 pym/_emerge/Binpkg.py                              |   78 +-
 pym/_emerge/BinpkgExtractorAsync.py                |   16 +-
 pym/_emerge/BinpkgFetcher.py                       |  104 +-
 pym/_emerge/BlockerDB.py                           |    4 +-
 pym/_emerge/CompositeTask.py                       |   46 +-
 pym/_emerge/EbuildBuild.py                         |   99 +-
 pym/_emerge/EbuildBuildDir.py                      |  172 ++--
 pym/_emerge/EbuildExecuter.py                      |    6 +-
 pym/_emerge/EbuildFetcher.py                       |  135 ++-
 pym/_emerge/EbuildIpcDaemon.py                     |   28 +-
 pym/_emerge/EbuildMerge.py                         |   26 +-
 pym/_emerge/EbuildMetadataPhase.py                 |   55 +-
 pym/_emerge/EbuildPhase.py                         |   35 +-
 pym/_emerge/FakeVartree.py                         |    2 +-
 pym/_emerge/FifoIpcDaemon.py                       |   32 +-
 pym/_emerge/MetadataRegen.py                       |   14 +-
 pym/_emerge/Package.py                             |   85 +-
 pym/_emerge/PackagePhase.py                        |   93 ++
 pym/_emerge/PackageUninstall.py                    |   37 +-
 pym/_emerge/PipeReader.py                          |   42 +-
 pym/_emerge/Scheduler.py                           |  109 +-
 pym/_emerge/SpawnProcess.py                        |   23 +-
 pym/_emerge/SubProcess.py                          |  123 +--
 pym/_emerge/actions.py                             |   76 +-
 pym/_emerge/create_depgraph_params.py              |   23 +-
 pym/_emerge/create_world_atom.py                   |    6 +-
 pym/_emerge/depgraph.py                            |  202 +++-
 pym/_emerge/main.py                                |   50 +-
 pym/_emerge/resolver/DbapiProvidesIndex.py         |    3 +-
 pym/_emerge/resolver/output.py                     |    4 +-
 pym/_emerge/search.py                              |    4 +
 pym/_emerge/show_invalid_depstring_notice.py       |    4 +-
 pym/portage/__init__.py                            |   65 +-
 pym/portage/_emirrordist/FetchIterator.py          |  323 ++++--
 pym/portage/_emirrordist/FetchTask.py              |    2 +-
 pym/portage/_emirrordist/MirrorDistTask.py         |   27 +-
 pym/portage/_legacy_globals.py                     |    3 +-
 pym/portage/_sets/base.py                          |   17 +-
 pym/portage/cache/metadata.py                      |    4 +-
 pym/portage/const.py                               |   10 +-
 pym/portage/dbapi/IndexedVardb.py                  |    2 +-
 pym/portage/dbapi/_MergeProcess.py                 |   47 +-
 pym/portage/dbapi/__init__.py                      |   48 +-
 pym/portage/dbapi/bintree.py                       |  105 +-
 pym/portage/dbapi/dep_expand.py                    |    2 +-
 pym/portage/dbapi/porttree.py                      |  256 ++++-
 pym/portage/dbapi/vartree.py                       |   76 +-
 pym/portage/dbapi/virtual.py                       |    4 +-
 pym/portage/dep/__init__.py                        |   27 +-
 pym/portage/dep/_slot_operator.py                  |    7 +-
 pym/portage/dep/dep_check.py                       |   75 +-
 pym/portage/dep/soname/multilib_category.py        |    4 +-
 pym/portage/eapi.py                                |   53 +-
 pym/portage/emaint/modules/binhost/binhost.py      |    1 +
 pym/portage/emaint/modules/move/move.py            |    4 +-
 pym/portage/exception.py                           |    3 +
 pym/portage/module.py                              |   49 +-
 .../package/ebuild/_config/LocationsManager.py     |   25 +-
 pym/portage/package/ebuild/_config/MaskManager.py  |   10 +-
 .../package/ebuild/_config/special_env_vars.py     |   13 +-
 pym/portage/package/ebuild/_ipc/QueryCommand.py    |    4 +-
 .../ebuild/_parallel_manifest/ManifestScheduler.py |   25 +-
 .../ebuild/_parallel_manifest/ManifestTask.py      |   24 +-
 pym/portage/package/ebuild/config.py               |  190 ++--
 pym/portage/package/ebuild/doebuild.py             |   98 +-
 pym/portage/package/ebuild/prepare_build_dirs.py   |   31 +-
 pym/portage/package/ebuild/profile_iuse.py         |   32 +
 pym/portage/process.py                             |   39 +-
 pym/portage/repository/config.py                   |   36 +-
 pym/portage/sync/modules/git/__init__.py           |    3 +-
 pym/portage/sync/modules/git/git.py                |   95 +-
 pym/portage/sync/modules/rsync/__init__.py         |    5 +-
 pym/portage/sync/modules/rsync/rsync.py            |  508 ++++++----
 pym/portage/sync/syncbase.py                       |   87 +-
 pym/portage/tests/__init__.py                      |   20 +-
 pym/portage/tests/bin/test_doins.py                |    7 +-
 pym/portage/tests/bin/test_eapi7_ver_funcs.py      |  240 +++++
 pym/portage/tests/bin/test_filter_bash_env.py      |  115 +++
 pym/portage/tests/dbapi/test_portdb_cache.py       |    3 +-
 pym/portage/tests/dep/testCheckRequiredUse.py      |    5 +-
 pym/portage/tests/dep/test_overlap_dnf.py          |    2 +-
 pym/portage/tests/ebuild/test_ipc_daemon.py        |   18 +-
 pym/portage/tests/emerge/test_simple.py            |   51 +-
 pym/portage/tests/locks/test_asynchronous_lock.py  |   22 +-
 pym/portage/tests/resolver/ResolverPlayground.py   |   12 +-
 pym/portage/tests/resolver/test_autounmask.py      |   71 +-
 pym/portage/tests/resolver/test_changed_deps.py    |    1 +
 pym/portage/tests/resolver/test_complete_graph.py  |   20 +-
 pym/portage/tests/resolver/test_eapi.py            |    9 +-
 pym/portage/tests/resolver/test_multirepo.py       |    4 +-
 .../tests/resolver/test_or_upgrade_installed.py    |  160 +++
 pym/portage/tests/resolver/test_required_use.py    |   22 +-
 .../resolver/test_slot_change_without_revbump.py   |   19 +
 pym/portage/tests/resolver/test_slot_collisions.py |   20 +-
 .../tests/resolver/test_slot_operator_rebuild.py   |   45 +-
 .../resolver/test_virtual_minimize_children.py     |  144 ++-
 pym/portage/tests/resolver/test_virtual_slot.py    |    2 +-
 .../tests/resolver/test_virtual_transition.py      |   51 -
 pym/portage/tests/runTests.py                      |    6 +-
 .../util/futures/asyncio}/__init__.py              |    0
 .../{bin => util/futures/asyncio}/__test__.py      |    0
 .../util/futures/asyncio/test_child_watcher.py     |   50 +
 .../futures/asyncio/test_event_loop_in_fork.py     |   65 ++
 .../tests/util/futures/asyncio/test_pipe_closed.py |  151 +++
 .../asyncio/test_policy_wrapper_recursion.py       |   29 +
 .../futures/asyncio/test_run_until_complete.py     |   34 +
 .../util/futures/asyncio/test_subprocess_exec.py   |  236 +++++
 .../tests/util/futures/test_iter_completed.py      |   86 ++
 pym/portage/tests/util/futures/test_retry.py       |  234 +++++
 pym/portage/util/SlotObject.py                     |    9 +-
 pym/portage/util/_async/AsyncFunction.py           |    7 +-
 pym/portage/util/_async/AsyncScheduler.py          |   49 +-
 pym/portage/util/_async/AsyncTaskFuture.py         |   31 +
 pym/portage/util/_async/FileDigester.py            |    7 +-
 pym/portage/util/_async/ForkProcess.py             |   10 +
 pym/portage/util/_async/PipeLogger.py              |   32 +-
 pym/portage/util/_async/PipeReaderBlockingIO.py    |   16 +-
 pym/portage/util/_async/PopenProcess.py            |   17 +-
 pym/portage/util/_async/SchedulerInterface.py      |   34 +-
 .../util/_dyn_libs/PreservedLibsRegistry.py        |    3 +-
 pym/portage/util/_eventloop/EventLoop.py           |  462 ++++++++-
 pym/portage/util/_eventloop/GlibEventLoop.py       |   23 -
 pym/portage/util/_eventloop/asyncio_event_loop.py  |   85 ++
 pym/portage/util/_eventloop/global_event_loop.py   |   11 +-
 pym/portage/util/backoff.py                        |   53 +
 pym/portage/util/elf/constants.py                  |    5 +-
 pym/portage/util/futures/__init__.py               |    8 +
 pym/portage/util/futures/_asyncio/__init__.py      |  185 ++++
 pym/portage/util/futures/_asyncio/tasks.py         |  105 ++
 pym/portage/util/futures/events.py                 |  191 ++++
 .../modules => util/futures/executor}/__init__.py  |    0
 pym/portage/util/futures/executor/fork.py          |  136 +++
 pym/portage/util/futures/futures.py                |   15 +-
 pym/portage/util/futures/iter_completed.py         |  183 ++++
 pym/portage/util/futures/retry.py                  |  182 ++++
 pym/portage/util/futures/transports.py             |   90 ++
 pym/portage/util/futures/unix_events.py            |  705 +++++++++++++
 pym/portage/util/install_mask.py                   |  125 +++
 pym/portage/util/monotonic.py                      |   34 +
 pym/portage/util/movefile.py                       |    4 +-
 pym/portage/versions.py                            |    6 +-
 repoman/NEWS                                       |    5 +
 repoman/RELEASE-NOTES                              |   13 +
 repoman/bin/repoman                                |    3 +
 repoman/cnf/linechecks/linechecks.yaml             |   35 +
 repoman/cnf/qa_data/qa_data.yaml                   |  136 +++
 repoman/cnf/repository/linechecks.yaml             |  252 +++++
 repoman/cnf/repository/qa_data.yaml                |  160 +++
 repoman/cnf/repository/repository.yaml             |   76 ++
 repoman/man/repoman.1                              |   29 +-
 repoman/pym/repoman/actions.py                     |  100 +-
 repoman/pym/repoman/argparser.py                   |    8 +-
 repoman/pym/repoman/config.py                      |  159 +++
 repoman/pym/repoman/main.py                        |   30 +-
 repoman/pym/repoman/metadata.py                    |    2 +-
 .../__test__.py => modules/linechecks/__init__.py} |    0
 .../modules/linechecks/assignment/__init__.py      |   28 +
 .../modules/linechecks/assignment/assignment.py    |   38 +
 repoman/pym/repoman/modules/linechecks/base.py     |  101 ++
 repoman/pym/repoman/modules/linechecks/config.py   |  118 +++
 .../pym/repoman/modules/linechecks/controller.py   |  145 +++
 .../repoman/modules/linechecks/depend/__init__.py  |   22 +
 .../repoman/modules/linechecks/depend/implicit.py  |   39 +
 .../modules/linechecks/deprecated/__init__.py      |   47 +
 .../modules/linechecks/deprecated/deprecated.py    |   32 +
 .../modules/linechecks/deprecated/inherit.py       |   69 ++
 .../pym/repoman/modules/linechecks/do/__init__.py  |   22 +
 repoman/pym/repoman/modules/linechecks/do/dosym.py |   16 +
 .../repoman/modules/linechecks/eapi/__init__.py    |   52 +
 .../pym/repoman/modules/linechecks/eapi/checks.py  |   83 ++
 .../repoman/modules/linechecks/eapi/definition.py  |   36 +
 .../repoman/modules/linechecks/emake/__init__.py   |   28 +
 .../pym/repoman/modules/linechecks/emake/emake.py  |   23 +
 .../modules/linechecks/gentoo_header/__init__.py   |   22 +
 .../modules/linechecks/gentoo_header/header.py     |   49 +
 .../repoman/modules/linechecks/helpers/__init__.py |   22 +
 .../repoman/modules/linechecks/helpers/offset.py   |   22 +
 .../repoman/modules/linechecks/nested/__init__.py  |   22 +
 .../repoman/modules/linechecks/nested/nested.py    |   15 +
 .../repoman/modules/linechecks/nested/nesteddie.py |   11 +
 .../repoman/modules/linechecks/patches/__init__.py |   22 +
 .../repoman/modules/linechecks/patches/patches.py  |   16 +
 .../repoman/modules/linechecks/phases/__init__.py  |   35 +
 .../pym/repoman/modules/linechecks/phases/phase.py |   71 ++
 .../repoman/modules/linechecks/portage/__init__.py |   28 +
 .../repoman/modules/linechecks/portage/internal.py |   37 +
 .../repoman/modules/linechecks/quotes/__init__.py  |   28 +
 .../repoman/modules/linechecks/quotes/quoteda.py   |   16 +
 .../repoman/modules/linechecks/quotes/quotes.py    |   87 ++
 .../pym/repoman/modules/linechecks/uri/__init__.py |   22 +
 repoman/pym/repoman/modules/linechecks/uri/uri.py  |   30 +
 .../pym/repoman/modules/linechecks/use/__init__.py |   22 +
 .../repoman/modules/linechecks/use/builtwith.py    |   10 +
 .../repoman/modules/linechecks/useless/__init__.py |   28 +
 .../pym/repoman/modules/linechecks/useless/cd.py   |   24 +
 .../repoman/modules/linechecks/useless/dodoc.py    |   16 +
 .../modules/linechecks/whitespace/__init__.py      |   28 +
 .../repoman/modules/linechecks/whitespace/blank.py |   25 +
 .../modules/linechecks/whitespace/whitespace.py    |   21 +
 .../modules/linechecks/workaround/__init__.py      |   28 +
 .../modules/linechecks/workaround/workarounds.py   |   18 +
 .../pym/repoman/modules/scan/depend/__init__.py    |    4 +-
 .../repoman/modules/scan/depend/_depend_checks.py  |   11 +-
 repoman/pym/repoman/modules/scan/depend/profile.py |    5 +-
 .../repoman/modules/scan/directories/__init__.py   |    5 +-
 repoman/pym/repoman/modules/scan/eapi/__init__.py  |    4 +-
 repoman/pym/repoman/modules/scan/eapi/eapi.py      |    4 +-
 .../pym/repoman/modules/scan/ebuild/__init__.py    |    7 +-
 repoman/pym/repoman/modules/scan/ebuild/checks.py  | 1044 --------------------
 repoman/pym/repoman/modules/scan/ebuild/ebuild.py  |    5 +-
 repoman/pym/repoman/modules/scan/ebuild/errors.py  |   53 -
 .../pym/repoman/modules/scan/ebuild/multicheck.py  |   10 +-
 .../pym/repoman/modules/scan/eclasses/__init__.py  |    7 +-
 repoman/pym/repoman/modules/scan/eclasses/ruby.py  |    5 +-
 repoman/pym/repoman/modules/scan/fetch/__init__.py |    4 +-
 repoman/pym/repoman/modules/scan/fetch/fetches.py  |    2 +-
 .../pym/repoman/modules/scan/keywords/__init__.py  |    4 +-
 .../pym/repoman/modules/scan/manifest/__init__.py  |    4 +-
 .../pym/repoman/modules/scan/metadata/__init__.py  |   13 +-
 .../repoman/modules/scan/metadata/description.py   |    6 +-
 .../modules/scan/metadata/ebuild_metadata.py       |   14 +-
 .../repoman/modules/scan/metadata/pkgmetadata.py   |    2 +-
 .../pym/repoman/modules/scan/metadata/restrict.py  |    4 +-
 repoman/pym/repoman/modules/scan/module.py         |  102 ++
 .../pym/repoman/modules/scan/options/__init__.py   |    4 +-
 repoman/pym/repoman/qa_data.py                     |  454 ++-------
 repoman/pym/repoman/qa_tracker.py                  |   10 +-
 repoman/pym/repoman/repos.py                       |   21 +-
 repoman/pym/repoman/scanner.py                     |   84 +-
 repoman/pym/repoman/tests/__init__.py              |    3 +
 .../pym/repoman/tests/commit}/__init__.py          |    2 +-
 .../repoman/tests/{simple => commit}/__test__.py   |    0
 repoman/pym/repoman/tests/commit/test_commitmsg.py |  109 ++
 repoman/pym/repoman/tests/runTests.py              |   14 +-
 repoman/pym/repoman/tests/simple/test_simple.py    |    8 +-
 repoman/pym/repoman/utilities.py                   |   22 +-
 repoman/setup.py                                   |   11 +-
 setup.py                                           |    5 +-
 src/portage_util_file_copy_reflink_linux.c         |    4 +-
 314 files changed, 12015 insertions(+), 4462 deletions(-)

diff --cc bin/eapi.sh
index ac22e6fc9,455bc9b0d..3d1445ede
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 2012 Gentoo Foundation
+ # Copyright 2012-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  # PHASES
diff --cc bin/ebuild
index d5939db89,710257549..75860e1a8
--- a/bin/ebuild
+++ b/bin/ebuild
@@@ -1,5 -1,5 +1,5 @@@
 -#!/usr/bin/python -b
 +#!@PREFIX_PORTAGE_PYTHON@ -b
- # Copyright 1999-2015 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  from __future__ import print_function
diff --cc bin/ebuild-helpers/dobin
index dc999ec04,975067fb1..0f0518aba
--- a/bin/ebuild-helpers/dobin
+++ b/bin/ebuild-helpers/dobin
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2012 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
diff --cc bin/ebuild-helpers/doconfd
index 441167d66,15ad980f3..e32c9d5c0
--- a/bin/ebuild-helpers/doconfd
+++ b/bin/ebuild-helpers/doconfd
@@@ -1,9 -1,10 +1,10 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2010 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
+ source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
+ 
  if [[ $# -lt 1 ]] ; then
-       source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
        __helpers_die "${0##*/}: at least one argument needed"
        exit 1
  fi
diff --cc bin/ebuild-helpers/dodir
index b1502c8ae,9b376c73f..4d309e4b1
--- a/bin/ebuild-helpers/dodir
+++ b/bin/ebuild-helpers/dodir
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2012 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
diff --cc bin/ebuild-helpers/doenvd
index c536ffd7a,f14b95104..4e8068659
--- a/bin/ebuild-helpers/doenvd
+++ b/bin/ebuild-helpers/doenvd
@@@ -1,9 -1,10 +1,10 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2010 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
+ source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
+ 
  if [[ $# -lt 1 ]] ; then
-       source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
        __helpers_die "${0##*/}: at least one argument needed"
        exit 1
  fi
diff --cc bin/ebuild-helpers/doexe
index 1e8665722,152c13bf6..5fa8f058d
--- a/bin/ebuild-helpers/doexe
+++ b/bin/ebuild-helpers/doexe
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2012 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
diff --cc bin/ebuild-helpers/dohard
index 8670200ad,66e2604b0..1dd2eb582
--- a/bin/ebuild-helpers/dohard
+++ b/bin/ebuild-helpers/dohard
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2012 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
diff --cc bin/ebuild-helpers/doheader
index 101b75742,aedc2322a..a87536c33
--- a/bin/ebuild-helpers/doheader
+++ b/bin/ebuild-helpers/doheader
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2012 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
diff --cc bin/ebuild-helpers/dohtml
index fe2e97d05,49d6a6dfb..a60dbdab8
--- a/bin/ebuild-helpers/dohtml
+++ b/bin/ebuild-helpers/dohtml
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 2009-2013 Gentoo Foundation
+ # Copyright 2009-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
diff --cc bin/ebuild-helpers/doinfo
index 1a2051b54,30a38e055..e261e9e74
--- a/bin/ebuild-helpers/doinfo
+++ b/bin/ebuild-helpers/doinfo
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2012 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
diff --cc bin/ebuild-helpers/doins
index 04bfdd0d4,fb5fc7c7c..cf843bce5
--- a/bin/ebuild-helpers/doins
+++ b/bin/ebuild-helpers/doins
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2012 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
diff --cc bin/ebuild-helpers/dolib
index e817896f2,bd8eebca7..049088de7
--- a/bin/ebuild-helpers/dolib
+++ b/bin/ebuild-helpers/dolib
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2012 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
diff --cc bin/ebuild-helpers/dolib.a
index f7670d0f5,5ea126b5d..f45aed3e6
--- a/bin/ebuild-helpers/dolib.a
+++ b/bin/ebuild-helpers/dolib.a
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2006 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
- LIBOPTIONS='-m0644' exec dolib "$@"
+ LIBOPTIONS='-m0644' PORTAGE_INTERNAL_DOLIB=1 exec dolib "$@"
diff --cc bin/ebuild-helpers/dolib.so
index 0b1e5fa62,a3b579e5e..2272679c8
--- a/bin/ebuild-helpers/dolib.so
+++ b/bin/ebuild-helpers/dolib.so
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2006 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
- LIBOPTIONS='-m0755' exec dolib "$@"
+ LIBOPTIONS='-m0755' PORTAGE_INTERNAL_DOLIB=1 exec dolib "$@"
diff --cc bin/ebuild-helpers/doman
index 500caff43,9cfc89df0..bfd7356a0
--- a/bin/ebuild-helpers/doman
+++ b/bin/ebuild-helpers/doman
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2012 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
diff --cc bin/ebuild-helpers/domo
index 10ae2fc41,2e95eb751..fb1475470
--- a/bin/ebuild-helpers/domo
+++ b/bin/ebuild-helpers/domo
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2012 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
diff --cc bin/ebuild-helpers/dosbin
index 9cd4d975e,ac0ab37ca..e92286088
--- a/bin/ebuild-helpers/dosbin
+++ b/bin/ebuild-helpers/dosbin
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2012 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
diff --cc bin/ebuild-helpers/dosed
index dfc30f06b,37c8a29d3..44752f54e
--- a/bin/ebuild-helpers/dosed
+++ b/bin/ebuild-helpers/dosed
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2012 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
diff --cc bin/ebuild-helpers/dosym
index a2157e96e,d5a651bf5..da15fe397
--- a/bin/ebuild-helpers/dosym
+++ b/bin/ebuild-helpers/dosym
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2017 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
diff --cc bin/ebuild-helpers/ecompressdir
index 18a2fae7f,dacb857be..9e8fd40f3
--- a/bin/ebuild-helpers/ecompressdir
+++ b/bin/ebuild-helpers/ecompressdir
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2013 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/helper-functions.sh || exit 1
diff --cc bin/ebuild-helpers/fowners
index f98b65aad,68004210b..981a6f895
--- a/bin/ebuild-helpers/fowners
+++ b/bin/ebuild-helpers/fowners
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2012 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
diff --cc bin/ebuild-helpers/fperms
index 1f031d06f,c63a6abc3..91cd8371c
--- a/bin/ebuild-helpers/fperms
+++ b/bin/ebuild-helpers/fperms
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2012 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
diff --cc bin/ebuild-helpers/keepdir
index b76c74bab,a3c0c151c..9b8986a5e
--- a/bin/ebuild-helpers/keepdir
+++ b/bin/ebuild-helpers/keepdir
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2013 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
diff --cc bin/ebuild-helpers/prepalldocs
index 2252b5250,6cdceb318..d38f8b943
--- a/bin/ebuild-helpers/prepalldocs
+++ b/bin/ebuild-helpers/prepalldocs
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2012 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
diff --cc bin/ebuild-helpers/prepallinfo
index 18cee4b9c,34d6a74b7..7d1ead071
--- a/bin/ebuild-helpers/prepallinfo
+++ b/bin/ebuild-helpers/prepallinfo
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2012 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
diff --cc bin/ebuild-helpers/prepinfo
index 80bfb74be,eb1b6a7e3..bac66f2f8
--- a/bin/ebuild-helpers/prepinfo
+++ b/bin/ebuild-helpers/prepinfo
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2012 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
diff --cc bin/ebuild-helpers/prepman
index 7302956d9,5e9fe45b6..998d69065
--- a/bin/ebuild-helpers/prepman
+++ b/bin/ebuild-helpers/prepman
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2012 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  # Do not compress man pages which are smaller than this (in bytes). #169260
diff --cc bin/ebuild-helpers/prepstrip
index 62daf817e,ecbea47ec..4a899ee1a
--- a/bin/ebuild-helpers/prepstrip
+++ b/bin/ebuild-helpers/prepstrip
@@@ -1,402 -1,11 +1,11 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2014 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
- source "${PORTAGE_BIN_PATH}"/helper-functions.sh || exit 1
+ source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
  
- # avoid multiple calls to `has`.  this creates things like:
- #   FEATURES_foo=false
- # if "foo" is not in $FEATURES
- tf() { "$@" && echo true || echo false ; }
- exp_tf() {
-       local flag var=$1
-       shift
-       for flag in "$@" ; do
-               eval ${var}_${flag}=$(tf has ${flag} ${!var})
-       done
- }
- exp_tf FEATURES compressdebug installsources nostrip splitdebug xattr
- exp_tf RESTRICT binchecks installsources splitdebug strip
- 
- if ! ___eapi_has_prefix_variables; then
-       EPREFIX= ED=${D}
- fi
- 
- banner=false
- SKIP_STRIP=false
- if ${RESTRICT_strip} || ${FEATURES_nostrip} ; then
-       SKIP_STRIP=true
-       banner=true
-       ${FEATURES_installsources} || exit 0
- fi
- 
- PRESERVE_XATTR=false
- if [[ ${KERNEL} == linux ]] && ${FEATURES_xattr} ; then
-       PRESERVE_XATTR=true
-       if type -P getfattr >/dev/null && type -P setfattr >/dev/null ; then
-               dump_xattrs() {
-                       getfattr -d --absolute-names "$1"
-               }
-               restore_xattrs() {
-                       setfattr --restore=-
-               }
-       else
-               dump_xattrs() {
-                       PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
-                       "${PORTAGE_PYTHON:-/usr/bin/python}" \
-                       "${PORTAGE_BIN_PATH}/xattr-helper.py" --dump < <(echo 
-n "$1")
-               }
-               restore_xattrs() {
-                       PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
-                       "${PORTAGE_PYTHON:-/usr/bin/python}" \
-                       "${PORTAGE_BIN_PATH}/xattr-helper.py" --restore
-               }
-       fi
- fi
- 
- # look up the tools we might be using
- for t in STRIP:strip OBJCOPY:objcopy READELF:readelf ; do
-       v=${t%:*} # STRIP
-       t=${t#*:} # strip
-       eval ${v}=\"${!v:-${CHOST}-${t}}\"
-       type -P -- ${!v} >/dev/null || eval ${v}=${t}
- done
- 
- # Figure out what tool set we're using to strip stuff
- unset SAFE_STRIP_FLAGS DEF_STRIP_FLAGS SPLIT_STRIP_FLAGS
- case $(${STRIP} --version 2>/dev/null) in
- *elfutils*) # dev-libs/elfutils
-       # elfutils default behavior is always safe, so don't need to specify
-       # any flags at all
-       SAFE_STRIP_FLAGS=""
-       DEF_STRIP_FLAGS="--remove-comment"
-       SPLIT_STRIP_FLAGS="-f"
-       ;;
- *GNU*) # sys-devel/binutils
-       # We'll leave out -R .note for now until we can check out the relevance
-       # of the section when it has the ALLOC flag set on it ...
-       SAFE_STRIP_FLAGS="--strip-unneeded"
-       DEF_STRIP_FLAGS="-R .comment -R .GCC.command.line -R 
.note.gnu.gold-version"
-       SPLIT_STRIP_FLAGS=
-       ;;
- esac
- : ${PORTAGE_STRIP_FLAGS=${SAFE_STRIP_FLAGS} ${DEF_STRIP_FLAGS}}
- 
- prepstrip_sources_dir=${EPREFIX}/usr/src/debug/${CATEGORY}/${PF}
- 
- debugedit=$(type -P debugedit)
- if [[ -z ${debugedit} ]]; then
-       debugedit_paths=(
-               "${EPREFIX}/usr/libexec/rpm/debugedit"
-       )
-       for x in "${debugedit_paths[@]}"; do
-               if [[ -x ${x} ]]; then
-                       debugedit=${x}
-                       break
-               fi
-       done
- fi
- [[ ${debugedit} ]] && debugedit_found=true || debugedit_found=false
- debugedit_warned=false
- 
- __multijob_init
- 
- # Setup $T filesystem layout that we care about.
- tmpdir="${T}/prepstrip"
- rm -rf "${tmpdir}"
- mkdir -p "${tmpdir}"/{inodes,splitdebug,sources}
- 
- # Usage: save_elf_sources <elf>
- save_elf_sources() {
-       ${FEATURES_installsources} || return 0
-       ${RESTRICT_installsources} && return 0
-       if ! ${debugedit_found} ; then
-               if ! ${debugedit_warned} ; then
-                       debugedit_warned=true
-                       ewarn "FEATURES=installsources is enabled but the 
debugedit binary could not be"
-                       ewarn "found. This feature will not work unless 
debugedit or rpm is installed!"
-               fi
-               return 0
-       fi
- 
-       local x=$1
- 
-       # since we're editing the ELF here, we should recompute the build-id
-       # (the -i flag below).  save that output so we don't need to recompute
-       # it later on in the save_elf_debug step.
-       buildid=$("${debugedit}" -i \
-               -b "${WORKDIR}" \
-               -d "${prepstrip_sources_dir}" \
-               -l "${tmpdir}/sources/${x##*/}.${BASHPID:-$(__bashpid)}" \
-               "${x}")
- }
- 
- # Usage: save_elf_debug <elf> [splitdebug file]
- save_elf_debug() {
-       ${FEATURES_splitdebug} || return 0
-       ${RESTRICT_splitdebug} && return 0
- 
-       # NOTE: Debug files must be installed in
-       # ${EPREFIX}/usr/lib/debug/${EPREFIX} (note that ${EPREFIX} occurs
-       # twice in this path) in order for gdb's debug-file-directory
-       # lookup to work correctly.
-       local x=$1
-       local inode_debug=$2
-       local splitdebug=$3
-       local y=${ED}usr/lib/debug/${x:${#D}}.debug
- 
-       # dont save debug info twice
-       [[ ${x} == *".debug" ]] && return 0
- 
-       mkdir -p "${y%/*}"
- 
-       if [ -f "${inode_debug}" ] ; then
-               ln "${inode_debug}" "${y}" || die "ln failed unexpectedly"
-       else
-               if [[ -n ${splitdebug} ]] ; then
-                       mv "${splitdebug}" "${y}"
-               else
-                       local objcopy_flags="--only-keep-debug"
-                       ${FEATURES_compressdebug} && objcopy_flags+=" 
--compress-debug-sections"
-                       ${OBJCOPY} ${objcopy_flags} "${x}" "${y}"
-                       ${OBJCOPY} --add-gnu-debuglink="${y}" "${x}"
-               fi
-               # Only do the following if the debug file was
-               # successfully created (see bug #446774).
-               if [ $? -eq 0 ] ; then
-                       local args="a-x,o-w"
-                       [[ -g ${x} || -u ${x} ]] && args+=",go-r"
-                       chmod ${args} "${y}"
-                       ln "${y}" "${inode_debug}" || die "ln failed 
unexpectedly"
-               fi
-       fi
- 
-       # if we don't already have build-id from debugedit, look it up
-       if [[ -z ${buildid} ]] ; then
-               # convert the readelf output to something useful
-               buildid=$(${READELF} -n "${x}" 2>/dev/null | awk '/Build ID:/{ 
print $NF; exit }')
-       fi
-       if [[ -n ${buildid} ]] ; then
-               local buildid_dir="${ED}usr/lib/debug/.build-id/${buildid:0:2}"
-               local buildid_file="${buildid_dir}/${buildid:2}"
-               mkdir -p "${buildid_dir}"
-               [ -L "${buildid_file}".debug ] || ln -s 
"../../${x:${#D}}.debug" "${buildid_file}.debug"
-               [ -L "${buildid_file}" ] || ln -s "/${x:${#D}}" 
"${buildid_file}"
-       fi
- }
- 
- # Usage: process_elf <elf>
- process_elf() {
-       local x=$1 inode_link=$2 strip_flags=${*:3}
-       local already_stripped lockfile xt_data
- 
-       __vecho "   ${x:${#ED}}"
- 
-       # If two processes try to debugedit or strip the same hardlink at the
-       # same time, it may corrupt files or cause loss of splitdebug info.
-       # So, use a lockfile to prevent interference (easily observed with
-       # dev-vcs/git which creates ~111 hardlinks to one file in
-       # /usr/libexec/git-core).
-       lockfile=${inode_link}_lockfile
-       if ! ln "${inode_link}" "${lockfile}" 2>/dev/null ; then
-               while [[ -f ${lockfile} ]] ; do
-                       sleep 1
-               done
-               unset lockfile
-       fi
- 
-       [ -f "${inode_link}_stripped" ] && already_stripped=true || 
already_stripped=false
- 
-       if ! ${already_stripped} ; then
-               if ${PRESERVE_XATTR} ; then
-                       xt_data=$(dump_xattrs "${x}")
-               fi
-               save_elf_sources "${x}"
-       fi
- 
-       if ${strip_this} ; then
- 
-               # see if we can split & strip at the same time
-               if [[ -n ${SPLIT_STRIP_FLAGS} ]] ; then
-                       local shortname="${x##*/}.debug"
-                       local 
splitdebug="${tmpdir}/splitdebug/${shortname}.${BASHPID:-$(__bashpid)}"
-                       ${already_stripped} || \
-                       ${STRIP} ${strip_flags} \
-                               -f "${splitdebug}" \
-                               -F "${shortname}" \
-                               "${x}"
-                       save_elf_debug "${x}" "${inode_link}_debug" 
"${splitdebug}"
-               else
-                       save_elf_debug "${x}" "${inode_link}_debug"
-                       ${already_stripped} || \
-                       ${STRIP} ${strip_flags} "${x}"
-               fi
-       fi
- 
-       if ${already_stripped} ; then
-               rm -f "${x}" || die "rm failed unexpectedly"
-               ln "${inode_link}_stripped" "${x}" || die "ln failed 
unexpectedly"
-       else
-               ln "${x}" "${inode_link}_stripped" || die "ln failed 
unexpectedly"
-               if [[ ${xt_data} ]] ; then
-                       restore_xattrs <<< "${xt_data}"
-               fi
-       fi
- 
-       [[ -n ${lockfile} ]] && rm -f "${lockfile}"
- }
- 
- # The existance of the section .symtab tells us that a binary is stripped.
- # We want to log already stripped binaries, as this may be a QA violation.
- # They prevent us from getting the splitdebug data.
- if ! ${RESTRICT_binchecks} && ! ${RESTRICT_strip} ; then
-       # We need to do the non-stripped scan serially first before we turn 
around
-       # and start stripping the files ourselves.  The log parsing can be done 
in
-       # parallel though.
-       log=${tmpdir}/scanelf-already-stripped.log
-       scanelf -yqRBF '#k%F' -k '!.symtab' "$@" | sed -e "s#^${ED}##" > 
"${log}"
-       (
-       __multijob_child_init
-       qa_var="QA_PRESTRIPPED_${ARCH/-/_}"
-       [[ -n ${!qa_var} ]] && QA_PRESTRIPPED="${!qa_var}"
-       if [[ -n ${QA_PRESTRIPPED} && -s ${log} && \
-               ${QA_STRICT_PRESTRIPPED-unset} = unset ]] ; then
-               shopts=$-
-               set -o noglob
-               for x in ${QA_PRESTRIPPED} ; do
-                       sed -e "s#^${x#/}\$##" -i "${log}"
-               done
-               set +o noglob
-               set -${shopts}
-       fi
-       sed -e "/^\$/d" -e "s#^#/#" -i "${log}"
-       if [[ -s ${log} ]] ; then
-               __vecho -e "\n"
-               eqawarn "QA Notice: Pre-stripped files found:"
-               eqawarn "$(<"${log}")"
-       else
-               rm -f "${log}"
-       fi
-       ) &
-       __multijob_post_fork
- fi
- 
- # Since strip creates a new inode, we need to know the initial set of
- # inodes in advance, so that we can avoid interference due to trying
- # to strip the same (hardlinked) file multiple times in parallel.
- # See bug #421099.
- if  [[ ${USERLAND} == BSD ]] ; then
-       get_inode_number() { stat -f '%i' "$1"; }
- else
-       get_inode_number() { stat -c '%i' "$1"; }
- fi
- cd "${tmpdir}/inodes" || die "cd failed unexpectedly"
- while read -r x ; do
-       inode_link=$(get_inode_number "${x}") || die "stat failed unexpectedly"
-       echo "${x}" >> "${inode_link}" || die "echo failed unexpectedly"
- done < <(
-       # Use sort -u to eliminate duplicates for bug #445336.
-       (
-               scanelf -yqRBF '#k%F' -k '.symtab' "$@"
-               find "$@" -type f ! -type l -name '*.a'
-       ) | LC_ALL=C sort -u
- )
- 
- # Now we look for unstripped binaries.
- for inode_link in $(shopt -s nullglob; echo *) ; do
- while read -r x
- do
- 
-       if ! ${banner} ; then
-               __vecho "strip: ${STRIP} ${PORTAGE_STRIP_FLAGS}"
-               banner=true
-       fi
- 
-       (
-       __multijob_child_init
-       f=$(file "${x}") || exit 0
-       [[ -z ${f} ]] && exit 0
- 
-       if ! ${SKIP_STRIP} ; then
-               # The noglob funk is to support STRIP_MASK="/*/booga" and to 
keep
-               #  the for loop from expanding the globs.
-               # The eval echo is to support STRIP_MASK="/*/{booga,bar}" sex.
-               set -o noglob
-               strip_this=true
-               for m in $(eval echo ${STRIP_MASK}) ; do
-                       [[ /${x#${ED}} == ${m} ]] && strip_this=false && break
-               done
-               set +o noglob
-       else
-               strip_this=false
-       fi
- 
-       # In Prefix we are usually an unprivileged user, so we can't strip
-       # unwritable objects.  Make them temporarily writable for the
-       # stripping.
-       was_not_writable=false
-       if [[ ! -w ${x} ]] ; then
-               was_not_writable=true
-               chmod u+w "${x}"
-       fi
- 
-       # only split debug info for final linked objects
-       # or kernel modules as debuginfo for intermediatary
-       # files (think crt*.o from gcc/glibc) is useless and
-       # actually causes problems.  install sources for all
-       # elf types though cause that stuff is good.
- 
-       buildid=
-       if [[ ${f} == *"current ar archive"* ]] ; then
-               __vecho "   ${x:${#ED}}"
-               if ${strip_this} ; then
-                       # If we have split debug enabled, then do not strip 
this.
-                       # There is no concept of splitdebug for objects not yet
-                       # linked in (only for finally linked ELFs), so we have 
to
-                       # retain the debug info in the archive itself.
-                       if ! ${FEATURES_splitdebug} || ${RESTRICT_splitdebug} ; 
then
-                               ${STRIP} -g "${x}"
-                       fi
-               fi
-       elif [[ ${f} == *"SB executable"* || ${f} == *"SB shared object"* ]] ; 
then
-               process_elf "${x}" "${inode_link}" ${PORTAGE_STRIP_FLAGS}
-       elif [[ ${f} == *"SB relocatable"* ]] ; then
-               process_elf "${x}" "${inode_link}" ${SAFE_STRIP_FLAGS}
-       fi
- 
-       if ${was_not_writable} ; then
-               chmod u-w "${x}"
-       fi
-       ) &
-       __multijob_post_fork
- 
- done < "${inode_link}"
- done
- 
- # With a bit more work, we could run the rsync processes below in
- # parallel, but not sure that'd be an overall improvement.
- __multijob_finish
- 
- cd "${tmpdir}"/sources/ && cat * > "${tmpdir}/debug.sources" 2>/dev/null
- if [[ -s ${tmpdir}/debug.sources ]] && \
-    ${FEATURES_installsources} && \
-    ! ${RESTRICT_installsources} && \
-    ${debugedit_found}
- then
-       __vecho "installsources: rsyncing source files"
-       [[ -d ${D}${prepstrip_sources_dir} ]] || mkdir -p 
"${D}${prepstrip_sources_dir}"
-       grep -zv '/<[^/>]*>$' "${tmpdir}"/debug.sources | \
-               (cd "${WORKDIR}"; LANG=C sort -z -u | \
-               rsync -tL0 --chmod=ugo-st,a+r,go-w,Da+x,Fa-x --files-from=- 
"${WORKDIR}/" "${D}${prepstrip_sources_dir}/" )
- 
-       # Preserve directory structure.
-       # Needed after running save_elf_sources.
-       # https://bugzilla.redhat.com/show_bug.cgi?id=444310
-       while read -r -d $'\0' emptydir
-       do
-               >> "${emptydir}"/.keepdir
-       done < <(find "${D}${prepstrip_sources_dir}/" -type d -empty -print0)
+ if ___eapi_has_dostrip; then
+       die "${0##*/}: ${0##*/} has been banned for EAPI '$EAPI'; use 'dostrip' 
instead"
  fi
  
- cd "${T}"
- rm -rf "${tmpdir}"
+ __PORTAGE_HELPER=prepstrip exec "${PORTAGE_BIN_PATH}"/estrip "${@}"
diff --cc bin/ebuild-ipc.py
index 66e70e67c,1f323bdc5..8de1c44f5
--- a/bin/ebuild-ipc.py
+++ b/bin/ebuild-ipc.py
@@@ -1,5 -1,5 +1,5 @@@
 -#!/usr/bin/python -b
 +#!@PREFIX_PORTAGE_PYTHON@ -b
- # Copyright 2010-2014 Gentoo Foundation
+ # Copyright 2010-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  #
  # This is a helper which ebuild processes can use
diff --cc bin/ebuild.sh
index a60a24da8,98ed570c2..f76a48d8e
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2015 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  # Prevent aliases from causing portage to act inappropriately.
diff --cc bin/install-qa-check.d/80libraries
index 6c7e3757d,bbabc0eb9..9eb811f43
--- a/bin/install-qa-check.d/80libraries
+++ b/bin/install-qa-check.d/80libraries
@@@ -122,12 -122,8 +122,12 @@@ lib_check() 
        # https://bugs.gentoo.org/4411
        local abort="no"
        local a s
-       for a in "${ED}"usr/lib*/*.a ; do
+       for a in "${ED%/}"/usr/lib*/*.a ; do
 -              s=${a%.a}.so
 +              # PREFIX LOCAL: support MachO objects
 +              [[ ${CHOST} == *-darwin* ]] \
 +                      && s=${a%.a}.dylib \
 +                      || s=${a%.a}.so
 +              # END PREFIX LOCAL
                if [[ ! -e ${s} ]] ; then
                        s=${s%usr/*}${s##*/usr/}
                        if [[ -e ${s} ]] ; then
@@@ -140,12 -136,7 +140,12 @@@
        [[ ${abort} == "yes" ]] && die "add those ldscripts"
  
        # Make sure people don't store libtool files or static libs in /lib
 -      f=$(ls "${ED%/}"/lib*/*.{a,la} 2>/dev/null)
 +      # PREFIX LOCAL: on AIX, "dynamic libs" have extension .a, so don't
 +      # get false positives
 +      [[ ${CHOST} == *-aix* ]] \
-               && f=$(ls "${ED}"lib*/*.la 2>/dev/null || true) \
-               || f=$(ls "${ED}"lib*/*.{a,la} 2>/dev/null)
++              && f=$(ls "${ED%/}"lib*/*.la 2>/dev/null || true) \
++              || f=$(ls "${ED%/}"lib*/*.{a,la} 2>/dev/null)
 +      # END PREFIX LOCAL
        if [[ -n ${f} ]] ; then
                __vecho -ne '\n'
                eqawarn "QA Notice: Excessive files found in the / partition"
diff --cc bin/isolated-functions.sh
index c6945dd51,28ca94532..6aaae944f
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2016 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  source "${PORTAGE_BIN_PATH}/eapi.sh" || exit 1
diff --cc bin/misc-functions.sh
index 702f1ff4a,de8af955d..b36ae8217
--- a/bin/misc-functions.sh
+++ b/bin/misc-functions.sh
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2014 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  #
  # Miscellaneous shell functions that make use of the ebuild env but don't need
@@@ -230,39 -224,12 +230,45 @@@ install_qa_check() 
        ecompressdir --dequeue
        ecompress --dequeue
  
+       if ___eapi_has_dostrip; then
+               "${PORTAGE_BIN_PATH}"/estrip --queue "${PORTAGE_DOSTRIP[@]}"
+               "${PORTAGE_BIN_PATH}"/estrip --ignore 
"${PORTAGE_DOSTRIP_SKIP[@]}"
+               "${PORTAGE_BIN_PATH}"/estrip --dequeue
+       fi
+ 
 +      # PREFIX LOCAL:
 +      # 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
 +      # END PREFIX LOCAL
 +}
 +
 +install_qa_check_elf() {
        # Create NEEDED.ELF.2 regardless of RESTRICT=binchecks, since this info 
is
        # too useful not to have (it's required for things like preserve-libs), 
and
        # it's tempting for ebuild authors to set RESTRICT=binchecks for 
packages
@@@ -290,396 -257,11 +296,396 @@@
                        eqawarn "$(while read -r x; do x=${x#*;} ; x=${x%%;*} ; 
echo "${x#${EPREFIX}}" ; done < "${PORTAGE_BUILDDIR}"/build-info/NEEDED.ELF.2)"
                fi
        fi
 +}
  
 +install_qa_check_misc() {
        # Portage regenerates this on the installed system.
-       rm -f "${ED}"/usr/share/info/dir{,.gz,.bz2} || die "rm failed!"
+       rm -f "${ED%/}"/usr/share/info/dir{,.gz,.bz2} || die "rm failed!"
  }
  
 +install_qa_check_macho() {
 +      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
 +
 +      install_name_is_relative() {
 +              case $1 in
 +                      "@executable_path/"*)  return 0  ;;
 +                      "@loader_path"/*)      return 0  ;;
 +                      "@rpath/"*)            return 0  ;;
 +                      *)                     return 1  ;;
 +              esac
 +      }
 +
 +      # 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#*;}
 +
 +              ignore=
 +              qa_var="QA_IGNORE_INSTALL_NAME_FILES_${ARCH/-/_}"
 +              eval "[[ -n \${!qa_var} ]] &&
 +                      QA_IGNORE_INSTALL_NAME_FILES=(\"\${${qa_var}[@]}\")"
 +
 +              if [[ ${#QA_IGNORE_INSTALL_NAME_FILES[@]} -gt 1 ]] ; then
 +                      for x in "${QA_IGNORE_INSTALL_NAME_FILES[@]}" ; do
 +                              [[ ${obj##*/} == ${x} ]] && \
 +                                      ignore=true
 +                      done
 +              else
 +                      local shopts=$-
 +                      set -o noglob
 +                      for x in ${QA_IGNORE_INSTALL_NAME_FILES} ; do
 +                              [[ ${obj##*/} == ${x} ]] && \
 +                                      ignore=true
 +                      done
 +                      set +o noglob
 +                      set -${shopts}
 +              fi
 +
 +              # 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 install_name_is_relative ${install_name} ; then
 +                      # try to locate the library in the installed image
 +                      local inpath=${install_name#@*/}
 +                      local libl
 +                      for libl in $(find "${ED}" -name "${inpath##*/}") ; do
 +                              if [[ ${libl} == */${inpath} ]] ; then
 +                                      install_name=/${libl#${D}}
 +                                      break
 +                              fi
 +                      done
 +              fi
 +              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
 +                      [[ -z ${ignore} ]] && touch 
"${T}"/.install_name_check_failed
 +              fi
 +
 +              # this is ugly, paths with spaces won't work
 +              for lib in ${needed//,/ } ; do
 +                      if [[ ${lib} == ${D}* ]] ; then
 +                              eqawarn "QA Notice: install_name references 
\${D}: ${lib} in ${obj}"
 +                              [[ -z ${ignore} ]] && touch 
"${T}"/.install_name_check_failed
 +                      elif [[ ${lib} == ${S}* ]] ; then
 +                              eqawarn "QA Notice: install_name references 
\${S}: ${lib} in ${obj}"
 +                              [[ -z ${ignore} ]] && touch 
"${T}"/.install_name_check_failed
 +                      elif ! install_name_is_relative ${lib} && [[ ! -e 
${lib} && ! -e ${D}${lib} ]] ; then
 +                              eqawarn "QA Notice: invalid reference to ${lib} 
in ${obj}"
 +                              [[ -z ${ignore} ]] && touch 
"${T}"/.install_name_check_failed
 +                      fi
 +              done
 +
 +              # backwards compatibility
 +              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)
 +              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 ! 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
 +}
 +
  preinst_qa_check() {
        postinst_qa_check preinst
  }
@@@ -741,278 -323,14 +747,267 @@@ postinst_qa_check() 
        done < <(printf "%s\0" "${qa_checks[@]}" | LC_ALL=C sort -u -z)
  }
  
 +install_mask() {
 +      local root="$1"
 +      shift
 +      local install_mask="$*"
 +
 +      # We think of $install_mask as a space-separated list of
 +      # globs. We don't want globbing in the "for" loop; that is, we
 +      # want to keep the asterisks in the indivual entries.
 +      local shopts=$-
 +      set -o noglob
 +      local no_inst
 +      for no_inst in ${install_mask}; do
 +              # Here, $no_inst is a single "entry" potentially
 +              # containing a glob. From now on, we *do* want to
 +              # expand it.
 +              set +o noglob
 +
 +              # The standard case where $no_inst is something that
 +              # the shell could expand on its own.
 +              if [[ -e "${root}"/${no_inst} || -L "${root}"/${no_inst} ||
 +                      "${root}"/${no_inst} != $(echo "${root}"/${no_inst}) ]] 
; then
 +                      __quiet_mode || einfo "Removing ${no_inst}"
 +                      rm -Rf "${root}"/${no_inst} >&/dev/null
 +              fi
 +
 +              # We also want to allow the user to specify a "bare
 +              # glob." For example, $no_inst="*.a" should prevent
 +              # ALL files ending in ".a" from being installed,
 +              # regardless of their location/depth. We achieve this
 +              # by passing the pattern to `find`.
 +              find "${root}" \( -path "${no_inst}" -or -name "${no_inst}" \) \
 +                      -print0 2> /dev/null \
 +              | LC_ALL=C sort -z \
 +              | while read -r -d ''; do
 +                      __quiet_mode || einfo "Removing /${REPLY#${root}}"
 +                      rm -Rf "${REPLY}" >&/dev/null
 +              done
 +
 +      done
 +      # set everything back the way we found it
 +      set +o noglob
 +      set -${shopts}
 +}
 +
 +preinst_aix() {
 +      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=() helperfiles=()
 +      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.
 +              helperfiles[${#helperfiles[@]}]=${ED}${contentmember}
 +      done < "${PORTAGE_BUILDDIR}"/build-info/NEEDED.XCOFF.1
 +      if [[ ${#helperfiles[@]} > 0 ]]; then
 +              rm -f "${helperfiles[@]}" || die "cannot prune 
${helperfiles[@]}"
 +              local f prev=
 +              for f in "${helperfiles[@]}"
 +              do
 +                      if [[ -z ${prev} ]]; then
 +                              {       echo "Please leave this file alone, it 
is an important helper"
 +                                      echo "for portage to implement the 
'preserve-libs' feature on AIX." 
 +                              } > "${f}" || die "cannot create ${f}"
 +                              chmod 0400 "${f}" || die "cannot chmod ${f}"
 +                              prev=${f}
 +                      else
 +                              ln "${prev}" "${f}" || die "cannot create 
hardlink ${f}"
 +                      fi
 +              done
 +      fi
 +
 +      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"
-                return 1
-       fi
- 
-       if ! ___eapi_has_prefix_variables; then
-               local ED=${D}
-       fi
- 
-       # Make sure $PWD is not ${D} so that we don't leave gmon.out files
-       # in there in case any tools were built with -pg in CFLAGS.
-       cd "${T}"
- 
-       # remove man pages, info pages, docs if requested
-       local f
+       # Remove man pages, info pages, docs if requested. This is
+       # implemented in bash in order to respect INSTALL_MASK settings
+       # from bashrc.
+       local f x
        for f in man info doc; do
 -              if has no${f} ${FEATURES}; then
 -                      INSTALL_MASK+=" /usr/share/${f}"
 +              if has no${f} $FEATURES; then
 +                      INSTALL_MASK="${INSTALL_MASK} ${EPREFIX}/usr/share/${f}"
                fi
        done
  
@@@ -1174,11 -478,11 +1155,11 @@@ __dyn_package() 
        mkdir -p "${PORTAGE_BINPKG_TMPFILE%/*}" || die "mkdir failed"
        [ -z "${PORTAGE_COMPRESSION_COMMAND}" ] && \
          die "PORTAGE_COMPRESSION_COMMAND is unset"
-       tar $tar_options -cf - $PORTAGE_BINPKG_TAR_OPTS -C "${PROOT}" . | \
-               $PORTAGE_COMPRESSION_COMMAND -c > "$PORTAGE_BINPKG_TMPFILE"
+       tar $tar_options -cf - $PORTAGE_BINPKG_TAR_OPTS -C "${D}" . | \
+               $PORTAGE_COMPRESSION_COMMAND > "$PORTAGE_BINPKG_TMPFILE"
        assert "failed to pack binary package: '$PORTAGE_BINPKG_TMPFILE'"
        PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
 -              "${PORTAGE_PYTHON:-/usr/bin/python}" 
"$PORTAGE_BIN_PATH"/xpak-helper.py recompose \
 +              "${PORTAGE_PYTHON:-@PREFIX_PORTAGE_PYTHON@}" 
"$PORTAGE_BIN_PATH"/xpak-helper.py recompose \
                "$PORTAGE_BINPKG_TMPFILE" "$PORTAGE_BUILDDIR/build-info"
        if [ $? -ne 0 ]; then
                rm -f "${PORTAGE_BINPKG_TMPFILE}"
diff --cc bin/phase-functions.sh
index bbffccf1e,1f9faaa41..209b76c68
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2015 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  # Hardcoded bash lists are needed for backward compatibility with
@@@ -30,9 -30,8 +30,8 @@@ PORTAGE_READONLY_VARS="D EBUILD EBUILD_
        PORTAGE_SAVED_READONLY_VARS PORTAGE_SIGPIPE_STATUS \
        PORTAGE_TMPDIR PORTAGE_UPDATE_ENV PORTAGE_USERNAME \
        PORTAGE_VERBOSE PORTAGE_WORKDIR_MODE PORTAGE_XATTR_EXCLUDE \
-       PORTDIR \
        REPLACING_VERSIONS REPLACED_BY_VERSION T WORKDIR \
 -      __PORTAGE_HELPER __PORTAGE_TEST_HARDLINK_LOCKS"
 +      __PORTAGE_HELPER __PORTAGE_TEST_HARDLINK_LOCKS ED EROOT"
  
  PORTAGE_SAVED_READONLY_VARS="A CATEGORY P PF PN PR PV PVR"
  
diff --cc bin/phase-helpers.sh
index 2cac6f426,5c9f957e9..75d92b407
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@@ -1,9 -1,14 +1,14 @@@
 -#!/bin/bash
 +#!@PORTAGE_BASH@
- # Copyright 1999-2017 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
- export DESTTREE=/usr
- export INSDESTTREE=""
+ if ___eapi_has_DESTTREE_INSDESTTREE; then
+       export DESTTREE=/usr
+       export INSDESTTREE=""
+ else
+       export _E_DESTTREE_=/usr
+       export _E_INSDESTTREE_=""
+ fi
  export _E_EXEDESTTREE_=""
  export _E_DOCDESTTREE_=""
  export INSOPTIONS="-m0644"
diff --cc bin/portageq
index 3518a0af0,35499afd2..7b9addb67
--- a/bin/portageq
+++ b/bin/portageq
@@@ -1,5 -1,5 +1,5 @@@
 -#!/usr/bin/python -b
 +#!@PREFIX_PORTAGE_PYTHON@ -b
- # Copyright 1999-2016 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  from __future__ import print_function, unicode_literals
diff --cc bin/save-ebuild-env.sh
index 4c6ca3f17,947ac79d5..bb17382d4
mode 100755,100644..100755
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@@ -1,5 -1,5 +1,5 @@@
 -#!/bin/bash
 +#!@PORTAGE_PREFIX_BASH@
- # Copyright 1999-2014 Gentoo Foundation
+ # Copyright 1999-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  # @FUNCTION: __save_ebuild_env
diff --cc bin/xattr-helper.py
index 43bf70dcb,49c981580..a8aef3880
--- a/bin/xattr-helper.py
+++ b/bin/xattr-helper.py
@@@ -1,5 -1,5 +1,5 @@@
 -#!/usr/bin/python -b
 +#!@PREFIX_PORTAGE_PYTHON@ -b
- # Copyright 2012-2014 Gentoo Foundation
+ # Copyright 2012-2018 Gentoo Foundation
  # Distributed under the terms of the GNU General Public License v2
  
  doc = """Dump and restore extended attributes.
diff --cc cnf/repos.conf
index b27d5c6b2,352073cfd..3b4b94209
--- a/cnf/repos.conf
+++ b/cnf/repos.conf
@@@ -1,11 -1,20 +1,20 @@@
  [DEFAULT]
 -main-repo = gentoo
 +main-repo = gentoo_prefix
  
 -[gentoo]
 -location = /usr/portage
 +[gentoo_prefix]
 +location = @PORTAGE_EPREFIX@/usr/portage
  sync-type = rsync
 -sync-uri = rsync://rsync.gentoo.org/gentoo-portage
 +sync-uri = rsync://rsync.prefix.bitzolder.nl/gentoo-portage-prefix
  auto-sync = yes
+ sync-rsync-verify-jobs = 1
+ sync-rsync-verify-metamanifest = yes
+ sync-rsync-verify-max-age = 24
+ sync-openpgp-key-path = /usr/share/openpgp-keys/gentoo-release.asc
+ sync-openpgp-key-refresh-retry-count = 40
+ sync-openpgp-key-refresh-retry-overall-timeout = 1200
+ sync-openpgp-key-refresh-retry-delay-exp-base = 2
+ sync-openpgp-key-refresh-retry-delay-max = 60
+ sync-openpgp-key-refresh-retry-delay-mult = 4
  
  # for daily squashfs snapshots
  #sync-type = squashdelta
diff --cc pym/_emerge/Package.py
index 44029bcb3,a7ce00bc9..1d3457ed8
--- a/pym/_emerge/Package.py
+++ b/pym/_emerge/Package.py
@@@ -42,15 -42,16 +42,16 @@@ class Package(Task)
                "_validated_atoms", "_visible")
  
        metadata_keys = [
+               "BDEPEND",
                "BUILD_ID", "BUILD_TIME", "CHOST", "COUNTER", "DEFINED_PHASES",
                "DEPEND", "EAPI", "HDEPEND", "INHERITED", "IUSE", "KEYWORDS",
-               "LICENSE", "MD5", "PDEPEND", "PROVIDE", "PROVIDES",
+               "LICENSE", "MD5", "PDEPEND", "PROVIDES",
                "RDEPEND", "repository", "REQUIRED_USE",
                "PROPERTIES", "REQUIRES", "RESTRICT", "SIZE",
 -              "SLOT", "USE", "_mtime_"]
 +              "SLOT", "USE", "_mtime_", "EPREFIX"]
  
-       _dep_keys = ('DEPEND', 'HDEPEND', 'PDEPEND', 'RDEPEND')
-       _buildtime_keys = ('DEPEND', 'HDEPEND')
+       _dep_keys = ('BDEPEND', 'DEPEND', 'HDEPEND', 'PDEPEND', 'RDEPEND')
+       _buildtime_keys = ('BDEPEND', 'DEPEND', 'HDEPEND')
        _runtime_keys = ('PDEPEND', 'RDEPEND')
        _use_conditional_misc_keys = ('LICENSE', 'PROPERTIES', 'RESTRICT')
        UNKNOWN_REPO = _unknown_repo
diff --cc pym/portage/__init__.py
index 9f3301ef0,166bfc700..95c6dff15
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@@ -419,55 -418,11 +419,10 @@@ def _shell_quote(s)
  
  bsd_chflags = None
  
- if platform.system() in ('FreeBSD',) and rootuid == 0:
- 
+ if platform.system() in ('FreeBSD',):
 -      # TODO: remove this class?
        class bsd_chflags(object):
- 
-               @classmethod
-               def chflags(cls, path, flags, opts=""):
-                       cmd = ['chflags']
-                       if opts:
-                               cmd.append(opts)
-                       cmd.append('%o' % (flags,))
-                       cmd.append(path)
- 
-                       if sys.hexversion < 0x3020000 and sys.hexversion >= 
0x3000000:
-                               # Python 3.1 _execvp throws TypeError for 
non-absolute executable
-                               # path passed as bytes (see 
https://bugs.python.org/issue8513).
-                               fullname = process.find_binary(cmd[0])
-                               if fullname is None:
-                                       raise exception.CommandNotFound(cmd[0])
-                               cmd[0] = fullname
- 
-                       encoding = _encodings['fs']
-                       cmd = [_unicode_encode(x, encoding=encoding, 
errors='strict')
-                               for x in cmd]
-                       proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
-                               stderr=subprocess.STDOUT)
-                       output = proc.communicate()[0]
-                       status = proc.wait()
-                       if os.WIFEXITED(status) and os.WEXITSTATUS(status) == 
os.EX_OK:
-                               return
-                       # Try to generate an ENOENT error if appropriate.
-                       if 'h' in opts:
-                               _os_merge.lstat(path)
-                       else:
-                               _os_merge.stat(path)
-                       # Make sure the binary exists.
-                       if not portage.process.find_binary('chflags'):
-                               raise 
portage.exception.CommandNotFound('chflags')
-                       # Now we're not sure exactly why it failed or what
-                       # the real errno was, so just report EPERM.
-                       output = _unicode_decode(output, encoding=encoding)
-                       e = OSError(errno.EPERM, output)
-                       e.errno = errno.EPERM
-                       e.filename = path
-                       e.message = output
-                       raise e
- 
-               @classmethod
-               def lchflags(cls, path, flags):
-                       return cls.chflags(path, flags, opts='-h')
+               chflags = os.chflags
+               lchflags = os.lchflags
  
  def load_mod(name):
        modname = ".".join(name.split(".")[:-1])
@@@ -581,8 -536,9 +536,8 @@@ def create_trees(config_root=None, targ
  
        if env is None:
                env = os.environ
 -
        settings = config(config_root=config_root, target_root=target_root,
-               env=env, eprefix=eprefix)
+               env=env, sysroot=sysroot, eprefix=eprefix)
        settings.lock()
  
        depcachedir = settings.get('PORTAGE_DEPCACHEDIR')
diff --cc pym/portage/dbapi/bintree.py
index 8841bf9ec,269a7b226..5376b7e17
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@@ -85,11 -86,11 +86,11 @@@ class bindbapi(fakedbapi)
                self.move_ent = mybintree.move_ent
                # Selectively cache metadata in order to optimize dep matching.
                self._aux_cache_keys = set(
-                       ["BUILD_ID", "BUILD_TIME", "CHOST", "DEFINED_PHASES",
+                       ["BDEPEND", "BUILD_ID", "BUILD_TIME", "CHOST", 
"DEFINED_PHASES",
                        "DEPEND", "EAPI", "HDEPEND", "IUSE", "KEYWORDS",
-                       "LICENSE", "MD5", "PDEPEND", "PROPERTIES", "PROVIDE",
+                       "LICENSE", "MD5", "PDEPEND", "PROPERTIES",
                        "PROVIDES", "RDEPEND", "repository", "REQUIRES", 
"RESTRICT",
 -                      "SIZE", "SLOT", "USE", "_mtime_"
 +                      "SIZE", "SLOT", "USE", "_mtime_", "EPREFIX"
                        ])
                self._aux_cache_slot_dict = 
slot_dict_class(self._aux_cache_keys)
                self._aux_cache = {}
@@@ -312,25 -313,26 +313,27 @@@ class binarytree(object)
                        self._pkgindex_keys = self.dbapi._aux_cache_keys.copy()
                        self._pkgindex_keys.update(["CPV", "SIZE"])
                        self._pkgindex_aux_keys = \
-                               ["BASE_URI", "BUILD_ID", "BUILD_TIME", "CHOST",
+                               ["BASE_URI", "BDEPEND", "BUILD_ID", 
"BUILD_TIME", "CHOST",
                                "DEFINED_PHASES", "DEPEND", "DESCRIPTION", 
"EAPI",
                                "HDEPEND", "IUSE", "KEYWORDS", "LICENSE", 
"PDEPEND",
-                               "PKGINDEX_URI", "PROPERTIES", "PROVIDE", 
"PROVIDES",
+                               "PKGINDEX_URI", "PROPERTIES", "PROVIDES",
                                "RDEPEND", "repository", "REQUIRES", "RESTRICT",
 -                              "SIZE", "SLOT", "USE"]
 +                              "SIZE", "SLOT", "USE", "EPREFIX"]
                        self._pkgindex_aux_keys = list(self._pkgindex_aux_keys)
                        self._pkgindex_use_evaluated_keys = \
-                               ("DEPEND", "HDEPEND", "LICENSE", "RDEPEND",
-                               "PDEPEND", "PROPERTIES", "PROVIDE", "RESTRICT")
+                               ("BDEPEND", "DEPEND", "HDEPEND", "LICENSE", 
"RDEPEND",
+                               "PDEPEND", "PROPERTIES", "RESTRICT")
+                       self._pkgindex_header = None
                        self._pkgindex_header_keys = set([
                                "ACCEPT_KEYWORDS", "ACCEPT_LICENSE",
                                "ACCEPT_PROPERTIES", "ACCEPT_RESTRICT", 
"CBUILD",
                                "CONFIG_PROTECT", "CONFIG_PROTECT_MASK", 
"FEATURES",
                                "GENTOO_MIRRORS", "INSTALL_MASK", 
"IUSE_IMPLICIT", "USE",
                                "USE_EXPAND", "USE_EXPAND_HIDDEN", 
"USE_EXPAND_IMPLICIT",
 -                              "USE_EXPAND_UNPREFIXED"])
 +                              "USE_EXPAND_UNPREFIXED",
 +                              "EPREFIX"])
                        self._pkgindex_default_pkg_data = {
+                               "BDEPEND" : "",
                                "BUILD_ID"           : "",
                                "BUILD_TIME"         : "",
                                "DEFINED_PHASES"     : "",
diff --cc pym/portage/package/ebuild/_config/special_env_vars.py
index 7e5291e58,a308518af..e2ea8c393
--- a/pym/portage/package/ebuild/_config/special_env_vars.py
+++ b/pym/portage/package/ebuild/_config/special_env_vars.py
@@@ -76,11 -77,9 +77,11 @@@ environ_whitelist += 
        "PORTAGE_VERBOSE", "PORTAGE_WORKDIR_MODE", "PORTAGE_XATTR_EXCLUDE",
        "PORTDIR", "PORTDIR_OVERLAY", "PREROOTPATH", "PYTHONDONTWRITEBYTECODE",
        "REPLACING_VERSIONS", "REPLACED_BY_VERSION",
-       "ROOT", "ROOTPATH", "T", "TMP", "TMPDIR",
+       "ROOT", "ROOTPATH", "SYSROOT", "T", "TMP", "TMPDIR",
        "USE_EXPAND", "USE_ORDER", "WORKDIR",
        "XARGS", "__PORTAGE_TEST_HARDLINK_LOCKS",
 +      "DEFAULT_PATH", "EXTRA_PATH",
 +      "PORTAGE_GROUP", "PORTAGE_USER",
  ]
  
  # user config variables
diff --cc pym/portage/package/ebuild/doebuild.py
index a24f8fec8,31b552ff3..fff03e1d4
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@@ -1391,14 -1366,8 +1369,9 @@@ def _spawn_actionmap(settings)
                ("usersandbox" not in features) and \
                "userpriv" not in restrict and \
                "nouserpriv" not in restrict)
-       if nosandbox and ("userpriv" not in features or \
-               "userpriv" in restrict or \
-               "nouserpriv" in restrict):
-               nosandbox = ("sandbox" not in features and \
-                       "usersandbox" not in features)
  
 -      if not portage.process.sandbox_capable:
 +      if not (portage.process.sandbox_capable or \
 +              portage.process.macossandbox_capable):
                nosandbox = True
  
        sesandbox = settings.selinux_enabled() and \
diff --cc pym/portage/process.py
index b91f17305,fd326731a..5261741b8
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@@ -91,9 -91,30 +91,32 @@@ sandbox_capable = (os.path.isfile(SANDB
  fakeroot_capable = (os.path.isfile(FAKEROOT_BINARY) and
                      os.access(FAKEROOT_BINARY, os.X_OK))
  
 +macossandbox_capable = (os.path.isfile(MACOSSANDBOX_BINARY) and
 +                   os.access(MACOSSANDBOX_BINARY, os.X_OK))
  
+ def sanitize_fds():
+       """
+       Set the inheritable flag to False for all open file descriptors,
+       except for those corresponding to stdin, stdout, and stderr. This
+       ensures that any unintentionally inherited file descriptors will
+       not be inherited by child processes.
+       """
+       if _set_inheritable is not None:
+ 
+               whitelist = frozenset([
+                       sys.__stdin__.fileno(),
+                       sys.__stdout__.fileno(),
+                       sys.__stderr__.fileno(),
+               ])
+ 
+               for fd in get_open_fds():
+                       if fd not in whitelist:
+                               try:
+                                       _set_inheritable(fd, False)
+                               except OSError:
+                                       pass
+ 
+ 
  def spawn_bash(mycommand, debug=False, opt_name=None, **keywords):
        """
        Spawns a bash shell running a specific commands

Reply via email to