commit:     c9aebae4633a972b78f7f999aa755fa6d25c8451
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 22 00:04:12 2015 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Mar 22 19:36:48 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=c9aebae4

_post_src_install_soname_symlinks: fix bug 543818

The SonameDepsProcessor.add() method raises AssertionError if the
multilib category of an ELF file is not recognized. It's not possible
to account for soname dependencies in this case (the file is probably
intended for a foreign architecture), so avoid the AssertionError and
generate an eqawarn message for this case. The eqawarn message is
suppressed for files matched by the QA_PREBUILT variable.

X-Gentoo-Bug: 543818
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=543818
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>

 bin/phase-functions.sh                 |  2 +-
 pym/portage/package/ebuild/doebuild.py | 59 +++++++++++++++++++++++-----------
 2 files changed, 42 insertions(+), 19 deletions(-)

diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index def2080..2743e27 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -580,7 +580,7 @@ __dyn_install() {
                for f in ASFLAGS CBUILD CC CFLAGS CHOST CTARGET CXX \
                        CXXFLAGS EXTRA_ECONF EXTRA_EINSTALL EXTRA_MAKE \
                        LDFLAGS LIBCFLAGS LIBCXXFLAGS QA_CONFIGURE_OPTIONS \
-                       QA_DESKTOP_FILE PROVIDES_EXCLUDE REQUIRES_EXCLUDE ; do
+                       QA_DESKTOP_FILE QA_PREBUILT PROVIDES_EXCLUDE 
REQUIRES_EXCLUDE ; do
                        x=$(echo -n ${!f})
                        [[ -n $x ]] && echo "$x" > $f
                done

diff --git a/pym/portage/package/ebuild/doebuild.py 
b/pym/portage/package/ebuild/doebuild.py
index 94785b5..1be83ad 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -8,6 +8,7 @@ __all__ = ['doebuild', 'doebuild_environment', 'spawn', 
'spawnebuild']
 import grp
 import gzip
 import errno
+import fnmatch
 import io
 from itertools import chain
 import logging
@@ -2209,24 +2210,29 @@ def _post_src_install_soname_symlinks(mysettings, out):
                if f is not None:
                        f.close()
 
-       qa_no_symlink = ""
-       f = None
-       try:
-               f = io.open(_unicode_encode(os.path.join(
-                       mysettings["PORTAGE_BUILDDIR"],
-                       "build-info", "QA_SONAME_NO_SYMLINK"),
-                       encoding=_encodings['fs'], errors='strict'),
-                       mode='r', encoding=_encodings['repo.content'],
-                       errors='replace')
-               qa_no_symlink = f.read()
-       except IOError as e:
-               if e.errno not in (errno.ENOENT, errno.ESTALE):
-                       raise
-       finally:
-               if f is not None:
-                       f.close()
+       metadata = {}
+       for k in ("QA_PREBUILT", "QA_NO_SYMLINK"):
+               try:
+                       with io.open(_unicode_encode(os.path.join(
+                               mysettings["PORTAGE_BUILDDIR"],
+                               "build-info", k),
+                               encoding=_encodings['fs'], errors='strict'),
+                               mode='r', encoding=_encodings['repo.content'],
+                               errors='replace') as f:
+                               v = f.read()
+               except IOError as e:
+                       if e.errno not in (errno.ENOENT, errno.ESTALE):
+                               raise
+               else:
+                       metadata[k] = v
+
+       qa_prebuilt = metadata.get("QA_PREBUILT", "").strip()
+       if qa_prebuilt:
+               qa_prebuilt = re.compile("|".join(
+                       fnmatch.translate(x.lstrip(os.sep))
+                       for x in portage.util.shlex_split(qa_prebuilt)))
 
-       qa_no_symlink = qa_no_symlink.split()
+       qa_no_symlink = metadata.get("QA_NO_SYMLINK", "").split()
        if qa_no_symlink:
                if len(qa_no_symlink) > 1:
                        qa_no_symlink = "|".join("(%s)" % x for x in 
qa_no_symlink)
@@ -2297,6 +2303,7 @@ def _post_src_install_soname_symlinks(mysettings, out):
                requires_exclude = ""
 
        missing_symlinks = []
+       unrecognized_elf_files = []
        soname_deps = SonameDepsProcessor(
                provides_exclude, requires_exclude)
 
@@ -2326,7 +2333,14 @@ def _post_src_install_soname_symlinks(mysettings, out):
                entry.multilib_category = compute_multilib_category(elf_header)
                needed_file.write(_unicode(entry))
 
-               soname_deps.add(entry)
+               if entry.multilib_category is None:
+                       if not qa_prebuilt or qa_prebuilt.match(
+                               
entry.filename[len(mysettings["EPREFIX"]):].lstrip(
+                               os.sep)) is None:
+                               unrecognized_elf_files.append(entry)
+               else:
+                       soname_deps.add(entry)
+
                obj = entry.filename
                soname = entry.soname
 
@@ -2365,6 +2379,15 @@ def _post_src_install_soname_symlinks(mysettings, out):
                        errors='strict') as f:
                        f.write(soname_deps.provides)
 
+       if unrecognized_elf_files:
+               qa_msg = ["QA Notice: Unrecognized ELF file(s):"]
+               qa_msg.append("")
+               qa_msg.extend("\t%s" % _unicode(entry).rstrip()
+                       for entry in unrecognized_elf_files)
+               qa_msg.append("")
+               for line in qa_msg:
+                       eqawarn(line, key=mysettings.mycpv, out=out)
+
        if not missing_symlinks:
                return
 

Reply via email to