aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2020-01-02 15:41:45 -0800
committerZac Medico <zmedico@gentoo.org>2020-01-22 22:11:53 -0800
commitd5dbe58beb5a4e73b919c7dbe8ed4d7b75a860f0 (patch)
treef64e8a952cce5ed8775f310bbf96ce4e8ff3437d /lib/_emerge
parentdoebuild: export SANDBOX_LOG=${T}/sandbox.log (bug 704848) (diff)
downloadportage-d5dbe58beb5a4e73b919c7dbe8ed4d7b75a860f0.tar.gz
portage-d5dbe58beb5a4e73b919c7dbe8ed4d7b75a860f0.tar.bz2
portage-d5dbe58beb5a4e73b919c7dbe8ed4d7b75a860f0.zip
Add QA check for unresolved soname dependencies (bug 704320)
Example output for maven-bin-3.6.2 (bug 704618): * QA Notice: Unresolved soname dependencies: * * /usr/share/maven-bin-3.6/lib/jansi-native/freebsd32/libjansi.so: libc.so.7 libutil.so.9 * /usr/share/maven-bin-3.6/lib/jansi-native/freebsd64/libjansi.so: libc.so.7 libutil.so.9 * This warning comes up when a library or executable has one or more soname dependencies (found in its NEEDED.ELF.2 metadata) that could not be resolved by usual means. If you run ldd on files like these then it will report a "not found" error for each unresolved soname dependency. In order to correct problems with soname dependency resolution, use one or more of the approaches described in the following sections. Content of the NEEDED.ELF.2 metadata file may be useful for debugging purposes. Find the NEEDED.ELF.2 file in the ${D}/../build-info/ directory after the ebuild src_install phase completes, or in the /var/db/pkg/*/*/ directory for an installed package. Each line of the NEEDED.ELF.2 file contains semicolon separated values for a single ELF file. The soname dependencies are found in the DT_NEEDED column: E_MACHINE;path;DT_SONAME;DT_RUNPATH;DT_NEEDED;multilib category External dependencies For packages that install pre-built binaries, it may be possible to resolve soname dependencies simply by adding dependencies for one or more other packages that are known to provide the needed sonames. Removal of unecessary files For packages that install pre-built binaries, it may be possible to resolve soname dependencies simply by removing unnecessary files which have unresolved soname dependencies. For example, some pre-built binary packages include binaries intended for irrelevant architectures or operating systems, and these files can simply be removed because they are unnecessary. Addition of DT_RUNPATH entries If the relevant dependencies are installed in a location that is not included in the dynamic linker search path, then it's necessary for files to include a DT_RUNPATH entry which refers to the appropriate directory. The special $ORIGIN value can be used to create a relative path reference in DT_RUNPATH, where $ORIGIN is a placeholder for the directory where the file having the DT_RUNPATH entry is located. For pre-built binaries, it may be necessary to fix up DT_RUNPATH using patchelf --set-rpath. For example, use patchelf --set-rpath '$ORIGIN' if a given binary should link to libraries found in the same directory as the binary itself, or use patchelf --set-rpath '$ORIGIN/libs' if a given binary should link to libraries found in a subdirectory named libs found in the same directory as the binary itself. For binaries built from source, a flag like -Wl,-rpath,/path/of/directory/containing/libs will create binaries with the desired DT_RUNPATH entry. Addition of DT_SONAME settings If a package installs dynamic libraries which do not set DT_SONAME, then this can lead to unresolved soname dependencies. For dynamic libraries built from source, a flag like -Wl,-soname=foo.so.1 will create a DT_SONAME setting. For pre-built dynamic libraries, it may be necessary to fix up DT_SONAME using patchelf --set-soname. Adjustment to Portage soname resolution logic It may be necessary to adjust Portage soname resolution logic in order to account for special circumstances. For example, Portage soname resolution tolerates missing DT_SONAME for dynamic libraries that a package installs in a directory that its binaries reference via DT_RUNPATH. This behavior is useful for packages that have internal dynamic libraries stored in a private directory. An example is ebtables, as discussed in bug 646190. Bug: https://bugs.gentoo.org/704320 Signed-off-by: Zac Medico <zmedico@gentoo.org>
Diffstat (limited to 'lib/_emerge')
-rw-r--r--lib/_emerge/EbuildPhase.py63
1 files changed, 52 insertions, 11 deletions
diff --git a/lib/_emerge/EbuildPhase.py b/lib/_emerge/EbuildPhase.py
index 50e3dd1f4..828e6e126 100644
--- a/lib/_emerge/EbuildPhase.py
+++ b/lib/_emerge/EbuildPhase.py
@@ -1,6 +1,8 @@
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
+from __future__ import unicode_literals
+
import functools
import gzip
import io
@@ -14,10 +16,17 @@ from _emerge.EbuildProcess import EbuildProcess
from _emerge.CompositeTask import CompositeTask
from _emerge.PackagePhase import PackagePhase
from _emerge.TaskSequence import TaskSequence
+from portage.package.ebuild._ipc.QueryCommand import QueryCommand
+from portage.util._dyn_libs.soname_deps_qa import (
+ _get_all_provides,
+ _get_unresolved_soname_deps,
+)
from portage.package.ebuild.prepare_build_dirs import (_prepare_workdir,
_prepare_fake_distdir, _prepare_fake_filesdir)
+from portage.util.futures.compat_coroutine import coroutine
from portage.util import writemsg
from portage.util._async.AsyncTaskFuture import AsyncTaskFuture
+from portage.util.futures.executor.fork import ForkExecutor
try:
from portage.xml.metadata import MetaDataXML
@@ -281,7 +290,7 @@ class EbuildPhase(CompositeTask):
fd, logfile = tempfile.mkstemp()
os.close(fd)
post_phase = _PostPhaseCommands(background=self.background,
- commands=post_phase_cmds, fd_pipes=self.fd_pipes,
+ commands=post_phase_cmds, elog=self._elog, fd_pipes=self.fd_pipes,
logfile=logfile, phase=self.phase, scheduler=self.scheduler,
settings=settings)
self._start_task(post_phase, self._post_phase_exit)
@@ -315,13 +324,6 @@ class EbuildPhase(CompositeTask):
self._die_hooks()
return
- if self.phase == "install":
- out = io.StringIO()
- _post_src_install_soname_symlinks(self.settings, out)
- msg = out.getvalue()
- if msg:
- self.scheduler.output(msg, log_path=log_path)
-
self._current_task = None
self.wait()
return
@@ -414,7 +416,7 @@ class EbuildPhase(CompositeTask):
class _PostPhaseCommands(CompositeTask):
- __slots__ = ("commands", "fd_pipes", "logfile", "phase", "settings")
+ __slots__ = ("commands", "elog", "fd_pipes", "logfile", "phase", "settings")
def _start(self):
if isinstance(self.commands, list):
@@ -436,4 +438,43 @@ class _PostPhaseCommands(CompositeTask):
logfile=self.logfile, phase=self.phase,
scheduler=self.scheduler, settings=self.settings, **kwargs))
- self._start_task(tasks, self._default_final_exit)
+ self._start_task(tasks, self._commands_exit)
+
+ def _commands_exit(self, task):
+
+ if self._default_exit(task) != os.EX_OK:
+ self._async_wait()
+ return
+
+ if self.phase == 'install':
+ out = io.StringIO()
+ _post_src_install_soname_symlinks(self.settings, out)
+ msg = out.getvalue()
+ if msg:
+ self.scheduler.output(msg, log_path=self.settings.get("PORTAGE_LOG_FILE"))
+
+ # This operates on REQUIRES metadata generated by the above function call.
+ future = self._soname_deps_qa()
+ # If an unexpected exception occurs, then this will raise it.
+ future.add_done_callback(lambda future: future.result())
+ self._start_task(AsyncTaskFuture(future=future), self._default_final_exit)
+ else:
+ self._default_final_exit(task)
+
+ @coroutine
+ def _soname_deps_qa(self):
+
+ vardb = QueryCommand.get_db()[self.settings['EROOT']]['vartree'].dbapi
+
+ all_provides = (yield self.scheduler.run_in_executor(ForkExecutor(loop=self.scheduler), _get_all_provides, vardb))
+
+ unresolved = _get_unresolved_soname_deps(os.path.join(self.settings['PORTAGE_BUILDDIR'], 'build-info'), all_provides)
+
+ if unresolved:
+ unresolved.sort()
+ qa_msg = ["QA Notice: Unresolved soname dependencies:"]
+ qa_msg.append("")
+ qa_msg.extend("\t%s: %s" % (filename, " ".join(sorted(soname_deps)))
+ for filename, soname_deps in unresolved)
+ qa_msg.append("")
+ self.elog("eqawarn", qa_msg)