diff mbox series

systemd: more optimistic dlopen notes processing

Message ID 20241125154739.416548-1-danismostlikely@gmail.com
State New
Headers show
Series systemd: more optimistic dlopen notes processing | expand

Commit Message

Dan McGregor Nov. 25, 2024, 3:47 p.m. UTC
From: Dan McGregor <dan.mcgregor@usask.ca>

Ignore shared object names that differ from names we've already
processed only by their version number. This assumes that the
highest priority is first in the list, and ignores those later
in the list if we've alredy found one.

I saw this with the qrencode PACKAGECONFIG enabled. Its note lists
both libqrencode.so.4 and libqrencode.so.3, which led to a packaging
warning.

Signed-off-by: Dan McGregor <dan.mcgregor@usask.ca>
---
 meta/recipes-core/systemd/dlopen-deps.inc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Ross Burton Nov. 25, 2024, 4:37 p.m. UTC | #1
On 25 Nov 2024, at 15:47, Dan McGregor via lists.openembedded.org <danismostlikely=gmail.com@lists.openembedded.org> wrote:
> 
> From: Dan McGregor <dan.mcgregor@usask.ca>
> 
> Ignore shared object names that differ from names we've already
> processed only by their version number. This assumes that the
> highest priority is first in the list, and ignores those later
> in the list if we've alredy found one.
> 
> I saw this with the qrencode PACKAGECONFIG enabled. Its note lists
> both libqrencode.so.4 and libqrencode.so.3, which led to a packaging
> warning.

I’m unconvinced that “just take the first one” is the right solution here. What was the resulting dependency without this patch?  Our qrencode recipe is version 4.1.1 so libqrencode.so <http://libqrencode.so/>.4 should have found the qrencode package, but libqrencode.so <http://libqrencode.so/>.3 shouldn’t have found anything and so a dependency shouldn’t have been created.

Unless my code is buggy in a different way, of course…

Ross
diff mbox series

Patch

diff --git a/meta/recipes-core/systemd/dlopen-deps.inc b/meta/recipes-core/systemd/dlopen-deps.inc
index e0b333398c2..18768d43491 100644
--- a/meta/recipes-core/systemd/dlopen-deps.inc
+++ b/meta/recipes-core/systemd/dlopen-deps.inc
@@ -3,7 +3,7 @@  PACKAGEFUNCS =+ "package_generate_dlopen_deps"
 python package_generate_dlopen_deps() {
     # https://systemd.io/ELF_DLOPEN_METADATA/
 
-    import struct, json
+    import struct, json, re
 
     def extract_segment(filename, segment):
         """
@@ -66,14 +66,18 @@  python package_generate_dlopen_deps() {
                     elf = oe.qa.ELFFile(f)
                     elf.open()
                     for dep in parse(extract_segment(f, ".note.dlopen"), elf.isLittleEndian()):
+                        # Ignore sonames if a higher priority version is found
+                        seen_sonames = []
                         for soname in dep["soname"]:
+                            base_soname = re.sub(r'\.so($|\..*$)', '', soname)
                             if soname in shlibs:
                                 # TODO assumes the first match is good
                                 package, version = list(shlibs[soname].values())[0]
                                 dependency = dep_map[dep["priority"]]
                                 bb.note(f"{pkg}: adding {dependency} on {package} via .note.dlopen")
                                 d.appendVar(f"{dependency}:{pkg}", f" {package} (>= {version})")
-                            else:
+                                seen_sonames.append(base_soname)
+                            elif base_soname not in seen_sonames:
                                 bb.warn(f"cannot find {soname}")
                 except oe.qa.NotELFFileError as e:
                     bb.note(f"Cannot extract ELF notes: {e}")